aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--java/com/google/turbine/main/Main.java3
-rw-r--r--javatests/com/google/turbine/main/MainTest.java15
2 files changed, 15 insertions, 3 deletions
diff --git a/java/com/google/turbine/main/Main.java b/java/com/google/turbine/main/Main.java
index 59ca165..66d3c1b 100644
--- a/java/com/google/turbine/main/Main.java
+++ b/java/com/google/turbine/main/Main.java
@@ -256,9 +256,6 @@ public class Main {
}
private static void usage(TurbineOptions options) {
- if (options.sources().isEmpty() && options.sourceJars().isEmpty()) {
- throw new UsageException("no sources were provided");
- }
if (options.help()) {
throw new UsageException();
}
diff --git a/javatests/com/google/turbine/main/MainTest.java b/javatests/com/google/turbine/main/MainTest.java
index 80a0372..b37cc8c 100644
--- a/javatests/com/google/turbine/main/MainTest.java
+++ b/javatests/com/google/turbine/main/MainTest.java
@@ -29,6 +29,7 @@ import com.google.common.io.ByteStreams;
import com.google.common.io.MoreFiles;
import com.google.turbine.diag.TurbineError;
import com.google.turbine.options.TurbineOptions;
+import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
@@ -261,4 +262,18 @@ public class MainTest {
.contains("at least one of --output, --gensrc_output, or --resource_output is required");
}
}
+
+ @Test
+ public void noSources() throws IOException {
+ // Compilations with no sources (or source jars) are accepted, and create empty for requested
+ // outputs. This is helpful for the Bazel integration, which allows java_library rules to be
+ // declared without sources.
+ File gensrc = temporaryFolder.newFile("gensrc.jar");
+ Main.compile(optionsWithBootclasspath().setGensrcOutput(gensrc.toString()).build());
+ try (JarFile jarFile = new JarFile(gensrc);
+ Stream<JarEntry> entries = jarFile.stream()) {
+ assertThat(entries.map(JarEntry::getName))
+ .containsExactly("META-INF/", "META-INF/MANIFEST.MF");
+ }
+ }
}