You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by dk...@apache.org on 2015/07/08 22:42:41 UTC
[1/4] cxf-xjc-utils git commit: Throw an exception when a dependency
fails to resolve
Repository: cxf-xjc-utils
Updated Branches:
refs/heads/master ad38d5a3b -> 92ab73fd7
Throw an exception when a dependency fails to resolve
Project: http://git-wip-us.apache.org/repos/asf/cxf-xjc-utils/repo
Commit: http://git-wip-us.apache.org/repos/asf/cxf-xjc-utils/commit/6c7770cc
Tree: http://git-wip-us.apache.org/repos/asf/cxf-xjc-utils/tree/6c7770cc
Diff: http://git-wip-us.apache.org/repos/asf/cxf-xjc-utils/diff/6c7770cc
Branch: refs/heads/master
Commit: 6c7770ccca2ccfaa752d469ae69252f57106f6d9
Parents: 48db284
Author: Hugo Trippaers <hu...@apache.org>
Authored: Thu Apr 16 09:41:50 2015 +0200
Committer: Hugo Trippaers <ht...@schubergphilis.com>
Committed: Thu Apr 16 10:39:11 2015 +0200
----------------------------------------------------------------------
.../org/apache/cxf/maven_plugin/AbstractXSDToJavaMojo.java | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cxf-xjc-utils/blob/6c7770cc/cxf-xjc-plugin/src/main/java/org/apache/cxf/maven_plugin/AbstractXSDToJavaMojo.java
----------------------------------------------------------------------
diff --git a/cxf-xjc-plugin/src/main/java/org/apache/cxf/maven_plugin/AbstractXSDToJavaMojo.java b/cxf-xjc-plugin/src/main/java/org/apache/cxf/maven_plugin/AbstractXSDToJavaMojo.java
index 371bc22..9947e2b 100644
--- a/cxf-xjc-plugin/src/main/java/org/apache/cxf/maven_plugin/AbstractXSDToJavaMojo.java
+++ b/cxf-xjc-plugin/src/main/java/org/apache/cxf/maven_plugin/AbstractXSDToJavaMojo.java
@@ -258,7 +258,7 @@ public abstract class AbstractXSDToJavaMojo extends AbstractMojo {
}
}
- private List<File> resolve(String artifactDescriptor) {
+ private List<File> resolve(String artifactDescriptor) throws MojoExecutionException {
String[] s = artifactDescriptor.split(":");
String type = s.length >= 4 ? s[3] : "jar";
@@ -281,7 +281,10 @@ public abstract class AbstractXSDToJavaMojo extends AbstractMojo {
ArtifactResolutionResult result = repository.resolve(request);
List<File> files = new ArrayList<File>();
for (Artifact a : result.getArtifacts()) {
- files.add(a.getFile());
+ if (a.getFile() == null) {
+ throw new MojoExecutionException("Unable to resolve " + a.toString()
+ + " while resolving " + artifactDescriptor);
+ }
}
if (!files.contains(artifact.getFile())) {
files.add(artifact.getFile());
[4/4] cxf-xjc-utils git commit: Merge branch 'master' of
https://github.com/mbert/cxf-xjc-utils This closes #2
Posted by dk...@apache.org.
Merge branch 'master' of https://github.com/mbert/cxf-xjc-utils
This closes #2
Project: http://git-wip-us.apache.org/repos/asf/cxf-xjc-utils/repo
Commit: http://git-wip-us.apache.org/repos/asf/cxf-xjc-utils/commit/92ab73fd
Tree: http://git-wip-us.apache.org/repos/asf/cxf-xjc-utils/tree/92ab73fd
Diff: http://git-wip-us.apache.org/repos/asf/cxf-xjc-utils/diff/92ab73fd
Branch: refs/heads/master
Commit: 92ab73fd7642b221d01129a26cb9e2206062ef2c
Parents: ef81073 fb0162e
Author: Daniel Kulp <dk...@apache.org>
Authored: Wed Jul 8 15:57:09 2015 -0400
Committer: Daniel Kulp <dk...@apache.org>
Committed: Wed Jul 8 15:57:21 2015 -0400
----------------------------------------------------------------------
.../cxf/maven_plugin/AbstractXSDToJavaMojo.java | 187 +++++++++++--------
.../org/apache/cxf/maven_plugin/XsdOption.java | 7 +
2 files changed, 118 insertions(+), 76 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cxf-xjc-utils/blob/92ab73fd/cxf-xjc-plugin/src/main/java/org/apache/cxf/maven_plugin/AbstractXSDToJavaMojo.java
----------------------------------------------------------------------
diff --cc cxf-xjc-plugin/src/main/java/org/apache/cxf/maven_plugin/AbstractXSDToJavaMojo.java
index 5a69545,dfbe3c4..8d4a087
--- a/cxf-xjc-plugin/src/main/java/org/apache/cxf/maven_plugin/AbstractXSDToJavaMojo.java
+++ b/cxf-xjc-plugin/src/main/java/org/apache/cxf/maven_plugin/AbstractXSDToJavaMojo.java
@@@ -258,7 -262,34 +262,34 @@@ public abstract class AbstractXSDToJava
}
}
+ private String[] getXsdFiles(String xsdDir, String xsd) throws MojoExecutionException {
+ final String[] xsdFiles;
+ if (xsdDir != null && !xsdDir.isEmpty()) {
+ File dir = new File(xsdDir);
+ if (!dir.isDirectory()) {
+ throw new MojoExecutionException("Error, xsdDir \"" + xsdDir + "\" does not exist.");
+ }
+ String[] fileList = dir.list(new FilenameFilter() {
+ @Override
+ public boolean accept(File dir, String name) {
+ return name.endsWith(".xsd");
+ }
+ });
+ if (fileList == null || fileList.length == 0) {
+ throw new MojoExecutionException("Error, xsdDir \"" + xsdDir + "\" does not contain any *.xsd files.");
+ }
+ xsdFiles = new String[fileList.length];
+ for (int i = 0; i < fileList.length; ++i) {
+ xsdFiles[i] = xsdDir + (xsdDir.endsWith(File.separator) ? "" : File.separator) + fileList[i];
+ }
+ } else {
+ xsdFiles = new String[1];
+ xsdFiles[0] = xsd;
+ }
+ return xsdFiles;
+ }
+
- private List<File> resolve(String artifactDescriptor) {
+ private List<File> resolve(String artifactDescriptor) throws MojoExecutionException {
String[] s = artifactDescriptor.split(":");
String type = s.length >= 4 ? s[3] : "jar";
[2/4] cxf-xjc-utils git commit: Convenience option for configuring
the code generation from XSD files: Instead of having to explicitly list
every single file using the '' element,
now the new '' element can be used instead for specifying a d
Posted by dk...@apache.org.
Convenience option for configuring the code generation from XSD files:
Instead of having to explicitly list every single file using the '<xsd>'
element, now the new '<xsdDir>' element can be used instead for
specifying a directory. From this directory all '*.xsd' files will be
used for code generation.
Project: http://git-wip-us.apache.org/repos/asf/cxf-xjc-utils/repo
Commit: http://git-wip-us.apache.org/repos/asf/cxf-xjc-utils/commit/fb0162e3
Tree: http://git-wip-us.apache.org/repos/asf/cxf-xjc-utils/tree/fb0162e3
Diff: http://git-wip-us.apache.org/repos/asf/cxf-xjc-utils/diff/fb0162e3
Branch: refs/heads/master
Commit: fb0162e35f313bebc0d92ab089f0905ade7f2b79
Parents: 48db284
Author: Martin Dietze <md...@gmail.com>
Authored: Wed Jun 17 15:12:38 2015 +0200
Committer: Martin Dietze <ma...@dermalog.com>
Committed: Wed Jun 17 15:12:38 2015 +0200
----------------------------------------------------------------------
.../cxf/maven_plugin/AbstractXSDToJavaMojo.java | 187 +++++++++++--------
.../org/apache/cxf/maven_plugin/XsdOption.java | 7 +
2 files changed, 118 insertions(+), 76 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cxf-xjc-utils/blob/fb0162e3/cxf-xjc-plugin/src/main/java/org/apache/cxf/maven_plugin/AbstractXSDToJavaMojo.java
----------------------------------------------------------------------
diff --git a/cxf-xjc-plugin/src/main/java/org/apache/cxf/maven_plugin/AbstractXSDToJavaMojo.java b/cxf-xjc-plugin/src/main/java/org/apache/cxf/maven_plugin/AbstractXSDToJavaMojo.java
index 371bc22..dfbe3c4 100644
--- a/cxf-xjc-plugin/src/main/java/org/apache/cxf/maven_plugin/AbstractXSDToJavaMojo.java
+++ b/cxf-xjc-plugin/src/main/java/org/apache/cxf/maven_plugin/AbstractXSDToJavaMojo.java
@@ -20,6 +20,7 @@
package org.apache.cxf.maven_plugin;
import java.io.File;
+import java.io.FilenameFilter;
import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URI;
@@ -167,97 +168,127 @@ public abstract class AbstractXSDToJavaMojo extends AbstractMojo {
for (int x = 0; x < xsdOptions.length; x++) {
ClassLoader origLoader = Thread.currentThread().getContextClassLoader();
- try {
- URI xsdURI = mapLocation(xsdOptions[x].getXsd());
- URI basedir = project.getBasedir().toURI();
-
- String doneFileName = xsdURI.toString();
- if (doneFileName.startsWith(basedir.toString())) {
- doneFileName = doneFileName.substring(basedir.toString().length());
- }
-
- doneFileName = doneFileName.replace('?', '_')
- .replace('&', '_').replace('/', '_').replace('\\', '_')
- .replace(':', '_').replace('!', '_');
-
- // If URL to WSDL, replace ? and & since they're invalid chars for file names
- File doneFile =
- new File(markerDirectory, "." + doneFileName + ".DONE");
-
- long srctimestamp = 0;
- if ("file".equals(xsdURI.getScheme())) {
- srctimestamp = new File(xsdURI).lastModified();
- } else {
- try {
- srctimestamp = xsdURI.toURL().openConnection().getDate();
- } catch (Exception e) {
- //ignore
+ final String[] xsdFiles = getXsdFiles(xsdOptions[x].getXsdDir(), xsdOptions[x].getXsd());
+ for (String xsdFile : xsdFiles) {
+ try {
+ URI xsdURI = mapLocation(xsdFile);
+ URI basedir = project.getBasedir().toURI();
+
+ String doneFileName = xsdURI.toString();
+ if (doneFileName.startsWith(basedir.toString())) {
+ doneFileName = doneFileName.substring(basedir.toString().length());
}
- }
- if (xsdOptions[x].getBindingFile() != null) {
- URI bindingURI = mapLocation(xsdOptions[x].getBindingFile());
- if ("file".equals(bindingURI.getScheme())) {
- long bts = new File(bindingURI).lastModified();
- if (bts > srctimestamp) {
- srctimestamp = bts;
+
+ doneFileName = doneFileName.replace('?', '_')
+ .replace('&', '_').replace('/', '_').replace('\\', '_')
+ .replace(':', '_').replace('!', '_');
+
+ // If URL to WSDL, replace ? and & since they're invalid chars for file names
+ File doneFile =
+ new File(markerDirectory, "." + doneFileName + ".DONE");
+
+ long srctimestamp = 0;
+ if ("file".equals(xsdURI.getScheme())) {
+ srctimestamp = new File(xsdURI).lastModified();
+ } else {
+ try {
+ srctimestamp = xsdURI.toURL().openConnection().getDate();
+ } catch (Exception e) {
+ //ignore
}
}
- }
-
- boolean doWork = false;
- if (!doneFile.exists()) {
- doWork = true;
- } else if (srctimestamp > doneFile.lastModified()) {
- doWork = true;
- } else {
- File files[] = xsdOptions[x].getDependencies();
- if (files != null) {
- for (int z = 0; z < files.length; ++z) {
- if (files[z].lastModified() > doneFile.lastModified()) {
- doWork = true;
+ if (xsdOptions[x].getBindingFile() != null) {
+ URI bindingURI = mapLocation(xsdOptions[x].getBindingFile());
+ if ("file".equals(bindingURI.getScheme())) {
+ long bts = new File(bindingURI).lastModified();
+ if (bts > srctimestamp) {
+ srctimestamp = bts;
}
}
}
- }
-
- if (doWork) {
- try {
+
+ boolean doWork = false;
+ if (!doneFile.exists()) {
+ doWork = true;
+ } else if (srctimestamp > doneFile.lastModified()) {
+ doWork = true;
+ } else {
File files[] = xsdOptions[x].getDependencies();
if (files != null) {
for (int z = 0; z < files.length; ++z) {
if (files[z].lastModified() > doneFile.lastModified()) {
- buildContext.removeMessages(files[z]);
+ doWork = true;
}
}
}
- removeMessages(xsdOptions[x].getXsd());
- removeMessages(xsdOptions[x].getBindingFile());
- int i = run(xsdOptions[x], outputDir);
- if (i == 0) {
- doneFile.delete();
- doneFile.createNewFile();
- }
- File dirs[] = xsdOptions[x].getDeleteDirs();
- if (dirs != null) {
- for (int idx = 0; idx < dirs.length; ++idx) {
- result = result && deleteDir(dirs[idx]);
+ }
+
+ if (doWork) {
+ try {
+ File files[] = xsdOptions[x].getDependencies();
+ if (files != null) {
+ for (int z = 0; z < files.length; ++z) {
+ if (files[z].lastModified() > doneFile.lastModified()) {
+ buildContext.removeMessages(files[z]);
+ }
+ }
+ }
+ removeMessages(xsdFile);
+ removeMessages(xsdOptions[x].getBindingFile());
+ int i = run(xsdOptions[x], xsdFile, outputDir);
+ if (i == 0) {
+ doneFile.delete();
+ doneFile.createNewFile();
}
+ File dirs[] = xsdOptions[x].getDeleteDirs();
+ if (dirs != null) {
+ for (int idx = 0; idx < dirs.length; ++idx) {
+ result = result && deleteDir(dirs[idx]);
+ }
+ }
+ buildContext.refresh(outputDirFile);
+ } catch (Exception e) {
+ throw new MojoExecutionException(e.getMessage(), e);
}
- buildContext.refresh(outputDirFile);
- } catch (Exception e) {
- throw new MojoExecutionException(e.getMessage(), e);
}
+
+ if (!result) {
+ throw new MojoExecutionException("Could not delete redundant dirs");
+ }
+ } finally {
+ Thread.currentThread().setContextClassLoader(origLoader);
}
-
- if (!result) {
- throw new MojoExecutionException("Could not delete redundant dirs");
- }
- } finally {
- Thread.currentThread().setContextClassLoader(origLoader);
}
}
}
+ private String[] getXsdFiles(String xsdDir, String xsd) throws MojoExecutionException {
+ final String[] xsdFiles;
+ if (xsdDir != null && !xsdDir.isEmpty()) {
+ File dir = new File(xsdDir);
+ if (!dir.isDirectory()) {
+ throw new MojoExecutionException("Error, xsdDir \"" + xsdDir + "\" does not exist.");
+ }
+ String[] fileList = dir.list(new FilenameFilter() {
+ @Override
+ public boolean accept(File dir, String name) {
+ return name.endsWith(".xsd");
+ }
+ });
+ if (fileList == null || fileList.length == 0) {
+ throw new MojoExecutionException("Error, xsdDir \"" + xsdDir + "\" does not contain any *.xsd files.");
+ }
+ xsdFiles = new String[fileList.length];
+ for (int i = 0; i < fileList.length; ++i) {
+ xsdFiles[i] = xsdDir + (xsdDir.endsWith(File.separator) ? "" : File.separator) + fileList[i];
+ }
+ } else {
+ xsdFiles = new String[1];
+ xsdFiles[0] = xsd;
+ }
+ return xsdFiles;
+ }
+
private List<File> resolve(String artifactDescriptor) {
String[] s = artifactDescriptor.split(":");
@@ -293,12 +324,12 @@ public abstract class AbstractXSDToJavaMojo extends AbstractMojo {
return project.getCompileClasspathElements();
}
- private int run(XsdOption option, String outputDir) throws Exception {
+ private int run(XsdOption option, String xsdFile, String outputDir) throws Exception {
if (!fork) {
String[] args = getArguments(option, outputDir);
this.getLog().debug("Args: " + Arrays.asList(args));
XJCErrorListener listener = new XJCErrorListener(buildContext);
- int i = new XSDToJavaRunner(args, listener, new File(option.getXsd()), getClasspathElements()).run();
+ int i = new XSDToJavaRunner(args, listener, new File(xsdFile), getClasspathElements()).run();
if (i != 0 && listener.getFirstError() != null) {
throw listener.getFirstError();
}
@@ -363,10 +394,14 @@ public abstract class AbstractXSDToJavaMojo extends AbstractMojo {
if (getLog().isDebugEnabled()) {
list.add("-verbose");
}
- list.add("-d");
- list.add(outputDir);
- list.add(mapLocation(option.getXsd()).toString());
-
+
+ String[] xsdFiles = getXsdFiles(option.getXsdDir(), option.getXsd());
+ for (String xsdFile : xsdFiles) {
+ list.add("-d");
+ list.add(outputDir);
+ list.add(mapLocation(xsdFile).toString());
+ }
+
return list.toArray(new String[list.size()]);
}
http://git-wip-us.apache.org/repos/asf/cxf-xjc-utils/blob/fb0162e3/cxf-xjc-plugin/src/main/java/org/apache/cxf/maven_plugin/XsdOption.java
----------------------------------------------------------------------
diff --git a/cxf-xjc-plugin/src/main/java/org/apache/cxf/maven_plugin/XsdOption.java b/cxf-xjc-plugin/src/main/java/org/apache/cxf/maven_plugin/XsdOption.java
index d1f1a6b..4329b39 100644
--- a/cxf-xjc-plugin/src/main/java/org/apache/cxf/maven_plugin/XsdOption.java
+++ b/cxf-xjc-plugin/src/main/java/org/apache/cxf/maven_plugin/XsdOption.java
@@ -24,6 +24,7 @@ import java.util.List;
public class XsdOption {
String xsd;
+ String xsdDir;
String packagename;
String bindingFile;
File dependencies[];
@@ -44,6 +45,12 @@ public class XsdOption {
public void setXsd(String x) {
this.xsd = x;
}
+ public String getXsdDir() {
+ return xsdDir;
+ }
+ public void setXsdDir(String x) {
+ this.xsdDir = x;
+ }
public String getBindingFile() {
return bindingFile;
}
[3/4] cxf-xjc-utils git commit: Merge branch 'NPE-fix' of
https://github.com/spark404/cxf-xjc-utils This closes #1
Posted by dk...@apache.org.
Merge branch 'NPE-fix' of https://github.com/spark404/cxf-xjc-utils
This closes #1
Project: http://git-wip-us.apache.org/repos/asf/cxf-xjc-utils/repo
Commit: http://git-wip-us.apache.org/repos/asf/cxf-xjc-utils/commit/ef810739
Tree: http://git-wip-us.apache.org/repos/asf/cxf-xjc-utils/tree/ef810739
Diff: http://git-wip-us.apache.org/repos/asf/cxf-xjc-utils/diff/ef810739
Branch: refs/heads/master
Commit: ef81073963ef5bf56031ad4cdb8aa42ab7f6b7ba
Parents: ad38d5a 6c7770c
Author: Daniel Kulp <dk...@apache.org>
Authored: Wed Jul 8 15:53:46 2015 -0400
Committer: Daniel Kulp <dk...@apache.org>
Committed: Wed Jul 8 15:55:40 2015 -0400
----------------------------------------------------------------------
.../org/apache/cxf/maven_plugin/AbstractXSDToJavaMojo.java | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cxf-xjc-utils/blob/ef810739/cxf-xjc-plugin/src/main/java/org/apache/cxf/maven_plugin/AbstractXSDToJavaMojo.java
----------------------------------------------------------------------
diff --cc cxf-xjc-plugin/src/main/java/org/apache/cxf/maven_plugin/AbstractXSDToJavaMojo.java
index 371bc22,9947e2b..5a69545
--- a/cxf-xjc-plugin/src/main/java/org/apache/cxf/maven_plugin/AbstractXSDToJavaMojo.java
+++ b/cxf-xjc-plugin/src/main/java/org/apache/cxf/maven_plugin/AbstractXSDToJavaMojo.java
@@@ -281,7 -281,10 +281,11 @@@ public abstract class AbstractXSDToJava
ArtifactResolutionResult result = repository.resolve(request);
List<File> files = new ArrayList<File>();
for (Artifact a : result.getArtifacts()) {
+ if (a.getFile() == null) {
+ throw new MojoExecutionException("Unable to resolve " + a.toString()
+ + " while resolving " + artifactDescriptor);
+ }
+ files.add(a.getFile());
}
if (!files.contains(artifact.getFile())) {
files.add(artifact.getFile());