jvanzyl 2003/12/26 20:36:32
Modified: maven-project/src/java/org/apache/maven/project Project.java
Log:
o we'll stick to the File, moving to URL prematurely. All I really care about
at this point is integrating the components ...
Revision Changes Path
1.16 +102 -14
maven-components/maven-project/src/java/org/apache/maven/project/Project.java
Index: Project.java
===================================================================
RCS file:
/home/cvs/maven-components/maven-project/src/java/org/apache/maven/project/Project.java,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -r1.15 -r1.16
--- Project.java 10 Dec 2003 05:37:36 -0000 1.15
+++ Project.java 27 Dec 2003 04:36:32 -0000 1.16
@@ -14,11 +14,10 @@
import org.codehaus.plexus.util.StringUtils;
import java.io.File;
+import java.util.ArrayList;
+import java.util.HashMap;
import java.util.List;
import java.util.Map;
-import java.util.HashMap;
-import java.util.ArrayList;
-import java.net.URL;
/**
* The concern of the project is provide runtime values based on the model.
@@ -50,7 +49,7 @@
private Project parent;
/** Source of the model. */
- private URL modelSource;
+ private File file;
/** Artifacts generated from dependencies. */
private List artifacts;
@@ -101,18 +100,18 @@
*
* @return
*/
- public URL getModelSource()
+ public File getFile()
{
- return modelSource;
+ return file;
}
/**
*
- * @param modelSource
+ * @param file
*/
- public void setModelSource( URL modelSource )
+ public void setFile( File file )
{
- this.modelSource = modelSource;
+ this.file = file;
}
/**
@@ -120,10 +119,7 @@
*/
public File getBasedir()
{
- // if the url is a file then we can return this.
-
- return null;
- //return getModel().getFile().getParentFile();
+ return getFile().getParentFile();
}
// ----------------------------------------------------------------------
@@ -563,6 +559,98 @@
}
return property;
+ }
+
+ // ----------------------------------------------------------------------
+ // L E G A C Y I D S U P P O R T
+ // ----------------------------------------------------------------------
+
+ /**
+ * This is to support methods that are using the legacy form of
+ * the project id. Currently the id is <groupId>:<artifactId> but the
+ * following methods assume <groupId>:
+ *
+ * Project::getDependencyPath( <groupId> )
+ * Project::getDependency( <groupId> )
+ *
+ * We don't want users to have to alter any usage until we have properly
+ * deprecated the use of the <groupId> form.
+ *
+ * @param id
+ * @return
+ */
+ public static String legacyToStandardId( String id )
+ {
+ String newId = id;
+
+ if ( id.indexOf( "+" ) != -1 )
+ {
+ // legacy format is groupId "+" partial artifactId
+ // standard format is groupId ":" groupId "-" partialArtifactId
+ int plusPos = id.indexOf( "+" );
+
+ String groupId = id.substring( 0, plusPos );
+
+ String partialArtifactId = id.substring( plusPos + 1 );
+
+ newId = groupId + ":" + groupId + "-" + partialArtifactId;
+ }
+ else if ( id.indexOf( ":" ) == -1 )
+ {
+ newId += ":" + id;
+ }
+
+ return newId;
+ }
+
+ /**
+ * This method is to support methods are expecting legacy ids. The following
+ * methods expect legacy ids.
+ *
+ * MavenJellyContext::getMavenJarOverride( <groupId> )
+ * Project::addPluginContext( <groupId>, pluginContext )
+ * Project::getArtifactDirectory( <groupId> )
+ *
+ * We don't want users to have to alter any usage until we have properly
+ * deprecated the use of the <groupId> form.
+ *
+ * @param id
+ * @return
+ */
+ public static String standardToLegacyId( String id )
+ {
+ int i = id.indexOf( ":" );
+
+ if ( i > 0 )
+ {
+ id = id.substring( i + 1 );
+ }
+
+ return id;
+ }
+
+ /**
+ * Convert a <code>String</code> property to a
+ * <code>Boolean</code> based on its contents. It would be nice
+ * if Jelly would deal with this automatically.
+ *
+ * @param key The property key to lookup and convert.
+ *
+ * @return The boolean value of the property if convertiable,
+ * otherwise <code>Boolean.FALSE</code>.
+ */
+ public boolean getBooleanProperty( String key )
+ {
+ String value = getProperty( key );
+
+ if ( "true".equalsIgnoreCase( value )
+ || "on".equalsIgnoreCase( value )
+ || "1".equals( value ) )
+ {
+ return true;
+ }
+
+ return false;
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]