use of aQute.libg.command.Command in project bnd by bndtools.
the class MavenDeployCmd method maven_gpg_sign_and_deploy.
// gpg:sign-and-deploy-file \
// -Durl=http://oss.sonatype.org/service/local/staging/deploy/maven2
// \
// -DrepositoryId=sonatype-nexus-staging \
// -DupdateReleaseInfo=true \
// -DpomFile=pom.xml \
// -Dfile=/Ws/bnd/biz.aQute.bndlib/tmp/biz.aQute.bndlib.jar \
// -Dpassphrase=a1k3v3t5x3
private void maven_gpg_sign_and_deploy(Project b, File file, String classifier, File pomFile) throws Exception {
Command command = new Command();
command.setTrace();
command.add(b.getProperty("mvn", "mvn"));
command.add("gpg:sign-and-deploy-file", "-DreleaseInfo=true", "-DpomFile=pom.xml");
command.add("-Dfile=" + file.getAbsolutePath());
command.add("-DrepositoryId=" + repository);
command.add("-Durl=" + url);
optional(command, "passphrase", passphrase);
optional(command, "keyname", keyname);
optional(command, "homedir", homedir);
optional(command, "classifier", classifier);
optional(command, "pomFile", pomFile == null ? null : pomFile.getAbsolutePath());
StringBuilder stdout = new StringBuilder();
StringBuilder stderr = new StringBuilder();
int result = command.execute(stdout, stderr);
if (result != 0) {
b.error("Maven deploy to %s failed to sign and transfer %s because %s", repository, file, "" + stdout + stderr);
}
}
use of aQute.libg.command.Command in project bnd by bndtools.
the class MavenDeployCmd method javadoc.
private Jar javadoc(File tmp, Project b, Set<String> exports) throws Exception {
Command command = new Command();
command.add(b.getProperty("javadoc", "javadoc"));
command.add("-d");
command.add(tmp.getAbsolutePath());
command.add("-sourcepath");
command.add(Processor.join(b.getSourcePath(), File.pathSeparator));
for (String packageName : exports) {
command.add(packageName);
}
StringBuilder out = new StringBuilder();
StringBuilder err = new StringBuilder();
Command c = new Command();
c.setTrace();
int result = c.execute(out, err);
if (result == 0) {
Jar jar = new Jar(tmp);
b.addClose(jar);
return jar;
}
b.error("Error during execution of javadoc command: %s / %s", out, err);
return null;
}
use of aQute.libg.command.Command in project bnd by bndtools.
the class Tool method doJavadoc.
public Jar doJavadoc(Map<String, String> options, boolean exportsOnly) throws Exception {
if (!hasSources())
return new Jar("javadoc");
IO.mkdirs(javadoc);
List<String> args = new ArrayList<>();
args.add("-quiet");
args.add("-protected");
args.add(String.format("%s '%s'", "-d", fileName(javadoc)));
args.add("-charset 'UTF-8'");
args.add(String.format("%s '%s'", "-sourcepath", fileName(sources)));
Properties pp = new UTF8Properties();
pp.putAll(options);
String name = manifest.getBundleName();
if (name == null)
name = manifest.getBundleSymbolicName().getKey();
String version = manifest.getBundleVersion();
if (version == null)
version = Version.LOWEST.toString();
String bundleDescription = manifest.getBundleDescription();
if (bundleDescription != null && !Strings.trim(bundleDescription).isEmpty()) {
printOverview(name, version, bundleDescription);
}
set(pp, "-doctitle", name);
set(pp, "-windowtitle", name);
set(pp, "-header", manifest.getBundleVendor());
set(pp, "-bottom", manifest.getBundleCopyright());
set(pp, "-footer", manifest.getBundleDocURL());
args.add("-tag 'Immutable:t:\"Immutable\"'");
args.add("-tag 'ThreadSafe:t:\"ThreadSafe\"'");
args.add("-tag 'NotThreadSafe:t:\"NotThreadSafe\"'");
args.add("-tag 'GuardedBy:mf:\"Guarded By:\"'");
args.add("-tag 'security:m:\"Required Permissions\"'");
args.add("-tag 'noimplement:t:\"Consumers of this API must not implement this interface\"'");
for (Enumeration<?> e = pp.propertyNames(); e.hasMoreElements(); ) {
String key = (String) e.nextElement();
String value = pp.getProperty(key);
if (key.startsWith("-")) {
//
// Allow people to add the same command multiple times
// by suffixing it with '.' something
//
int n = key.lastIndexOf('.');
if (n > 0) {
key = key.substring(0, n);
}
args.add(String.format("%s '%s'", key, escape(value)));
}
}
FileSet set = new FileSet(sources, "**.java");
for (File f : set.getFiles()) {
args.add(String.format("'%s'", fileName(f)));
}
if (exportsOnly) {
Parameters exports = manifest.getExportPackage();
for (String packageName : exports.keySet()) {
args.add(String.format("'%s'", packageName));
}
}
StringBuilder sb = new StringBuilder();
for (String arg : args) {
sb.append(arg);
sb.append('\n');
}
IO.store(sb, javadocOptions);
Command command = new Command();
command.add(getProperty("javadoc", "javadoc"));
command.add("@" + fileName(javadocOptions));
StringBuilder out = new StringBuilder();
StringBuilder err = new StringBuilder();
int result = command.execute(out, err);
if (result != 0) {
warning("Error during execution of javadoc command: %s\n******************\n%s", out, err);
}
return new Jar(javadoc);
}
use of aQute.libg.command.Command in project bnd by bndtools.
the class RemoteSink method launch.
@Override
public boolean launch(String areaId, Map<String, String> env, List<String> args) throws Exception {
final AreaImpl area = getArea(areaId);
if (area == null)
throw new IllegalArgumentException("No such area");
if (area.running)
throw new IllegalStateException("Already running");
area.command = new Command();
area.command.addAll(args);
area.command.setCwd(area.cwd);
if (env != null) {
for (Map.Entry<String, String> e : env.entrySet()) {
area.command.var(e.getKey(), e.getValue());
}
}
area.line = area.command.toString();
PipedInputStream pin = new PipedInputStream();
@SuppressWarnings("resource") PipedOutputStream pout = new PipedOutputStream();
pout.connect(pin);
area.toStdin = pout;
area.stdin = pin;
area.stdout = new Appender(sources, area.id, false);
area.stderr = new Appender(sources, area.id, true);
area.thread = new Thread(areaId + "::" + args) {
public void run() {
try {
event(Event.launching, area);
area.running = true;
area.command.setCwd(area.cwd);
area.command.setUseThreadForInput(true);
area.exitCode = area.command.execute(area.stdin, area.stdout, area.stderr);
} catch (Throwable e) {
area.exitCode = -1;
area.exception = e.toString();
} finally {
area.running = false;
area.toStdin = null;
area.stderr = null;
area.stdout = null;
area.stdin = null;
area.command = null;
event(Event.exited, area);
}
}
};
area.thread.start();
return true;
}
use of aQute.libg.command.Command in project bnd by bndtools.
the class RemoteSink method exit.
@Override
public int exit(String areaId) throws Exception {
AreaImpl area = getArea(areaId);
Command c = area.command;
if (!area.running || c == null)
throw new IllegalStateException("Area " + areaId + " is not running");
c.cancel();
area.thread.join(10000);
return area.exitCode;
}
Aggregations