/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License.
*/
publicvoid setFailOnError(boolean b) {
failOnError = b;
}
@Override publicvoid execute() throws BuildException { if (fileName == null) { thrownew BuildException("FileName has to filed", getLocation());
} if (packages == null) { thrownew BuildException("Packages has to filed", getLocation());
} if (action == null) { thrownew BuildException("Action has to filed", getLocation());
} if (classpath == null) { thrownew BuildException("Classpath has to filed", getLocation());
} if (sigtestJar == null) { thrownew BuildException("SigtestJar has to filed", getLocation());
}
if (packages.equals("-")) {
log("No public packages, skipping"); return;
}
if (!sigtestJar.exists()) { thrownew BuildException("Cannot find JAR with testing infrastructure: " + sigtestJar);
}
try {
ZipFile zip = new ZipFile(sigtestJar);
String c2 = "org/netbeans/apitest/Sigtest.class"; if (zip.getEntry(c2) != null) {
log("Using " + c2 + " found in " + sigtestJar, Project.MSG_DEBUG);
zip.close(); try {
apitest();
} catch (Exception ex) { thrownew BuildException(ex);
} return;
}
String c1 = "com/sun/tdk/signaturetest/Setup.class"; if (zip.getEntry(c1) != null) {
log("Using " + c1 + " found in " + sigtestJar, Project.MSG_DEBUG);
zip.close();
tdk(); return;
}
zip.close(); thrownew BuildException("Cannot find " + c1 + " nor " + c2 + " in " + sigtestJar);
} catch (IOException ex) { thrownew BuildException(ex);
}
}
privatevoid tdk() {
Java java = new Java();
java.setProject(getProject());
Path sigtestPath = new Path(getProject());
sigtestPath.setLocation(sigtestJar);
java.setClasspath(sigtestPath);
String a = null; if ("strictcheck".equals(action.getValue())) { // NOI18N
a = "SignatureTest"; // NOI18N
} if ("generate".equals(action.getValue())) { // NOI18N
a = "Setup"; // NOI18N
} if (a == null) { thrownew BuildException("Unsupported action " + action + " use: strictcheck or generate");
}
java.setClassname("com.sun.tdk.signaturetest." + a);
Commandline.Argument arg;
arg = java.createArg();
arg.setValue("-FileName");
arg = java.createArg();
arg.setValue(fileName.getAbsolutePath());
arg = java.createArg();
arg.setValue("-Classpath");
arg = java.createArg();
{
Path extracp = new Path(getProject());
extracp.add(classpath);
FileSet jdk = new FileSet();
jdk.setDir(new File(new File(System.getProperty("java.home")), "lib"));
jdk.setIncludes("*.jar");
extracp.addFileset(jdk);
arg.setPath(extracp);
}
File outputFile = null;
String s = getProject().getProperty("sigtest.output.dir"); if (s != null) {
File dir = getProject().resolveFile(s);
dir.mkdirs();
outputFile = new File(dir, fileName.getName().replace(".sig", "").replace("-", "."));
log(outputFile.toString());
String email = getProject().getProperty("sigtest.mail"); if (email != null) { try { try (FileWriter w = new FileWriter(outputFile)) {
w.write("email: ");
w.write(email);
w.write("\n");
}
} catch (IOException ex) { thrownew BuildException(ex);
}
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.