aboutsummaryrefslogtreecommitdiff
path: root/javatests
diff options
context:
space:
mode:
authorcushon <cushon@google.com>2020-01-10 12:47:26 -0800
committerColin Decker <cgdecker@gmail.com>2020-01-13 16:39:19 -0500
commit68bbea5139ae8f1750c5028b3bd63d8629c02b2f (patch)
treebdf872ea0b9c4922845ffe97f0e1e2930d8bea97 /javatests
parent76dbaaf3e9b1926a8c4f9d801e27aca4a0695fda (diff)
downloadturbine-68bbea5139ae8f1750c5028b3bd63d8629c02b2f.tar.gz
Allow --sources to be empty
and perform a no-op compilation, which produces empty jars for any requested outputs. This is helpful for the Bazel integration, which allows java_library rules to be declared without sources. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=289146397
Diffstat (limited to 'javatests')
-rw-r--r--javatests/com/google/turbine/main/MainTest.java15
1 files changed, 15 insertions, 0 deletions
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");
+ }
+ }
}