Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 41 additions & 6 deletions src/main/java/org/apache/maven/archiver/MavenArchiver.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
import org.apache.maven.artifact.versioning.OverConstrainedVersionException;
import org.apache.maven.execution.MavenSession;
import org.apache.maven.project.MavenProject;
import org.apache.maven.toolchain.Toolchain;
import org.codehaus.plexus.archiver.jar.JarArchiver;
import org.codehaus.plexus.archiver.jar.Manifest;
import org.codehaus.plexus.archiver.jar.ManifestException;
Expand Down Expand Up @@ -118,6 +119,8 @@ static boolean isValidModuleName(String name) {

private boolean buildJdkSpecDefaultEntry = true;

private Toolchain toolchain;

/**
* <p>getManifest.</p>
*
Expand Down Expand Up @@ -615,7 +618,17 @@ private void handleDefaultEntries(MavenProject project, Manifest m, Map<String,
addManifestAttribute(m, entries, "Java-Version", javaVersion);
}
if (buildJdkSpecDefaultEntry) {
addManifestAttribute(m, entries, "Build-Jdk-Spec", System.getProperty("java.specification.version"));
String runtimeSpec = System.getProperty("java.specification.version");
String buildSpec;
if (toolchain == null) {
buildSpec = runtimeSpec;
} else {
// TODO extract JDK Spec from toolchain
buildSpec = "TODO";
}

addManifestAttribute(m, entries, "Build-Tool-Jre-Spec", runtimeSpec);
addManifestAttribute(m, entries, "Build-Jdk-Spec", buildSpec);
}
}

Expand All @@ -626,11 +639,19 @@ private void handleBuildEnvironmentEntries(MavenSession session, Manifest m, Map
entries,
"Build-Tool",
session != null ? session.getSystemProperties().getProperty("maven.build.version") : "Apache Maven");
addManifestAttribute(
m,
entries,
"Build-Jdk",
String.format("%s (%s)", System.getProperty("java.version"), System.getProperty("java.vendor")));

String runtimeJvm =
String.format("%s (%s)", System.getProperty("java.version"), System.getProperty("java.vendor"));
String buildJvm;
if (toolchain == null) {
buildJvm = runtimeJvm;
} else {
// TODO extract JDK from toolchain
buildJvm = "TODO";
}
addManifestAttribute(m, entries, "Build-Tool-Jre", runtimeJvm);
addManifestAttribute(m, entries, "Build-Jdk", buildJvm);

addManifestAttribute(
m,
entries,
Expand Down Expand Up @@ -810,4 +831,18 @@ public void configureReproducibleBuild(String outputTimestamp) {
parseBuildOutputTimestamp(outputTimestamp).map(FileTime::from).ifPresent(modifiedTime -> getArchiver()
.configureReproducibleBuild(modifiedTime));
}

/**
* Configure Toolchain used for creating the archive.
*
* @param toolchain the toolchain (may be {@code null})
* @since 3.6.7
*/
public void setToolchain(Toolchain toolchain) {
this.toolchain = toolchain;
}

public Toolchain getToolchain() {
return toolchain;
}
}
10 changes: 7 additions & 3 deletions src/site/xdoc/index.xml.vm
Original file line number Diff line number Diff line change
Expand Up @@ -218,13 +218,16 @@ version=\${project.version}</source>
<td>
If the manifest will contain these entries:
<source>Created-By: Maven Archiver ${project.version}
Build-Jdk-Spec: ${java.specification.version}
Build-Tool-Jre-Spec: ${java.specification.version}
Build-Jdk-Spec: ${java.specification.version} of compiler
Java-Version: &#36;{project maven.compiler.release/target}</source>
Since 3.5.0, the default value of <code>Created-By</code> entry can be overridden (usually by plugin code) using
<a href="./apidocs/org/apache/maven/archiver/MavenArchiver.html">MavenArchiver.setCreatedBy(...)</a> API.<br />
Since 3.6.5, <code>Java-Version</code> entry is discovered by
<a href="./apidocs/org/apache/maven/archiver/BuildHelper.html">BuildHelper.discoverJavaRelease(...)</a> API.<br />
The default value is <code>true</code>.
The default value is <code>true</code>.<br />
Since 3.6.7, <code>Build-Tool-Jre-Spec</code> entry is added with Maven runtime info, while
<code>Build-Jdk-Spec</code> follows eventual toolchain.
</td>
</tr>
<tr>
Expand Down Expand Up @@ -258,7 +261,8 @@ Specification-Vendor: \${project.organization.name}</source>
<td>
If the manifest will contain these entries:
<source>Build-Tool: ${maven.build.version}
Build-Jdk: ${java.version} (${java.vendor})
Build-Tool-Jre: ${java.version} (${java.vendor})
Build-Jdk: ${java.version} (${java.vendor}) of compiler
Build-Os: ${os.name} (${os.version}; (${os.arch})</source>
The default value is <code>false</code>.
</td>
Expand Down