dion 2004/01/08 22:27:01 Modified: src/bootstrap/org/apache/maven Tag: MAVEN-1_0-BRANCH Dependency.java BootstrapPomParser.java BootstrapTask.java Log: Code cleanup Revision Changes Path No revision No revision 1.3.10.2 +3 -4 maven/src/bootstrap/org/apache/maven/Dependency.java Index: Dependency.java =================================================================== RCS file: /home/cvs/maven/src/bootstrap/org/apache/maven/Dependency.java,v retrieving revision 1.3.10.1 retrieving revision 1.3.10.2 diff -u -r1.3.10.1 -r1.3.10.2 --- Dependency.java 7 Jan 2004 15:33:56 -0000 1.3.10.1 +++ Dependency.java 9 Jan 2004 06:27:01 -0000 1.3.10.2 @@ -101,8 +101,7 @@ } /** - * - * @return + * @return the id attribute (groupId:artifactId) */ public String getId() { @@ -194,7 +193,7 @@ { return jar; } - + if ( isValid( getArtifactId() ) ) { return getArtifactId() + "-" + getVersion() + "." + getType(); 1.5.10.4 +24 -1 maven/src/bootstrap/org/apache/maven/BootstrapPomParser.java Index: BootstrapPomParser.java =================================================================== RCS file: /home/cvs/maven/src/bootstrap/org/apache/maven/BootstrapPomParser.java,v retrieving revision 1.5.10.3 retrieving revision 1.5.10.4 diff -u -r1.5.10.3 -r1.5.10.4 --- BootstrapPomParser.java 7 Jan 2004 15:28:26 -0000 1.5.10.3 +++ BootstrapPomParser.java 9 Jan 2004 06:27:01 -0000 1.5.10.4 @@ -68,14 +68,20 @@ import java.util.List; /** + * A class to parse the POM. */ public class BootstrapPomParser extends DefaultHandler { + /** the project dependencies */ private ArrayList dependencies = new ArrayList(); + /** current dependency being processed */ private Dependency currentDependency; + /** factory to create a sax parser */ private static SAXParserFactory saxFactory; + /** whether we're inside a dependency element during parsing */ private boolean insideDependency = false; + /** text of the element being processed */ private StringBuffer bodyText = new StringBuffer(); /** @@ -87,6 +93,8 @@ } /** + * Parse a POM + * @param project the project file to parse */ public void parse(File project) { @@ -105,6 +113,10 @@ /** * Handles opening elements of the xml file. + * @param uri the uri being parsed + * @param localName element without namespace + * @param rawName element name + * @param attributes element attributes */ public void startElement(String uri, String localName, String rawName, Attributes attributes) { @@ -116,13 +128,19 @@ } /** - * Description of the Method + * some xml element text + * @param buffer the text found + * @param start the start position of text in the buffer + * @param length the length of the text in the buffer */ public void characters(char[] buffer, int start, int length) { bodyText.append(buffer, start, length); } + /** + * @return the current text from the characters method + */ private String getBodyText() { return bodyText.toString().trim(); @@ -130,6 +148,9 @@ /** * Handles closing elements of the xml file. + * @param uri the uri being parsed + * @param localName element without namespace + * @param rawName element name */ public void endElement(String uri, String localName, String rawName) { @@ -198,6 +219,8 @@ /** * Description of the Method + * @param type the type of error + * @param spe The parse exception that caused the callback to be invoked. */ private final void printParseError(String type, SAXParseException spe) { 1.20.2.2 +37 -25 maven/src/bootstrap/org/apache/maven/BootstrapTask.java Index: BootstrapTask.java =================================================================== RCS file: /home/cvs/maven/src/bootstrap/org/apache/maven/BootstrapTask.java,v retrieving revision 1.20.2.1 retrieving revision 1.20.2.2 diff -u -r1.20.2.1 -r1.20.2.2 --- BootstrapTask.java 7 Jan 2004 15:33:56 -0000 1.20.2.1 +++ BootstrapTask.java 9 Jan 2004 06:27:01 -0000 1.20.2.2 @@ -56,13 +56,6 @@ * ==================================================================== */ -import org.apache.maven.util.HttpUtils; -import org.apache.tools.ant.BuildException; -import org.apache.tools.ant.Project; -import org.apache.tools.ant.Task; -import org.apache.tools.ant.types.Path; -import org.apache.tools.ant.types.PatternSet; - import java.io.File; import java.io.FileWriter; import java.io.IOException; @@ -71,6 +64,13 @@ import java.util.Iterator; import java.util.List; +import org.apache.maven.util.HttpUtils; +import org.apache.tools.ant.BuildException; +import org.apache.tools.ant.Project; +import org.apache.tools.ant.Task; +import org.apache.tools.ant.types.Path; +import org.apache.tools.ant.types.PatternSet; + /** * Get a list of resources from a website. * @@ -79,28 +79,29 @@ public class BootstrapTask extends Task { + /** the parser to load the pom */ private BootstrapPomParser bootstrapPomParser; - + /** the pom to be bootstrapped */ private File projectDescriptor; - + /** the dependencies of the pom */ private List dependencies; - + /** the local repo of jars */ private File mavenRepoLocal; - + /** whether to use the file timestamp when checking freshness */ private boolean useTimestamp = true; - + /** whether to ignore errors on downloads */ private boolean ignoreErrors = true; - + /** the url to download from */ private String baseUrl; - + /** whether we've got 'net access */ private String online; - + /** the proxy to use */ private String proxyHost; - + /** the port to use on the proxy */ private String proxyPort; - + /** the user name to use for the proxy */ private String proxyUserName; - + /** the password to use for the proxy */ private String proxyPassword; /** list of files to process */ @@ -109,6 +110,9 @@ /** Location to put the cope_deps scripts. */ private File copyScriptDir = null; + /** number of times to retry download */ + private static final int MAX_RETRIES = 3; + /** * Get the directory to put the copy script into. * @return the directory @@ -129,6 +133,7 @@ /** * Sets the projectDescriptor attribute of the BootstrapTask object + * @param projectDescriptor the file to bootstrap */ public void setProjectDescriptor( File projectDescriptor ) { @@ -136,7 +141,7 @@ } /** - * Gets the projectDescriptor attribute of the BootstrapTask object + * @return the projectDescriptor attribute */ public File getProjectDescriptor() { @@ -144,7 +149,8 @@ } /** - * Sets the basedir attribute of the BootstrapTask object + * Sets the mavenRepoLocal attribute of the BootstrapTask object + * @param mavenRepoLocal the repository to use */ public void setMavenRepoLocal( File mavenRepoLocal ) { @@ -152,7 +158,7 @@ } /** - * Gets the basedir attribute of the BootstrapTask object + * @return the local maven repository */ public File getMavenRepoLocal() { @@ -163,6 +169,7 @@ /** * Sets the files attribute of the BootstrapTask object + * @param files a list of dependency file names */ public void setFiles( List files ) { @@ -170,7 +177,7 @@ } /** - * Gets the files attribute of the BootstrapTask object + * @return the files attribute */ public List getFiles() { @@ -317,9 +324,9 @@ downloadDependencies(); } - createClasspathReference( project, "bootstrap-classpath", list, mavenRepoLocal ); + createClasspathReference( getProject(), "bootstrap-classpath", list, mavenRepoLocal ); - createPatternSetReference( project, "bootstrap-patternset", list ); + createPatternSetReference( getProject(), "bootstrap-patternset", list ); try { @@ -398,6 +405,7 @@ /** * Get the artifact path for a dependency in the repository. * @param d the dependency + * @param pathSeparator the path separator (e.g. '/') to use in building the path * @return the path to the dependency */ private String getArtifactPath( Dependency d, String pathSeparator ) @@ -439,7 +447,7 @@ log( "Downloading dependency: " + baseUrl + file ); - int numRetries = 3; + int numRetries = MAX_RETRIES; while ( numRetries >= 0 ) { @@ -545,6 +553,10 @@ project.addReference( reference, patternSet ); } + /** + * @param property the property to test + * @return true if the given property is not null and startsWith '${' + */ private boolean validProperty( String property ) { if ( property != null && property.length() > 0 && !property.startsWith( "${" ) )
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]