You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ant.apache.org by bo...@apache.org on 2003/04/01 13:38:30 UTC
cvs commit: ant/proposal/sandbox/antlib/src/main/org/apache/tools/ant/taskdefs Antjar.java Antlib.java
bodewig 2003/04/01 03:38:30
Modified: proposal/sandbox/antlib/src/main/org/apache/tools/ant/taskdefs
Antjar.java Antlib.java
Log:
Part 2 of Antoine's patch
Revision Changes Path
1.5 +6 -8 ant/proposal/sandbox/antlib/src/main/org/apache/tools/ant/taskdefs/Antjar.java
Index: Antjar.java
===================================================================
RCS file: /home/cvs/ant/proposal/sandbox/antlib/src/main/org/apache/tools/ant/taskdefs/Antjar.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- Antjar.java 7 Mar 2003 11:22:59 -0000 1.4
+++ Antjar.java 1 Apr 2003 11:38:30 -0000 1.5
@@ -1,7 +1,7 @@
/*
* The Apache Software License, Version 1.1
*
- * Copyright (c) 2000 The Apache Software Foundation. All rights
+ * Copyright (c) 2000,2003 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -53,15 +53,12 @@
*/
package org.apache.tools.ant.taskdefs;
-import org.xml.sax.*;
-import javax.xml.parsers.*;
import org.apache.tools.ant.*;
import org.apache.tools.ant.types.ZipFileSet;
import org.apache.tools.zip.*;
import java.io.*;
-import java.util.*;
/**
* Creates a ANTLIB archive. Code is similar to the War class, but with
@@ -129,7 +126,7 @@
// If no antxml file is specified, it's an error.
if (libraryDescriptor == null) {
throw new BuildException("antxml attribute is required",
- location);
+ getLocation());
}
super.initZipOutputStream(zOut);
@@ -142,9 +139,10 @@
* @param file file to add
* @param zOut stream to add to
* @param vPath the path to add it to in the zipfile
+ * @param mode the Unix permissions to set.
* @exception IOException io trouble
*/
- protected void zipFile(File file, ZipOutputStream zOut, String vPath)
+ protected void zipFile(File file, ZipOutputStream zOut, String vPath, int mode)
throws IOException {
// If the file being added is META-INF/antlib.xml, we warn if it's not the
// one specified in the "antxml" attribute - or if it's being added twice,
@@ -159,12 +157,12 @@
" task)", Project.MSG_WARN);
}
else {
- super.zipFile(file, zOut, vPath);
+ super.zipFile(file, zOut, vPath, mode);
descriptorAdded = true;
}
}
else {
- super.zipFile(file, zOut, vPath);
+ super.zipFile(file, zOut, vPath, mode);
}
}
1.6 +25 -31 ant/proposal/sandbox/antlib/src/main/org/apache/tools/ant/taskdefs/Antlib.java
Index: Antlib.java
===================================================================
RCS file: /home/cvs/ant/proposal/sandbox/antlib/src/main/org/apache/tools/ant/taskdefs/Antlib.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- Antlib.java 3 Mar 2002 12:37:41 -0000 1.5
+++ Antlib.java 1 Apr 2003 11:38:30 -0000 1.6
@@ -1,7 +1,7 @@
/*
* The Apache Software License, Version 1.1
*
- * Copyright (c) 1999 The Apache Software Foundation. All rights
+ * Copyright (c) 1999,2003 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -55,7 +55,6 @@
import org.apache.tools.ant.*;
import org.apache.tools.ant.types.*;
-import org.apache.tools.ant.taskdefs.*;
import org.xml.sax.*;
import javax.xml.parsers.*;
@@ -108,10 +107,6 @@
*/
private Path classpath = null;
- /**
- * the manufacture set of classes to load
- */
- private Path loaderPath = null;
/**
* our little xml parse
@@ -357,7 +352,7 @@
* Default is <code>true</code>.
* This property is mostly used by the core when loading core tasks.
*
- * @param failedonerror if true loading will stop if classes
+ * @param onerror if true loading will stop if classes
* cannot be instantiated
*/
public void setOnerror(FailureAction onerror) {
@@ -399,7 +394,7 @@
*/
public Path createClasspath() {
if (classpath == null) {
- classpath = new Path(project);
+ classpath = new Path(getProject());
}
return classpath.createPath();
}
@@ -424,7 +419,7 @@
private File libraryFile(String homeSubDir, String lib) {
// For the time being libraries live in $ANT_HOME/antlib.
// The idea being that not to load all the jars there anymore
- String home = project.getProperty("ant.home");
+ String home = getProject().getProperty("ant.home");
if (home == null) {
throw new BuildException("ANT_HOME not set as required.");
@@ -443,11 +438,11 @@
if (file == null && classpath == null) {
String msg =
"Must specify either library or file attribute or classpath.";
- throw new BuildException(msg, location);
+ throw new BuildException(msg, getLocation());
}
if (file != null && !file.exists()) {
String msg = "Cannot find library: " + file;
- throw new BuildException(msg, location);
+ throw new BuildException(msg, getLocation());
}
loadDefinitions();
@@ -492,7 +487,7 @@
case FAIL:
throw new BuildException(msg);
case REPORT:
- log(msg, project.MSG_WARN);
+ log(msg, Project.MSG_WARN);
}
}
}
@@ -502,7 +497,7 @@
case FAIL:
throw new BuildException(msg, io);
case REPORT:
- log(io.getMessage(), project.MSG_WARN);
+ log(io.getMessage(), Project.MSG_WARN);
}
}
return found;
@@ -534,7 +529,7 @@
if (loaderId == null) {
// Path cannot be added to the CoreLoader so simply
// ask for all instances of the resource descriptors
- return project.getCoreLoader().getResources(res);
+ return getProject().getCoreLoader().getResources(res);
}
return new DescriptorEnumeration(path.list(), res);
@@ -561,7 +556,7 @@
* create the classpath for this library from the file passed in and
* any classpath parameters
*
- * @param file library file to use
+ * @param clspath library file to use
* @return classloader using te
* @exception BuildException trouble creating the classloader
*/
@@ -569,13 +564,13 @@
throws BuildException {
if (loaderId == null) {
log("Loading definitions from CORE, <classpath> ignored",
- project.MSG_VERBOSE);
- return project.getCoreLoader();
+ Project.MSG_VERBOSE);
+ return getProject().getCoreLoader();
}
log("Using ClassLoader '" + loaderId + "' to load path: " + clspath,
- project.MSG_VERBOSE);
- return project.addToLoader(loaderId, clspath);
+ Project.MSG_VERBOSE);
+ return getProject().addToLoader(loaderId, clspath);
}
@@ -584,7 +579,7 @@
*/
private Path makeLoaderClasspath()
{
- Path clspath = new Path(project);
+ Path clspath = new Path(getProject());
if (file != null) clspath.setLocation(file);
//append any build supplied classpath
if (classpath != null) {
@@ -606,11 +601,10 @@
throws BuildException {
try {
SAXParser saxParser = saxFactory.newSAXParser();
- Parser parser = saxParser.getParser();
InputSource inputSource = new InputSource(is);
//inputSource.setSystemId(uri); //URI is nasty for jar entries
- project.log("parsing descriptor for library: " + file,
+ getProject().log("parsing descriptor for library: " + file,
Project.MSG_VERBOSE);
saxParser.parse(inputSource, new AntLibraryHandler(cl, als));
}
@@ -683,7 +677,7 @@
/**
* Constructor for the AntLibraryHandler object
*
- * @param cl optional classloader
+ * @param classloader optional classloader
* @param als alias list
*/
AntLibraryHandler(ClassLoader classloader, Properties als) {
@@ -759,7 +753,7 @@
try {
if ("role".equals(tag)) {
- if (project.isRoleDefined(name)) {
+ if (getProject().isRoleDefined(name)) {
String msg = "Cannot override role: " + name;
log(msg, Project.MSG_WARN);
return;
@@ -767,7 +761,7 @@
// Defining a new role
Class clz = loadClass(className);
if (clz != null) {
- project.addRoleDefinition(name, clz,
+ getProject().addRoleDefinition(name, clz,
(adapter == null? null :
loadClass(adapter)));
}
@@ -781,24 +775,24 @@
name = alias;
}
//catch an attempted override of an existing name
- if (!override && project.isDefinedOnRole(tag, name)) {
+ if (!override && getProject().isDefinedOnRole(tag, name)) {
String msg = "Cannot override " + tag + ": " + name;
log(msg, Project.MSG_WARN);
return;
}
Class clz = loadClass(className);
if (clz != null)
- project.addDefinitionOnRole(tag, name, clz);
+ getProject().addDefinitionOnRole(tag, name, clz);
}
catch(BuildException be) {
switch (onerror.getIndex()) {
case FAIL:
throw new SAXParseException(be.getMessage(), locator, be);
case REPORT:
- project.log(be.getMessage(), project.MSG_WARN);
+ getProject().log(be.getMessage(), Project.MSG_WARN);
break;
default:
- project.log(be.getMessage(), project.MSG_DEBUG);
+ getProject().log(be.getMessage(), Project.MSG_DEBUG);
}
}
}
@@ -833,10 +827,10 @@
}
if (onerror.getIndex() == REPORT) {
- project.log(msg, project.MSG_WARN);
+ getProject().log(msg, Project.MSG_WARN);
}
else {
- project.log(msg, project.MSG_DEBUG);
+ getProject().log(msg, Project.MSG_DEBUG);
}
return null;
}