/* * 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.
*/
/** * Validates the syntax and semantics of one or more JNLP files. * Any other JNLP fragments referred to recursively from these files will be validated as well. * JNLP files must specify a document type, normally: * <!DOCTYPE jnlp PUBLIC "-//Sun Microsystems, Inc//DTD JNLP Descriptor 6.0//EN" "http://java.sun.com/dtd/JNLP-6.0.dtd"> * The codebase specified in the file is used as is if a file: URL; * if $$codebase, it is taken to be the immediately containing directory, to match the behavior of JnlpDownloadServlet; * if a remote URL, it is also taken to be the immediately containing directory, * since otherwise it would be impossible to validate files which were generated with intent to upload to a server. * See issue #96630.
*/ publicclass VerifyJNLP extends Task {
private List<FileSet> filesets = new ArrayList<>(); /** * Add one or more JNLP files to validate. * Use <fileset file="..."/> if you have just one. * Fragments referred to from higher JNLP files are checked automatically and do not need to be specified.
*/ publicvoid addConfiguredFileset(FileSet fs) {
filesets.add(fs);
}
private File report; /** * JUnit report file to create rather than halting build if errors are encountered.
*/ publicvoid setReport(File report) { this.report = report;
}
privateboolean failOnError = true; /** * Whether to halt the build if there is a verification error. Default true.
*/ publicvoid setFailOnError(boolean failOnError) { this.failOnError = failOnError;
}
public @Override void execute() throws BuildException {
Map<String,String> results = new LinkedHashMap<>(); for (FileSet fs : filesets) {
DirectoryScanner s = fs.getDirectoryScanner(getProject());
File basedir = s.getBasedir(); for (String incl : s.getIncludedFiles()) {
validate(new File(basedir, incl), results);
}
}
JUnitReportWriter.writeReport(this, null, failOnError ? null : report, results);
}
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.