You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@turbine.apache.org by jv...@apache.org on 2002/02/28 23:41:02 UTC
cvs commit: jakarta-turbine-maven/src/java/org/apache/maven/transformer Instructions.java Transformation.java
jvanzyl 02/02/28 14:41:02
Modified: src/java/org/apache/maven ChangeLog.java Reactor.java
src/java/org/apache/maven/transformer Instructions.java
Transformation.java
Added: src/java/org/apache/maven BaseProjectTask.java Jxr.java
MavenUtils.java ProjectProperties.java
UpdateResources.java
Log:
Adding executor beans, slowly moving away from the Ant coupling. Texen
is still a problem because I started with an Ant task for Maven instead
of using the bean pattern. But I will convert texen to a bean, I didn't
realize that Costin had the TaskAdapter cooked right into Ant to allow
beans to be used by Ant provided they contained a setProject() and execute()
method. Not sure why the setProject() is needed but it allows us to
have plain beans used by Ant which is what we want so that I can
use the beans in conjunction with a CLI util, or a GUI (more important for
the stuff I want to do).
Revision Changes Path
1.8 +55 -85 jakarta-turbine-maven/src/java/org/apache/maven/ChangeLog.java
Index: ChangeLog.java
===================================================================
RCS file: /home/cvs/jakarta-turbine-maven/src/java/org/apache/maven/ChangeLog.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- ChangeLog.java 26 Feb 2002 05:27:54 -0000 1.7
+++ ChangeLog.java 28 Feb 2002 22:41:02 -0000 1.8
@@ -1,8 +1,10 @@
package org.apache.maven;
-/*
+/* ====================================================================
+ * The Apache Software License, Version 1.1
*
- * Copyright (c) 1998 The Java Apache Project. All rights reserved.
+ * Copyright (c) 2002 The Apache Software Foundation. All rights
+ * reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -16,50 +18,53 @@
* the documentation and/or other materials provided with the
* distribution.
*
- * 3. Every modification must be notified to the Java Apache Project
- * and redistribution of the modified code without prior notification
- * is not permitted in any form.
- *
- * 4. All advertising materials mentioning features or use of this
- * software must display the following acknowledgment:
- * "This product includes software developed by the Java Apache Project
- * (http://java.apache.org/)."
- *
- * 5. The names "Alexandria", "Apache Alexandria" and "Apache Alexandria
- * Project" must not be used to endorse or promote products
- * derived from this software without prior written permission.
- *
- * 6. Redistributions of any form whatsoever must retain the following
- * acknowledgment:
- * "This product includes software developed by the Java Apache Project
- * (http://java.apache.org/)."
- *
- * THIS SOFTWARE IS PROVIDED BY THE JAVA APACHE PROJECT "AS IS" AND ANY
- * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE JAVA APACHE PROJECT OR
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache Maven" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache Maven", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
- * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
- * OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * License version 1.0
- *
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
*/
import java.io.*;
import java.util.*;
import java.text.*;
-import org.apache.tools.ant.*;
-import org.apache.tools.ant.taskdefs.*;
-import org.apache.tools.ant.types.*;
+import org.apache.tools.ant.types.Commandline;
+import org.apache.tools.ant.taskdefs.Execute;
+import org.apache.tools.ant.taskdefs.ExecuteStreamHandler;
import org.apache.stratum.xo.Mapper;
+
+import org.apache.maven.executor.ProjectExecutor;
import org.apache.maven.project.Project;
import org.apache.maven.project.Developer;
@@ -70,18 +75,13 @@
*
* @author <a href="mailto:jeff.martin@synamic.co.uk">Jeff Martin</a>
* @author <a href="mailto:jason@zenplex.com">Jason van Zyl</a>
- * @version $Id: ChangeLog.java,v 1.7 2002/02/26 05:27:54 jvanzyl Exp $
+ * @version $Id: ChangeLog.java,v 1.8 2002/02/28 22:41:02 jvanzyl Exp $
*/
public class ChangeLog
- extends Task
- implements ExecuteStreamHandler
+ extends ProjectExecutor
+ implements ExecuteStreamHandler
{
/**
- * Project descriptor.
- */
- private File projectDescriptor;
-
- /**
* Date range option to use with the 'cvs log' command. Only used
* when <code>days</code> is set.
*/
@@ -145,14 +145,6 @@
new SimpleDateFormat("hh:mm");
/**
- * Set the project descriptor file. This file must exist.
- */
- public void setProjectDescriptor (File projectDescriptor)
- {
- this.projectDescriptor = projectDescriptor;
- }
-
- /**
* Set the numbers of days worth of log entries to process.
*/
public void setDays(int days)
@@ -212,50 +204,30 @@
{
this.output = output;
}
-
+
/**
* Execute task
*/
- public void execute()
- throws BuildException
+ public void doExecute()
+ throws Exception
{
- if (projectDescriptor == null)
- {
- throw new BuildException("projectDescriptor must be set");
- }
-
-
if (base == null)
{
- throw new BuildException("basedir must be set");
+ throw new Exception("basedir must be set");
}
if (output == null)
{
- throw new BuildException("output must be set");
+ throw new Exception("output must be set");
}
if (!base.exists())
{
- throw new BuildException(
+ throw new Exception(
"Cannot find base dir " + base.getAbsolutePath());
}
- Project mavenProject = null;
-
- try
- {
- Mapper m = new Mapper();
- mavenProject = (Project) m.map(projectDescriptor,
- "org.apache.maven.project.Project");
-
- }
- catch (Exception e)
- {
- throw new BuildException(e);
- }
-
List developers = mavenProject.getDevelopers();
userList = new Properties();
@@ -275,21 +247,19 @@
{
toExecute.createArgument().setValue(dateRange);
}
-
+
Execute exe = new Execute(this);
exe.setCommandline(toExecute.getCommandline());
- exe.setAntRun(project);
+ exe.setAntRun(getProject());
exe.setWorkingDirectory(base);
try
{
exe.execute();
-
-
}
catch (IOException e)
{
- throw new BuildException(e);
+ throw new Exception(e.getMessage());
}
}
@@ -436,7 +406,7 @@
}
catch (ParseException e)
{
- log("I don't understand this date -> " + date);
+ //log("I don't understand this date -> " + date);
}
this.author = author;
this.comment = comment;
1.4 +88 -99 jakarta-turbine-maven/src/java/org/apache/maven/Reactor.java
Index: Reactor.java
===================================================================
RCS file: /home/cvs/jakarta-turbine-maven/src/java/org/apache/maven/Reactor.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- Reactor.java 24 Feb 2002 05:23:47 -0000 1.3
+++ Reactor.java 28 Feb 2002 22:41:02 -0000 1.4
@@ -53,6 +53,7 @@
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
+
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileOutputStream;
@@ -63,8 +64,6 @@
import java.util.List;
import java.util.ArrayList;
-import org.apache.tools.ant.Task;
-import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.DirectoryScanner;
import org.apache.maven.project.Project;
@@ -81,22 +80,22 @@
import org.apache.stratum.xo.Mapper;
import org.apache.commons.graph.Graphable;
import org.apache.commons.graph.util.DependencyResolver;
+import org.apache.maven.executor.AbstractExecutor;
/**
- * Task for controlling a multi-project build. The logic in
- * this task will probably be placed in another core file and
- * this task will be a wrapper around it. So that the build logic
- * can be used in many interfaces: ant, command line, servlet ...
+ * Task for controlling a multi-project build. The logic in this task will
+ * probably be placed in another core file and this task will be a wrapper
+ * around it. So that the build logic can be used in many interfaces: ant,
+ * command line, servlet ...
*
* @author <a href="mailto:jvanzyl@apache.org">Jason van Zyl</a>
- * @version $Id: Reactor.java,v 1.3 2002/02/24 05:23:47 jvanzyl Exp $
+ * @version $Id: Reactor.java,v 1.4 2002/02/28 22:41:02 jvanzyl Exp $
*/
public class Reactor
- extends Task
+ extends AbstractExecutor
{
/**
- * Workspace descriptor used to control a build session in
- * in Maven.
+ * Workspace descriptor used to control a build session in in Maven.
*/
private File workspace;
@@ -106,14 +105,12 @@
private Category category = Category.getInstance(getClass().getName());
/**
- * The directory where all the Maven descriptors are
- * stored.
+ * The directory where all the Maven descriptors are stored.
*/
private File descriptorDir;
/**
- * Set the workspace that will be used with this Maven
- * build.
+ * Set the workspace that will be used with this Maven build.
*
* @param workspace descriptor
*/
@@ -123,8 +120,7 @@
}
/**
- * Get the workspace descriptor being used with
- * this Maven build.
+ * Get the workspace descriptor being used with this Maven build.
*
* @return File workspace descriptor
*/
@@ -134,11 +130,10 @@
}
/**
- * Set the directory where all the Maven descriptors
- * are stored.
+ * Set the directory where all the Maven descriptors are stored.
*
- * @param descriptorDir The directory where all the Maven descriptors
- * are stored.
+ * @param descriptorDir The directory where all the Maven descriptors are
+ * stored.
*/
public void setDescriptorDir(File descriptorDir)
{
@@ -146,11 +141,9 @@
}
/**
- * Get the directory where all the Maven descriptors
- * are stored.
+ * Get the directory where all the Maven descriptors are stored.
*
- * @return The directory where all the Maven descriptors
- * are stored.
+ * @return The directory where all the Maven descriptors are stored.
*/
public File getDescriptorDir()
{
@@ -179,16 +172,22 @@
}
/**
- * Project to build. This can be an individual project or
- * the special project "all" where everything is built.
+ * Project to build. This can be an individual project or the special
+ * project "all" where everything is built.
*/
private String javaProject;
+ /**
+ * Sets the javaProject attribute of the Reactor object
+ */
public void setJavaProject(String javaProject)
{
this.javaProject = javaProject;
}
+ /**
+ * Gets the javaProject attribute of the Reactor object
+ */
public String getJavaProject()
{
return javaProject;
@@ -200,7 +199,7 @@
* @throws BuildException
*/
public void execute()
- throws BuildException
+ throws Exception
{
// Setup log4j with a standard properties file.
PropertyConfigurator.configure("log4j.properties");
@@ -208,105 +207,95 @@
category.debug("Workspace file: " + workspace);
- try
- {
- // Now the workspace only deals with projects stating
- // their direct dependencies so if we have a profile that
- // simply lists 'jakarta-turbine-3' that we need to determine
- // every project that 'jakarta-turbine-3' depends on directly
- // and indirectly.
- List profiles = mapProjectDescriptors();
- DependencyResolver dr = new DependencyResolver();
+ // Now the workspace only deals with projects stating
+ // their direct dependencies so if we have a profile that
+ // simply lists 'jakarta-turbine-3' that we need to determine
+ // every project that 'jakarta-turbine-3' depends on directly
+ // and indirectly.
+ List profiles = mapProjectDescriptors();
+ DependencyResolver dr = new DependencyResolver();
- if (javaProject.equals("all") == false)
- {
- dr.setTraverseAll(false);
- }
+ if (javaProject.equals("all") == false)
+ {
+ dr.setTraverseAll(false);
+ }
- for (Iterator i = profiles.iterator(); i.hasNext();)
- {
- Graphable g = (Graphable) i.next();
- dr.addGraphable(g, ((Project)g).getDependencies());
- }
-
- // We need special workspace for all the projects
- // for the typical gump build.
-
- // Everything starts with a workspace.
- Mapper m = new Mapper();
- m.setDebug(false);
- m.setInclusionRule("profile", "../profile");
- m.setInclusionRule("project", "../project");
- m.setInclusionRule("repository", "../repository");
-
- Workspace w = (Workspace) m.map(workspace.toString(),
- "org.apache.maven.project.Workspace");
-
- // We want to be able to differentiate
- Graphable gg = (Graphable) w.getProfile().getProjects().get(1);
- dr.printGraph("graph.xml", (Graphable)gg);
- List deps = dr.getSortedDependencies(gg.getName());
+ for (Iterator i = profiles.iterator(); i.hasNext(); )
+ {
+ Graphable g = (Graphable) i.next();
+ dr.addGraphable(g, ((Project) g).getDependencies());
+ }
- category.info("< " + gg.getName() + " >");
+ // We need special workspace for all the projects
+ // for the typical gump build.
- for (Iterator i = deps.iterator(); i.hasNext();)
- {
- category.info(i.next());
- }
+ // Everything starts with a workspace.
+ Mapper m = new Mapper();
+ m.setDebug(false);
+ m.setInclusionRule("profile", "../profile");
+ m.setInclusionRule("project", "../project");
+ m.setInclusionRule("repository", "../repository");
+
+ Workspace w = (Workspace) m.map(workspace.toString(),
+ "org.apache.maven.project.Workspace");
+
+ // We want to be able to differentiate
+ Graphable gg = (Graphable) w.getProfile().getProjects().get(1);
+ dr.printGraph("graph.xml", (Graphable) gg);
+ List deps = dr.getSortedDependencies(gg.getName());
- Velocity.init();
+ category.info("< " + gg.getName() + " >");
- VelocityContext context = new VelocityContext();
- context.put("workspace", w);
+ for (Iterator i = deps.iterator(); i.hasNext(); )
+ {
+ category.info(i.next());
+ }
- //!! Make the name of the build file configurable. Make
- // it an option in the workspace descriptor.
- FileOutputStream fos =
- new FileOutputStream(new File("work","build.xml"));
+ Velocity.init();
- Writer writer = new BufferedWriter(new OutputStreamWriter(fos));
+ VelocityContext context = new VelocityContext();
+ context.put("workspace", w);
- //!! Make this configurable.
- Velocity.mergeTemplate("src/templates/build.vm", context, writer);
- writer.flush();
- writer.close();
- }
- catch(Exception e)
- {
- e.printStackTrace();
- throw new BuildException("Cannot process workspace!", e);
- }
+ //!! Make the name of the build file configurable. Make
+ // it an option in the workspace descriptor.
+ FileOutputStream fos =
+ new FileOutputStream(new File("work", "build.xml"));
+
+ Writer writer = new BufferedWriter(new OutputStreamWriter(fos));
+
+ //!! Make this configurable.
+ Velocity.mergeTemplate("src/templates/build.vm", context, writer);
+ writer.flush();
+ writer.close();
}
/**
- * Make sure we have everything necessary for
- * the maven build.
+ * Make sure we have everything necessary for the maven build.
*/
private void checkPrerequisites()
+ throws Exception
{
// Make sure a workspace descriptor has been specified.
if (workspace == null)
{
- throw new BuildException(
- "workspace attribute must be set!");
+ throw new Exception("workspace attribute must be set!");
}
}
/**
- * Read in all the project descriptors and register each
- * of the projects within the module with the dependency
- * engine. Subsequently a list of projects to be built
- * can be passed to the dependency engine and it will
- * divine the order in which the projects need to be
- * built in order to satisfy dependency requirements.
+ * Read in all the project descriptors and register each of the projects
+ * within the module with the dependency engine. Subsequently a list of
+ * projects to be built can be passed to the dependency engine and it will
+ * divine the order in which the projects need to be built in order to
+ * satisfy dependency requirements.
*/
public List mapProjectDescriptors()
{
DirectoryScanner directoryScanner = new DirectoryScanner();
- File baseDir = new File(getDescriptorDir(),"project");
+ File baseDir = new File(getDescriptorDir(), "project");
directoryScanner.setBasedir(baseDir);
- String[] includes = { "**/*.xml" };
+ String[] includes = {"**/*.xml"};
directoryScanner.setIncludes(includes);
directoryScanner.scan();
String[] files = directoryScanner.getIncludedFiles();
@@ -320,7 +309,7 @@
{
try
{
- File project = new File(getDescriptorDir(),"project/" + files[i]);
+ File project = new File(getDescriptorDir(), "project/" + files[i]);
category.debug("Processing module -> " + project);
Project p = (Project) projectMapper.map(
project.toString(), "org.apache.maven.project.Project");
1.1 jakarta-turbine-maven/src/java/org/apache/maven/BaseProjectTask.java
Index: BaseProjectTask.java
===================================================================
package org.apache.maven;
/* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2002 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Apache" and "Apache Software Foundation" and
* "Apache Maven" must not be used to endorse or promote products
* derived from this software without prior written permission. For
* written permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* "Apache Maven", nor may "Apache" appear in their name, without
* prior written permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
import java.io.File;
import org.apache.tools.ant.BuildException;
import org.apache.maven.project.Project;
import org.apache.stratum.xo.Mapper;
import org.apache.velocity.context.Context;
import org.apache.velocity.VelocityContext;
import org.apache.velocity.texen.ant.TexenTask;
/**
* An ant task for creating an xml schema from an sql schema
*
* @author <a href="jason@zenplex.com">Jason van Zyl</a>
* @version $Id: BaseProjectTask.java,v 1.1 2002/02/28 22:41:02 jvanzyl Exp $
*/
public class BaseProjectTask
extends TexenTask
{
/**
* Project descriptor.
*/
protected File projectDescriptor;
/**
* Velocity context use in rendering the build system.
*/
protected Context context;
/**
* Project
*/
protected Project mavenProject;
/**
* Set the project descriptor file. This file must exist.
*/
public void setProjectDescriptor (File projectDescriptor)
{
this.projectDescriptor = projectDescriptor;
}
/**
* Execute the task.
*
* @throws BuildException
*/
public Context initControlContext()
throws Exception
{
context = new VelocityContext();
try
{
Mapper m = new Mapper();
mavenProject = (Project) m.map(projectDescriptor,
"org.apache.maven.project.Project");
context.put("project", mavenProject);
return context;
}
catch (Exception e)
{
// Propagate the error up the stack so that
// the stacktrace will appear in the standard
// ant output.
throw new BuildException(e);
}
}
}
1.1 jakarta-turbine-maven/src/java/org/apache/maven/Jxr.java
Index: Jxr.java
===================================================================
package org.apache.maven;
/* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2002 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Apache" and "Apache Software Foundation" and
* "Apache Maven" must not be used to endorse or promote products
* derived from this software without prior written permission. For
* written permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* "Apache Maven", nor may "Apache" appear in their name, without
* prior written permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
import org.apache.maven.jxr.*;
import org.apache.maven.jxr.pacman.PackageManager;
import org.apache.maven.executor.AbstractExecutor;
/**
* Creates an html-based, cross referenced version of Java source code
* for a project.
*
* @author <a href="mailto:lucas@collab.net">Josh Lucas</a>
* @author <a href="mailto:jason@zenplex.com">Jason van Zyl</a>
* @version $Id: Jxr.java,v 1.1 2002/02/28 22:41:02 jvanzyl Exp $
*/
public class Jxr
extends AbstractExecutor
{
/**
* the starting directory housing the .java files
*/
private String startDir;
/**
* the destination directory
*/
private String destDir;
/**
* the location of the folder.gif
*/
private String imageFolder;
/**
* the location of the file.gif
*/
private String imageFile;
/**
* Description of the Method
*/
public void execute()
throws Exception
{
PackageManager pkgmgr = PackageManager.getInstance();
pkgmgr.process(startDir);
// It is certainly not clear what's going on here. I believe we
// have some in-memory work going on and then the results of the
// work are placed in 'destDir' by the DirectoryIndexer.
new JXR(startDir, destDir, "HEAD");
new DirectoryIndexer(destDir, imageFolder, imageFile, DirectoryIndexer.MODE_JAVA);
}
/**
* Sets the imageFile attribute of the JxrTask object
*/
public void setImageFile(String imageFile)
{
this.imageFile = imageFile;
}
/**
* Sets the imageFolder attribute of the JxrTask object
*/
public void setImageFolder(String imageFolder)
{
this.imageFolder = imageFolder;
}
/**
* Sets the startDir attribute of the JxrTask object
*/
public void setStartDir(String startDir)
{
this.startDir = startDir;
}
/**
* Sets the destDir attribute of the JxrTask object
*/
public void setDestDir(String destDir)
{
this.destDir = destDir;
}
}
1.1 jakarta-turbine-maven/src/java/org/apache/maven/MavenUtils.java
Index: MavenUtils.java
===================================================================
package org.apache.maven;
/* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2002 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Apache" and "Apache Software Foundation" and
* "Apache Maven" must not be used to endorse or promote products
* derived from this software without prior written permission. For
* written permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* "Apache Maven", nor may "Apache" appear in their name, without
* prior written permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
import java.io.File;
import org.apache.maven.project.Project;
import org.apache.stratum.xo.Mapper;
/**
* An ant task that takes values from the project descriptor and
* creates the necessary patternsets and paths required to build
* the project.
*
* @author <a href="jason@zenplex.com">Jason van Zyl</a>
* @version $Id: MavenUtils.java,v 1.1 2002/02/28 22:41:02 jvanzyl Exp $
*/
public class MavenUtils
{
/**
* Maven project class name.
*/
private final static String PROJECT_CLASS = "org.apache.maven.project.Project";
/**
* Create a Project object given a file descriptor.
*
* @throws Exception
*/
public static Project getProject(File projectDescriptor)
throws Exception
{
Mapper mapper = new Mapper();
Project project = (Project) mapper.map(projectDescriptor,PROJECT_CLASS);
return project;
}
}
1.1 jakarta-turbine-maven/src/java/org/apache/maven/ProjectProperties.java
Index: ProjectProperties.java
===================================================================
package org.apache.maven;
/* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2002 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Apache" and "Apache Software Foundation" and
* "Apache Maven" must not be used to endorse or promote products
* derived from this software without prior written permission. For
* written permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* "Apache Maven", nor may "Apache" appear in their name, without
* prior written permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
import java.io.File;
import java.util.Iterator;
import org.apache.tools.ant.types.PatternSet;
import org.apache.tools.ant.types.Path;
import org.apache.tools.ant.Task;
import org.apache.tools.ant.BuildException;
import org.apache.commons.util.StringUtils;
import org.apache.maven.executor.ProjectExecutor;
import org.apache.maven.project.Dependency;
import org.apache.maven.project.Project;
import org.apache.stratum.xo.Mapper;
import org.apache.velocity.context.Context;
/**
* An ant task that takes values from the project descriptor and
* creates the necessary patternsets and paths required to build
* the project.
*
* @author <a href="jason@zenplex.com">Jason van Zyl</a>
* @version $Id: ProjectProperties.java,v 1.1 2002/02/28 22:41:02 jvanzyl Exp $
*/
public class ProjectProperties
extends ProjectExecutor
{
/**
* Execute the task.
*
* @throws BuildException
*/
public void doExecute()
throws Exception
{
log("Creating classpath reference ...");
createClasspathReference();
log("Creating source set reference ...");
createSourceSetReference();
log("Creating test source set reference ...");
createTestSourceSetReference();
log("Creating unit test class entries reference ...");
createUnitTestClassEntriesReference();
}
// Create the classpath reference
private void createClasspathReference()
{
Path classpath = new Path(getProject());
String libRepo = getProject().getProperty("lib.repo");
for (Iterator i = mavenProject.getDependencies().iterator(); i.hasNext();)
{
Dependency dependency = (Dependency) i.next();
log(dependency.toString());
Path p = new Path(getProject());
p.setPath(new File(libRepo, dependency.getJar()).getAbsolutePath());
classpath.append(p);
}
getProject().addReference("classpath", classpath);
}
// Create the source directories reference
private void createSourceSetReference()
{
Path srcSet = new Path(getProject());
String libRepo = getProject().getProperty("lib.repo");
for (Iterator i =
mavenProject.getBuild().getSourceDirectories().iterator(); i.hasNext();)
{
String sourceDirectory = (String) i.next();
log(sourceDirectory);
Path p = new Path(getProject());
p.setPath(new File(sourceDirectory).getAbsolutePath());
srcSet.append(p);
}
getProject().addReference("src.set", srcSet);
}
// Create the source directories reference
private void createTestSourceSetReference()
{
Path srcSet = new Path(getProject());
String libRepo = getProject().getProperty("lib.repo");
for (Iterator i =
mavenProject.getBuild().getTestSourceDirectories().iterator(); i.hasNext();)
{
String sourceDirectory = (String) i.next();
log(sourceDirectory);
Path p = new Path(getProject());
p.setPath(new File(sourceDirectory).getAbsolutePath());
srcSet.append(p);
}
getProject().addReference("test.src.set", srcSet);
}
// Create the source directories reference
private void createUnitTestClassEntriesReference()
{
String libRepo = getProject().getProperty("lib.repo");
StringBuffer includesSb = new StringBuffer();
StringBuffer excludesSb = new StringBuffer();
PatternSet patternSet = new PatternSet();
for (Iterator i =
mavenProject.getBuild().getUnitTestClassEntries().iterator(); i.hasNext();)
{
String line = (String) i.next();
line = line.trim();
if (line.startsWith("include"))
{
// We have something like the following pattern:
// include = conf/foo.xml
includesSb.append(StringUtils.split(line,"=",-1)[1]).append(",");
}
if (line.startsWith("exclude"))
{
// We have something like the following pattern:
// exclude = conf/foo.xml
excludesSb.append(StringUtils.split(line,"=",-1)[1]).append(",");
}
// We have a jar descriptor file
includesSb.append(line).append(",");
}
String includes = includesSb.toString();
String excludes = excludesSb.toString();
if (includes.length() > 0)
{
// Remove trailing comma
includes = includes.substring(0,includes.length()-1);
patternSet.setIncludes(includes);
log("includes: " + includes);
}
if (excludes.length() > 0)
{
// Remove trailing comma
excludes = excludes.substring(0,excludes.length()-1);
patternSet.setExcludes(excludes);
log("excludes: " + excludes);
}
getProject().addReference("unit.test.set", patternSet);
}
}
1.1 jakarta-turbine-maven/src/java/org/apache/maven/UpdateResources.java
Index: UpdateResources.java
===================================================================
package org.apache.maven;
/*
* The Apache Software License, Version 1.1
*
* Copyright (c) 2000-2001 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution, if
* any, must include the following acknowlegement:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowlegement may appear in the software itself,
* if and wherever such third-party acknowlegements normally appear.
*
* 4. The names "The Jakarta Project", "Ant", and "Apache Software
* Foundation" must not be used to endorse or promote products derived
* from this software without prior written permission. For written
* permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache"
* nor may "Apache" appear in their names without prior written
* permission of the Apache Group.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
import java.io.File;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.io.IOException;
import java.net.URL;
import java.net.URLConnection;
import java.net.HttpURLConnection;
import java.util.Date;
import java.util.List;
import java.util.ArrayList;
import java.util.Iterator;
import java.io.BufferedReader;
import java.io.FileReader;
import org.apache.maven.project.Dependency;
import org.apache.maven.executor.ProjectExecutor;
/**
* Get a particular file from a URL source. Options include verbose reporting,
* timestamp based fetches and controlling actions on failures. NB: access
* through a firewall only works if the whole Java runtime is correctly
* configured.
*
* @author costin@dnt.ro
* @author gg@grtmail.com (Added Java 1.1 style HTTP basic auth)
* @author <a href="mailto:jason@zenplex.com">Jason van Zyl</a>
* @todo Decouple from Ant: Touch and Ant project references.
*/
public class UpdateResources
extends ProjectExecutor
{
private URL source;// required
private File dest;// required
private boolean verbose = false;
private boolean useTimestamp = true;//on by default
private boolean ignoreErrors = false;
private String uname = null;
private String pword = null;
private String baseUrl;
private StringBuffer warnings = new StringBuffer();
/**
* Sets the baseUrl attribute of the Get object
*/
public void setBaseUrl(String baseUrl)
{
this.baseUrl = baseUrl;
}
/**
* Sets the proxyHost attribute of the Get object
*/
public void setProxyHost(String proxyHost)
{
System.getProperties().put("proxySet", "true");
System.getProperties().put("proxyHost", proxyHost);
}
/**
* Sets the proxyPort attribute of the Get object
*/
public void setProxyPort(String proxyPort)
{
System.getProperties().put("proxyPort", proxyPort);
}
/**
* Does the work.
*
* @exception Exception Thrown in unrecoverable error.
*/
public void doExecute()
throws Exception
{
if (baseUrl == null)
{
throw new Exception("baseUrl attribute is required");
}
if (dest == null)
{
throw new Exception("dest attribute is required");
}
if (dest.exists() && !dest.canWrite())
{
throw new Exception("Can't write to " + dest.getAbsolutePath());
}
for (Iterator j = mavenProject.getDependencies().iterator(); j.hasNext(); )
{
String file = ((Dependency) j.next()).getJar();
File destinationFile = new File(dest, file);
try
{
URL source = new URL(baseUrl + file);
log("Getting: " + source);
//set the timestamp to the file date.
long timestamp = 0;
boolean hasTimestamp = false;
if (useTimestamp && destinationFile.exists())
{
timestamp = destinationFile.lastModified();
if (verbose)
{
Date t = new Date(timestamp);
log("local file date : " + t.toString());
}
hasTimestamp = true;
}
//set up the URL connection
URLConnection connection = source.openConnection();
//modify the headers
//NB: things like user authentication could go in here too.
if (useTimestamp && hasTimestamp)
{
connection.setIfModifiedSince(timestamp);
}
// prepare Java 1.1 style credentials
if (uname != null || pword != null)
{
String up = uname + ":" + pword;
String encoding;
// check to see if sun's Base64 encoder is available.
try
{
sun.misc.BASE64Encoder encoder =
(sun.misc.BASE64Encoder) Class.forName(
"sun.misc.BASE64Encoder").newInstance();
encoding = encoder.encode(up.getBytes());
}
catch (Exception ex)
{// sun's base64 encoder isn't available
Base64Converter encoder = new Base64Converter();
encoding = encoder.encode(up.getBytes());
}
connection.setRequestProperty("Authorization", "Basic " + encoding);
}
//connect to the remote site (may take some time)
connection.connect();
//next test for a 304 result (HTTP only)
if (connection instanceof HttpURLConnection)
{
HttpURLConnection httpConnection = (HttpURLConnection) connection;
if (httpConnection.getResponseCode() == HttpURLConnection.HTTP_NOT_MODIFIED)
{
//not modified so no file download. just return instead
//and trace out something so the user doesn't think that the
//download happened when it didnt
log("Not modified - so not downloaded");
continue;
}
// test for 401 result (HTTP only)
if (httpConnection.getResponseCode() == HttpURLConnection.HTTP_UNAUTHORIZED)
{
log("Not authorized - check " + destinationFile + " for details");
continue;
}
}
//REVISIT: at this point even non HTTP connections may support the if-modified-since
//behaviour -we just check the date of the content and skip the write if it is not
//newer. Some protocols (FTP) dont include dates, of course.
FileOutputStream fos = new FileOutputStream(destinationFile);
log("Writing " + destinationFile);
InputStream is = null;
for (int i = 0; i < 3; i++)
{
try
{
is = connection.getInputStream();
break;
}
catch (IOException ex)
{
log("Error opening connection " + ex);
}
}
if (is == null)
{
log("Can't get " + source + " to " + destinationFile);
if (ignoreErrors)
{
return;
}
throw new Exception(
"Can't get " + source + " to " + destinationFile);
}
byte[] buffer = new byte[100 * 1024];
int length;
while ((length = is.read(buffer)) >= 0)
{
fos.write(buffer, 0, length);
if (verbose)
{
System.out.print(".");
}
}
if (verbose)
{
System.out.println();
}
fos.close();
is.close();
//if (and only if) the use file time option is set, then the
//saved file now has its timestamp set to that of the downloaded file
if (useTimestamp)
{
long remoteTimestamp = connection.getLastModified();
if (verbose)
{
Date t = new Date(remoteTimestamp);
log("last modified = " + t.toString() +
((remoteTimestamp == 0) ? " - using current time instead" : ""));
}
if (remoteTimestamp != 0)
{
touchFile(destinationFile, remoteTimestamp);
}
}
}
catch (IOException ioe)
{
log("Error getting " + source + " to " + destinationFile);
if (ignoreErrors)
{
return;
}
throw new Exception(ioe.getMessage());
}
catch (Exception e)
{
e.printStackTrace();
}
}
if (warnings.length() > 1)
{
log("\n" + warnings.toString());
}
}
/**
* set the timestamp of a named file to a specified time.
*
* @param file
* @param timemillis in milliseconds since the start of the era
* @return true if it succeeded. False means that this is a java1.1 system
* and that file times can not be set
* @exception Exception Thrown in unrecoverable error. Likely this
* comes from file access failures.
*/
protected boolean touchFile(File file, long timemillis)
throws Exception
{
long modifiedTime;
if (timemillis < 0)
{
modifiedTime = System.currentTimeMillis();
}
else
{
modifiedTime = timemillis;
}
file.setLastModified(modifiedTime);
return true;
}
/**
* Set the URL.
*
* @param u URL for the file.
*/
public void setSrc(URL u)
{
this.source = u;
}
/**
* Where to copy the source file.
*
* @param dest Path to file.
*/
public void setDest(File dest)
{
this.dest = dest;
}
/**
* Be verbose, if set to "<CODE>true</CODE>".
*
* @param v if "true" then be verbose
*/
public void setVerbose(boolean v)
{
verbose = v;
}
/**
* Don't stop if get fails if set to "<CODE>true</CODE>".
*
* @param v if "true" then don't report download errors up to ant
*/
public void setIgnoreErrors(boolean v)
{
ignoreErrors = v;
}
/**
* Use timestamps, if set to "<CODE>true</CODE>". <p>
*
* In this situation, the if-modified-since header is set so that the file
* is only fetched if it is newer than the local file (or there is no local
* file) This flag is only valid on HTTP connections, it is ignored in other
* cases. When the flag is set, the local copy of the downloaded file will
* also have its timestamp set to the remote file time. <br>
* Note that remote files of date 1/1/1970 (GMT) are treated as 'no
* timestamp', and web servers often serve files with a timestamp in the
* future by replacing their timestamp with that of the current time. Also,
* inter-computer clock differences can cause no end of grief.
*
* @param v "true" to enable file time fetching
*/
public void setUseTimestamp(boolean v)
{
useTimestamp = v;
}
/**
* Username for basic auth.
*
* @param u username for authentication
*/
public void setUsername(String u)
{
this.uname = u;
}
/**
* password for the basic auth.
*
* @param p password for authentication
*/
public void setPassword(String p)
{
this.pword = p;
}
/**
* BASE 64 encoding of a String or an array of bytes. Based on RFC 1421.
*
* @author Unknown
* @author <a HREF="gg@grtmail.com">Gautam Guliani</a>
*/
class Base64Converter
{
/**
* Description of the Field
*/
public final char[] alphabet = {
'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', // 0 to 7
'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', // 8 to 15
'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', // 16 to 23
'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f', // 24 to 31
'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', // 32 to 39
'o', 'p', 'q', 'r', 's', 't', 'u', 'v', // 40 to 47
'w', 'x', 'y', 'z', '0', '1', '2', '3', // 48 to 55
'4', '5', '6', '7', '8', '9', '+', '/'};// 56 to 63
/**
* Description of the Method
*/
public String encode(String s)
{
return encode(s.getBytes());
}
/**
* Description of the Method
*/
public String encode(byte[] octetString)
{
int bits24;
int bits6;
char[] out
= new char[((octetString.length - 1) / 3 + 1) * 4];
int outIndex = 0;
int i = 0;
while ((i + 3) <= octetString.length)
{
// store the octets
bits24 = (octetString[i++] & 0xFF) << 16;
bits24 |= (octetString[i++] & 0xFF) << 8;
bits6 = (bits24 & 0x00FC0000) >> 18;
out[outIndex++] = alphabet[bits6];
bits6 = (bits24 & 0x0003F000) >> 12;
out[outIndex++] = alphabet[bits6];
bits6 = (bits24 & 0x00000FC0) >> 6;
out[outIndex++] = alphabet[bits6];
bits6 = (bits24 & 0x0000003F);
out[outIndex++] = alphabet[bits6];
}
if (octetString.length - i == 2)
{
// store the octets
bits24 = (octetString[i] & 0xFF) << 16;
bits24 |= (octetString[i + 1] & 0xFF) << 8;
bits6 = (bits24 & 0x00FC0000) >> 18;
out[outIndex++] = alphabet[bits6];
bits6 = (bits24 & 0x0003F000) >> 12;
out[outIndex++] = alphabet[bits6];
bits6 = (bits24 & 0x00000FC0) >> 6;
out[outIndex++] = alphabet[bits6];
// padding
out[outIndex++] = '=';
}
else if (octetString.length - i == 1)
{
// store the octets
bits24 = (octetString[i] & 0xFF) << 16;
bits6 = (bits24 & 0x00FC0000) >> 18;
out[outIndex++] = alphabet[bits6];
bits6 = (bits24 & 0x0003F000) >> 12;
out[outIndex++] = alphabet[bits6];
// padding
out[outIndex++] = '=';
out[outIndex++] = '=';
}
return new String(out);
}
}
}
1.3 +1 -0 jakarta-turbine-maven/src/java/org/apache/maven/transformer/Instructions.java
Index: Instructions.java
===================================================================
RCS file: /home/cvs/jakarta-turbine-maven/src/java/org/apache/maven/transformer/Instructions.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- Instructions.java 21 Feb 2002 14:09:43 -0000 1.2
+++ Instructions.java 28 Feb 2002 22:41:02 -0000 1.3
@@ -1,4 +1,5 @@
package org.apache.maven.transformer;
+
/* ====================================================================
* The Apache Software License, Version 1.1
*
1.3 +1 -0 jakarta-turbine-maven/src/java/org/apache/maven/transformer/Transformation.java
Index: Transformation.java
===================================================================
RCS file: /home/cvs/jakarta-turbine-maven/src/java/org/apache/maven/transformer/Transformation.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- Transformation.java 21 Feb 2002 14:09:43 -0000 1.2
+++ Transformation.java 28 Feb 2002 22:41:02 -0000 1.3
@@ -1,4 +1,5 @@
package org.apache.maven.transformer;
+
/* ====================================================================
* The Apache Software License, Version 1.1
*
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>