Skip to content
Merged
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
2 changes: 1 addition & 1 deletion src/it/MJAR-62-toolchain/invoker.properties
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@
# specific language governing permissions and limitations
# under the License.

invoker.toolchain.jdk.version = 17
invoker.toolchain.jdk.version = [17,18)
2 changes: 1 addition & 1 deletion src/it/MJAR-62-toolchain/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
<configuration>
<toolchains>
<jdk>
<version>17</version>
<version>[17,18)</version>
</jdk>
</toolchains>
</configuration>
Expand Down
20 changes: 20 additions & 0 deletions src/it/github-470-1.8/invoker.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# 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.

invoker.toolchain.jdk.version = [1.8,9)

invoker.environmentVariables.JAVA_TOOL_OPTIONS = -XX:ActiveProcessorCount=1
60 changes: 60 additions & 0 deletions src/it/github-470-1.8/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
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.
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>gh-470</artifactId>
<name>gh-470</name>
<packaging>jar</packaging>
<version>1.0-SNAPSHOT</version>
<organization>
<name>jar plugin it</name>
</organization>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-toolchains-plugin</artifactId>
<version>3.1.0</version>
<executions>
<execution>
<goals>
<goal>toolchain</goal>
</goals>
</execution>
</executions>
<configuration>
<toolchains>
<jdk>
<version>[1.8,9)</version>
</jdk>
</toolchains>
</configuration>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>@project.version@</version>
</plugin>
</plugins>
</build>
</project>
36 changes: 36 additions & 0 deletions src/it/github-470-1.8/src/main/java/myproject/HelloWorld.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package myproject;

/*
* 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.
*/

/**
* The classic Hello World App.
*/
public class HelloWorld {

/**
* Main method.
*
* @param args Not used
*/
public static void main( String[] args )
{
System.out.println( "Hi!" );
}
}
26 changes: 26 additions & 0 deletions src/it/github-470-1.8/verify.groovy
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/*
* 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.
*/

import java.util.jar.JarFile

def mrjar = new JarFile(new File(basedir, 'target/gh-470-1.0-SNAPSHOT.jar'))
def manifest = mrjar.manifest.mainAttributes

assert manifest.getValue("Build-Jdk-Spec") == "1.8"
assert manifest.getValue("Build-Tool-Jdk-Spec") == System.getProperty("java.specification.version")
2 changes: 1 addition & 1 deletion src/it/github-470/invoker.properties
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@
# specific language governing permissions and limitations
# under the License.

invoker.toolchain.jdk.version = 17
invoker.toolchain.jdk.version = [17,18)

invoker.environmentVariables.JAVA_TOOL_OPTIONS = -XX:ActiveProcessorCount=1
2 changes: 1 addition & 1 deletion src/it/github-470/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
<configuration>
<toolchains>
<jdk>
<version>17</version>
<version>[17,18)</version>
</jdk>
</toolchains>
</configuration>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@
import java.io.UncheckedIOException;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Optional;

Expand Down Expand Up @@ -73,8 +75,8 @@ private String getSpecForPath(Path path) {
ProcessBuilder processBuilder = new ProcessBuilder(path.toString(), "-version");
processBuilder.redirectErrorStream(false);
Process process = processBuilder.start();
String stdout = readOutput(process.getInputStream()).trim();
String stderr = readOutput(process.getErrorStream()).trim();
List<String> stdout = readOutput(process.getInputStream());
List<String> stderr = readOutput(process.getErrorStream());
process.waitFor();

String version = tryParseVersion(stdout);
Expand All @@ -100,28 +102,30 @@ private String getSpecForPath(Path path) {
return null;
}

private String tryParseVersion(String version) {
if (version.startsWith("javac ")) {
version = version.substring(6);
if (version.startsWith("1.")) {
version = version.substring(0, 3);
} else {
version = version.substring(0, 2);
private String tryParseVersion(List<String> versions) {
for (String version : versions) {
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;
}
return version;
}
return null;
}

private String readOutput(InputStream inputstream) throws IOException {
private List<String> readOutput(InputStream inputstream) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(inputstream));

StringBuilder output = new StringBuilder();
List<String> result = new ArrayList<>();
String line;
while ((line = br.readLine()) != null) {
output.append(line + System.lineSeparator());
result.add(line);
}

return output.toString();
return result;
}
}