use of org.gradle.api.java.archives.internal.DefaultManifest in project jib by google.
the class ProjectPropertiesTest method testGetMainClassFromJarTask.
@Test
public void testGetMainClassFromJarTask() {
Manifest fakeManifest = new DefaultManifest(Mockito.mock(FileResolver.class));
fakeManifest.attributes(ImmutableMap.of("Main-Class", "some.main.class"));
Jar mockJar = Mockito.mock(Jar.class);
Mockito.when(mockJar.getManifest()).thenReturn(fakeManifest);
Project mockProject = Mockito.mock(Project.class);
Mockito.when(mockProject.getTasksByName("jar", false)).thenReturn(ImmutableSet.of(mockJar));
ProjectProperties testProjectProperties = new ProjectProperties(mockProject, Mockito.mock(Logger.class));
Assert.assertEquals("some.main.class", testProjectProperties.getMainClassFromJarTask());
}
use of org.gradle.api.java.archives.internal.DefaultManifest in project gradle by gradle.
the class Jar method computeManifest.
private ManifestInternal computeManifest() {
Manifest manifest = getManifest();
if (manifest == null) {
manifest = new DefaultManifest(null);
}
ManifestInternal manifestInternal;
if (manifest instanceof ManifestInternal) {
manifestInternal = (ManifestInternal) manifest;
} else {
manifestInternal = new CustomManifestInternalWrapper(manifest);
}
manifestInternal.setContentCharset(manifestContentCharset);
return manifestInternal;
}
use of org.gradle.api.java.archives.internal.DefaultManifest in project gradle by gradle.
the class DefaultOsgiManifest method getEffectiveManifest.
@Override
public DefaultManifest getEffectiveManifest() {
ContainedVersionAnalyzer analyzer = analyzerFactory.create();
DefaultManifest effectiveManifest = new DefaultManifest(null);
try {
setAnalyzerProperties(analyzer);
Manifest osgiManifest = analyzer.calcManifest();
java.util.jar.Attributes attributes = osgiManifest.getMainAttributes();
for (Map.Entry<Object, Object> entry : attributes.entrySet()) {
effectiveManifest.attributes(WrapUtil.toMap(entry.getKey().toString(), (String) entry.getValue()));
}
effectiveManifest.attributes(this.getAttributes());
for (Map.Entry<String, Attributes> ent : getSections().entrySet()) {
effectiveManifest.attributes(ent.getValue(), ent.getKey());
}
if (classesDir != null) {
long mod = classesDir.lastModified();
if (mod > 0) {
effectiveManifest.getAttributes().put(Analyzer.BND_LASTMODIFIED, mod);
}
}
} catch (Exception e) {
throw UncheckedException.throwAsUncheckedException(e);
}
return getEffectiveManifestInternal(effectiveManifest);
}
Aggregations