use of org.gradle.api.java.archives.Manifest in project gradle by gradle.
the class JavaPluginConvention method manifest.
/**
* Creates and configures a new instance of a {@link Manifest}.
*
* @param action The action to use to configure the manifest.
* @since 3.5
*/
public Manifest manifest(Action<? super Manifest> action) {
Manifest manifest = createManifest();
action.execute(manifest);
return manifest;
}
use of org.gradle.api.java.archives.Manifest 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.Manifest 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.Manifest in project spring-boot by spring-projects.
the class BootArchiveSupport method createCopyAction.
CopyAction createCopyAction(Jar jar, LayerResolver layerResolver, String layerToolsLocation) {
File output = jar.getArchiveFile().get().getAsFile();
Manifest manifest = jar.getManifest();
boolean preserveFileTimestamps = jar.isPreserveFileTimestamps();
boolean includeDefaultLoader = isUsingDefaultLoader(jar);
Spec<FileTreeElement> requiresUnpack = this.requiresUnpack.getAsSpec();
Spec<FileTreeElement> exclusions = this.exclusions.getAsExcludeSpec();
LaunchScriptConfiguration launchScript = this.launchScript;
Spec<FileCopyDetails> librarySpec = this.librarySpec;
Function<FileCopyDetails, ZipCompression> compressionResolver = this.compressionResolver;
String encoding = jar.getMetadataCharset();
CopyAction action = new BootZipCopyAction(output, manifest, preserveFileTimestamps, includeDefaultLoader, layerToolsLocation, requiresUnpack, exclusions, launchScript, librarySpec, compressionResolver, encoding, layerResolver);
return jar.isReproducibleFileOrder() ? new ReproducibleOrderingCopyAction(action) : action;
}
use of org.gradle.api.java.archives.Manifest in project gradle by gradle.
the class Jar method manifestFileTree.
private FileTreeInternal manifestFileTree() {
final Cached<ManifestInternal> manifest = Cached.of(this::computeManifest);
final OutputChangeListener outputChangeListener = outputChangeListener();
return fileCollectionFactory().generated(getTemporaryDirFactory(), "MANIFEST.MF", action(file -> outputChangeListener.beforeOutputChange(ImmutableList.of(file.getAbsolutePath()))), action(outputStream -> manifest.get().writeTo(outputStream)));
}
Aggregations