[jira] [Commented] (MJAR-62) Build-Jdk in Manifest.mf does not reflect which compiler version actually compiled the classes in the jar
[ https://issues.apache.org/jira/browse/MJAR-62?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17830242#comment-17830242 ] ASF GitHub Bot commented on MJAR-62: slawekjaranowski merged PR #73: URL: https://github.com/apache/maven-jar-plugin/pull/73 > Build-Jdk in Manifest.mf does not reflect which compiler version actually > compiled the classes in the jar > - > > Key: MJAR-62 > URL: https://issues.apache.org/jira/browse/MJAR-62 > Project: Maven JAR Plugin > Issue Type: Bug >Reporter: Stefan Magnus Landrø >Assignee: Slawomir Jaranowski >Priority: Major > Fix For: 3.4.0 > > Attachments: example-app.zip > > > Manifest.mf does not reflect the version of the compiler that built the jar, > but defaults to the version that maven runs under: Build-Jdk: > ${java.version}. > I believe this makes users uncertain of which compiler was actually used to > build the classes. -- This message was sent by Atlassian Jira (v8.20.10#820010)
[jira] [Commented] (MJAR-62) Build-Jdk in Manifest.mf does not reflect which compiler version actually compiled the classes in the jar
[ https://issues.apache.org/jira/browse/MJAR-62?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17830240#comment-17830240 ] ASF GitHub Bot commented on MJAR-62: slawekjaranowski commented on code in PR #73: URL: https://github.com/apache/maven-jar-plugin/pull/73#discussion_r1536778031 ## src/main/java/org/apache/maven/plugins/jar/ToolchainsJdkSpecification.java: ## @@ -0,0 +1,99 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.maven.plugins.jar; + +import javax.inject.Named; +import javax.inject.Singleton; + +import java.io.IOException; +import java.io.UncheckedIOException; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.HashMap; +import java.util.Map; +import java.util.Optional; + +import org.apache.maven.toolchain.Toolchain; +import org.codehaus.plexus.util.cli.CommandLineException; +import org.codehaus.plexus.util.cli.CommandLineUtils; +import org.codehaus.plexus.util.cli.Commandline; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * Component provided JDK specification based on toolchains. + */ +@Named +@Singleton +class ToolchainsJdkSpecification { + +private final Logger logger = LoggerFactory.getLogger(ToolchainsJdkSpecification.class); + +private final Map cache = new HashMap<>(); + +public synchronized Optional getJDKSpecification(Toolchain toolchain) { +Optional javacPath = getJavacPath(toolchain); +return javacPath.map(path -> cache.computeIfAbsent(path, this::getSpecForPath)); +} + +private Optional getJavacPath(Toolchain toolchain) { +return Optional.ofNullable(toolchain.findTool("javac")).map(Paths::get).map(this::getCanonicalPath); +} + +private Path getCanonicalPath(Path path) { +try { +return path.toRealPath(); +} catch (IOException e) { +if (path.getParent() != null) { +return getCanonicalPath(path.getParent()).resolve(path.getFileName()); +} else { +throw new UncheckedIOException(e); +} +} +} + +private String getSpecForPath(Path path) { +try { +Commandline cl = new Commandline(path.toString()); +cl.createArg().setValue("-version"); +CommandLineUtils.StringStreamConsumer out = new CommandLineUtils.StringStreamConsumer(); +CommandLineUtils.StringStreamConsumer err = new CommandLineUtils.StringStreamConsumer(); +CommandLineUtils.executeCommandLine(cl, out, err); +String version = out.getOutput().trim(); +if (version.isEmpty()) { +version = err.getOutput().trim(); +} +if (version.startsWith("javac ")) { +version = version.substring(6); +if (version.startsWith("1.")) { +version = version.substring(0, 3); +} else { +version = version.substring(0, 2); +} +return version; +} else { +logger.warn("Unrecognized output form " + path + " -version - " + version); +return null; +} +} catch (CommandLineException e) { Review Comment: done > Build-Jdk in Manifest.mf does not reflect which compiler version actually > compiled the classes in the jar > - > > Key: MJAR-62 > URL: https://issues.apache.org/jira/browse/MJAR-62 > Project: Maven JAR Plugin > Issue Type: Bug >Reporter: Stefan Magnus Landrø >Assignee: Slawomir Jaranowski >Priority: Major > Fix For: 3.4.0 > > Attachments: example-app.zip > > > Manifest.mf does not reflect the version of the compiler that built the jar, > but defaults to the version that maven runs under: Build-Jdk: > ${java.version}. > I believe this makes users uncertain of which compiler was actually used to > build the classes. -- This message was sent by
[jira] [Commented] (MJAR-62) Build-Jdk in Manifest.mf does not reflect which compiler version actually compiled the classes in the jar
[ https://issues.apache.org/jira/browse/MJAR-62?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17830177#comment-17830177 ] ASF GitHub Bot commented on MJAR-62: elharo commented on code in PR #73: URL: https://github.com/apache/maven-jar-plugin/pull/73#discussion_r1536701278 ## src/main/java/org/apache/maven/plugins/jar/ToolchainsJdkSpecification.java: ## @@ -0,0 +1,99 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.maven.plugins.jar; + +import javax.inject.Named; +import javax.inject.Singleton; + +import java.io.IOException; +import java.io.UncheckedIOException; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.HashMap; +import java.util.Map; +import java.util.Optional; + +import org.apache.maven.toolchain.Toolchain; +import org.codehaus.plexus.util.cli.CommandLineException; +import org.codehaus.plexus.util.cli.CommandLineUtils; +import org.codehaus.plexus.util.cli.Commandline; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * Component provided JDK specification based on toolchains. + */ +@Named +@Singleton +class ToolchainsJdkSpecification { + +private final Logger logger = LoggerFactory.getLogger(ToolchainsJdkSpecification.class); + +private final Map cache = new HashMap<>(); + +public synchronized Optional getJDKSpecification(Toolchain toolchain) { +Optional javacPath = getJavacPath(toolchain); +return javacPath.map(path -> cache.computeIfAbsent(path, this::getSpecForPath)); +} + +private Optional getJavacPath(Toolchain toolchain) { +return Optional.ofNullable(toolchain.findTool("javac")).map(Paths::get).map(this::getCanonicalPath); +} + +private Path getCanonicalPath(Path path) { +try { +return path.toRealPath(); +} catch (IOException e) { +if (path.getParent() != null) { +return getCanonicalPath(path.getParent()).resolve(path.getFileName()); +} else { +throw new UncheckedIOException(e); +} +} +} + +private String getSpecForPath(Path path) { +try { +Commandline cl = new Commandline(path.toString()); +cl.createArg().setValue("-version"); +CommandLineUtils.StringStreamConsumer out = new CommandLineUtils.StringStreamConsumer(); +CommandLineUtils.StringStreamConsumer err = new CommandLineUtils.StringStreamConsumer(); +CommandLineUtils.executeCommandLine(cl, out, err); +String version = out.getOutput().trim(); +if (version.isEmpty()) { +version = err.getOutput().trim(); +} +if (version.startsWith("javac ")) { +version = version.substring(6); +if (version.startsWith("1.")) { +version = version.substring(0, 3); +} else { +version = version.substring(0, 2); +} +return version; +} else { +logger.warn("Unrecognized output form " + path + " -version - " + version); +return null; +} +} catch (CommandLineException e) { Review Comment: CommandLineException | IndexOutOfBoundsException > Build-Jdk in Manifest.mf does not reflect which compiler version actually > compiled the classes in the jar > - > > Key: MJAR-62 > URL: https://issues.apache.org/jira/browse/MJAR-62 > Project: Maven JAR Plugin > Issue Type: Bug >Reporter: Stefan Magnus Landrø >Assignee: Slawomir Jaranowski >Priority: Major > Fix For: 3.4.0 > > Attachments: example-app.zip > > > Manifest.mf does not reflect the version of the compiler that built the jar, > but defaults to the version that maven runs under: Build-Jdk: > ${java.version}. > I believe this makes users uncertain of which compiler was actually used to > build the classes.
[jira] [Commented] (MJAR-62) Build-Jdk in Manifest.mf does not reflect which compiler version actually compiled the classes in the jar
[ https://issues.apache.org/jira/browse/MJAR-62?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17830162#comment-17830162 ] ASF GitHub Bot commented on MJAR-62: slawekjaranowski commented on code in PR #73: URL: https://github.com/apache/maven-jar-plugin/pull/73#discussion_r1536684208 ## src/main/java/org/apache/maven/plugins/jar/ToolchainsJdkSpecification.java: ## @@ -0,0 +1,99 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.maven.plugins.jar; + +import javax.inject.Named; +import javax.inject.Singleton; + +import java.io.IOException; +import java.io.UncheckedIOException; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.HashMap; +import java.util.Map; +import java.util.Optional; + +import org.apache.maven.toolchain.Toolchain; +import org.codehaus.plexus.util.cli.CommandLineException; +import org.codehaus.plexus.util.cli.CommandLineUtils; +import org.codehaus.plexus.util.cli.Commandline; + +/** + * Component provided JDK specification based on toolchains. + */ +@Named +@Singleton +class ToolchainsJdkSpecification { + +private static class UncheckedCommandLineException extends RuntimeException { +UncheckedCommandLineException(CommandLineException e) { +super(e); +} +} + +private final Map cache = new HashMap<>(); + +public synchronized Optional getJDKSpecification(Toolchain toolchain) { +Optional javacPath = getJavacPath(toolchain); +return javacPath.map(path -> cache.computeIfAbsent(path, this::getSpecForPath)); +} + +private Optional getJavacPath(Toolchain toolchain) { +return Optional.ofNullable(toolchain.findTool("javac")).map(Paths::get).map(this::getCanonicalPath); +} + +private Path getCanonicalPath(Path path) { +try { +return path.toRealPath(); +} catch (IOException e) { +if (path.getParent() != null) { +return getCanonicalPath(path.getParent()).resolve(path.getFileName()); +} else { +throw new UncheckedIOException(e); +} +} +} + +private String getSpecForPath(Path path) { +try { +Commandline cl = new Commandline(path.toString()); +cl.createArg().setValue("-version"); +CommandLineUtils.StringStreamConsumer out = new CommandLineUtils.StringStreamConsumer(); +CommandLineUtils.StringStreamConsumer err = new CommandLineUtils.StringStreamConsumer(); +CommandLineUtils.executeCommandLine(cl, out, err); +String version = out.getOutput().trim(); +if (version.isEmpty()) { +version = err.getOutput().trim(); +} +if (version.startsWith("javac ")) { +version = version.substring(6); +if (version.startsWith("1.")) { +version = version.substring(0, 3); +} else { +version = version.substring(0, 2); +} +return version; +} else { +return null; +} +} catch (CommandLineException e) { +throw new UncheckedCommandLineException(e); Review Comment: ok, no exception - only warn about something wrong as it is not critical build should not be broken > Build-Jdk in Manifest.mf does not reflect which compiler version actually > compiled the classes in the jar > - > > Key: MJAR-62 > URL: https://issues.apache.org/jira/browse/MJAR-62 > Project: Maven JAR Plugin > Issue Type: Bug >Reporter: Stefan Magnus Landrø >Assignee: Slawomir Jaranowski >Priority: Major > Fix For: 3.4.0 > > Attachments: example-app.zip > > > Manifest.mf does not reflect the version of the compiler that built the jar, > but defaults to the version that maven runs under: Build-Jdk: > ${java.version}. > I believe this makes users uncertain
[jira] [Commented] (MJAR-62) Build-Jdk in Manifest.mf does not reflect which compiler version actually compiled the classes in the jar
[ https://issues.apache.org/jira/browse/MJAR-62?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17830085#comment-17830085 ] ASF GitHub Bot commented on MJAR-62: slawekjaranowski commented on code in PR #73: URL: https://github.com/apache/maven-jar-plugin/pull/73#discussion_r1536641995 ## src/main/java/org/apache/maven/plugins/jar/ToolchainsJdkSpecification.java: ## @@ -0,0 +1,99 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.maven.plugins.jar; + +import javax.inject.Named; +import javax.inject.Singleton; + +import java.io.IOException; +import java.io.UncheckedIOException; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.HashMap; +import java.util.Map; +import java.util.Optional; + +import org.apache.maven.toolchain.Toolchain; +import org.codehaus.plexus.util.cli.CommandLineException; +import org.codehaus.plexus.util.cli.CommandLineUtils; +import org.codehaus.plexus.util.cli.Commandline; + +/** + * Component provided JDK specification based on toolchains. + */ +@Named +@Singleton +class ToolchainsJdkSpecification { + +private static class UncheckedCommandLineException extends RuntimeException { +UncheckedCommandLineException(CommandLineException e) { +super(e); +} +} + +private final Map cache = new HashMap<>(); + +public synchronized Optional getJDKSpecification(Toolchain toolchain) { +Optional javacPath = getJavacPath(toolchain); +return javacPath.map(path -> cache.computeIfAbsent(path, this::getSpecForPath)); +} + +private Optional getJavacPath(Toolchain toolchain) { +return Optional.ofNullable(toolchain.findTool("javac")).map(Paths::get).map(this::getCanonicalPath); +} + +private Path getCanonicalPath(Path path) { +try { +return path.toRealPath(); +} catch (IOException e) { +if (path.getParent() != null) { +return getCanonicalPath(path.getParent()).resolve(path.getFileName()); +} else { +throw new UncheckedIOException(e); +} +} +} + +private String getSpecForPath(Path path) { +try { +Commandline cl = new Commandline(path.toString()); +cl.createArg().setValue("-version"); +CommandLineUtils.StringStreamConsumer out = new CommandLineUtils.StringStreamConsumer(); +CommandLineUtils.StringStreamConsumer err = new CommandLineUtils.StringStreamConsumer(); +CommandLineUtils.executeCommandLine(cl, out, err); +String version = out.getOutput().trim(); +if (version.isEmpty()) { +version = err.getOutput().trim(); +} +if (version.startsWith("javac ")) { +version = version.substring(6); +if (version.startsWith("1.")) { +version = version.substring(0, 3); +} else { +version = version.substring(0, 2); +} +return version; +} else { +return null; +} +} catch (CommandLineException e) { +throw new UncheckedCommandLineException(e); Review Comment: It is idea but we should log a warning about it > Build-Jdk in Manifest.mf does not reflect which compiler version actually > compiled the classes in the jar > - > > Key: MJAR-62 > URL: https://issues.apache.org/jira/browse/MJAR-62 > Project: Maven JAR Plugin > Issue Type: Bug >Reporter: Stefan Magnus Landrø >Assignee: Slawomir Jaranowski >Priority: Major > Fix For: 3.4.0 > > Attachments: example-app.zip > > > Manifest.mf does not reflect the version of the compiler that built the jar, > but defaults to the version that maven runs under: Build-Jdk: > ${java.version}. > I believe this makes users uncertain of which compiler was actually used to > build
[jira] [Commented] (MJAR-62) Build-Jdk in Manifest.mf does not reflect which compiler version actually compiled the classes in the jar
[ https://issues.apache.org/jira/browse/MJAR-62?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17829984#comment-17829984 ] ASF GitHub Bot commented on MJAR-62: elharo commented on code in PR #73: URL: https://github.com/apache/maven-jar-plugin/pull/73#discussion_r1536163772 ## src/main/java/org/apache/maven/plugins/jar/ToolchainsJdkSpecification.java: ## @@ -0,0 +1,99 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.maven.plugins.jar; + +import javax.inject.Named; +import javax.inject.Singleton; + +import java.io.IOException; +import java.io.UncheckedIOException; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.HashMap; +import java.util.Map; +import java.util.Optional; + +import org.apache.maven.toolchain.Toolchain; +import org.codehaus.plexus.util.cli.CommandLineException; +import org.codehaus.plexus.util.cli.CommandLineUtils; +import org.codehaus.plexus.util.cli.Commandline; + +/** + * Component provided JDK specification based on toolchains. + */ +@Named +@Singleton +class ToolchainsJdkSpecification { + +private static class UncheckedCommandLineException extends RuntimeException { +UncheckedCommandLineException(CommandLineException e) { +super(e); +} +} + +private final Map cache = new HashMap<>(); + +public synchronized Optional getJDKSpecification(Toolchain toolchain) { +Optional javacPath = getJavacPath(toolchain); +return javacPath.map(path -> cache.computeIfAbsent(path, this::getSpecForPath)); +} + +private Optional getJavacPath(Toolchain toolchain) { +return Optional.ofNullable(toolchain.findTool("javac")).map(Paths::get).map(this::getCanonicalPath); +} + +private Path getCanonicalPath(Path path) { +try { +return path.toRealPath(); +} catch (IOException e) { +if (path.getParent() != null) { +return getCanonicalPath(path.getParent()).resolve(path.getFileName()); +} else { +throw new UncheckedIOException(e); +} +} +} + +private String getSpecForPath(Path path) { +try { +Commandline cl = new Commandline(path.toString()); +cl.createArg().setValue("-version"); +CommandLineUtils.StringStreamConsumer out = new CommandLineUtils.StringStreamConsumer(); +CommandLineUtils.StringStreamConsumer err = new CommandLineUtils.StringStreamConsumer(); +CommandLineUtils.executeCommandLine(cl, out, err); +String version = out.getOutput().trim(); +if (version.isEmpty()) { +version = err.getOutput().trim(); +} +if (version.startsWith("javac ")) { +version = version.substring(6); +if (version.startsWith("1.")) { +version = version.substring(0, 3); +} else { +version = version.substring(0, 2); +} +return version; +} else { +return null; +} +} catch (CommandLineException e) { +throw new UncheckedCommandLineException(e); Review Comment: Since you're already returning null in line 93, it might make sense to return null here as well. ## src/main/java/org/apache/maven/plugins/jar/ToolchainsJdkSpecification.java: ## @@ -0,0 +1,99 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + *
[jira] [Commented] (MJAR-62) Build-Jdk in Manifest.mf does not reflect which compiler version actually compiled the classes in the jar
[ https://issues.apache.org/jira/browse/MJAR-62?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17829921#comment-17829921 ] ASF GitHub Bot commented on MJAR-62: slawekjaranowski commented on code in PR #73: URL: https://github.com/apache/maven-jar-plugin/pull/73#discussion_r1535834916 ## src/test/java/org/apache/maven/plugins/jar/ToolchainsJdkVersionTest.java: ## @@ -0,0 +1,88 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.maven.plugins.jar; + +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.Locale; +import java.util.Optional; + +import org.apache.maven.toolchain.Toolchain; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Assumptions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.Mock; +import org.mockito.junit.jupiter.MockitoExtension; + +import static org.mockito.Mockito.when; + +@ExtendWith(MockitoExtension.class) +class ToolchainsJdkVersionTest { + +@Mock +private Toolchain toolchain; + +private final ToolchainsJdkSpecification toolchainsJdkSpecification = new ToolchainsJdkSpecification(); + +@Test +void shouldReturnCorrectSpec() { + +Path javaCPath = getJavaCPath(); Review Comment: You are right I missed in unit test - fixed also > Build-Jdk in Manifest.mf does not reflect which compiler version actually > compiled the classes in the jar > - > > Key: MJAR-62 > URL: https://issues.apache.org/jira/browse/MJAR-62 > Project: Maven JAR Plugin > Issue Type: Bug >Reporter: Stefan Magnus Landrø >Assignee: Slawomir Jaranowski >Priority: Major > Fix For: 3.4.0 > > Attachments: example-app.zip > > > Manifest.mf does not reflect the version of the compiler that built the jar, > but defaults to the version that maven runs under: Build-Jdk: > ${java.version}. > I believe this makes users uncertain of which compiler was actually used to > build the classes. -- This message was sent by Atlassian Jira (v8.20.10#820010)
[jira] [Commented] (MJAR-62) Build-Jdk in Manifest.mf does not reflect which compiler version actually compiled the classes in the jar
[ https://issues.apache.org/jira/browse/MJAR-62?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17829843#comment-17829843 ] ASF GitHub Bot commented on MJAR-62: elharo commented on code in PR #73: URL: https://github.com/apache/maven-jar-plugin/pull/73#discussion_r1535452791 ## src/test/java/org/apache/maven/plugins/jar/ToolchainsJdkVersionTest.java: ## @@ -0,0 +1,88 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.maven.plugins.jar; + +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.Locale; +import java.util.Optional; + +import org.apache.maven.toolchain.Toolchain; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Assumptions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.Mock; +import org.mockito.junit.jupiter.MockitoExtension; + +import static org.mockito.Mockito.when; + +@ExtendWith(MockitoExtension.class) +class ToolchainsJdkVersionTest { + +@Mock +private Toolchain toolchain; + +private final ToolchainsJdkSpecification toolchainsJdkSpecification = new ToolchainsJdkSpecification(); + +@Test +void shouldReturnCorrectSpec() { + +Path javaCPath = getJavaCPath(); Review Comment: do you need to push? I still see javaCPath > Build-Jdk in Manifest.mf does not reflect which compiler version actually > compiled the classes in the jar > - > > Key: MJAR-62 > URL: https://issues.apache.org/jira/browse/MJAR-62 > Project: Maven JAR Plugin > Issue Type: Bug >Reporter: Stefan Magnus Landrø >Assignee: Slawomir Jaranowski >Priority: Major > Fix For: 3.4.0 > > Attachments: example-app.zip > > > Manifest.mf does not reflect the version of the compiler that built the jar, > but defaults to the version that maven runs under: Build-Jdk: > ${java.version}. > I believe this makes users uncertain of which compiler was actually used to > build the classes. -- This message was sent by Atlassian Jira (v8.20.10#820010)
[jira] [Commented] (MJAR-62) Build-Jdk in Manifest.mf does not reflect which compiler version actually compiled the classes in the jar
[ https://issues.apache.org/jira/browse/MJAR-62?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17829780#comment-17829780 ] ASF GitHub Bot commented on MJAR-62: slawekjaranowski commented on code in PR #73: URL: https://github.com/apache/maven-jar-plugin/pull/73#discussion_r1535215589 ## src/main/java/org/apache/maven/plugins/jar/ToolchainsJdkSpecification.java: ## @@ -0,0 +1,93 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.maven.plugins.jar; + +import javax.inject.Named; +import javax.inject.Singleton; + +import java.io.IOException; +import java.io.UncheckedIOException; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.HashMap; +import java.util.Map; +import java.util.Optional; + +import org.apache.maven.toolchain.Toolchain; +import org.codehaus.plexus.util.cli.CommandLineException; +import org.codehaus.plexus.util.cli.CommandLineUtils; +import org.codehaus.plexus.util.cli.Commandline; + +/** + * Component provided JDK specification based on toolchains. + */ +@Named +@Singleton +class ToolchainsJdkSpecification { + +private final Map cache = new HashMap<>(); + +public synchronized Optional getJDKSpecification(Toolchain toolchain) { +Optional javaCPath = getJavaCPath(toolchain); +return javaCPath.map(path -> cache.computeIfAbsent(path, this::getSpecForPath)); +} + +private Optional getJavaCPath(Toolchain toolchain) { +return Optional.ofNullable(toolchain.findTool("javac")).map(Paths::get).map(this::getCanonicalPath); +} + +private Path getCanonicalPath(Path path) { +try { +return path.toRealPath(); +} catch (IOException e) { +if (path.getParent() != null) { +return getCanonicalPath(path.getParent()).resolve(path.getFileName()); +} else { +throw new UncheckedIOException(e); +} +} +} + +private String getSpecForPath(Path path) { +try { +Commandline cl = new Commandline(path.toString()); +cl.createArg().setValue("-version"); +CommandLineUtils.StringStreamConsumer out = new CommandLineUtils.StringStreamConsumer(); +CommandLineUtils.StringStreamConsumer err = new CommandLineUtils.StringStreamConsumer(); +CommandLineUtils.executeCommandLine(cl, out, err); +String version = out.getOutput().trim(); +if (version.isEmpty()) { +version = err.getOutput().trim(); +} +if (version.startsWith("javac ")) { +version = version.substring(6); +if (version.startsWith("1.")) { +version = version.substring(0, 3); +} else { +version = version.substring(0, 2); +} +return version; +} else { +return null; +} +} catch (CommandLineException e) { +throw new RuntimeException(e); Review Comment: introduce own class for unchecked exception it is used in: `Map.computeIfAbsent` instead of it I need to check map item and add new item ... code will be more complicated > Build-Jdk in Manifest.mf does not reflect which compiler version actually > compiled the classes in the jar > - > > Key: MJAR-62 > URL: https://issues.apache.org/jira/browse/MJAR-62 > Project: Maven JAR Plugin > Issue Type: Bug >Reporter: Stefan Magnus Landrø >Assignee: Slawomir Jaranowski >Priority: Major > Fix For: 3.4.0 > > Attachments: example-app.zip > > > Manifest.mf does not reflect the version of the compiler that built the jar, > but defaults to the version that maven runs under: Build-Jdk: > ${java.version}. > I believe this makes users uncertain of which compiler was actually used to > build the classes. -- This message was sent by Atlassian Jira (v8.20.10#820010)
[jira] [Commented] (MJAR-62) Build-Jdk in Manifest.mf does not reflect which compiler version actually compiled the classes in the jar
[ https://issues.apache.org/jira/browse/MJAR-62?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17829704#comment-17829704 ] ASF GitHub Bot commented on MJAR-62: elharo commented on code in PR #73: URL: https://github.com/apache/maven-jar-plugin/pull/73#discussion_r1534812073 ## src/main/java/org/apache/maven/plugins/jar/ToolchainsJdkSpecification.java: ## @@ -0,0 +1,93 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.maven.plugins.jar; + +import javax.inject.Named; +import javax.inject.Singleton; + +import java.io.IOException; +import java.io.UncheckedIOException; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.HashMap; +import java.util.Map; +import java.util.Optional; + +import org.apache.maven.toolchain.Toolchain; +import org.codehaus.plexus.util.cli.CommandLineException; +import org.codehaus.plexus.util.cli.CommandLineUtils; +import org.codehaus.plexus.util.cli.Commandline; + +/** + * Component provided JDK specification based on toolchains. + */ +@Named +@Singleton +class ToolchainsJdkSpecification { + +private final Map cache = new HashMap<>(); + +public synchronized Optional getJDKSpecification(Toolchain toolchain) { +Optional javaCPath = getJavaCPath(toolchain); +return javaCPath.map(path -> cache.computeIfAbsent(path, this::getSpecForPath)); +} + +private Optional getJavaCPath(Toolchain toolchain) { +return Optional.ofNullable(toolchain.findTool("javac")).map(Paths::get).map(this::getCanonicalPath); +} + +private Path getCanonicalPath(Path path) { +try { +return path.toRealPath(); +} catch (IOException e) { +if (path.getParent() != null) { +return getCanonicalPath(path.getParent()).resolve(path.getFileName()); +} else { +throw new UncheckedIOException(e); +} +} +} + +private String getSpecForPath(Path path) { +try { +Commandline cl = new Commandline(path.toString()); +cl.createArg().setValue("-version"); +CommandLineUtils.StringStreamConsumer out = new CommandLineUtils.StringStreamConsumer(); +CommandLineUtils.StringStreamConsumer err = new CommandLineUtils.StringStreamConsumer(); +CommandLineUtils.executeCommandLine(cl, out, err); +String version = out.getOutput().trim(); +if (version.isEmpty()) { +version = err.getOutput().trim(); +} +if (version.startsWith("javac ")) { +version = version.substring(6); +if (version.startsWith("1.")) { +version = version.substring(0, 3); +} else { +version = version.substring(0, 2); +} +return version; +} else { +return null; +} +} catch (CommandLineException e) { +throw new RuntimeException(e); Review Comment: The tail is wagging the dog. If this needs to be a checked exception, then it should be a checked exception. You don't have to use lambdas. If it should be a runtime exception, it should still be a subclass, not java.lang.RuntimeException, though in this case it really does look like checked exception is the way to go. > Build-Jdk in Manifest.mf does not reflect which compiler version actually > compiled the classes in the jar > - > > Key: MJAR-62 > URL: https://issues.apache.org/jira/browse/MJAR-62 > Project: Maven JAR Plugin > Issue Type: Bug >Reporter: Stefan Magnus Landrø >Assignee: Slawomir Jaranowski >Priority: Major > Fix For: 3.4.0 > > Attachments: example-app.zip > > > Manifest.mf does not reflect the version of the compiler that built the jar, > but defaults to the version that maven runs under: Build-Jdk: > ${java.version}. > I believe this makes
[jira] [Commented] (MJAR-62) Build-Jdk in Manifest.mf does not reflect which compiler version actually compiled the classes in the jar
[ https://issues.apache.org/jira/browse/MJAR-62?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17829691#comment-17829691 ] ASF GitHub Bot commented on MJAR-62: slawekjaranowski commented on code in PR #73: URL: https://github.com/apache/maven-jar-plugin/pull/73#discussion_r1534663246 ## src/main/java/org/apache/maven/plugins/jar/ToolchainsJdkSpecification.java: ## @@ -0,0 +1,93 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.maven.plugins.jar; + +import javax.inject.Named; +import javax.inject.Singleton; + +import java.io.IOException; +import java.io.UncheckedIOException; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.HashMap; +import java.util.Map; +import java.util.Optional; + +import org.apache.maven.toolchain.Toolchain; +import org.codehaus.plexus.util.cli.CommandLineException; +import org.codehaus.plexus.util.cli.CommandLineUtils; +import org.codehaus.plexus.util.cli.Commandline; + +/** + * Component provided JDK specification based on toolchains. + */ +@Named +@Singleton +class ToolchainsJdkSpecification { + +private final Map cache = new HashMap<>(); + +public synchronized Optional getJDKSpecification(Toolchain toolchain) { +Optional javaCPath = getJavaCPath(toolchain); +return javaCPath.map(path -> cache.computeIfAbsent(path, this::getSpecForPath)); +} + +private Optional getJavaCPath(Toolchain toolchain) { +return Optional.ofNullable(toolchain.findTool("javac")).map(Paths::get).map(this::getCanonicalPath); +} + +private Path getCanonicalPath(Path path) { +try { +return path.toRealPath(); +} catch (IOException e) { +if (path.getParent() != null) { +return getCanonicalPath(path.getParent()).resolve(path.getFileName()); +} else { +throw new UncheckedIOException(e); +} +} +} + +private String getSpecForPath(Path path) { +try { +Commandline cl = new Commandline(path.toString()); +cl.createArg().setValue("-version"); +CommandLineUtils.StringStreamConsumer out = new CommandLineUtils.StringStreamConsumer(); +CommandLineUtils.StringStreamConsumer err = new CommandLineUtils.StringStreamConsumer(); +CommandLineUtils.executeCommandLine(cl, out, err); +String version = out.getOutput().trim(); +if (version.isEmpty()) { +version = err.getOutput().trim(); +} +if (version.startsWith("javac ")) { +version = version.substring(6); +if (version.startsWith("1.")) { +version = version.substring(0, 3); +} else { +version = version.substring(0, 2); +} +return version; +} else { +return null; +} +} catch (CommandLineException e) { +throw new RuntimeException(e); Review Comment: method `getSpecForPath` is used in lambda so some of runtime exception is easier to handle it > Build-Jdk in Manifest.mf does not reflect which compiler version actually > compiled the classes in the jar > - > > Key: MJAR-62 > URL: https://issues.apache.org/jira/browse/MJAR-62 > Project: Maven JAR Plugin > Issue Type: Bug >Reporter: Stefan Magnus Landrø >Assignee: Slawomir Jaranowski >Priority: Major > Fix For: 3.4.0 > > Attachments: example-app.zip > > > Manifest.mf does not reflect the version of the compiler that built the jar, > but defaults to the version that maven runs under: Build-Jdk: > ${java.version}. > I believe this makes users uncertain of which compiler was actually used to > build the classes. -- This message was sent by Atlassian Jira (v8.20.10#820010)
[jira] [Commented] (MJAR-62) Build-Jdk in Manifest.mf does not reflect which compiler version actually compiled the classes in the jar
[ https://issues.apache.org/jira/browse/MJAR-62?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17829690#comment-17829690 ] ASF GitHub Bot commented on MJAR-62: slawekjaranowski commented on code in PR #73: URL: https://github.com/apache/maven-jar-plugin/pull/73#discussion_r1534660928 ## src/test/java/org/apache/maven/plugins/jar/ToolchainsJdkVersionTest.java: ## @@ -0,0 +1,88 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.maven.plugins.jar; + +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.Locale; +import java.util.Optional; + +import org.apache.maven.toolchain.Toolchain; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Assumptions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.Mock; +import org.mockito.junit.jupiter.MockitoExtension; + +import static org.mockito.Mockito.when; + +@ExtendWith(MockitoExtension.class) +class ToolchainsJdkVersionTest { + +@Mock +private Toolchain toolchain; + +private final ToolchainsJdkSpecification toolchainsJdkSpecification = new ToolchainsJdkSpecification(); + +@Test +void shouldReturnCorrectSpec() { + +Path javaCPath = getJavaCPath(); Review Comment: done > Build-Jdk in Manifest.mf does not reflect which compiler version actually > compiled the classes in the jar > - > > Key: MJAR-62 > URL: https://issues.apache.org/jira/browse/MJAR-62 > Project: Maven JAR Plugin > Issue Type: Bug >Reporter: Stefan Magnus Landrø >Assignee: Slawomir Jaranowski >Priority: Major > Fix For: 3.4.0 > > Attachments: example-app.zip > > > Manifest.mf does not reflect the version of the compiler that built the jar, > but defaults to the version that maven runs under: Build-Jdk: > ${java.version}. > I believe this makes users uncertain of which compiler was actually used to > build the classes. -- This message was sent by Atlassian Jira (v8.20.10#820010)
[jira] [Commented] (MJAR-62) Build-Jdk in Manifest.mf does not reflect which compiler version actually compiled the classes in the jar
[ https://issues.apache.org/jira/browse/MJAR-62?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17829688#comment-17829688 ] ASF GitHub Bot commented on MJAR-62: slawekjaranowski commented on code in PR #73: URL: https://github.com/apache/maven-jar-plugin/pull/73#discussion_r1534659142 ## src/main/java/org/apache/maven/plugins/jar/ToolchainsJdkSpecification.java: ## @@ -0,0 +1,93 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.maven.plugins.jar; + +import javax.inject.Named; +import javax.inject.Singleton; + +import java.io.IOException; +import java.io.UncheckedIOException; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.HashMap; +import java.util.Map; +import java.util.Optional; + +import org.apache.maven.toolchain.Toolchain; +import org.codehaus.plexus.util.cli.CommandLineException; +import org.codehaus.plexus.util.cli.CommandLineUtils; +import org.codehaus.plexus.util.cli.Commandline; + +/** + * Component provided JDK specification based on toolchains. + */ +@Named +@Singleton +class ToolchainsJdkSpecification { + +private final Map cache = new HashMap<>(); + +public synchronized Optional getJDKSpecification(Toolchain toolchain) { +Optional javaCPath = getJavaCPath(toolchain); +return javaCPath.map(path -> cache.computeIfAbsent(path, this::getSpecForPath)); +} + +private Optional getJavaCPath(Toolchain toolchain) { +return Optional.ofNullable(toolchain.findTool("javac")).map(Paths::get).map(this::getCanonicalPath); +} + +private Path getCanonicalPath(Path path) { +try { +return path.toRealPath(); +} catch (IOException e) { +if (path.getParent() != null) { +return getCanonicalPath(path.getParent()).resolve(path.getFileName()); +} else { +throw new UncheckedIOException(e); +} +} +} + +private String getSpecForPath(Path path) { +try { +Commandline cl = new Commandline(path.toString()); +cl.createArg().setValue("-version"); +CommandLineUtils.StringStreamConsumer out = new CommandLineUtils.StringStreamConsumer(); +CommandLineUtils.StringStreamConsumer err = new CommandLineUtils.StringStreamConsumer(); +CommandLineUtils.executeCommandLine(cl, out, err); +String version = out.getOutput().trim(); +if (version.isEmpty()) { +version = err.getOutput().trim(); +} +if (version.startsWith("javac ")) { +version = version.substring(6); +if (version.startsWith("1.")) { +version = version.substring(0, 3); +} else { +version = version.substring(0, 2); +} +return version; +} else { +return null; +} +} catch (CommandLineException e) { +throw new RuntimeException(e); Review Comment: can be thrown from `executeCommandLine` - what is your proposition here? > Build-Jdk in Manifest.mf does not reflect which compiler version actually > compiled the classes in the jar > - > > Key: MJAR-62 > URL: https://issues.apache.org/jira/browse/MJAR-62 > Project: Maven JAR Plugin > Issue Type: Bug >Reporter: Stefan Magnus Landrø >Assignee: Slawomir Jaranowski >Priority: Major > Fix For: 3.4.0 > > Attachments: example-app.zip > > > Manifest.mf does not reflect the version of the compiler that built the jar, > but defaults to the version that maven runs under: Build-Jdk: > ${java.version}. > I believe this makes users uncertain of which compiler was actually used to > build the classes. -- This message was sent by Atlassian Jira (v8.20.10#820010)
[jira] [Commented] (MJAR-62) Build-Jdk in Manifest.mf does not reflect which compiler version actually compiled the classes in the jar
[ https://issues.apache.org/jira/browse/MJAR-62?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17828935#comment-17828935 ] ASF GitHub Bot commented on MJAR-62: elharo commented on code in PR #73: URL: https://github.com/apache/maven-jar-plugin/pull/73#discussion_r1531982231 ## src/main/java/org/apache/maven/plugins/jar/ToolchainsJdkSpecification.java: ## @@ -0,0 +1,93 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.maven.plugins.jar; + +import javax.inject.Named; +import javax.inject.Singleton; + +import java.io.IOException; +import java.io.UncheckedIOException; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.HashMap; +import java.util.Map; +import java.util.Optional; + +import org.apache.maven.toolchain.Toolchain; +import org.codehaus.plexus.util.cli.CommandLineException; +import org.codehaus.plexus.util.cli.CommandLineUtils; +import org.codehaus.plexus.util.cli.Commandline; + +/** + * Component provided JDK specification based on toolchains. + */ +@Named +@Singleton +class ToolchainsJdkSpecification { + +private final Map cache = new HashMap<>(); + +public synchronized Optional getJDKSpecification(Toolchain toolchain) { +Optional javaCPath = getJavaCPath(toolchain); +return javaCPath.map(path -> cache.computeIfAbsent(path, this::getSpecForPath)); +} + +private Optional getJavaCPath(Toolchain toolchain) { +return Optional.ofNullable(toolchain.findTool("javac")).map(Paths::get).map(this::getCanonicalPath); +} + +private Path getCanonicalPath(Path path) { +try { +return path.toRealPath(); +} catch (IOException e) { +if (path.getParent() != null) { +return getCanonicalPath(path.getParent()).resolve(path.getFileName()); +} else { +throw new UncheckedIOException(e); +} +} +} + +private String getSpecForPath(Path path) { +try { +Commandline cl = new Commandline(path.toString()); +cl.createArg().setValue("-version"); +CommandLineUtils.StringStreamConsumer out = new CommandLineUtils.StringStreamConsumer(); +CommandLineUtils.StringStreamConsumer err = new CommandLineUtils.StringStreamConsumer(); +CommandLineUtils.executeCommandLine(cl, out, err); +String version = out.getOutput().trim(); +if (version.isEmpty()) { +version = err.getOutput().trim(); +} +if (version.startsWith("javac ")) { +version = version.substring(6); +if (version.startsWith("1.")) { +version = version.substring(0, 3); +} else { +version = version.substring(0, 2); +} +return version; +} else { +return null; +} +} catch (CommandLineException e) { +throw new RuntimeException(e); Review Comment: don't throw raw runtime exceptions, and possibly don't use a runtime exception at all here. Under what circumstances will this be thrown? ## src/test/java/org/apache/maven/plugins/jar/ToolchainsJdkVersionTest.java: ## @@ -0,0 +1,88 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package
[jira] [Commented] (MJAR-62) Build-Jdk in Manifest.mf does not reflect which compiler version actually compiled the classes in the jar
[ https://issues.apache.org/jira/browse/MJAR-62?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17828532#comment-17828532 ] ASF GitHub Bot commented on MJAR-62: slawekjaranowski opened a new pull request, #73: URL: https://github.com/apache/maven-jar-plugin/pull/73 https://issues.apache.org/jira/browse/MJAR-62 > Build-Jdk in Manifest.mf does not reflect which compiler version actually > compiled the classes in the jar > - > > Key: MJAR-62 > URL: https://issues.apache.org/jira/browse/MJAR-62 > Project: Maven JAR Plugin > Issue Type: Bug >Reporter: Stefan Magnus Landrø >Priority: Major > Attachments: example-app.zip > > > Manifest.mf does not reflect the version of the compiler that built the jar, > but defaults to the version that maven runs under: Build-Jdk: > ${java.version}. > I believe this makes users uncertain of which compiler was actually used to > build the classes. -- This message was sent by Atlassian Jira (v8.20.10#820010)
[jira] [Commented] (MJAR-62) Build-Jdk in Manifest.mf does not reflect which compiler version actually compiled the classes in the jar
[ https://issues.apache.org/jira/browse/MJAR-62?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17827740#comment-17827740 ] Jorge Solórzano commented on MJAR-62: - [~sjaranowski] Yes, the *Build-Jdk* entry is more like an _extension_ of Maven added to the Manifest. > Build-Jdk in Manifest.mf does not reflect which compiler version actually > compiled the classes in the jar > - > > Key: MJAR-62 > URL: https://issues.apache.org/jira/browse/MJAR-62 > Project: Maven JAR Plugin > Issue Type: Bug >Reporter: Stefan Magnus Landrø >Priority: Major > Attachments: example-app.zip > > > Manifest.mf does not reflect the version of the compiler that built the jar, > but defaults to the version that maven runs under: Build-Jdk: > ${java.version}. > I believe this makes users uncertain of which compiler was actually used to > build the classes. -- This message was sent by Atlassian Jira (v8.20.10#820010)
[jira] [Commented] (MJAR-62) Build-Jdk in Manifest.mf does not reflect which compiler version actually compiled the classes in the jar
[ https://issues.apache.org/jira/browse/MJAR-62?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17827720#comment-17827720 ] Slawomir Jaranowski commented on MJAR-62: - There is not specification for *Build-Jdk* entry https://docs.oracle.com/en/java/javase/21/docs/specs/jar/jar.html > Build-Jdk in Manifest.mf does not reflect which compiler version actually > compiled the classes in the jar > - > > Key: MJAR-62 > URL: https://issues.apache.org/jira/browse/MJAR-62 > Project: Maven JAR Plugin > Issue Type: Bug >Reporter: Stefan Magnus Landrø >Priority: Major > Attachments: example-app.zip > > > Manifest.mf does not reflect the version of the compiler that built the jar, > but defaults to the version that maven runs under: Build-Jdk: > ${java.version}. > I believe this makes users uncertain of which compiler was actually used to > build the classes. -- This message was sent by Atlassian Jira (v8.20.10#820010)
[jira] [Commented] (MJAR-62) Build-Jdk in Manifest.mf does not reflect which compiler version actually compiled the classes in the jar
[ https://issues.apache.org/jira/browse/MJAR-62?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17693701#comment-17693701 ] Jorge Solórzano commented on MJAR-62: - [~michael-o] That could work, but again, that will only refer to the baseline code in an MRJAR, and ideally, it makes sense to use something like Target-Bytecode and use the bytecode version instead. > Build-Jdk in Manifest.mf does not reflect which compiler version actually > compiled the classes in the jar > - > > Key: MJAR-62 > URL: https://issues.apache.org/jira/browse/MJAR-62 > Project: Maven JAR Plugin > Issue Type: Bug >Reporter: Stefan Magnus Landrø >Priority: Major > Attachments: example-app.zip > > > Manifest.mf does not reflect the version of the compiler that built the jar, > but defaults to the version that maven runs under: Build-Jdk: > ${java.version}. > I believe this makes users uncertain of which compiler was actually used to > build the classes. -- This message was sent by Atlassian Jira (v8.20.10#820010)
[jira] [Commented] (MJAR-62) Build-Jdk in Manifest.mf does not reflect which compiler version actually compiled the classes in the jar
[ https://issues.apache.org/jira/browse/MJAR-62?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17693685#comment-17693685 ] Michael Osipov commented on MJAR-62: [~jorsol], so one would require a {{Target-Jdk}} manifest entry. > Build-Jdk in Manifest.mf does not reflect which compiler version actually > compiled the classes in the jar > - > > Key: MJAR-62 > URL: https://issues.apache.org/jira/browse/MJAR-62 > Project: Maven JAR Plugin > Issue Type: Bug >Reporter: Stefan Magnus Landrø >Priority: Major > Attachments: example-app.zip > > > Manifest.mf does not reflect the version of the compiler that built the jar, > but defaults to the version that maven runs under: Build-Jdk: > ${java.version}. > I believe this makes users uncertain of which compiler was actually used to > build the classes. -- This message was sent by Atlassian Jira (v8.20.10#820010)
[jira] [Commented] (MJAR-62) Build-Jdk in Manifest.mf does not reflect which compiler version actually compiled the classes in the jar
[ https://issues.apache.org/jira/browse/MJAR-62?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17693678#comment-17693678 ] Jorge Solórzano commented on MJAR-62: - This issue as it stands out today is irrelevant, and it actually does the correct thing, let me explain: The {{MANIFEST.MF}} does not reflect the version of the compiler that built the jar because you can compile a class using a higher JDK version that targets a lower Java bytecode, so assume that you build a JAR that compiles the classes with JDK 17 but targets (–release) Java 11, which version do you use as *Build-Jdk* option? you are using Java 17 so it makes sense to set the version to {+}17{+}, but at the same time, you are compiling to Java 11 so you could argue that it must use {+}11{+}, but that is not true, and even the bytecode produced could be different. But even if we try to use the "same" version in the *Build-Jdk* property that compiles the classes, the most important point that this is irrelevant now, is that we now have Multi-Release JARs ("MRJAR"), that contain bytecode generated for different Java versions in a versioned area of the JAR, so, if you build a JAR which compiles the base classes as Java 8, and have versioned classes for Java 9, Java 11, and Java 17, which version do you set in the *Build-Jdk* property? If you use the lower one (Java 8) that is not correct since it contains classes with different bytecode, and if you use the higher one (Java 17) that could not be entirely true as you might probably build the JAR using JDK 19. In the end, the *Build-Jdk* should be used more as a property to signal which JDK was used to build (or a better term "assemble") the JAR rather than to know the compiled bytecode contained, when I mean that it actually does the correct thing is because if the JDK used to assemble the JAR is the one that Maven uses, then that's the JDK to be used in the property. NOTE: This has no relation with the issue MJAR-289 since Toolchains handling is a different topic and this issue does not duplicate that, and while I agree that toolchain support could be improved, the same premise should be done, if maven-jar-plugin is aware of the toolchain, and the toolchain of maven-compiler-plugin is different from the toolchain used in maven-jar-plugin, which version should be used in the property? of course the one that uses maven-jar-plugin, yet doesn't need any special treatment since it will use the "java.version" property which again is the correct thing to do. > Build-Jdk in Manifest.mf does not reflect which compiler version actually > compiled the classes in the jar > - > > Key: MJAR-62 > URL: https://issues.apache.org/jira/browse/MJAR-62 > Project: Maven JAR Plugin > Issue Type: Bug >Reporter: Stefan Magnus Landrø >Priority: Major > Attachments: example-app.zip > > > Manifest.mf does not reflect the version of the compiler that built the jar, > but defaults to the version that maven runs under: Build-Jdk: > ${java.version}. > I believe this makes users uncertain of which compiler was actually used to > build the classes. -- This message was sent by Atlassian Jira (v8.20.10#820010)
[jira] [Commented] (MJAR-62) Build-Jdk in Manifest.mf does not reflect which compiler version actually compiled the classes in the jar
[ https://issues.apache.org/jira/browse/MJAR-62?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17607916#comment-17607916 ] b. ohnsorg commented on MJAR-62: maven-jar-plugin uses [MavenArchiver|https://github.com/apache/maven-archiver]. MavenArchiver depends on [Plexus Archiver|https://github.com/codehaus-plexus/plexus-archiver]. PlexusArchiver uses java.util.spi.ToolProvider. Instead https://cwiki.apache.org/confluence/display/MAVENOLD/Toolchains suggests (omitted some checks for brevity): {code} /** * @component */ private ToolchainManager toolchainManager; /** * The current build session instance. This is used for * toolchain manager API calls. * * @parameter expression="${session}" * @required * @readonly */ private MavenSession session; public void execute() { . // get toolchain from context Toolchain tc = toolchainManager.getToolchainFromBuildContext( "jdk", //NOI18N session ); javadocExecutable = tc.findTool( "javadoc" ); //NOI18N } {code} I assume that none of the Plexus-provided archivers supports toolchains by any means. This is either not a simple patch to maven-jar-plugin since it requires replacement of manifest generation. Or it spans across all the projects mentioned to put ToolchainManager down the stream. > Build-Jdk in Manifest.mf does not reflect which compiler version actually > compiled the classes in the jar > - > > Key: MJAR-62 > URL: https://issues.apache.org/jira/browse/MJAR-62 > Project: Maven JAR Plugin > Issue Type: Bug >Reporter: Stefan Magnus Landrø >Priority: Major > Attachments: example-app.zip > > > Manifest.mf does not reflect the version of the compiler that built the jar, > but defaults to the version that maven runs under: Build-Jdk: > ${java.version}. > I believe this makes users uncertain of which compiler was actually used to > build the classes. -- This message was sent by Atlassian Jira (v8.20.10#820010)
[jira] [Commented] (MJAR-62) Build-Jdk in Manifest.mf does not reflect which compiler version actually compiled the classes in the jar
[ https://issues.apache.org/jira/browse/MJAR-62?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16999091#comment-16999091 ] Michael Osipov commented on MJAR-62: Partially, but we still have: https://github.com/apache/maven-archiver/blob/master/src/main/java/org/apache/maven/archiver/MavenArchiver.java#L694-L702 > Build-Jdk in Manifest.mf does not reflect which compiler version actually > compiled the classes in the jar > - > > Key: MJAR-62 > URL: https://issues.apache.org/jira/browse/MJAR-62 > Project: Maven JAR Plugin > Issue Type: Bug >Reporter: Stefan Magnus Landrø >Priority: Major > Attachments: example-app.zip > > > Manifest.mf does not reflect the version of the compiler that built the jar, > but defaults to the version that maven runs under: Build-Jdk: > ${java.version}. > I believe this makes users uncertain of which compiler was actually used to > build the classes. -- This message was sent by Atlassian Jira (v8.3.4#803005)
[jira] [Commented] (MJAR-62) Build-Jdk in Manifest.mf does not reflect which compiler version actually compiled the classes in the jar
[ https://issues.apache.org/jira/browse/MJAR-62?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16999081#comment-16999081 ] Elliotte Rusty Harold commented on MJAR-62: --- Has the work on reproducible builds mooted this one? > Build-Jdk in Manifest.mf does not reflect which compiler version actually > compiled the classes in the jar > - > > Key: MJAR-62 > URL: https://issues.apache.org/jira/browse/MJAR-62 > Project: Maven JAR Plugin > Issue Type: Bug >Reporter: Stefan Magnus Landrø >Priority: Major > Attachments: example-app.zip > > > Manifest.mf does not reflect the version of the compiler that built the jar, > but defaults to the version that maven runs under: Build-Jdk: > ${java.version}. > I believe this makes users uncertain of which compiler was actually used to > build the classes. -- This message was sent by Atlassian Jira (v8.3.4#803005)
[jira] [Commented] (MJAR-62) Build-Jdk in Manifest.mf does not reflect which compiler version actually compiled the classes in the jar
[ https://issues.apache.org/jira/browse/MJAR-62?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15098039#comment-15098039 ] Michael Osipov commented on MJAR-62: Maven version [3.3.1|https://issues.apache.org/jira/secure/ReleaseNote.jspa?projectId=12316922=12330193] has improved toolchains support. I have a look at your questions later. > Build-Jdk in Manifest.mf does not reflect which compiler version actually > compiled the classes in the jar > - > > Key: MJAR-62 > URL: https://issues.apache.org/jira/browse/MJAR-62 > Project: Maven JAR Plugin > Issue Type: Bug >Reporter: Stefan Magnus Landrø > Attachments: example-app.zip > > > Manifest.mf does not reflect the version of the compiler that built the jar, > but defaults to the version that maven runs under: Build-Jdk: > ${java.version}. > I believe this makes users uncertain of which compiler was actually used to > build the classes. -- This message was sent by Atlassian JIRA (v6.3.4#6332)
[jira] [Commented] (MJAR-62) Build-Jdk in Manifest.mf does not reflect which compiler version actually compiled the classes in the jar
[ https://issues.apache.org/jira/browse/MJAR-62?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15098038#comment-15098038 ] Michael Osipov commented on MJAR-62: Maven version [3.3.1|https://issues.apache.org/jira/secure/ReleaseNote.jspa?projectId=12316922=12330193] has improved toolchains support. I have a look at your questions later. > Build-Jdk in Manifest.mf does not reflect which compiler version actually > compiled the classes in the jar > - > > Key: MJAR-62 > URL: https://issues.apache.org/jira/browse/MJAR-62 > Project: Maven JAR Plugin > Issue Type: Bug >Reporter: Stefan Magnus Landrø > Attachments: example-app.zip > > > Manifest.mf does not reflect the version of the compiler that built the jar, > but defaults to the version that maven runs under: Build-Jdk: > ${java.version}. > I believe this makes users uncertain of which compiler was actually used to > build the classes. -- This message was sent by Atlassian JIRA (v6.3.4#6332)
[jira] [Commented] (MJAR-62) Build-Jdk in Manifest.mf does not reflect which compiler version actually compiled the classes in the jar
[ https://issues.apache.org/jira/browse/MJAR-62?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15096901#comment-15096901 ] Michael Osipov commented on MJAR-62: Nathan, do you think you can provide some valueable patch because toolchains support has been improved lately? > Build-Jdk in Manifest.mf does not reflect which compiler version actually > compiled the classes in the jar > - > > Key: MJAR-62 > URL: https://issues.apache.org/jira/browse/MJAR-62 > Project: Maven JAR Plugin > Issue Type: Bug >Reporter: Stefan Magnus Landrø > Attachments: example-app.zip > > > Manifest.mf does not reflect the version of the compiler that built the jar, > but defaults to the version that maven runs under: Build-Jdk: > ${java.version}. > I believe this makes users uncertain of which compiler was actually used to > build the classes. -- This message was sent by Atlassian JIRA (v6.3.4#6332)
[jira] [Commented] (MJAR-62) Build-Jdk in Manifest.mf does not reflect which compiler version actually compiled the classes in the jar
[ https://issues.apache.org/jira/browse/MJAR-62?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15097311#comment-15097311 ] Nathan Revo commented on MJAR-62: - [~michael-o]I will look into creating a patch. What maven version were you referring to in your comment? Also, it felt like my custom plugin would turn into a messy patch as I was calling the "javac" command directly and parsing the output. Here are some questions I have that should be addressed before a meaningful patch can be created: * How are these options handled for for compiling code and/or making archives (jar files). What is the precedence? * - runtime jdk. assuming it is a JDK and not just a JRE use javac/jar binaries from here? * - toolchains.xml, is it present, is it configured properly, use javac/jar binaries from here? * - compiler executable, do I use the value from the maven compiler plugin, do I provide one in the archiver plugin? * - java.home environment variable, is this where javac or jar are executed from? * which plugin will this be added to? archiver, compiler, jar? > Build-Jdk in Manifest.mf does not reflect which compiler version actually > compiled the classes in the jar > - > > Key: MJAR-62 > URL: https://issues.apache.org/jira/browse/MJAR-62 > Project: Maven JAR Plugin > Issue Type: Bug >Reporter: Stefan Magnus Landrø > Attachments: example-app.zip > > > Manifest.mf does not reflect the version of the compiler that built the jar, > but defaults to the version that maven runs under: Build-Jdk: > ${java.version}. > I believe this makes users uncertain of which compiler was actually used to > build the classes. -- This message was sent by Atlassian JIRA (v6.3.4#6332)
[jira] [Commented] (MJAR-62) Build-Jdk in Manifest.mf does not reflect which compiler version actually compiled the classes in the jar
[ https://issues.apache.org/jira/browse/MJAR-62?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=14968178#comment-14968178 ] Nathan Revo commented on MJAR-62: - I just spent 3 days trying to work around this problem. Lots of frustration involved, and I want to know why Build-Jdk is defined inside maven-archiver. Also, why doesn't toolchains expose useful properties by default. Version, home and architecture seem important to me. Our solution is to create a custom plugin that will call the javac binary with the -version argument and extract the version. This value will be set as a maven property, which should be usable inside the pom. > Build-Jdk in Manifest.mf does not reflect which compiler version actually > compiled the classes in the jar > - > > Key: MJAR-62 > URL: https://issues.apache.org/jira/browse/MJAR-62 > Project: Maven JAR Plugin > Issue Type: Bug >Reporter: Stefan Magnus Landrø > Attachments: example-app.zip > > > Manifest.mf does not reflect the version of the compiler that built the jar, > but defaults to the version that maven runs under: Build-Jdk: > ${java.version}. > I believe this makes users uncertain of which compiler was actually used to > build the classes. -- This message was sent by Atlassian JIRA (v6.3.4#6332)
[jira] [Commented] (MJAR-62) Build-Jdk in Manifest.mf does not reflect which compiler version actually compiled the classes in the jar
[ https://issues.apache.org/jira/browse/MJAR-62?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=14802757#comment-14802757 ] Peter Janssen commented on MJAR-62: --- I agree with Stefan that this is not expected behaviour. I supplied an example project (requiring a JDK17 profile in the settings.xml). Can we reconsider the close? > Build-Jdk in Manifest.mf does not reflect which compiler version actually > compiled the classes in the jar > - > > Key: MJAR-62 > URL: https://issues.apache.org/jira/browse/MJAR-62 > Project: Maven JAR Plugin > Issue Type: Bug >Reporter: Stefan Magnus Landrø > > Manifest.mf does not reflect the version of the compiler that built the jar, > but defaults to the version that maven runs under: Build-Jdk: > ${java.version}. > I believe this makes users uncertain of which compiler was actually used to > build the classes. -- This message was sent by Atlassian JIRA (v6.3.4#6332)
[jira] Commented: (MJAR-62) Build-Jdk in Manifest.mf does not reflect which compiler version actually compiled the classes in the jar
[ http://jira.codehaus.org/browse/MJAR-62?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=210191#action_210191 ] Frederic commented on MJAR-62: -- Is it possible for the jar plugin to support the toolchain features? The manifest information (Build-Jdk) would then be correct. Build-Jdk in Manifest.mf does not reflect which compiler version actually compiled the classes in the jar - Key: MJAR-62 URL: http://jira.codehaus.org/browse/MJAR-62 Project: Maven 2.x Jar Plugin Issue Type: Bug Reporter: Stefan Magnus Landrø Manifest.mf does not reflect the version of the compiler that built the jar, but defaults to the version that maven runs under: Build-Jdk: ${java.version}. I believe this makes users uncertain of which compiler was actually used to build the classes. -- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: http://jira.codehaus.org/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] Commented: (MJAR-62) Build-Jdk in Manifest.mf does not reflect which compiler version actually compiled the classes in the jar
[ http://jira.codehaus.org/browse/MJAR-62?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_117330 ] Olivier Lamy commented on MJAR-62: -- Agree in case of forked compilation. But currently it's impossible for the jar plugin to know if the javac was forked with using an other JAVA_HOME. http://docs.codehaus.org/display/MAVEN/Toolchains will probably help. Build-Jdk in Manifest.mf does not reflect which compiler version actually compiled the classes in the jar - Key: MJAR-62 URL: http://jira.codehaus.org/browse/MJAR-62 Project: Maven 2.x Jar Plugin Issue Type: Bug Reporter: Stefan Magnus Landrø Manifest.mf does not reflect the version of the compiler that built the jar, but defaults to the version that maven runs under: Build-Jdk: ${java.version}. I believe this makes users uncertain of which compiler was actually used to build the classes. -- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: http://jira.codehaus.org/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira