Skip to content

Commit

Permalink
[issue #3] introduced operation to make an absolute path manifest com…
Browse files Browse the repository at this point in the history
…patible
  • Loading branch information
Martin Scholl committed Sep 18, 2012
1 parent b440bf4 commit ad85bc6
Showing 1 changed file with 25 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -369,8 +369,6 @@ private File generateStarterJar(final ArtifactEx artifactEx) throws MojoFailureE
throw new MojoFailureException("starter configuration needs main class definition"); // NOI18N
}

final StringBuilder classpath = new StringBuilder();

final LocalConfiguration localConfiguration = starter.getLocalConfiguration();
final File localDir;
try {
Expand Down Expand Up @@ -435,18 +433,20 @@ public boolean accept(final File file) {
+ sb.toString());
}

final StringBuilder classpath = new StringBuilder();

for (final File localJar : localJars) {
if (!isSigned(localJar)) {
signJar(localJar);
}

classpath.append(localJar.getAbsolutePath()).append(' ');
classpath.append(getManifestCompatiblePath(localJar.getAbsolutePath())).append(' ');
}

if (artifactEx.getExtendedClassPathJar() == null) {
classpath.append(artifactEx.getClassPathJar().getAbsolutePath());
classpath.append(getManifestCompatiblePath(artifactEx.getClassPathJar().getAbsolutePath()));
} else {
classpath.append(artifactEx.getExtendedClassPathJar().getAbsolutePath());
classpath.append(getManifestCompatiblePath(artifactEx.getExtendedClassPathJar().getAbsolutePath()));
}

// Generate Manifest and jar File
Expand Down Expand Up @@ -732,6 +732,23 @@ private Model createModel(final ArtifactEx artifactEx) throws MojoExecutionExcep
return model;
}

/**
* Prepends a {@link File#separator} to the given absolute path to solve issue #3
* {@linkplain https://github.com/cismet/cids-maven-plugin/issues/3}. Be sure to call only with an absolute path
* string as relative paths will be turned absolute.
*
* @param absolutePath the path to convert to a manifest compatible path
*
* @return the given absolute path with a leading <code>File.separator</code>
*/
private String getManifestCompatiblePath(final String absolutePath) {
if (absolutePath == null) {
return null;
}

return absolutePath.startsWith(File.separator) ? absolutePath : (File.separator + absolutePath);
}

/**
* DOCUMENT ME!
*
Expand All @@ -757,7 +774,7 @@ private File generateJar(final ArtifactEx parent, final ArtifactEx child) throws
if (virtual) {
classpath = new StringBuilder();
} else {
classpath = new StringBuilder(parentArtifact.getFile().getAbsolutePath());
classpath = new StringBuilder(getManifestCompatiblePath(parentArtifact.getFile().getAbsolutePath()));
classpath.append(' ');
}

Expand All @@ -766,7 +783,7 @@ private File generateJar(final ArtifactEx parent, final ArtifactEx child) throws
filter = new ScopeArtifactFilter(Artifact.SCOPE_RUNTIME);
} else {
filter = new ChildDependencyFilter(child);
classpath.append(child.getClassPathJar().getAbsolutePath()).append(' ');
classpath.append(getManifestCompatiblePath(child.getClassPathJar().getAbsolutePath())).append(' ');
}

JarOutputStream target = null;
Expand All @@ -782,7 +799,7 @@ private File generateJar(final ArtifactEx parent, final ArtifactEx child) throws
if (!isSigned(dep.getFile())) {
signJar(dep.getFile());
}
classpath.append(dep.getFile().getAbsolutePath()).append(' ');
classpath.append(getManifestCompatiblePath(dep.getFile().getAbsolutePath())).append(' ');
}

// Generate Manifest and jar File
Expand Down

0 comments on commit ad85bc6

Please sign in to comment.