Skip to content
Permalink
Browse files
[CXFXJC-8] Fix how the parameters are setup for Windows
  • Loading branch information
dkulp committed Oct 22, 2014
1 parent 58e162c commit 95eb1fd5c492e8b86a412ab1bb529cf3556281c3
Showing 1 changed file with 30 additions and 8 deletions.
@@ -21,6 +21,7 @@

import java.io.File;
import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;
@@ -114,16 +115,25 @@ public abstract class AbstractXSDToJavaMojo extends AbstractMojo {

private URI mapLocation(String s) throws MojoExecutionException {
try {
File file = new File(s);
File file = new File(s).getAbsoluteFile();
URI uri;
if (file.exists()) {
uri = file.toURI();
} else {
file = new File(project.getBasedir(), s);
file = new File(project.getBasedir(), s).getAbsoluteFile();
if (file.exists()) {
uri = file.toURI();
} else {
uri = new URI(s);
try {
uri = new URI(s);
} catch (URISyntaxException use) {
file = new File(s).getAbsoluteFile();
if (file.getParentFile().exists()) {
return file.toURI();
} else {
throw use;
}
}
}
}
if ("classpath".equals(uri.getScheme())) {
@@ -309,15 +319,17 @@ private void removeMessages(String file) throws MojoExecutionException {
}
}
}
private String[] getArguments(XsdOption option, String outputDir) throws MojoExecutionException {
private String[] getArguments(XsdOption option, String outputDir)
throws MojoExecutionException, MalformedURLException {

List<URL> newCp = new ArrayList<URL>();
List<String> list = new ArrayList<String>();
if (extensions != null && extensions.size() > 0) {
try {
for (String ext : extensions) {
for (File file : resolve(ext)) {
list.add("-classpath");
list.add(file.getAbsolutePath());
list.add(file.toURI().toURL().toExternalForm());
newCp.add(file.toURI().toURL());
}
}
@@ -410,7 +422,7 @@ private int runForked(XsdOption option, String outputDir) throws Exception {

File file = null;
try {
// file = new File("/tmp/test.jar");
//file = new File("Y:\\Users\\dkulp\\tmp\\test.jar");
file = File.createTempFile("cxf-xjc-plugin", ".jar");
file.deleteOnExit();

@@ -422,10 +434,13 @@ private int runForked(XsdOption option, String outputDir) throws Exception {
attr.setName("Class-Path");
StringBuilder b = new StringBuilder(8000);
for (String cp : getClasspathElements()) {
b.append(cp).append(' ');
URI uri = mapLocation(cp);
if (uri != null) {
b.append(uri.toString()).append(' ');
}
}
for (Artifact a : pluginArtifacts) {
b.append(a.getFile().getAbsolutePath()).append(' ');
b.append(a.getFile().toURI().toURL().toExternalForm()).append(' ');
}
attr.setValue(b.toString());
manifest.getMainSection().addConfiguredAttribute(attr);
@@ -435,6 +450,10 @@ private int runForked(XsdOption option, String outputDir) throws Exception {
attr.setValue(XSDToJavaRunner.class.getName());
manifest.getMainSection().addConfiguredAttribute(attr);

if (getLog().isDebugEnabled()) {
getLog().debug("Manifest: " + manifest);
}

jar.addConfiguredManifest(manifest);
jar.createArchive();

@@ -460,6 +479,9 @@ private int runForked(XsdOption option, String outputDir) throws Exception {
StringBuilder message = new StringBuilder();

public void consumeLine(String line) {
if (getLog().isDebugEnabled()) {
getLog().debug(line);
}
if (line.startsWith("DONE")) {
buildContext.addMessage(file, linenum, column, message.toString(), severity, null);
} else if (line.startsWith("MSG: ")

0 comments on commit 95eb1fd

Please sign in to comment.