本文整理汇总了Java中org.apache.tools.ant.BuildException类的典型用法代码示例。如果您正苦于以下问题:Java BuildException类的具体用法?Java BuildException怎么用?Java BuildException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
BuildException类属于org.apache.tools.ant包,在下文中一共展示了BuildException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: verify
import org.apache.tools.ant.BuildException; //导入依赖的package包/类
private void verify(String clazz, byte[] data, Map<String,Boolean> loadable, ClassLoader loader, AtomicInteger maxWarn)
throws IOException, BuildException {
//log("Verifying linkage of " + clazz.replace('/', '.'), Project.MSG_DEBUG);
Set<String> dependencies = dependencies(data);
//System.err.println(clazz + " -> " + dependencies);
for (String clazz2 : dependencies) {
Boolean exists = loadable.get(clazz2);
if (exists == null) {
exists = loader.getResource(clazz2.replace('.', '/') + ".class") != null;
loadable.put(clazz2, exists);
}
if (!exists) {
String message = clazz + " cannot access " + clazz2;
if (failOnError) {
throw new BuildException(message, getLocation());
} else if (maxWarn.getAndDecrement() > 0) {
log("Warning: " + message, Project.MSG_WARN);
} else {
log("(additional warnings not reported)", Project.MSG_WARN);
return;
}
} else {
//log("Working reference to " + clazz2, Project.MSG_DEBUG);
}
}
}
示例2: execute
import org.apache.tools.ant.BuildException; //导入依赖的package包/类
/**
* Execute the requested operation.
*
* @exception BuildException if an error occurs
*/
@Override
public void execute() throws BuildException {
super.execute();
if (bean == null || attribute == null || value == null) {
throw new BuildException
("Must specify 'bean', 'attribute' and 'value' attributes");
}
log("Setting attribute " + attribute +
" in bean " + bean +
" to " + value);
try {
execute("/jmxproxy/?set=" + URLEncoder.encode(bean, getCharset())
+ "&att=" + URLEncoder.encode(attribute, getCharset())
+ "&val=" + URLEncoder.encode(value, getCharset()));
} catch (UnsupportedEncodingException e) {
throw new BuildException
("Invalid 'charset' attribute: " + getCharset());
}
}
示例3: execute
import org.apache.tools.ant.BuildException; //导入依赖的package包/类
public void execute() throws BuildException {
ProfilerLauncher.Session s = ProfilerLauncher.getLastSession();
if (s != null && s.isConfigured()) {
Map<String, String> props = s.getProperties();
if (props != null) {
for(Map.Entry<String, String> e : props.entrySet()) {
getProject().setProperty(e.getKey(), e.getValue());
}
getProject().setProperty("profiler.jvmargs", "-J-Dprofiler.pre72=true"); // NOI18N
getProject().addBuildListener(new BuildEndListener(connectionCancel));
if (!NetBeansProfiler.getDefaultNB().startEx(s.getProfilingSettings(), s.getSessionSettings(), connectionCancel)) {
throw new BuildException("User abort"); // NOI18N
}
}
} else {
throw new BuildException("User abort");// NOI18N
}
}
示例4: resolveDependencies
import org.apache.tools.ant.BuildException; //导入依赖的package包/类
private void resolveDependencies(IEclipseProject project,
List<IEclipseProject> resolved, List<IEclipseProject> stack) {
stack = new ArrayList<IEclipseProject>(stack);
stack.add(project);
if (!resolved.contains(project)) {
for (IEclipseProject ref : project.getDependencies()) {
if (stack.contains(ref)) {
// reduce the stack to the actual cycle:
stack = stack.subList(stack.indexOf(ref), stack.size());
throw new BuildException("Dependency Cycle: " + stack);
}
resolveDependencies(ref, resolved, stack);
}
resolved.add(project);
}
}
示例5: execute
import org.apache.tools.ant.BuildException; //导入依赖的package包/类
@Override
public final void execute() throws BuildException {
ClassLoader defaultCL = ServiceFactory.replaceClassloader();
try {
executeInternal();
} catch (Throwable e) {
if (e instanceof BuildException) {
log("Build exception " + e.getMessage(), 0);
throw (BuildException) e;
} else {
if (e instanceof WebtestTaskException) {
// just a message carrier
throwBuildException(e.getMessage());
} else {
throwBuildException(null, e);
}
}
} finally {
Thread.currentThread().setContextClassLoader(defaultCL);
log(ServiceFactory.getHeapInfo());
}
}
示例6: execute
import org.apache.tools.ant.BuildException; //导入依赖的package包/类
@Override
public void execute() throws BuildException {
if (StringUtils.isEmpty(dirName)) {
throw new BuildException("dirname is mandatory");
}
if (StringUtils.isEmpty(fileName)) {
throw new BuildException("filename is mandatory");
}
File file = new File(dirName + File.separator + fileName);
if (!file.exists()) {
throw new BuildException("wsit file does not exist");
}
try {
String content = convertStreamToString(file);
content = xmlContent + content;
FileWriter fw = new FileWriter(file);
fw.write(content);
fw.close();
} catch (IOException e) {
throw new BuildException(e);
}
}
示例7: execute
import org.apache.tools.ant.BuildException; //导入依赖的package包/类
/**
* Executes the task. This method sends an HTTP POST request to the server,
* uploading the package archive.
*
* @throws org.apache.tools.ant.BuildException if an I/O error occurs.
*/
public void execute() throws BuildException {
try {
final Map<String, Object> args = new HashMap<String, Object>();
args.put("registry", registry); // NOI18N
args.put("uid", uid); // NOI18N
args.put("version", version); // NOI18N
args.put("platforms", platforms); // NOI18N
args.put("archive", archive); // NOI18N
String response = Utils.post(url + "/add-package", args); // NOI18N
log(response);
if (!response.startsWith("200")) { // NOI18N
throw new BuildException("Failed to release the package."); // NOI18N
}
} catch (IOException e) {
throw new BuildException(e);
}
}
示例8: execute
import org.apache.tools.ant.BuildException; //导入依赖的package包/类
/**
* Execute the requested operation.
*
* @exception BuildException
* if an error occurs
*/
@Override
public void execute() throws BuildException {
super.execute();
String queryString;
if (query == null) {
queryString = "";
} else {
try {
queryString = "?qry=" + URLEncoder.encode(query, getCharset());
} catch (UnsupportedEncodingException e) {
throw new BuildException("Invalid 'charset' attribute: " + getCharset());
}
}
log("Query string is " + queryString);
execute("/jmxproxy/" + queryString);
}
示例9: generateTestModules1
import org.apache.tools.ant.BuildException; //导入依赖的package包/类
private void generateTestModules1(boolean sortTests) throws IOException, BuildException {
// a -> b means: a depends on b
// a-> b,c
// b -> d,e, unittest g
// f -> g
createModule(g,NULL);
createModule(d,NULL);
createModule(c,NULL);
createModule(e,NULL);
createModule(a,new String[]{b,c});
createModule(b,new String[]{e,d},new String[]{g},NULL);
createModule(f,new String[]{g});
Path path = createPath(new String[]{a,b,c,d,e,f,g});
SortSuiteModules ssm = new SortSuiteModules();
ssm.setProject(project);
ssm.setUnsortedModules(path);
ssm.setSortedModulesProperty(SORTED_MODULES);
if (sortTests) {
ssm.setSortTests(true);
}
ssm.execute();
}
示例10: addTask
import org.apache.tools.ant.BuildException; //导入依赖的package包/类
/**
* Add a nested task to Try.
*
* @param task Nested task to try to execute
*/
public void addTask( Task task ) {
if ( task instanceof CatchTask ) {
if ( catchTask == null ) {
catchTask = task;
return ;
} else {
throw new BuildException( "Only one Catch allowed per Try." );
}
} else if ( task instanceof FinallyTask ) {
if ( finallyTask == null ) {
finallyTask = task;
return ;
} else {
throw new BuildException( "Only one Finally allowed per Try." );
}
}
tasks.addElement( task );
}
示例11: execute
import org.apache.tools.ant.BuildException; //导入依赖的package包/类
/**
* Execute the requested operation.
*
* @exception BuildException if an error occurs
*/
public void execute() throws BuildException {
super.execute();
if (path == null) {
throw new BuildException
("Must specify 'path' attribute");
}
try {
execute("/sessions?path=" + URLEncoder.encode(this.path, getCharset()));
} catch (UnsupportedEncodingException e) {
throw new BuildException
("Invalid 'charset' attribute: " + getCharset());
}
}
示例12: loadFile
import org.apache.tools.ant.BuildException; //导入依赖的package包/类
/**
* load variables from a file
*
* @param file file to load
* @exception BuildException Description of the Exception
*/
private void loadFile( File file ) throws BuildException {
Properties props = new Properties();
try {
if ( file.exists() ) {
FileInputStream fis = new FileInputStream( file );
try {
props.load( fis );
}
finally {
if ( fis != null ) {
fis.close();
}
}
addProperties( props );
}
else {
log( "Unable to find property file: " + file.getAbsolutePath(),
Project.MSG_VERBOSE );
}
}
catch ( IOException ex ) {
throw new BuildException( ex, location );
}
}
示例13: getFilter
import org.apache.tools.ant.BuildException; //导入依赖的package包/类
private IFileFilter getFilter(String name) {
if (name.equals("replace")) {
return replacefilter;
}
if (name.equals("renamewsitfile")) {
return renamewsitfilefilter;
}
if (name.startsWith("chmod")) {
final String[] args = name.split("\\s+");
if (args.length != 2) {
throw new BuildException("Invalid parameter for chmod filter.");
}
final String mode = args[1];
try {
return Files.permissionsFilter(Integer.parseInt(mode, 8));
} catch (NumberFormatException e) {
throw new BuildException("Invalid mode for chmod filter: "
+ mode);
}
}
throw new BuildException("Unknown filter: " + name);
}
示例14: constructJarHref
import org.apache.tools.ant.BuildException; //导入依赖的package包/类
/**
* Constructs jar or nativelib tag for jars using custom name
* @param f
* @param dashcnb
* @return
* @throws IOException
*/
private String constructJarHref(File f, String dashcnb, String name) throws IOException {
String tag = "jar";
if (nativeLibraries != null && nativeLibraries.contains(name)) {
tag = "nativelib";
}
if (processJarVersions) {
if (!f.exists()) {
throw new BuildException("JAR file " + f + " does not exist, cannot extract required versioning info.");
}
JarFile extJar = new JarFile(f);
String version = getJarVersion(extJar);
if (version != null) {
return " <" + tag + " href='" + dashcnb + '/' + name + "' version='" + version + "' size='" + f.length() + "'/>\n";
}
}
return " <" + tag + " href='" + dashcnb + '/' + name + "'/>\n";
}
示例15: execute
import org.apache.tools.ant.BuildException; //导入依赖的package包/类
public void execute() throws BuildException {
// execute all nested tasks
for ( Enumeration e = tasks.elements(); e.hasMoreElements(); ) {
Task task = ( Task ) e.nextElement();
if ( task instanceof Breakable ) {
task.perform();
if ( ( ( Breakable ) task ).doBreak() ) {
setBreak( true );
return ;
}
}
else {
task.perform();
}
}
}