You are viewing a plain text version of this content. The canonical link for it is here.
Posted to m2-dev@maven.apache.org by br...@apache.org on 2005/03/07 21:54:35 UTC
cvs commit: maven-components/maven-plugins/maven-compiler-plugin/src/main/java/org/apache/maven/plugin CompilerMojo.java TestCompilerMojo.java
brett 2005/03/07 12:54:35
Modified: maven-core/src/main/java/org/apache/maven/project
DefaultMavenProjectBuilder.java MavenProject.java
maven-model maven.mdo
maven-artifact/src/main/java/org/apache/maven/artifact
Artifact.java DefaultArtifact.java
maven-plugins/maven-compiler-plugin/src/main/java/org/apache/maven/plugin
CompilerMojo.java TestCompilerMojo.java
Log:
refactor source roots to be lists
Revision Changes Path
1.35 +3 -0 maven-components/maven-core/src/main/java/org/apache/maven/project/DefaultMavenProjectBuilder.java
Index: DefaultMavenProjectBuilder.java
===================================================================
RCS file: /home/cvs/maven-components/maven-core/src/main/java/org/apache/maven/project/DefaultMavenProjectBuilder.java,v
retrieving revision 1.34
retrieving revision 1.35
diff -u -r1.34 -r1.35
--- DefaultMavenProjectBuilder.java 1 Mar 2005 07:05:33 -0000 1.34
+++ DefaultMavenProjectBuilder.java 7 Mar 2005 20:54:34 -0000 1.35
@@ -164,6 +164,9 @@
pathTranslator.alignToBaseDirectory( project.getModel(), projectDescriptor );
+ project.addCompileSourceRoot( project.getBuild().getSourceDirectory() );
+ project.addTestCompileSourceRoot( project.getBuild().getUnitTestSourceDirectory() );
+
return project;
}
catch ( Exception e )
1.22 +23 -64 maven-components/maven-core/src/main/java/org/apache/maven/project/MavenProject.java
Index: MavenProject.java
===================================================================
RCS file: /home/cvs/maven-components/maven-core/src/main/java/org/apache/maven/project/MavenProject.java,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -r1.21 -r1.22
--- MavenProject.java 7 Mar 2005 19:03:19 -0000 1.21
+++ MavenProject.java 7 Mar 2005 20:54:34 -0000 1.22
@@ -30,7 +30,6 @@
import org.apache.maven.model.Model;
import org.apache.maven.model.Organization;
import org.apache.maven.model.Scm;
-import org.codehaus.plexus.util.StringUtils;
import java.io.File;
import java.util.ArrayList;
@@ -125,88 +124,48 @@
// Test and compile sourceroots.
// ----------------------------------------------------------------------
- //!!! Refactor, collect the list of compile source roots and create a
- // path1:path2
- // type construct from the list instead of the other way around. jvz.
+ private List compileSourceRoots = new ArrayList();
- private String compileSourceRoots = "";
-
- private String testCompileSourceRoots = "";
+ private List testCompileSourceRoots = new ArrayList();
public void addCompileSourceRoot( String path )
{
- if ( path != null || path.trim().length() != 0 )
+ if ( path != null )
{
- if ( compileSourceRoots.length() > 0 )
+ path = path.trim();
+ if ( path.length() != 0 )
{
- compileSourceRoots += File.pathSeparator;
+ if ( !compileSourceRoots.contains( path ) )
+ {
+ compileSourceRoots.add( path );
+ }
}
- compileSourceRoots += path;
}
}
- public String getCompileSourceRoots()
- {
- // Get rid of any trailing path separators.
- if ( compileSourceRoots.endsWith( File.pathSeparator ) )
- {
- compileSourceRoots = compileSourceRoots.substring( 0, compileSourceRoots.length() - 1 );
- }
-
- // Always add the build.sourceDirectory
- return getBuild().getSourceDirectory() + File.pathSeparator + compileSourceRoots;
- }
-
- public List getCompileSourceRootsList()
- {
- String[] s = StringUtils.split( getCompileSourceRoots(), File.pathSeparator );
-
- List list = new ArrayList();
-
- for ( int i = 0; i < s.length; i++ )
- {
- list.add( s[i] );
- }
-
- return list;
- }
-
public void addTestCompileSourceRoot( String path )
{
- if ( path != null || path.trim().length() != 0 )
+ if ( path != null )
{
- if ( testCompileSourceRoots.length() > 0 )
+ path = path.trim();
+ if ( path.length() != 0 )
{
- testCompileSourceRoots += File.pathSeparator;
+ if ( !testCompileSourceRoots.contains( path ) )
+ {
+ testCompileSourceRoots.add( path );
+ }
}
- testCompileSourceRoots += path;
}
}
- public String getTestCompileSourceRoots()
+ public List getCompileSourceRoots()
{
- // Get rid of any trailing path separators.
- if ( testCompileSourceRoots.endsWith( File.pathSeparator ) )
- {
- testCompileSourceRoots = testCompileSourceRoots.substring( 0, testCompileSourceRoots.length() - 1 );
- }
-
- // Always add the build.unitTestSourceDirectory
- return getBuild().getUnitTestSourceDirectory() + File.pathSeparator + testCompileSourceRoots;
+ return compileSourceRoots;
}
- public List getTestCompileSourceRootsList()
+ public List getTestCompileSourceRoots()
{
- String[] s = StringUtils.split( getTestCompileSourceRoots(), File.pathSeparator );
-
- List list = new ArrayList();
-
- for ( int i = 0; i < s.length; i++ )
- {
- list.add( s[i] );
- }
-
- return list;
+ return testCompileSourceRoots;
}
public List getCompileClasspathElements()
@@ -218,7 +177,7 @@
Artifact a = (Artifact) i.next();
// TODO: let the scope handler deal with this
- if ( a.getScope() == null || "compile".equals( a.getScope() ) )
+ if ( a.getScope() == null || Artifact.SCOPE_COMPILE.equals( a.getScope() ) )
{
list.add( a.getPath() );
}
@@ -239,8 +198,8 @@
if ( isAddedToClasspath( a ) )
{
// TODO: let the scope handler deal with this
- if ( a.getScope() == null || "test".equals( a.getScope() ) || "compile".equals( a.getScope() )
- || "runtime".equals( a.getScope() ) )
+ if ( a.getScope() == null || Artifact.SCOPE_TEST.equals( a.getScope() ) || Artifact.SCOPE_COMPILE.equals( a.getScope() )
+ || Artifact.SCOPE_RUNTIME.equals( a.getScope() ) )
{
list.add( a.getPath() );
}
1.80 +1 -0 maven-components/maven-model/maven.mdo
Index: maven.mdo
===================================================================
RCS file: /home/cvs/maven-components/maven-model/maven.mdo,v
retrieving revision 1.79
retrieving revision 1.80
diff -u -r1.79 -r1.80
--- maven.mdo 7 Mar 2005 19:03:19 -0000 1.79
+++ maven.mdo 7 Mar 2005 20:54:34 -0000 1.80
@@ -807,6 +807,7 @@
<version>4.0.0</version>
<description>The scope of the dependency - build, compile, test, runtime</description>
<type>String</type>
+ <defaultValue>runtime</defaultValue>
</field>
</fields>
<codeSegments>
1.3 +5 -0 maven-components/maven-artifact/src/main/java/org/apache/maven/artifact/Artifact.java
Index: Artifact.java
===================================================================
RCS file: /home/cvs/maven-components/maven-artifact/src/main/java/org/apache/maven/artifact/Artifact.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- Artifact.java 7 Mar 2005 09:41:54 -0000 1.2
+++ Artifact.java 7 Mar 2005 20:54:35 -0000 1.3
@@ -20,6 +20,11 @@
public interface Artifact
{
+ // TODO: into scope handler
+ String SCOPE_COMPILE = "compile";
+ String SCOPE_TEST = "test";
+ String SCOPE_RUNTIME = "runtime";
+
String getGroupId();
String getArtifactId();
1.5 +2 -2 maven-components/maven-artifact/src/main/java/org/apache/maven/artifact/DefaultArtifact.java
Index: DefaultArtifact.java
===================================================================
RCS file: /home/cvs/maven-components/maven-artifact/src/main/java/org/apache/maven/artifact/DefaultArtifact.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- DefaultArtifact.java 7 Mar 2005 09:41:54 -0000 1.4
+++ DefaultArtifact.java 7 Mar 2005 20:54:35 -0000 1.5
@@ -57,7 +57,7 @@
/** @todo this should be replaced by type handler */
public DefaultArtifact( String groupId, String artifactId, String version, String type, String extension )
{
- this( groupId, artifactId, version, null, type, extension );
+ this( groupId, artifactId, version, SCOPE_RUNTIME, type, extension );
}
public DefaultArtifact( String groupId, String artifactId, String version, String type )
1.16 +7 -7 maven-components/maven-plugins/maven-compiler-plugin/src/main/java/org/apache/maven/plugin/CompilerMojo.java
Index: CompilerMojo.java
===================================================================
RCS file: /home/cvs/maven-components/maven-plugins/maven-compiler-plugin/src/main/java/org/apache/maven/plugin/CompilerMojo.java,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -r1.15 -r1.16
--- CompilerMojo.java 7 Mar 2005 09:41:55 -0000 1.15
+++ CompilerMojo.java 7 Mar 2005 20:54:35 -0000 1.16
@@ -18,11 +18,11 @@
* @description Compiles application sources
*
* @parameter
- * name="compileSourceRootsList"
+ * name="compileSourceRoots"
* type="java.util.List"
* required="true"
* validator=""
- * expression="#project.compileSourceRootsList"
+ * expression="#project.compileSourceRoots"
* description=""
*
* @parameter
@@ -68,7 +68,7 @@
//
// ----------------------------------------------------------------------
- List compileSourceRootsList = (List) request.getParameter( "compileSourceRootsList" );
+ List compileSourceRoots = (List) request.getParameter( "compileSourceRoots" );
String outputDirectory = (String) request.getParameter( "outputDirectory" );
@@ -78,8 +78,8 @@
//
// ----------------------------------------------------------------------
- compileSourceRootsList = removeEmptyCompileSourceRoots( compileSourceRootsList );
- if ( compileSourceRootsList.isEmpty() )
+ compileSourceRoots = removeEmptyCompileSourceRoots( compileSourceRoots );
+ if ( compileSourceRoots.isEmpty() )
{
return;
}
@@ -88,7 +88,7 @@
compilerConfiguration.setOutputLocation(outputDirectory);
compilerConfiguration.setClasspathEntries( classpathElements );
- compilerConfiguration.setSourceLocations( compileSourceRootsList );
+ compilerConfiguration.setSourceLocations( compileSourceRoots );
/* Compile with debugging info */
String debugAsString = (String) request.getParameter( "debug" );
1.8 +3 -3 maven-components/maven-plugins/maven-compiler-plugin/src/main/java/org/apache/maven/plugin/TestCompilerMojo.java
Index: TestCompilerMojo.java
===================================================================
RCS file: /home/cvs/maven-components/maven-plugins/maven-compiler-plugin/src/main/java/org/apache/maven/plugin/TestCompilerMojo.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- TestCompilerMojo.java 7 Mar 2005 09:41:55 -0000 1.7
+++ TestCompilerMojo.java 7 Mar 2005 20:54:35 -0000 1.8
@@ -10,11 +10,11 @@
* @requiresDependencyResolution
*
* @parameter
- * name="compileSourceRootsList"
+ * name="compileSourceRoots"
* type="java.util.List"
* required="true"
* validator=""
- * expression="#project.testCompileSourceRootsList"
+ * expression="#project.testCompileSourceRoots"
* description=""
*
* @parameter