jvanzyl 2002/11/11 20:04:37
Modified: src/java/org/apache/maven CreateDependencyClasspath.java
MavenConstants.java MavenUtils.java
src/java/org/apache/maven/ant MavenTask.java
src/java/org/apache/maven/app App.java
LazyAttainGoalTag.java Maven.java
MavenJellyContext.java PluginManager.java
ProjectVerifier.java
src/java/org/apache/maven/jelly/tags/project MavenTag.java
Added: src/java/org/apache/maven/util Expand.java
Removed: src/java/org/apache/maven/app Expand.java
Log:
o Cleanup, use constants. Preparing for another pass.
Revision Changes Path
1.11 +5 -4
jakarta-turbine-maven/src/java/org/apache/maven/CreateDependencyClasspath.java
Index: CreateDependencyClasspath.java
===================================================================
RCS file:
/home/cvs/jakarta-turbine-maven/src/java/org/apache/maven/CreateDependencyClasspath.java,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- CreateDependencyClasspath.java 12 Nov 2002 03:23:55 -0000 1.10
+++ CreateDependencyClasspath.java 12 Nov 2002 04:04:36 -0000 1.11
@@ -161,11 +161,11 @@
setMavenProject((Project)
context.getVariable(MavenJellyContext.MAVEN_POM));
}
- Object b = context.getVariable("maven.jar.override");
+ Object b = context.getVariable(MavenConstants.JAR_OVERRIDE);
boolean mavenJarOverride = (b != null && b instanceof Boolean &&
((Boolean) b).booleanValue());
String mavenRepoLocal =
- (String) context.getVariable("maven.repo.local");
+ (String) context.getVariable(MavenConstants.REPO_LOCAL);
org.apache.tools.ant.Project antProject = (org.apache.tools.ant.Project)
context.getVariable(MavenJellyContext.MAVEN_ANT_PROJECT);
@@ -184,7 +184,8 @@
continue;
}
- String mavenJarProperty = (String) context.getVariable("maven.jar." +
d.getId());
+ String mavenJarProperty = (String)
+ context.getVariable(MavenConstants.JAR_OVERRIDE_PROPERTY +
d.getId());
Path path = new Path(antProject);
1.7 +35 -1
jakarta-turbine-maven/src/java/org/apache/maven/MavenConstants.java
Index: MavenConstants.java
===================================================================
RCS file:
/home/cvs/jakarta-turbine-maven/src/java/org/apache/maven/MavenConstants.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- MavenConstants.java 1 Jun 2002 20:59:42 -0000 1.6
+++ MavenConstants.java 12 Nov 2002 04:04:36 -0000 1.7
@@ -80,4 +80,38 @@
* the POM will be transformed into compliance.
*/
public static final int POM_VERSION = 3;
+
+ /** Maven home tag. */
+ public static final String HOME = "maven.home";
+
+ /** Online tag. */
+ public static final String ONLINE = "maven.mode.online";
+
+ /** Jar Override tag. */
+ public static final String JAR_OVERRIDE = "maven.jar.override";
+
+ /** Jar Override property tag. */
+ public static final String JAR_OVERRIDE_PROPERTY = "maven.jar.";
+
+ /** Local Repository tag. */
+ public static final String REPO_LOCAL = "maven.repo.local";
+
+ /** Local Repository tag. */
+ public static final String REPO_REMOTE = "maven.repo.remote";
+
+ /** Local Repository enabled tag. */
+ public static final String REPO_REMOTE_ENABLED = "maven.repo.remote.enabled";
+
+ /** Proxy host tag. */
+ public static final String PROXY_HOST = "maven.proxy.host";
+
+ /** Proxy port tag. */
+ public static final String PROXY_PORT = "maven.proxy.port";
+
+ /** Proxy user name tag. */
+ public static final String PROXY_USERNAME = "maven.proxy.username";
+
+ /** Proxy password tag. */
+ public static final String PROXY_PASSWORD = "maven.proxy.password";
+
}
1.55 +3 -2 jakarta-turbine-maven/src/java/org/apache/maven/MavenUtils.java
Index: MavenUtils.java
===================================================================
RCS file: /home/cvs/jakarta-turbine-maven/src/java/org/apache/maven/MavenUtils.java,v
retrieving revision 1.54
retrieving revision 1.55
diff -u -r1.54 -r1.55
--- MavenUtils.java 5 Nov 2002 15:37:37 -0000 1.54
+++ MavenUtils.java 12 Nov 2002 04:04:36 -0000 1.55
@@ -284,7 +284,8 @@
{
context = new JellyContext();
}
- context.setVariable("pom", project);
+
+ context.setVariable(MavenJellyContext.MAVEN_POM, project);
Script script = JellyUtils.compileScript(getProjectInputStream(project),
context,
1.4 +2 -1
jakarta-turbine-maven/src/java/org/apache/maven/ant/MavenTask.java
Index: MavenTask.java
===================================================================
RCS file:
/home/cvs/jakarta-turbine-maven/src/java/org/apache/maven/ant/MavenTask.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- MavenTask.java 12 Nov 2002 02:38:33 -0000 1.3
+++ MavenTask.java 12 Nov 2002 04:04:36 -0000 1.4
@@ -2,6 +2,7 @@
import com.werken.forehead.Forehead;
+import org.apache.maven.MavenConstants;
import org.apache.maven.app.App;
import org.apache.maven.app.Maven;
import org.apache.tools.ant.BuildException;
@@ -144,7 +145,7 @@
// I'm pretty sure this isn't the *best* way to get the job
// done but at the same time I'm pretty sure it *is* the
// quickest means to my desired end...
- System.setProperty("maven.home", this.getMavenHome());
+ System.setProperty(MavenConstants.HOME, this.getMavenHome());
System.setProperty("forehead.conf.file",
this.getMavenHome() + "/bin/forehead.conf");
System.setProperty("tools.jar", this.getToolsJar());
1.30 +6 -5 jakarta-turbine-maven/src/java/org/apache/maven/app/App.java
Index: App.java
===================================================================
RCS file: /home/cvs/jakarta-turbine-maven/src/java/org/apache/maven/app/App.java,v
retrieving revision 1.29
retrieving revision 1.30
diff -u -r1.29 -r1.30
--- App.java 12 Nov 2002 03:08:11 -0000 1.29
+++ App.java 12 Nov 2002 04:04:36 -0000 1.30
@@ -81,6 +81,7 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.apache.maven.MavenConstants;
import org.apache.maven.MavenUtils;
import org.apache.maven.project.Project;
@@ -309,18 +310,18 @@
private void checkOnline()
{
- if (getMaven().getProperty("maven.mode.online") != null)
+ if (getMaven().getProperty(MavenConstants.ONLINE) != null)
{
return;
}
if (getCli().hasOption("o"))
{
- getMaven().setVariable("maven.mode.online", Boolean.FALSE);
+ getMaven().setVariable(MavenConstants.ONLINE, Boolean.FALSE);
}
else
{
- getMaven().setVariable("maven.mode.online", Boolean.TRUE);
+ getMaven().setVariable(MavenConstants.ONLINE, Boolean.TRUE);
}
}
@@ -933,7 +934,7 @@
public static void main(String[] args)
{
Date start = new Date();
- File mavenHome = new File(System.getProperty("maven.home"));
+ File mavenHome = new File(System.getProperty(MavenConstants.HOME));
Maven maven = new Maven();
maven.setMavenHome(mavenHome);
App app = new App(maven);
1.4 +2 -2
jakarta-turbine-maven/src/java/org/apache/maven/app/LazyAttainGoalTag.java
Index: LazyAttainGoalTag.java
===================================================================
RCS file:
/home/cvs/jakarta-turbine-maven/src/java/org/apache/maven/app/LazyAttainGoalTag.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- LazyAttainGoalTag.java 30 Oct 2002 21:01:44 -0000 1.3
+++ LazyAttainGoalTag.java 12 Nov 2002 04:04:36 -0000 1.4
@@ -93,7 +93,7 @@
*/
public void doTag(final XMLOutput output) throws Exception
{
- Maven maven = (Maven) getContext().findVariable( "maven.obj" );
+ Maven maven = (Maven) getContext().findVariable(
MavenJellyContext.MAVEN_OBJECT );
PluginManager pluginManager = maven.getPluginManager();
1.128 +4 -2 jakarta-turbine-maven/src/java/org/apache/maven/app/Maven.java
Index: Maven.java
===================================================================
RCS file: /home/cvs/jakarta-turbine-maven/src/java/org/apache/maven/app/Maven.java,v
retrieving revision 1.127
retrieving revision 1.128
diff -u -r1.127 -r1.128
--- Maven.java 12 Nov 2002 03:08:11 -0000 1.127
+++ Maven.java 12 Nov 2002 04:04:36 -0000 1.128
@@ -742,11 +742,13 @@
{
projectVerifier = new ProjectVerifier();
projectVerifier.setContext(getJellyContext());
- Boolean online = (Boolean)getVariable("maven.mode.online");
+ Boolean online = (Boolean)getVariable(MavenConstants.ONLINE);
+
if (online != null && !online.booleanValue())
{
projectVerifier.setOnline(false);
}
+
return projectVerifier;
}
1.30 +2 -2
jakarta-turbine-maven/src/java/org/apache/maven/app/MavenJellyContext.java
Index: MavenJellyContext.java
===================================================================
RCS file:
/home/cvs/jakarta-turbine-maven/src/java/org/apache/maven/app/MavenJellyContext.java,v
retrieving revision 1.29
retrieving revision 1.30
diff -u -r1.29 -r1.30
--- MavenJellyContext.java 12 Nov 2002 00:41:05 -0000 1.29
+++ MavenJellyContext.java 12 Nov 2002 04:04:36 -0000 1.30
@@ -318,7 +318,7 @@
*/
Maven getMaven()
{
- return (Maven) findVariable( "maven.obj" );
+ return (Maven) findVariable( MAVEN_OBJECT );
}
/** Retrieve the plugin manager.
1.49 +8 -4
jakarta-turbine-maven/src/java/org/apache/maven/app/PluginManager.java
Index: PluginManager.java
===================================================================
RCS file:
/home/cvs/jakarta-turbine-maven/src/java/org/apache/maven/app/PluginManager.java,v
retrieving revision 1.48
retrieving revision 1.49
diff -u -r1.48 -r1.49
--- PluginManager.java 11 Nov 2002 02:42:10 -0000 1.48
+++ PluginManager.java 12 Nov 2002 04:04:36 -0000 1.49
@@ -89,10 +89,12 @@
import com.werken.werkz.Goal;
+import org.apache.maven.MavenConstants;
import org.apache.maven.MavenUtils;
import org.apache.maven.CreateDependencyClasspath;
import org.apache.maven.project.Dependency;
import org.apache.maven.project.Project;
+import org.apache.maven.util.Expand;
import org.apache.maven.util.JellyUtils;
// Tmp
@@ -410,7 +412,7 @@
MavenJellyContext context = getJellyContext();
com.werken.werkz.Project werkzProject
- = (com.werken.werkz.Project) context.getVariable(
"org.apache.commons.jelly.werkz.Project" );
+ = (com.werken.werkz.Project) context.getVariable(
MavenJellyContext.WERKZ_PROJECT );
Set originalGoals = new HashSet( werkzProject.getGoals() );
@@ -575,7 +577,7 @@
MavenJellyContext context = getJellyContext();
com.werken.werkz.Project werkzProject
- = (com.werken.werkz.Project) context.getVariable(
"org.apache.commons.jelly.werkz.Project" );
+ = (com.werken.werkz.Project) context.getVariable(
MavenJellyContext.WERKZ_PROJECT );
Set originalGoals = new HashSet( werkzProject.getGoals() );
@@ -963,8 +965,10 @@
{
Artifact artifact = DefaultArtifactFactory.createArtifact(
dependency);
+
String localRepo = (String) getJellyContext()
- .getVariable("maven.repo.local");
+ .getVariable(MavenConstants.REPO_LOCAL);
+
File jarFile = new File(localRepo,artifact.getPath());
if (log.isDebugEnabled())
1.13 +11 -10
jakarta-turbine-maven/src/java/org/apache/maven/app/ProjectVerifier.java
Index: ProjectVerifier.java
===================================================================
RCS file:
/home/cvs/jakarta-turbine-maven/src/java/org/apache/maven/app/ProjectVerifier.java,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -r1.12 -r1.13
--- ProjectVerifier.java 11 Nov 2002 02:42:10 -0000 1.12
+++ ProjectVerifier.java 12 Nov 2002 04:04:36 -0000 1.13
@@ -75,6 +75,7 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.apache.maven.MavenConstants;
import org.apache.maven.project.Project;
import org.apache.maven.project.Dependency;
import org.apache.maven.util.HttpUtils;
@@ -283,7 +284,7 @@
throws Exception
{
String localRepoProp = (String) getContext()
- .getVariable("maven.repo.local");
+ .getVariable(MavenConstants.REPO_LOCAL);
if (localRepoProp == null)
{
@@ -293,7 +294,7 @@
}
String remoteRepoProp = (String) getContext()
- .getVariable("maven.repo.remote");
+ .getVariable(MavenConstants.REPO_REMOTE);
if (remoteRepoProp == null)
{
@@ -335,19 +336,19 @@
// The project may have already been set by the plugin manager.
if (getMavenProject() == null)
{
- setMavenProject((Project) context.getVariable("pom"));
+ setMavenProject((Project)
context.getVariable(MavenJellyContext.MAVEN_POM));
}
- String proxyHost = (String) context.getVariable("maven.proxy.host");
+ String proxyHost = (String) context.getVariable(MavenConstants.PROXY_HOST);
if (proxyHost != null)
{
setProxyHost(proxyHost);
- setProxyPort((String) context.getVariable("maven.proxy.port"));
- setProxyUserName((String) context.getVariable("maven.proxy.username"));
- setProxyPassword((String) context.getVariable("maven.proxy.password"));
+ setProxyPort((String) context.getVariable(MavenConstants.PROXY_PORT));
+ setProxyUserName((String)
context.getVariable(MavenConstants.PROXY_USERNAME));
+ setProxyPassword((String)
context.getVariable(MavenConstants.PROXY_PASSWORD));
}
- Boolean online = (Boolean) context.getVariable("maven.mode.online");
+ Boolean online = (Boolean) context.getVariable(MavenConstants.ONLINE);
if (online != null && !online.booleanValue())
{
setOnline(false);
@@ -372,7 +373,7 @@
throws Exception
{
Boolean remoteRepoEnabled = (Boolean)
- context.getVariable("maven.repo.remote.enabled");
+ context.getVariable(MavenConstants.REPO_REMOTE_ENABLED);
if (remoteRepoEnabled != null && !remoteRepoEnabled.booleanValue())
{
1.9 +4 -2
jakarta-turbine-maven/src/java/org/apache/maven/jelly/tags/project/MavenTag.java
Index: MavenTag.java
===================================================================
RCS file:
/home/cvs/jakarta-turbine-maven/src/java/org/apache/maven/jelly/tags/project/MavenTag.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- MavenTag.java 11 Nov 2002 23:17:41 -0000 1.8
+++ MavenTag.java 12 Nov 2002 04:04:37 -0000 1.9
@@ -58,7 +58,9 @@
import java.io.File;
+import org.apache.maven.MavenUtils;
import org.apache.maven.app.Maven;
+import org.apache.maven.app.MavenJellyContext;
import org.apache.commons.jelly.MissingAttributeException;
import org.apache.commons.jelly.TagSupport;
@@ -105,7 +107,7 @@
throw new MissingAttributeException("descriptor");
}
- Maven parent = (Maven) getContext().getVariable("maven.obj");
+ Maven parent = (Maven)
getContext().getVariable(MavenJellyContext.MAVEN_OBJECT);
try
{
@@ -139,7 +141,7 @@
Maven maven = new Maven();
maven.setMavenHome(parent.getMavenHome());
maven.setDir(getBasedir());
- maven.setProjectFile(getDescriptor());
+ maven.setProject(MavenUtils.getProject(getDescriptor()));
maven.setXMLOutput(output, parent.isDebug());
if (this.goals != null)
1.1 jakarta-turbine-maven/src/java/org/apache/maven/util/Expand.java
Index: Expand.java
===================================================================
/*
* The Apache Software License, Version 1.1
*
* Copyright (c) 2000-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 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 [EMAIL PROTECTED]
*
* 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/>.
*/
//package org.apache.tools.ant.taskdefs;
package org.apache.maven.app;
import org.apache.tools.ant.util.FileUtils;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.FileNotFoundException;
import java.io.InputStream;
import java.io.IOException;
import java.util.Date;
import java.util.Vector;
import java.util.zip.ZipInputStream;
import java.util.zip.ZipEntry;
/**
* Unzip a file.
*
* @author [EMAIL PROTECTED]
* @author <a href="mailto:stefan.bodewig@;epost.de">Stefan Bodewig</a>
* @author <a href="mailto:umagesh@;apache.org">Magesh Umasankar</a>
* @since Ant 1.1
* @ant.task category="packaging" name="unzip" name="unjar" name="unwar"
*/
public class Expand
{
private File dest;//req
private File source;// req
private boolean overwrite = true;
/**
* Do the work.
*
* @exception BuildException Thrown in unrecoverable error.
*/
public void execute()
throws Exception
{
FileUtils fileUtils = FileUtils.newFileUtils();
expandFile(fileUtils, source, dest);
}
/*
* This method is to be overridden by extending unarchival tasks.
*/
/**
* Description of the Method
*/
protected void expandFile(FileUtils fileUtils, File srcF, File dir)
{
ZipInputStream zis = null;
try
{
// code from WarExpand
zis = new ZipInputStream(new FileInputStream(srcF));
ZipEntry ze = null;
while ((ze = zis.getNextEntry()) != null)
{
extractFile(fileUtils, srcF, dir, zis,
ze.getName(), new Date(ze.getTime()),
ze.isDirectory());
}
//log("expand complete", Project.MSG_VERBOSE);
}
catch (IOException ioe)
{
//throw new BuildException("Error while expanding " + srcF.getPath(),
// ioe);
}
finally
{
if (zis != null)
{
try
{
zis.close();
}
catch (IOException e)
{}
}
}
}
/**
* Description of the Method
*/
protected void extractFile(FileUtils fileUtils, File srcF, File dir,
InputStream compressedInputStream,
String entryName,
Date entryDate, boolean isDirectory)
throws IOException
{
File f = fileUtils.resolveFile(dir, entryName);
try
{
if (!overwrite && f.exists()
&& f.lastModified() >= entryDate.getTime())
{
//log("Skipping " + f + " as it is up-to-date",
// Project.MSG_DEBUG);
return;
}
//log("expanding " + entryName + " to " + f,
// Project.MSG_VERBOSE);
// create intermediary directories - sometimes zip don't add them
File dirF = f.getParentFile();
//File dirF = fileUtils.getParentFile(f);
dirF.mkdirs();
if (isDirectory)
{
f.mkdirs();
}
else
{
byte[] buffer = new byte[1024];
int length = 0;
FileOutputStream fos = null;
try
{
fos = new FileOutputStream(f);
while ((length =
compressedInputStream.read(buffer)) >= 0)
{
fos.write(buffer, 0, length);
}
fos.close();
fos = null;
}
finally
{
if (fos != null)
{
try
{
fos.close();
}
catch (IOException e)
{}
}
}
}
fileUtils.setFileLastModified(f, entryDate.getTime());
}
catch (FileNotFoundException ex)
{
}
}
/**
* Set the destination directory. File will be unzipped into the destination
* directory.
*
* @param d Path to the directory.
*/
public void setDest(File d)
{
this.dest = d;
}
/**
* Set the path to zip-file.
*
* @param s Path to zip-file.
*/
public void setSrc(File s)
{
this.source = s;
}
/**
* Should we overwrite files in dest, even if they are newer than the
* corresponding entries in the archive?
*/
public void setOverwrite(boolean b)
{
overwrite = b;
}
}
--
To unsubscribe, e-mail: <mailto:turbine-maven-dev-unsubscribe@;jakarta.apache.org>
For additional commands, e-mail: <mailto:turbine-maven-dev-help@;jakarta.apache.org>