use of org.codehaus.plexus.archiver.jar.Manifest in project intellij-community by JetBrains.
the class ManifestBuilder method getDefaultManifest.
@NotNull
private Manifest getDefaultManifest(@NotNull Map<String, String> entries) throws ManifestException {
Manifest finalManifest = new Manifest();
addManifestAttribute(finalManifest, entries, "Created-By", ApplicationNamesInfo.getInstance().getFullProductName());
addManifestAttribute(finalManifest, entries, "Built-By", System.getProperty("user.name"));
if (!StringUtil.isEmpty(myJdkVersion)) {
addManifestAttribute(finalManifest, entries, "Build-Jdk", myJdkVersion);
}
return finalManifest;
}
use of org.codehaus.plexus.archiver.jar.Manifest in project maven-plugins by apache.
the class ManifestCreationFinalizer method finalizeArchiveCreation.
@Override
public void finalizeArchiveCreation(final Archiver archiver) {
if (archiveConfiguration != null) {
try {
Manifest manifest;
final File manifestFile = archiveConfiguration.getManifestFile();
if (manifestFile != null) {
Reader manifestFileReader = null;
try {
manifestFileReader = new InputStreamReader(new FileInputStream(manifestFile), "UTF-8");
manifest = new Manifest(manifestFileReader);
manifestFileReader.close();
manifestFileReader = null;
} catch (final FileNotFoundException e) {
throw new ArchiverException("Manifest not found: " + e.getMessage(), e);
} catch (final IOException e) {
throw new ArchiverException("Error processing manifest: " + e.getMessage(), e);
} finally {
IOUtil.close(manifestFileReader);
}
} else {
manifest = mavenArchiver.getManifest(session, project, archiveConfiguration);
}
if ((manifest != null) && (archiver instanceof JarArchiver)) {
final JarArchiver jarArchiver = (JarArchiver) archiver;
jarArchiver.addConfiguredManifest(manifest);
}
} catch (final ManifestException e) {
throw new ArchiverException("Error creating manifest: " + e.getMessage(), e);
} catch (final DependencyResolutionRequiredException e) {
throw new ArchiverException("Dependencies were not resolved: " + e.getMessage(), e);
}
}
}
use of org.codehaus.plexus.archiver.jar.Manifest in project cxf by apache.
the class AbstractCodeGeneratorMojo method runForked.
private void runForked(Set<URI> classPath, Class<?> cls, String[] args) throws MojoExecutionException {
getLog().info("Running wadl2java in fork mode...");
Commandline cmd = new Commandline();
// for JVM args
cmd.getShell().setQuotedArgumentsEnabled(true);
cmd.setWorkingDirectory(project.getBuild().getDirectory());
try {
cmd.setExecutable(getJavaExecutable().getAbsolutePath());
} catch (IOException e) {
getLog().debug(e);
throw new MojoExecutionException(e.getMessage(), e);
}
cmd.createArg().setLine(additionalJvmArgs);
File file = null;
try {
// file = new File("/tmp/test.jar");
file = FileUtils.createTempFile("cxf-codegen", ".jar");
JarArchiver jar = new JarArchiver();
jar.setDestFile(file.getAbsoluteFile());
Manifest manifest = new Manifest();
Attribute attr = new Attribute();
attr.setName("Class-Path");
StringBuilder b = new StringBuilder(8000);
for (URI cp : classPath) {
b.append(cp.toURL().toExternalForm()).append(' ');
}
attr.setValue(b.toString());
manifest.getMainSection().addConfiguredAttribute(attr);
attr = new Attribute();
attr.setName("Main-Class");
attr.setValue(cls.getName());
manifest.getMainSection().addConfiguredAttribute(attr);
jar.addConfiguredManifest(manifest);
jar.createArchive();
cmd.createArg().setValue("-jar");
cmd.createArg().setValue(file.getAbsolutePath());
} catch (Exception e1) {
throw new MojoExecutionException("Could not create runtime jar", e1);
}
cmd.addArguments(args);
CommandLineUtils.StringStreamConsumer err = new CommandLineUtils.StringStreamConsumer();
CommandLineUtils.StringStreamConsumer out = new CommandLineUtils.StringStreamConsumer();
int exitCode;
try {
exitCode = CommandLineUtils.executeCommandLine(cmd, out, err);
} catch (CommandLineException e) {
getLog().debug(e);
throw new MojoExecutionException(e.getMessage(), e);
}
String output = StringUtils.isEmpty(out.getOutput()) ? null : '\n' + out.getOutput().trim();
String cmdLine = CommandLineUtils.toString(cmd.getCommandline());
if (exitCode != 0) {
if (StringUtils.isNotEmpty(output)) {
getLog().info(output);
}
StringBuilder msg = new StringBuilder("\nExit code: ");
msg.append(exitCode);
if (StringUtils.isNotEmpty(err.getOutput())) {
msg.append(" - ").append(err.getOutput());
}
msg.append('\n');
msg.append("Command line was: ").append(cmdLine).append('\n').append('\n');
throw new MojoExecutionException(msg.toString());
}
if (file != null) {
file.delete();
}
if (StringUtils.isNotEmpty(err.getOutput()) && err.getOutput().contains("WADL2Java Error")) {
StringBuilder msg = new StringBuilder();
msg.append(err.getOutput());
msg.append('\n');
msg.append("Command line was: ").append(cmdLine).append('\n').append('\n');
throw new MojoExecutionException(msg.toString());
}
}
Aggregations