diff options
author | tomlu <tomlu@google.com> | 2018-02-09 10:32:40 -0800 |
---|---|---|
committer | Copybara-Service <copybara-piper@google.com> | 2018-02-09 10:34:20 -0800 |
commit | 8a56b164facce7844718a0c80554f6c11ba155f2 (patch) | |
tree | 0c977e9834d2d67f257dc8db4600ada757bd285f /third_party/ijar/test/IjarTests.java | |
parent | ad32f62952e2b6f8293a26ea5fd677e61975c9ff (diff) |
Accept --target_label, --injecting_rule_kind in ijar.
This is a rollforward with fixes.
The values (if present) are written into the manifest with this format:
Target-Label: <label>
Injecting-Rule-Kind: <kind>
In the future, JavaBuilder will make sure of this instead of command line arguments to find owners for jars for its add_dep commands.
PiperOrigin-RevId: 185159950
Diffstat (limited to 'third_party/ijar/test/IjarTests.java')
-rw-r--r-- | third_party/ijar/test/IjarTests.java | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/third_party/ijar/test/IjarTests.java b/third_party/ijar/test/IjarTests.java index 4e0fb5d839..467680552b 100644 --- a/third_party/ijar/test/IjarTests.java +++ b/third_party/ijar/test/IjarTests.java @@ -23,15 +23,19 @@ import com.google.common.io.ByteStreams; import com.google.devtools.build.java.bazel.BazelJavaCompiler; import java.io.File; import java.io.IOException; +import java.time.Instant; import java.util.Arrays; import java.util.Collections; import java.util.Enumeration; +import java.util.GregorianCalendar; import java.util.HashMap; import java.util.Locale; import java.util.Map; import java.util.Set; +import java.util.jar.Attributes; import java.util.jar.JarEntry; import java.util.jar.JarFile; +import java.util.jar.Manifest; import java.util.zip.ZipEntry; import java.util.zip.ZipFile; import javax.annotation.processing.AbstractProcessor; @@ -274,4 +278,18 @@ public class IjarTests { assertThat(new String(lib.get("module-info.class"), UTF_8)).isEqualTo("hello"); assertThat(new String(lib.get("foo/module-info.class"), UTF_8)).isEqualTo("goodbye"); } + + @Test + public void testTargetLabel() throws Exception { + try (JarFile jf = + new JarFile("third_party/ijar/test/interface_ijar_testlib_with_target_label.jar")) { + Manifest manifest = jf.getManifest(); + Attributes attributes = manifest.getMainAttributes(); + assertThat(attributes.getValue("Target-Label")).isEqualTo("//foo:foo"); + assertThat(attributes.getValue("Injecting-Rule-Kind")).isEqualTo("foo_library"); + assertThat(jf.getEntry(JarFile.MANIFEST_NAME).getLastModifiedTime().toInstant()) + .isEqualTo( + Instant.ofEpochMilli(new GregorianCalendar(1980, 0, 1, 0, 0, 0).getTimeInMillis())); + } + } } |