Skip to content

Commit

Permalink
Make WSConsume work on JDK9 by 1) forcing fork mode, 2) adding explic…
Browse files Browse the repository at this point in the history
…it dependency to the java compiler module, 3) adding back additional plugin dependencies (namely gnu getop)

Also removed ensorsing test (not java.endorsed.dirs supported anymore in jdk9) and updated dependencies.
  • Loading branch information
asoldano committed Mar 12, 2018
1 parent 4d1aaa5 commit e166dab
Show file tree
Hide file tree
Showing 15 changed files with 64 additions and 300 deletions.
7 changes: 6 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<parent>
<groupId>org.jboss.ws</groupId>
<artifactId>jbossws-parent</artifactId>
<version>1.3.0.Final</version>
<version>1.4.0.Final</version>
</parent>

<!-- Source Control Management -->
Expand Down Expand Up @@ -43,6 +43,11 @@
<artifactId>jbossws-common-tools</artifactId>
<version>${jbossws.common.tools.version}</version>
</dependency>
<dependency>
<groupId>gnu.getopt</groupId>
<artifactId>java-getopt</artifactId>
<version>${getopt.version}</version>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-project</artifactId>
Expand Down
17 changes: 11 additions & 6 deletions src/main/java/org/jboss/ws/plugins/tools/AbstractToolsMojo.java
Original file line number Diff line number Diff line change
Expand Up @@ -125,26 +125,26 @@ protected URLClassLoader getMavenClasspathAwareClassLoader()
*
* @return a list with the required plugin dependencies
*/
protected List<String> getRequiredPluginDependencyPaths()
protected List<File> getRequiredPluginDependencyPaths()
{
//TODO!! retrieve the actual version to be used from the included stack dependency instead?
List<String> result = new ArrayList<String>(3);
List<File> result = new ArrayList<File>(3);
for (Artifact s : getPluginArtifacts()) {
if ("org.jboss.ws".equals(s.getGroupId()) && "jbossws-common-tools".equals(s.getArtifactId()))
{
result.add(s.getFile().getAbsolutePath());
result.add(s.getFile());
}
else if ("gnu-getopt".equals(s.getGroupId()) && "getopt".equals(s.getArtifactId()))
{
result.add(s.getFile().getAbsolutePath());
result.add(s.getFile());
}
else if ("gnu.getopt".equals(s.getGroupId()) && "java-getopt".equals(s.getArtifactId()))
{
result.add(s.getFile().getAbsolutePath());
result.add(s.getFile());
}
else if ("log4j".equals(s.getGroupId()) && "log4j".equals(s.getArtifactId()))
{
result.add(s.getFile().getAbsolutePath());
result.add(s.getFile());
}
}
return result;
Expand Down Expand Up @@ -199,6 +199,11 @@ public File createJar(List<String> classPath, String startClassName) throws IOEx
cp.append(new File(el).toURI().toURL().toExternalForm());
cp.append(" ");
}
List<File> pluginDeps = getRequiredPluginDependencyPaths();
for (File f : pluginDeps) {
cp.append(f.getAbsolutePath());
cp.append(" ");
}

man.getMainAttributes().putValue("Manifest-Version", "1.0");
man.getMainAttributes().putValue("Class-Path", cp.toString().trim());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,10 +147,19 @@ public void execute() throws MojoExecutionException
params.setWsdlLocation(wsdlLocation);
params.setEncoding(encoding);
params.setArgLine(argLine);
params.setFork(fork);

File manifestOnlyJar = createJar(getClasspathElements(), "");
params.setManifestOnlyJar(manifestOnlyJar);
if (fork || Util.getJVMMajorVersion() > 8) {
params.setFork(true);
File manifestOnlyJar = createJar(getClasspathElements(), "");
params.setManifestOnlyJar(manifestOnlyJar);
if (verbose)
{
log.info("Additional plugin classpath:");
for (File f : getRequiredPluginDependencyPaths())
{
log.info(" " + f.getAbsolutePath());
}
}
}

WSContractDelegate delegate = new WSContractDelegate(getLog());

Expand Down
21 changes: 21 additions & 0 deletions src/main/java/org/jboss/ws/plugins/tools/Util.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package org.jboss.ws.plugins.tools;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class Util {

public static int getJVMMajorVersion() {
try {
String vmVersionStr = System.getProperty("java.specification.version", null);
Matcher matcher = Pattern.compile("^(?:1\\.)?(\\d+)$").matcher(vmVersionStr); //match 1.<number> or <number>
if (matcher.find()) {
return Integer.valueOf(matcher.group(1));
} else {
throw new RuntimeException("Unknown version of jvm " + vmVersionStr);
}
} catch (Exception e) {
return 8;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public class WSContractDelegate
{
private static final PrintStream PS = System.out;
private Log log;

public WSContractDelegate(Log log)
{
this.log = log;
Expand Down Expand Up @@ -144,6 +144,9 @@ private static List<String> initCommandList(String argLine, File manifestOnlyJar
{
commandList.add(argLine);
}
if (Util.getJVMMajorVersion() > 8) {
commandList.add("--add-modules=java.compiler ");
}
commandList.add("-classpath ");
commandList.add(manifestOnlyJar.getCanonicalPath());
commandList.add(toolClass);
Expand Down

This file was deleted.

136 changes: 0 additions & 136 deletions src/test/resources/test-embedded/testEndorse/pom-cxf.xml

This file was deleted.

7 changes: 0 additions & 7 deletions src/test/resources/test-embedded/testEndorse/setup.bsh

This file was deleted.

This file was deleted.

This file was deleted.

Loading

0 comments on commit e166dab

Please sign in to comment.