Skip to content

Commit

Permalink
Fixed a couple of issues preventing schemadist from running.
Browse files Browse the repository at this point in the history
  • Loading branch information
mederly committed Oct 2, 2014
1 parent b24c9bd commit 87c5d53
Showing 1 changed file with 18 additions and 3 deletions.
Expand Up @@ -203,7 +203,7 @@ public void execute() throws MojoExecutionException, MojoFailureException {
for (ArtifactItem artifactItem: artifactItems) {
Artifact artifact = artifactItem.getArtifact();
getLog().info( "SchemaDist unpacking artifact " + artifact);
File workDir = new File(workDirectory, artifact.toString());
File workDir = new File(workDirectory, artifact.getArtifactId());
initializeOutDir(workDir);
artifactItem.setWorkDir(workDir);
unpack(artifactItem, workDir);
Expand All @@ -215,7 +215,18 @@ public void execute() throws MojoExecutionException, MojoFailureException {
Catalog catalog = new Catalog(catalogManager);
catalog.setupReaders();
try {
catalog.parseCatalog(catalogFile.getPath());
// UGLY HACK. On Windows, file names like d:\abc\def\catalog.xml eventually get treated very strangely
// (resulting in names like "file:<current-working-dir>d:\abc\def\catalog.xml" that are obviously wrong)
// Prefixing such names with "file:/" helps.
String prefix;
if (catalogFile.isAbsolute() && !catalogFile.getPath().startsWith("/")) {
prefix = "/";
} else {
prefix = "";
}
String fileName = "file:" + prefix + catalogFile.getPath();
getLog().debug("Calling parseCatalog with: " + fileName);
catalog.parseCatalog(fileName);
} catch (MalformedURLException e) {
throw new MojoExecutionException("Error parsing catalog file "+catalogPath+" in artifact "+artifact, e);
} catch (IOException e) {
Expand Down Expand Up @@ -340,7 +351,11 @@ private void processWsdl(Path filePath, File workDir, File outDir) throws MojoEx
private String resolveSchemaLocation(String namespace, Path filePath, File workDir) throws MojoExecutionException, IOException {
for(ArtifactItem artifactItem: artifactItems) {
Catalog catalog = artifactItem.getResolveCatalog();
String resolvedString = catalog.resolveEntity(filePath.toString(), namespace, namespace);
String publicId = namespace;
if (publicId.endsWith("#")) {
publicId = publicId.substring(0, publicId.length()-1);
}
String resolvedString = catalog.resolveEntity(filePath.toString(), publicId, publicId);
if (resolvedString != null) {
getLog().debug("-------------------");
getLog().debug("Resolved namespace "+namespace+" to "+resolvedString+" using catalog "+catalog);
Expand Down

0 comments on commit 87c5d53

Please sign in to comment.