From qroberts@example.com Thu Sep 02 12:34:25 2004 Return-Path: <qroberts@example.com> Delivered-To: qroberts@example.com Received: (qmail 38319 invoked from network); 2 Sep 2004 12:34:25 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (83.161.120.155) by minotaur-2.apache.org with SMTP; 2 Sep 2004 12:34:25 -0000 Received: (qmail 29655 invoked by uid 500); 2 Sep 2004 12:34:25 -0000 Delivered-To: qroberts@example.com Received: (qmail 29637 invoked by uid 500); 2 Sep 2004 12:34:25 -0000 Mailing-List: contact qroberts@example.com; run by ezmlm Precedence: bulk list-help: <mailto:qroberts@example.com> list-unsubscribe: <mailto:qroberts@example.com> list-post: <mailto:qroberts@example.com> List-Id: "Maven 2 Developers List" <m2-dev.maven.apache.org> Reply-To: "Maven 2 Developers List" <qroberts@example.com> Delivered-To: mailing list qroberts@example.com Received: (qmail 29620 invoked by uid 500); 2 Sep 2004 12:34:24 -0000 Delivered-To: qroberts@example.com Received: (qmail 29616 invoked by uid 99); 2 Sep 2004 12:34:24 -0000 X-ASF-Spam-Status: No, hits=-2.8 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Received: from [83.161.120.155] (HELO minotaur.apache.org) (83.161.120.155) by apache.org (qpsmtpd/0.28) with SMTP; Thu, 02 Sep 2004 05:34:20 -0700 Received: (qmail 38291 invoked by uid 1717); 2 Sep 2004 12:34:19 -0000 Date: 2 Sep 2004 12:34:19 -0000 Message-ID: <qroberts@example.com> From: qroberts@example.com To: qroberts@example.com Subject: cvs commit: maven-components/maven-plugins/maven-surefire-plugin/src/main/java/org/apache/maven/test SurefirePlugin.java X-Virus-Checked: Checked X-Spam-Rating: minotaur-2.apache.org 1.6.2 0/1000/N brett 2004/09/02 05:34:19 Modified: . ci.sh m2-bootstrap-all.sh pom.xml maven-artifact/src/test/java/org/apache/maven/artifact ArtifactComponentTestCase.java maven-artifact/src/test/java/org/apache/maven/artifact/resolver ArtifactResolverTest.java maven-core plugin-notes.txt maven-core/src/main/java/org/apache/maven DefaultMaven.java JarOverrideRequestTransformation.java Maven.java MavenCli.java MavenConstants.java maven-core/src/main/java/org/apache/maven/plugin DefaultPluginManager.java OgnlProjectValueExtractor.java maven-core/src/main/java/org/apache/maven/project DefaultMavenProjectBuilder.java MavenProject.java MavenProjectBuilder.java maven-core/src/main/java/org/apache/maven/repository RepositoryUtils.java maven-core/src/main/resources/org/apache/maven/project pom.xml maven-core/src/test/java/org/apache/maven MavenTestCase.java maven-core/src/test/java/org/apache/maven/lifecycle/goal/phase GoalResolutionPhaseTest.java maven-core/src/test/java/org/apache/maven/plugin OgnlProjectValueExtractorTest.java maven-core/src/test/java/org/apache/maven/project AbstractProjectTestCase.java ProjectBaseDirectoryAlignmentTest.java maven-core/src/test/java/org/apache/maven/project/inheritance ProjectInheritanceTestCase.java maven-core/src/test/java/org/apache/maven/project/inheritance/t00 ProjectInheritanceTest.java maven-core/src/test/java/org/apache/maven/project/inheritance/t01 ProjectInheritanceTest.java maven-core-it maven-core-it.sh maven-core-it/it0002 expected-results.txt prebuild.hook maven-core-it/it0003 expected-results.txt prebuild.hook maven-core-it/it0004 expected-results.txt prebuild.hook maven-core-it/it0005 expected-results.txt prebuild.hook maven-core-it/it0007 expected-results.txt prebuild.hook maven-core-it-verifier/src/main/java/org/apache/maven/it Verifier.java maven-mboot2/src/main/java ArtifactDownloader.java MBoot.java maven-model maven.mdo maven-plugins/maven-surefire-plugin/src/main/java/org/apache/maven/test SurefirePlugin.java Removed: maven-core/src/main/java/org/apache/maven/project MavenProjectConstants.java Log: PR: MNG-74 remove maven.properties use everywhere except classworlds conf Revision Changes Path 1.32 +3 -12 maven-components/ci.sh Index: ci.sh =================================================================== RCS file: /home/cvs/maven-components/ci.sh,v retrieving revision 1.31 retrieving revision 1.32 diff -u -r1.31 -r1.32 --- ci.sh 11 Aug 2004 20:38:32 -0000 1.31 +++ ci.sh 2 Sep 2004 12:34:16 -0000 1.32 @@ -5,20 +5,10 @@ # # 1. export JAVA_HOME=/path/to/java # -# 2. export MBOOT_HOME=~/mboot -# -# 3. export M2_HOME=~/maven -# -# 4. export PATH=$PATH:$MBOOT:$M2_HOME/bin -# -# 5. Your ~/maven.properties must have: maven.repo.local = ~/path/to/repo -# # ---------------------------------------------------------------------------------- export JAVA_HOME=/usr/local/java -export MBOOT_HOME=$HOME/mboot -export M2_HOME=$HOME/m2 -export PATH=$PATH:$MBOOT_HOME:$M2_HOME/bin:$JAVA_HOME/bin +export PATH=$PATH:$JAVA_HOME/bin # ---------------------------------------------------------------------------------- @@ -117,7 +107,7 @@ ( cd $DIR/maven-components - sh m2-bootstrap-all.sh + sh m2-bootstrap-all.sh -Dmaven.repo.local="$HOME_DIR/$REPO" -Dmaven.home="$HOME_DIR/m2" ) DIST=m2-${TIMESTAMP}.tar.gz @@ -128,6 +118,7 @@ mkdir -p $DEPLOY_DIR > /dev/null 2>&1 + # Assumes pwd is still $HOME_DIR tar czf $DEPLOY_DIR/$DIST m2 else 1.3 +1 -1 maven-components/m2-bootstrap-all.sh Index: m2-bootstrap-all.sh =================================================================== RCS file: /home/cvs/maven-components/m2-bootstrap-all.sh,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- m2-bootstrap-all.sh 14 Aug 2004 20:46:24 -0000 1.2 +++ m2-bootstrap-all.sh 2 Sep 2004 12:34:16 -0000 1.3 @@ -12,7 +12,7 @@ echo "-----------------------------------------------------------------------" cd ./maven-mboot2 - ./build + ./build $ARGS ret=$?; if [ $ret != 0 ]; then exit $ret; fi ) ret=$?; if [ $ret != 0 ]; then exit $ret; fi 1.8 +2 -0 maven-components/pom.xml Index: pom.xml =================================================================== RCS file: /home/cvs/maven-components/pom.xml,v retrieving revision 1.7 retrieving revision 1.8 diff -u -r1.7 -r1.8 --- pom.xml 26 Aug 2004 01:18:07 -0000 1.7 +++ pom.xml 2 Sep 2004 12:34:16 -0000 1.8 @@ -20,6 +20,8 @@ <repository> <id>central</id> <name>Maven Central Repository at Ibiblio</name> + <!-- TODO: should this be scp888a:dbb7:2d49:b3f6:8605:bf4e:caed:e5a4//login.ibiblio.org:/public/html/maven? Or should we even use url? + How about protocol, host, directory, etc? --> <url>scp://login.ibiblio.org//public/html/maven</url> </repository> </distributionManagement> 1.3 +16 -1 maven-components/maven-artifact/src/test/java/org/apache/maven/artifact/ArtifactComponentTestCase.java Index: ArtifactComponentTestCase.java =================================================================== RCS file: /home/cvs/maven-components/maven-artifact/src/test/java/org/apache/maven/artifact/ArtifactComponentTestCase.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- ArtifactComponentTestCase.java 17 Aug 2004 20:58:29 -0000 1.2 +++ ArtifactComponentTestCase.java 2 Sep 2004 12:34:17 -0000 1.3 @@ -46,6 +46,21 @@ protected abstract String component(); + /** Return an existing file, not a directory - causes creation to fail. */ + protected ArtifactRepository badLocalRepository() throws IOException + { + ArtifactRepository localRepository = new ArtifactRepository(); + + String path = "target/test-classes/repositories/" + component() + "/bad-local-repository"; + + File f = new File( path ); + f.createNewFile(); + + localRepository.setUrl( "file://" + path ); + + return localRepository; + } + protected ArtifactRepository localRepository() { ArtifactRepository localRepository = new ArtifactRepository(); 1.4 +14 -1 maven-components/maven-artifact/src/test/java/org/apache/maven/artifact/resolver/ArtifactResolverTest.java Index: ArtifactResolverTest.java =================================================================== RCS file: /home/cvs/maven-components/maven-artifact/src/test/java/org/apache/maven/artifact/resolver/ArtifactResolverTest.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- ArtifactResolverTest.java 17 Aug 2004 20:58:29 -0000 1.3 +++ ArtifactResolverTest.java 2 Sep 2004 12:34:17 -0000 1.4 @@ -256,5 +256,18 @@ assertLocalArtifactPresent( l ); } + +/* + public void testResolutionOfASingleArtifactWhereTheArtifactIsNotPresentLocallyAndMustBeRetrievedFromTheRemoteRepositoryAndLocalCannotBeCreated() + throws Exception + { + Artifact m = createRemoteArtifact( "m", "1.0" ); + + artifactResolver.resolve( m, remoteRepositories(), badLocalRepository() ); + + // TODO [failing test case]: throw and handle a more informative exception + } +*/ + } 1.2 +2 -2 maven-components/maven-core/plugin-notes.txt Index: plugin-notes.txt =================================================================== RCS file: /home/cvs/maven-components/maven-core/plugin-notes.txt,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- plugin-notes.txt 9 Aug 2004 19:02:33 -0000 1.1 +++ plugin-notes.txt 2 Sep 2004 12:34:17 -0000 1.2 @@ -42,7 +42,7 @@ <plugin> <id>surefire</id> <configuration> - <mavenRepoLocal>#maven.repo.local</mavenRepoLocal> + <mavenRepoLocal>#localRepository</mavenRepoLocal> <basedir>#basedir</basedir> <includes>#project.build.unitTest.includes</includes> <excludes>#project.build.unitTest.excludes</excludes> @@ -53,4 +53,4 @@ If say for example you used DbUnit or XMLUnit then the configurations for each of the plugin executions would be different. ---> \ No newline at end of file +--> 1.9 +18 -30 maven-components/maven-core/src/main/java/org/apache/maven/DefaultMaven.java Index: DefaultMaven.java =================================================================== RCS file: /home/cvs/maven-components/maven-core/src/main/java/org/apache/maven/DefaultMaven.java,v retrieving revision 1.8 retrieving revision 1.9 diff -u -r1.8 -r1.9 --- DefaultMaven.java 26 Aug 2004 16:37:08 -0000 1.8 +++ DefaultMaven.java 2 Sep 2004 12:34:17 -0000 1.9 @@ -51,7 +51,7 @@ private String mavenHome; - private String localRepository; + private String mavenHomeLocal; private boolean logResults = true; @@ -70,7 +70,9 @@ // ---------------------------------------------------------------------- // Project execution // ---------------------------------------------------------------------- - + + /** @todo probable need to do getProject( null ) here instead - but no project doesn't seem supported just yet, + at least from the CLI. */ public ExecutionResponse execute( List goals ) throws GoalNotFoundException { return execute( (MavenProject) null, goals ); @@ -90,7 +92,13 @@ ExecutionResponse response = new ExecutionResponse(); - MavenSession session = new MavenSession( container, pluginManager, project, getLocalRepository(), goals ); + pluginManager.setLocalRepository( project.getLocalRepository() ); + + MavenSession session = new MavenSession( container, + pluginManager, + project, + project.getLocalRepository(), + goals ); try { @@ -205,7 +213,7 @@ { File f = (File) iterator.next(); - MavenProject project = projectBuilder.build( f, getLocalRepository() ); + MavenProject project = projectBuilder.build( f ); projects.add( project ); } @@ -281,7 +289,7 @@ } } - return projectBuilder.build( project, getLocalRepository() ); + return projectBuilder.build( project ); } // ---------------------------------------------------------------------- @@ -307,25 +315,14 @@ return mavenHome; } - // ---------------------------------------------------------------------- - // Maven local repository - // ---------------------------------------------------------------------- - - public void setLocalRepository( String localRepository ) + public void setMavenHomeLocal( String mavenHomeLocal ) { - this.localRepository = localRepository; + this.mavenHomeLocal = mavenHomeLocal; } - private ArtifactRepository wagonLocalRepository; - - public ArtifactRepository getLocalRepository() + public String getMavenHomeLocal() { - if ( wagonLocalRepository == null ) - { - wagonLocalRepository = new ArtifactRepository( "local", "file://" + localRepository ); - } - - return wagonLocalRepository; + return mavenHomeLocal; } // ---------------------------------------------------------------------- @@ -358,13 +355,4 @@ return secs + " seconds"; } } - - // ---------------------------------------------------------------------- - // - // ---------------------------------------------------------------------- - - public void booty() throws Exception - { - pluginManager.setLocalRepository( getLocalRepository() ); - } -} \ No newline at end of file +} 1.2 +2 -1 maven-components/maven-core/src/main/java/org/apache/maven/JarOverrideRequestTransformation.java Index: JarOverrideRequestTransformation.java =================================================================== RCS file: /home/cvs/maven-components/maven-core/src/main/java/org/apache/maven/JarOverrideRequestTransformation.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- JarOverrideRequestTransformation.java 9 Aug 2004 19:02:34 -0000 1.1 +++ JarOverrideRequestTransformation.java 2 Sep 2004 12:34:17 -0000 1.2 @@ -35,6 +35,7 @@ Map parameters ) throws Exception { +/* TODO: need an override in the POM MavenProject project = (MavenProject) parameters.get( "project" ); boolean mavenJarOverride = project.getBooleanProperty( "maven.jar.override" ); @@ -49,7 +50,7 @@ artifact.getType() ); return transformedArtifact; } - +*/ return artifact; } } 1.3 +3 -14 maven-components/maven-core/src/main/java/org/apache/maven/Maven.java Index: Maven.java =================================================================== RCS file: /home/cvs/maven-components/maven-core/src/main/java/org/apache/maven/Maven.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- Maven.java 15 Aug 2004 15:01:50 -0000 1.2 +++ Maven.java 2 Sep 2004 12:34:17 -0000 1.3 @@ -71,13 +71,9 @@ String getMavenHome(); - // ---------------------------------------------------------------------- - // Maven local repository - // ---------------------------------------------------------------------- + void setMavenHomeLocal( String mavenHomeLocal ); - void setLocalRepository( String localRepository ); - - ArtifactRepository getLocalRepository(); + String getMavenHomeLocal(); // ---------------------------------------------------------------------- // Maven project handling @@ -85,11 +81,4 @@ MavenProject getProject( File project ) throws ProjectBuildingException; - - // ---------------------------------------------------------------------- - // - // ---------------------------------------------------------------------- - - void booty() - throws Exception; } 1.4 +7 -54 maven-components/maven-core/src/main/java/org/apache/maven/MavenCli.java Index: MavenCli.java =================================================================== RCS file: /home/cvs/maven-components/maven-core/src/main/java/org/apache/maven/MavenCli.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- MavenCli.java 26 Aug 2004 01:18:08 -0000 1.3 +++ MavenCli.java 2 Sep 2004 12:34:17 -0000 1.4 @@ -62,11 +62,9 @@ Maven maven = (Maven) embedder.lookup( Maven.ROLE ); - maven.setMavenHome( findMavenHome() ); + maven.setMavenHome( System.getProperty( "maven.home" ) ); - maven.setLocalRepository( findLocalRepository() ); - - maven.booty(); + maven.setMavenHomeLocal( System.getProperty( "maven.home.local", System.getProperty( "user.home" ) + "/.m2" ) ); //--- @@ -96,6 +94,10 @@ // Take this info from generated piece of meta data which uses // the POM itself as the source. We don't want to get into the same // bullshit of manually updating some constant in the source. + // [Brett] My thoughts on this (something I long ago slated for m1), is to store the pom in + // META-INF or something similar for a jar, and then read that back. maven-model being so + // trim makes that more of a reality. The other alternative is simply to store that info in + // the manifest in plain text and read that back. System.out.println( "Maven version: " ); return; @@ -153,46 +155,6 @@ } // ---------------------------------------------------------------------- - // Local repository - // ---------------------------------------------------------------------- - - /** @todo shouldn't need to duplicate the code to load maven.properties. */ - private static String findLocalRepository() - throws Exception - { - Properties properties = new Properties(); - - properties.load( new FileInputStream( new File( System.getProperty( "user.home" ), "maven.properties" ) ) ); - - for ( Iterator i = properties.keySet().iterator(); i.hasNext(); ) - { - String key = (String) i.next(); - - properties.setProperty( key, StringUtils.interpolate( properties.getProperty( key ), System.getProperties() ) ); - } - - String localRepository = properties.getProperty( MavenConstants.MAVEN_REPO_LOCAL ); - - if ( localRepository == null ) - { - throw new Exception( "Missing 'maven.repo.local' from ~/maven.properties." ); - } - - return localRepository; - } - - // ---------------------------------------------------------------------- - // Maven home - // ---------------------------------------------------------------------- - - private static String findMavenHome() - { - String mavenHome = System.getProperty( "maven.home" ); - - return mavenHome; - } - - // ---------------------------------------------------------------------- // System properties handling // ---------------------------------------------------------------------- @@ -209,15 +171,6 @@ else { System.setProperty( MavenConstants.DEBUG_ON, "false" ); - } - - if ( commandLine.hasOption( CLIManager.WORK_OFFLINE ) ) - { - System.setProperty( MavenConstants.WORK_OFFLINE, "true" ); - } - else - { - System.setProperty( MavenConstants.WORK_OFFLINE, "false" ); } if ( commandLine.hasOption( CLIManager.SET_SYSTEM_PROPERTY ) ) 1.2 +1 -12 maven-components/maven-core/src/main/java/org/apache/maven/MavenConstants.java Index: MavenConstants.java =================================================================== RCS file: /home/cvs/maven-components/maven-core/src/main/java/org/apache/maven/MavenConstants.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- MavenConstants.java 9 Aug 2004 19:02:34 -0000 1.1 +++ MavenConstants.java 2 Sep 2004 12:34:17 -0000 1.2 @@ -18,17 +18,6 @@ public class MavenConstants { - public static final int MAVEN_VERSION = 3; - - public static final int POM_VERSION = 3; - - public static final String MAVEN_PROPERTIES = "maven.properties"; - + // TODO: remove? only used in CLI for now - once set, never used public static final String DEBUG_ON = "maven.debugOn"; - - public static final String WORK_OFFLINE = "maven.workOffline"; - - public static final String MAVEN_HOME = "m2.home"; - - public static final String MAVEN_REPO_LOCAL = "maven.repo.local"; } 1.6 +6 -2 maven-components/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginManager.java Index: DefaultPluginManager.java =================================================================== RCS file: /home/cvs/maven-components/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginManager.java,v retrieving revision 1.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- DefaultPluginManager.java 26 Aug 2004 04:39:53 -0000 1.5 +++ DefaultPluginManager.java 2 Sep 2004 12:34:17 -0000 1.6 @@ -207,7 +207,7 @@ public boolean isPluginInstalled( String pluginId ) { - return (pluginDescriptors.get( pluginId ) != null); + return pluginDescriptors.containsKey( pluginId ); } private String getPluginId( String goalName ) @@ -261,6 +261,7 @@ MavenMetadataSource sr = new MavenMetadataSource( remotePluginRepositories, localRepository, artifactResolver ); + // TODO: needs to be configurable String[] excludes = new String[] { "maven-core", "maven-artifact", "maven-model", "maven-plugin", "plexus", "xstream", "xpp3", "classworlds", "ognl" }; @@ -275,17 +276,20 @@ public void initialize() throws Exception { - //!! move this to be configurable from the Maven component + // TODO: move this to be configurable from the Maven component remotePluginRepositories = new HashSet(); + // TODO: needs to be configured from the POM element remotePluginRepositories.add( new ArtifactRepository( "plugin-repository", "http://www.ibiblio.org/maven" ) ); } + // TODO: is this needed or can it be found from the session? public ArtifactRepository getLocalRepository() { return localRepository; } + // TODO: is this needed or can it be found from the session? It is currently set from the session public void setLocalRepository( ArtifactRepository localRepository ) { this.localRepository = localRepository; 1.4 +18 -5 maven-components/maven-core/src/main/java/org/apache/maven/plugin/OgnlProjectValueExtractor.java Index: OgnlProjectValueExtractor.java =================================================================== RCS file: /home/cvs/maven-components/maven-core/src/main/java/org/apache/maven/plugin/OgnlProjectValueExtractor.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- OgnlProjectValueExtractor.java 15 Aug 2004 15:01:51 -0000 1.3 +++ OgnlProjectValueExtractor.java 2 Sep 2004 12:34:17 -0000 1.4 @@ -44,9 +44,19 @@ // do nothing } } - else if ( expression.equals( "#localRepository") ) + else if ( expression.equals( "#localRepository" ) ) { - value = context.getLocalRepository(); + value = context.getSession().getLocalRepository(); + } + else if ( expression.equals( "#maven.repo.local" ) ) + { + // TODO: remove this alias: but note that it is a string instead of an ArtifactRepository + value = context.getSession().getLocalRepository().getUrl().substring( "file://".length() ); + } + else if ( expression.equals( "#maven.final.name" ) ) + { + // TODO: remove this alias + value = context.getProject().getModel().getBuild().getFinalName(); } else if ( expression.equals( "#project" ) ) { @@ -71,6 +81,7 @@ catch ( OgnlException e ) { // do nothing + e.printStackTrace(); // TODO: should log? should ignore as previously? } } else if ( expression.equals( "#basedir" ) ) @@ -79,6 +90,8 @@ } else if ( expression.startsWith( "#" ) ) { + new Exception( "Got expression '" + expression + "' that was not recognised" ).printStackTrace(); +/* TODO: this probably isn't needed - log something properly though that is invalid? Probably should throw exception. expression = expression.substring( 1 ); int pathSeparator = expression.indexOf( "/" ); @@ -92,10 +105,9 @@ { value = context.getProject().getProperty( expression ); } - +*/ } - // If we strike out we'll just use the expression which allows // people to use hardcoded values if they wish. @@ -107,3 +119,4 @@ return value; } } + 1.7 +57 -86 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.6 retrieving revision 1.7 diff -u -r1.6 -r1.7 --- DefaultMavenProjectBuilder.java 18 Aug 2004 07:28:10 -0000 1.6 +++ DefaultMavenProjectBuilder.java 2 Sep 2004 12:34:17 -0000 1.7 @@ -55,7 +55,6 @@ import java.util.LinkedList; import java.util.List; import java.util.Map; -import java.util.Properties; import java.util.Set; import java.util.Collection; import java.util.Collections; @@ -64,8 +63,6 @@ extends AbstractLogEnabled implements MavenProjectBuilder, Initializable { - public static final String MAVEN_PROPERTIES = "maven.properties"; - private ArtifactResolver artifactResolver; private ArtifactFactory artifactFactory; @@ -90,25 +87,29 @@ modelReader = new MavenXpp3Reader(); } - public MavenProject build( File projectDescriptor, ArtifactRepository localRepository ) + public MavenProject build( File projectDescriptor ) throws ProjectBuildingException { - return build( projectDescriptor, localRepository, false ); + return build( projectDescriptor, false ); } /** @todo can we move the super model reading to the initialize method? what about the user/site? Is it reused? - * @todo we should be passing in some more configuration here so that maven.home.local can be used for user properties. Then, the new stuff should be unit tested. + * @todo this is still not completely faithful to the "always override" method of the user POM: there is potential for settings not to be used in some rare circumstances. Some restructuring is necessary. + * @todo we should be passing in some more configuration here so that maven home local can be used for user properties. Then, the new stuff should be unit tested. * @todo the user model bit overwriting the super model seems a bit gross, but is needed so that any repositories given take affect */ - public MavenProject build( File projectDescriptor, ArtifactRepository localRepository, boolean resolveDependencies ) + public MavenProject build( File projectDescriptor, boolean resolveDependencies ) throws ProjectBuildingException { + String localRepositoryValue = null; + try { + // TODO: rename to super-pom.xml so it is not used by the reactor superModel = modelReader.read( new InputStreamReader( DefaultMavenProjectBuilder.class.getResourceAsStream( "pom.xml" ) ) ); Model userModel = null; - // TODO: use maven.home.local instead of user.home/.m2 + // TODO: use maven home local instead of user.home/.m2 File userModelFile = new File( System.getProperty( "user.home" ) + "/.m2", "pom.xml" ); if ( userModelFile.exists() ) { @@ -118,9 +119,31 @@ throw new ProjectBuildingException( "Inheritence not supported in the user override POM" ); } + if ( localRepositoryValue == null && userModel.getLocal() != null && userModel.getLocal().getRepository() != null ) + { + localRepositoryValue = userModel.getLocal().getRepository(); + } superModel.getRepositories().addAll( userModel.getRepositories() ); } + if ( localRepositoryValue == null && superModel.getLocal() != null && superModel.getLocal().getRepository() != null ) + { + localRepositoryValue = superModel.getLocal().getRepository(); + } + + // TODO: systemProperty in modello will make this redundant + localRepositoryValue = System.getProperty( "maven.repo.local", localRepositoryValue ); + + ArtifactRepository localRepository = null; + if ( localRepositoryValue != null ) + { + localRepository = RepositoryUtils.localRepositoryToWagonRepository( localRepositoryValue ); + } + else + { + throw new ProjectBuildingException( "A local repository must be specified" ); + } + LinkedList lineage = new LinkedList(); MavenProject project = assembleLineage( projectDescriptor, @@ -145,15 +168,12 @@ project = new MavenProject( userModel ); project.setFile( parent.getFile() ); project.setParent( parent ); - - // Note that we don't currently support maven.properties here: this might be a better place to do - // the overrides though, if it is kept. If so, would need to process this regardless of the existence - // of pom.xml - project.setProperties( parent.getProperties() ); } + project.setLocalRepository( localRepository ); project.setArtifacts( artifactFactory.createArtifacts( project.getDependencies(), localRepository ) ); + // @todo this should be in the super POM when interpolation works setupMavenFinalName( project ); // ---------------------------------------------------------------------- @@ -201,16 +221,12 @@ } } - /** @todo loading of project properties could be handled much more effeciently as they are never loaded from - the repository. However, I believe they should be removedC anyway and use the POM -- Brett. */ private MavenProject assembleLineage( File projectDescriptor, ArtifactRepository localRepository, LinkedList lineage, List remoteRepositories ) throws Exception { - Map properties = createProjectProperties( projectDescriptor.getParentFile() ); - Model model = readModel( projectDescriptor ); MavenProject project = new MavenProject( model ); @@ -256,11 +272,17 @@ project.setParent( parent ); } - project.setProperties( properties ); - return project; } + private void setupMavenFinalName( MavenProject project ) + { + if ( project.getModel().getBuild().getFinalName() == null ) + { + project.getModel().getBuild().setFinalName( project.getArtifactId() + "-" + project.getVersion() ); + } + } + private Model readModel( File projectDescriptor ) throws Exception { @@ -306,65 +328,16 @@ } catch ( ArtifactResolutionException e ) { - throw new ProjectBuildingException( "Missing parent POM: ", e ); - + // @todo use parent.toString() if modello could generate it, or specify in a code segment + throw new ProjectBuildingException( "Missing parent POM: " + + parent.getGroupId() + ":" + + parent.getArtifactId() + "-" + + parent.getVersion(), e ); } return artifact.getFile(); } - private void setupMavenFinalName( MavenProject project ) - { - String mavenFinalName = project.getProperty( "maven.final.name" ); - - if ( mavenFinalName == null || mavenFinalName.indexOf( "${" ) >= 0 ) - { - project.setProperty( "maven.final.name", project.getArtifactId() + "-" + project.getVersion() ); - } - } - - private Map createProjectProperties( File descriptorDirectory ) - { - File f; - - Properties systemProperties = System.getProperties(); - - f = new File( System.getProperty( "user.home" ), MAVEN_PROPERTIES ); - - Properties mavenProperties = PropertyUtils.loadProperties( f ); - - // project build properties - Properties userOverridesMavenProperties = null; - - if ( descriptorDirectory != null ) - { - f = new File( descriptorDirectory, MAVEN_PROPERTIES ); - - userOverridesMavenProperties = PropertyUtils.loadProperties( f ); - } - - Map result = CollectionUtils.mergeMaps( new Map[] - { - systemProperties, - mavenProperties, - userOverridesMavenProperties, - } ); - - // Set the basedir value in the context. - result.put( "basedir", descriptorDirectory.getAbsolutePath() ); - - for ( Iterator i = result.keySet().iterator(); i.hasNext(); ) - { - String key = (String) i.next(); - - String value = (String) result.get( key ); - - result.put( key, StringUtils.interpolate( value, result ) ); - } - - return result; - } - private Model interpolateModel( Model model, Map map ) throws Exception { @@ -381,19 +354,17 @@ return writer.toString(); } - // ---------------------------------------------------------------------- - // - // 1. collect all the vertices for the projects that we want to build. - // - // 2. iterate through the deps of each project and if that dep is within - // the set of projects we want to build then add an edge, otherwise throw - // the edge away because that dependency is not within the set of projects - // we are trying to build. we assume a closed set. - // - // 3. do a topo sort on the graph that remains. - // - // ---------------------------------------------------------------------- - + /** + * Sort a list of projects. + * <ul> + * <li>collect all the vertices for the projects that we want to build.</li> + * <li>iterate through the deps of each project and if that dep is within + * the set of projects we want to build then add an edge, otherwise throw + * the edge away because that dependency is not within the set of projects + * we are trying to build. we assume a closed set.</li> + * <li>do a topo sort on the graph that remains.</li> + * </ul> + */ public List getSortedProjects( List projects ) throws Exception { 1.4 +12 -45 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.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- MavenProject.java 29 Aug 2004 18:57:30 -0000 1.3 +++ MavenProject.java 2 Sep 2004 12:34:17 -0000 1.4 @@ -24,6 +24,7 @@ import java.util.Set; import org.apache.maven.artifact.Artifact; +import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.model.Build; import org.apache.maven.model.CiManagement; import org.apache.maven.model.Contributor; @@ -32,10 +33,11 @@ import org.apache.maven.model.IssueManagement; import org.apache.maven.model.License; import org.apache.maven.model.MailingList; +import org.apache.maven.model.Local; import org.apache.maven.model.Model; import org.apache.maven.model.Organization; import org.apache.maven.model.Scm; - +import org.apache.maven.repository.RepositoryUtils; import org.codehaus.plexus.util.StringUtils; /** @@ -63,7 +65,7 @@ private Set artifacts; - private Map properties; + private ArtifactRepository wagonLocalRepository; public MavenProject( Model model ) { @@ -509,59 +511,24 @@ return artifacts; } - public void setProperty( String key, String value ) - { - getProperties().put( key, value ); - } - - public void setProperties( Map properties ) - { - this.properties = properties; - } - - public Map getProperties() + public List getRepositories() { - return properties; + return model.getRepositories(); } - public String getProperty( String key ) + public ArtifactRepository getLocalRepository() { - String property = (String) properties.get( key ); - - if ( property == null && hasParent() ) + if ( wagonLocalRepository == null && model.getLocal() != null && model.getLocal().getRepository() != null ) { - property = getParent().getProperty( key ); + wagonLocalRepository = RepositoryUtils.localRepositoryToWagonRepository( model.getLocal().getRepository() ); } - return property; + return wagonLocalRepository; } - /** - * 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; - } - - public List getRepositories() + public void setLocalRepository( ArtifactRepository repository ) { - return model.getRepositories(); + this.wagonLocalRepository = repository; } } 1.2 +2 -4 maven-components/maven-core/src/main/java/org/apache/maven/project/MavenProjectBuilder.java Index: MavenProjectBuilder.java =================================================================== RCS file: /home/cvs/maven-components/maven-core/src/main/java/org/apache/maven/project/MavenProjectBuilder.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- MavenProjectBuilder.java 9 Aug 2004 19:02:37 -0000 1.1 +++ MavenProjectBuilder.java 2 Sep 2004 12:34:17 -0000 1.2 @@ -16,8 +16,6 @@ * limitations under the License. */ -import org.apache.maven.artifact.repository.ArtifactRepository; - import java.io.File; import java.util.List; @@ -27,10 +25,10 @@ // ---------------------------------------------------------------------- - MavenProject build( File project, ArtifactRepository localRepository ) + MavenProject build( File project ) throws ProjectBuildingException; - MavenProject build( File project, ArtifactRepository localRepository, boolean followTransitiveDeps ) + MavenProject build( File project, boolean followTransitiveDeps ) throws ProjectBuildingException; // ---------------------------------------------------------------------- 1.2 +7 -2 maven-components/maven-core/src/main/java/org/apache/maven/repository/RepositoryUtils.java Index: RepositoryUtils.java =================================================================== RCS file: /home/cvs/maven-components/maven-core/src/main/java/org/apache/maven/repository/RepositoryUtils.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- RepositoryUtils.java 9 Aug 2004 19:02:37 -0000 1.1 +++ RepositoryUtils.java 2 Sep 2004 12:34:17 -0000 1.2 @@ -9,6 +9,7 @@ import java.util.Set; /** + * @todo not sure "wagon" notation is appropriate here - it is really maven-artifact which is not the same as wagon * @author <a href="mailto:qroberts@example.com">Michal Maczka</a> * @version $Id$ */ @@ -25,7 +26,6 @@ return repos; } - public static ArtifactRepository mavenRepositoryToWagonRepository( Repository mavenRepository ) { @@ -34,5 +34,10 @@ retValue.setUrl( mavenRepository.getUrl() ); return retValue; + } + + public static ArtifactRepository localRepositoryToWagonRepository( String repository ) + { + return new ArtifactRepository( "local", "file://" + repository ); } } 1.4 +18 -0 maven-components/maven-core/src/main/resources/org/apache/maven/project/pom.xml Index: pom.xml =================================================================== RCS file: /home/cvs/maven-components/maven-core/src/main/resources/org/apache/maven/project/pom.xml,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- pom.xml 10 Aug 2004 19:48:56 -0000 1.3 +++ pom.xml 2 Sep 2004 12:34:17 -0000 1.4 @@ -10,6 +10,24 @@ </repository> </repositories> +<!-- + <pluginRepositories> + <repository> + <id>pluginCentral</id> + <name>Maven Central Repository at ibiblio</name> + <url>http://www.ibiblio.org/maven</url> + </repository> + </pluginRepositories> +--> + + <!-- TODO: should be the maven local home --> + <!-- TODO: substitution not working --> +<!-- + <local> + <repository>${user.home}/.m2/repository</repository> + </local> +--> + <!-- Default plugins <plugins> <plugin> 1.6 +5 -6 maven-components/maven-core/src/test/java/org/apache/maven/MavenTestCase.java Index: MavenTestCase.java =================================================================== RCS file: /home/cvs/maven-components/maven-core/src/test/java/org/apache/maven/MavenTestCase.java,v retrieving revision 1.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- MavenTestCase.java 26 Aug 2004 04:39:53 -0000 1.5 +++ MavenTestCase.java 2 Sep 2004 12:34:17 -0000 1.6 @@ -76,6 +76,7 @@ getContainer().addContextValue( "rootClassRealm", rootClassRealm ); + // TODO: are these used? Are they correct? getContainer().addContextValue( "maven.home", new File( getBasedir(), "target/maven.home" ).getPath() ); getContainer().addContextValue( "maven.home.local", @@ -105,13 +106,13 @@ if ( pom != null ) { - project = projectBuilder.build( pom, localRepository ); + project = projectBuilder.build( pom ); } else { File f = new File( basedir, "target/test-classes/pom.xml" ); - project = projectBuilder.build( f, localRepository ); + project = projectBuilder.build( f ); } return createGoalExecutionContext( project, localRepository, goal ); @@ -120,8 +121,6 @@ protected MavenGoalExecutionContext createGoalExecutionContext( MavenProject project, ArtifactRepository localRepository, String goal ) { - project.setProperty( "foo", "bar" ); - List goals = new ArrayList(); MavenSession session = new MavenSession( getContainer(), pluginManager, project, localRepository, goals ); @@ -143,4 +142,4 @@ return context; } -} \ No newline at end of file +} 1.3 +1 -2 maven-components/maven-core/src/test/java/org/apache/maven/lifecycle/goal/phase/GoalResolutionPhaseTest.java Index: GoalResolutionPhaseTest.java =================================================================== RCS file: /home/cvs/maven-components/maven-core/src/test/java/org/apache/maven/lifecycle/goal/phase/GoalResolutionPhaseTest.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- GoalResolutionPhaseTest.java 26 Aug 2004 04:40:00 -0000 1.2 +++ GoalResolutionPhaseTest.java 2 Sep 2004 12:34:17 -0000 1.3 @@ -264,7 +264,6 @@ model.setPostGoals( postGoals ); MavenProject project = new MavenProject( model ); - project.setProperties( new TreeMap() ); MavenGoalExecutionContext context = createGoalExecutionContext( project, localRepository, mainGoal ); context.setGoalName( mainGoal ); @@ -292,4 +291,4 @@ assertEquals( failureMessage, goal, resolvedGoal ); } } -} \ No newline at end of file +} 1.5 +2 -18 maven-components/maven-core/src/test/java/org/apache/maven/plugin/OgnlProjectValueExtractorTest.java Index: OgnlProjectValueExtractorTest.java =================================================================== RCS file: /home/cvs/maven-components/maven-core/src/test/java/org/apache/maven/plugin/OgnlProjectValueExtractorTest.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- OgnlProjectValueExtractorTest.java 15 Aug 2004 15:01:52 -0000 1.4 +++ OgnlProjectValueExtractorTest.java 2 Sep 2004 12:34:18 -0000 1.5 @@ -30,25 +30,9 @@ File f = new File( basedir, "src/test/resources/pom.xml" ); - project = builder.build( f, new ArtifactRepository() ); - - project.setProperty( "foo", "bar" ); + project = builder.build( f ); context = createGoalExecutionContext(); - } - - public void testPropertyValueExtraction() - { - Object value = OgnlProjectValueExtractor.evaluate( "#foo", context ); - - assertEquals( "bar", value ); - } - - public void testValueExtractionWithAPropertyContainingAPath() - { - Object value = OgnlProjectValueExtractor.evaluate( "#foo/META-INF/maven", context ); - - assertEquals( "bar/META-INF/maven", value ); } public void testValueExtractionWithAPomValueContainingAPath() 1.3 +4 -26 maven-components/maven-core/src/test/java/org/apache/maven/project/AbstractProjectTestCase.java Index: AbstractProjectTestCase.java =================================================================== RCS file: /home/cvs/maven-components/maven-core/src/test/java/org/apache/maven/project/AbstractProjectTestCase.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- AbstractProjectTestCase.java 12 Aug 2004 17:55:48 -0000 1.2 +++ AbstractProjectTestCase.java 2 Sep 2004 12:34:18 -0000 1.3 @@ -32,43 +32,21 @@ return localRepository; } - public void initLocalRepository() - { - File tempLocalRepository = new File( getBasedir(), "target/temp-repo-local" ); - - // delete - try - { - FileUtils.deleteDirectory( tempLocalRepository ); - } - catch ( Exception e ) - { - System.out.println( "Could not delete the remaining from previous tests!! Test will continue anyway " ); - - } - - tempLocalRepository.mkdirs(); - - System.out.println( "Created temporary local repository: " + tempLocalRepository ); - - System.setProperty( "maven.repo.local", tempLocalRepository.getPath() ); - } - - protected MavenProject buildProject( File f, ArtifactRepository localRepository, boolean followTransitiveDeps ) + protected MavenProject buildProject( File f, boolean followTransitiveDeps ) throws Exception { MavenProject project; - project = projectBuilder.build( f, localRepository, followTransitiveDeps ); + project = projectBuilder.build( f, followTransitiveDeps ); assertNotNull( "Project is null", project ); return project; } - protected MavenProject buildProject( File f, ArtifactRepository localRepository ) + protected MavenProject buildProject( File f ) throws Exception { - return buildProject( f, localRepository, false ); + return buildProject( f, false ); } } 1.2 +2 -2 maven-components/maven-core/src/test/java/org/apache/maven/project/ProjectBaseDirectoryAlignmentTest.java Index: ProjectBaseDirectoryAlignmentTest.java =================================================================== RCS file: /home/cvs/maven-components/maven-core/src/test/java/org/apache/maven/project/ProjectBaseDirectoryAlignmentTest.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- ProjectBaseDirectoryAlignmentTest.java 9 Aug 2004 19:02:38 -0000 1.1 +++ ProjectBaseDirectoryAlignmentTest.java 2 Sep 2004 12:34:18 -0000 1.2 @@ -17,7 +17,7 @@ { File f = new File( basedir, dir + "project-which-needs-directory-alignment.xml" ); - MavenProject project = projectBuilder.build( f, getLocalRepository(), false ); + MavenProject project = projectBuilder.build( f, false ); assertNotNull( "Test project can't be null!", project ); @@ -32,7 +32,7 @@ assertTrue( resource.getDirectory().startsWith( basedir ) ); } - /* + /* TODO: why commented out? public void testProjectDirectoryBaseDirectoryAlignmentInheritance() throws Exception { 1.2 +5 -9 maven-components/maven-core/src/test/java/org/apache/maven/project/inheritance/ProjectInheritanceTestCase.java Index: ProjectInheritanceTestCase.java =================================================================== RCS file: /home/cvs/maven-components/maven-core/src/test/java/org/apache/maven/project/inheritance/ProjectInheritanceTestCase.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- ProjectInheritanceTestCase.java 9 Aug 2004 19:02:39 -0000 1.1 +++ ProjectInheritanceTestCase.java 2 Sep 2004 12:34:18 -0000 1.2 @@ -31,17 +31,13 @@ super.setUp(); projectBuilder = (MavenProjectBuilder) lookup( MavenProjectBuilder.ROLE ); + + System.setProperty( "maven.repo.local", getLocalRepository() ); } - protected ArtifactRepository getLocalRepository() + private String getLocalRepository() { - ArtifactRepository r = new ArtifactRepository(); - - String s = new File( basedir, "src/test/resources/inheritance-repo/" + getTestSeries() ).getPath(); - - r.setUrl( "file://" + s ); - - return r; + return new File( basedir, "src/test/resources/inheritance-repo/" + getTestSeries() ).getPath(); } protected File projectFile( String name ) 1.2 +2 -2 maven-components/maven-core/src/test/java/org/apache/maven/project/inheritance/t00/ProjectInheritanceTest.java Index: ProjectInheritanceTest.java =================================================================== RCS file: /home/cvs/maven-components/maven-core/src/test/java/org/apache/maven/project/inheritance/t00/ProjectInheritanceTest.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- ProjectInheritanceTest.java 9 Aug 2004 19:02:39 -0000 1.1 +++ ProjectInheritanceTest.java 2 Sep 2004 12:34:18 -0000 1.2 @@ -36,7 +36,7 @@ public void testProjectInheritance() throws Exception { - MavenProject p4 = projectBuilder.build( projectFile( "p4" ), getLocalRepository() ); + MavenProject p4 = projectBuilder.build( projectFile( "p4" ) ); assertEquals( "p4", p4.getName() ); 1.2 +6 -6 maven-components/maven-core/src/test/java/org/apache/maven/project/inheritance/t01/ProjectInheritanceTest.java Index: ProjectInheritanceTest.java =================================================================== RCS file: /home/cvs/maven-components/maven-core/src/test/java/org/apache/maven/project/inheritance/t01/ProjectInheritanceTest.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- ProjectInheritanceTest.java 9 Aug 2004 19:02:39 -0000 1.1 +++ ProjectInheritanceTest.java 2 Sep 2004 12:34:18 -0000 1.2 @@ -39,7 +39,7 @@ // Check p0 value for org name // ---------------------------------------------------------------------- - MavenProject p0 = projectBuilder.build( projectFile( "p0" ), getLocalRepository() ); + MavenProject p0 = projectBuilder.build( projectFile( "p0" ) ); assertEquals( "p0-org", p0.getOrganization().getName() ); @@ -47,7 +47,7 @@ // Check p1 value for org name // ---------------------------------------------------------------------- - MavenProject p1 = projectBuilder.build( projectFile( "p1" ), getLocalRepository() ); + MavenProject p1 = projectBuilder.build( projectFile( "p1" ) ); assertEquals( "p1-org", p1.getOrganization().getName() ); @@ -55,7 +55,7 @@ // Check p2 value for org name // ---------------------------------------------------------------------- - MavenProject p2 = projectBuilder.build( projectFile( "p2" ), getLocalRepository() ); + MavenProject p2 = projectBuilder.build( projectFile( "p2" ) ); assertEquals( "p2-org", p2.getOrganization().getName() ); @@ -63,7 +63,7 @@ // Check p2 value for org name // ---------------------------------------------------------------------- - MavenProject p3 = projectBuilder.build( projectFile( "p3" ), getLocalRepository() ); + MavenProject p3 = projectBuilder.build( projectFile( "p3" ) ); assertEquals( "p3-org", p3.getOrganization().getName() ); @@ -71,7 +71,7 @@ // Check p4 value for org name // ---------------------------------------------------------------------- - MavenProject p4 = projectBuilder.build( projectFile( "p4" ), getLocalRepository() ); + MavenProject p4 = projectBuilder.build( projectFile( "p4" ) ); assertEquals( "p4-org", p4.getOrganization().getName() ); } 1.14 +15 -3 maven-components/maven-core-it/maven-core-it.sh Index: maven-core-it.sh =================================================================== RCS file: /home/cvs/maven-components/maven-core-it/maven-core-it.sh,v retrieving revision 1.13 retrieving revision 1.14 diff -u -r1.13 -r1.14 --- maven-core-it.sh 15 Aug 2004 16:52:07 -0000 1.13 +++ maven-core-it.sh 2 Sep 2004 12:34:18 -0000 1.14 @@ -10,6 +10,17 @@ integration_tests=`cat integration-tests.txt | egrep -v '^#'` +# TODO: this is rubbish. Let's rewrite this in java +local_repo=`cat $HOME/.m2/pom.xml | tr '\n' ' ' | sed 's/^.*<local> *<repository>//' | sed 's#</repository> *</local>.*$##'` + +for i in "$@" +do + j=`echo $i | sed 's/^-Dmaven.repo.local=//'` + if [ "$i" != "$j" ]; then + local_repo=$j + fi +done + for integration_test in $integration_tests do ( @@ -18,11 +29,11 @@ if [ -f prebuild.hook ] then echo - sh prebuild.hook + sh prebuild.hook "$local_repo" echo fi - m2 clean:clean `cat goals.txt` + m2 -Dmaven.repo.local="$local_repo" clean:clean `cat goals.txt` if [ -f postbuild.hook ] then @@ -33,7 +44,7 @@ basedir=. - java -cp "$cp" $verifier "$basedir" + java -cp "$cp" $verifier "$basedir" "$local_repo" ) > ${integration_test}-log.txt if [ "$?" = "0" ] @@ -47,3 +58,4 @@ fi done + 1.2 +5 -5 maven-components/maven-core-it/it0002/expected-results.txt Index: expected-results.txt =================================================================== RCS file: /home/cvs/maven-components/maven-core-it/it0002/expected-results.txt,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- expected-results.txt 17 Jun 2004 19:36:02 -0000 1.1 +++ expected-results.txt 2 Sep 2004 12:34:18 -0000 1.2 @@ -1,5 +1,5 @@ -target/classes/org/apache/maven/it0001/Person.class -target/test-classes/org/apache/maven/it0001/PersonTest.class -target/maven-core-it0001-1.0.jar -target/maven-core-it0001-1.0.jar!/it0001.properties -${maven.repo.local}/maven/jars/maven-it-support-1.0.jar +target/classes/org/apache/maven/it0002/Person.class +target/test-classes/org/apache/maven/it0002/PersonTest.class +target/maven-core-it0002-1.0.jar +target/maven-core-it0002-1.0.jar!/it0002.properties +${localRepository}/maven/jars/maven-it-support-1.0.jar 1.3 +1 -3 maven-components/maven-core-it/it0002/prebuild.hook Index: prebuild.hook =================================================================== RCS file: /home/cvs/maven-components/maven-core-it/it0002/prebuild.hook,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- prebuild.hook 27 Jul 2004 13:23:35 -0000 1.2 +++ prebuild.hook 2 Sep 2004 12:34:18 -0000 1.3 @@ -1,7 +1,5 @@ #!/bin/sh -repoLocal=`cat $HOME/maven.properties | grep "maven.repo.local" | sed 's/^.*= *//'` - echo "Removing maven-it-support-1.0.jar from the local repository so we can verify its downloading ..." -rm -f $repoLocal/maven/jars/maven-it-support-1.0.jar > /dev/null 2>&1 +rm -f $1/maven/jars/maven-it-support-1.0.jar > /dev/null 2>&1 1.2 +1 -1 maven-components/maven-core-it/it0003/expected-results.txt Index: expected-results.txt =================================================================== RCS file: /home/cvs/maven-components/maven-core-it/it0003/expected-results.txt,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- expected-results.txt 18 Jun 2004 02:08:37 -0000 1.1 +++ expected-results.txt 2 Sep 2004 12:34:18 -0000 1.2 @@ -2,4 +2,4 @@ target/test-classes/org/apache/maven/it0003/PersonTest.class target/maven-core-it0003-1.0.jar target/maven-core-it0003-1.0.jar!/it0003.properties -${maven.repo.local}/maven/jars/maven-core-it0003-1.0.jar +${localRepository}/maven/jars/maven-core-it0003-1.0.jar 1.3 +1 -3 maven-components/maven-core-it/it0003/prebuild.hook Index: prebuild.hook =================================================================== RCS file: /home/cvs/maven-components/maven-core-it/it0003/prebuild.hook,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- prebuild.hook 27 Jul 2004 13:23:35 -0000 1.2 +++ prebuild.hook 2 Sep 2004 12:34:18 -0000 1.3 @@ -1,7 +1,5 @@ #!/bin/sh -repoLocal=`cat $HOME/maven.properties | grep "maven.repo.local" | sed 's/^.*= *//'` - echo "Removing maven-core-it0003-1.0.jar from the local repository so we can verify jar installation ..." -rm -f $repoLocal/maven/jars/maven-core-it0003-1.0.jar > /dev/null 2>&1 +rm -f $1/maven/jars/maven-core-it0003-1.0.jar > /dev/null 2>&1 1.2 +1 -1 maven-components/maven-core-it/it0004/expected-results.txt Index: expected-results.txt =================================================================== RCS file: /home/cvs/maven-components/maven-core-it/it0004/expected-results.txt,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- expected-results.txt 5 Jul 2004 16:53:16 -0000 1.1 +++ expected-results.txt 2 Sep 2004 12:34:18 -0000 1.2 @@ -1 +1 @@ -${maven.repo.local}/maven/poms/maven-core-it0004-1.0.pom +${localRepository}/maven/poms/maven-core-it0004-1.0.pom 1.3 +1 -3 maven-components/maven-core-it/it0004/prebuild.hook Index: prebuild.hook =================================================================== RCS file: /home/cvs/maven-components/maven-core-it/it0004/prebuild.hook,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- prebuild.hook 27 Jul 2004 13:23:35 -0000 1.2 +++ prebuild.hook 2 Sep 2004 12:34:18 -0000 1.3 @@ -1,7 +1,5 @@ #!/bin/sh -repoLocal=`cat $HOME/maven.properties | grep "maven.repo.local" | sed 's/^.*= *//'` - echo "Removing maven-core-it0004-1.0.pom from the local repository so we can verify pom installation ..." -rm -f $repoLocal/maven/poms/maven-core-it0004-1.0.pom > /dev/null 2>&1 +rm -f $1/maven/poms/maven-core-it0004-1.0.pom > /dev/null 2>&1 1.3 +1 -1 maven-components/maven-core-it/it0005/expected-results.txt Index: expected-results.txt =================================================================== RCS file: /home/cvs/maven-components/maven-core-it/it0005/expected-results.txt,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- expected-results.txt 15 Aug 2004 16:18:21 -0000 1.2 +++ expected-results.txt 2 Sep 2004 12:34:18 -0000 1.3 @@ -1 +1 @@ -${maven.repo.local}/maven/poms/maven-core-it0005-1.0-SNAPSHOT.pom +${localRepository}/maven/poms/maven-core-it0005-1.0-SNAPSHOT.pom 1.4 +1 -3 maven-components/maven-core-it/it0005/prebuild.hook Index: prebuild.hook =================================================================== RCS file: /home/cvs/maven-components/maven-core-it/it0005/prebuild.hook,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- prebuild.hook 15 Aug 2004 16:18:21 -0000 1.3 +++ prebuild.hook 2 Sep 2004 12:34:18 -0000 1.4 @@ -1,7 +1,5 @@ #!/bin/sh -repoLocal=`cat $HOME/maven.properties | grep "maven.repo.local" | sed 's/^.*= *//'` - echo "Removing maven-core-it0005-1.0.pom from the local repository so we can verify pom installation ..." -rm -f $repoLocal/maven/poms/maven-core-it0005-1.0-SNAPSHOT.pom > /dev/null 2>&1 +rm -f $1/maven/poms/maven-core-it0005-1.0-SNAPSHOT.pom > /dev/null 2>&1 1.3 +1 -1 maven-components/maven-core-it/it0007/expected-results.txt Index: expected-results.txt =================================================================== RCS file: /home/cvs/maven-components/maven-core-it/it0007/expected-results.txt,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- expected-results.txt 10 Aug 2004 17:54:40 -0000 1.2 +++ expected-results.txt 2 Sep 2004 12:34:18 -0000 1.3 @@ -2,4 +2,4 @@ target/test-classes/org/apache/maven/it0007/PersonTest.class target/maven-core-it0007-1.0.jar target/maven-core-it0007-1.0.jar!/it0007.properties -${maven.repo.local}/maven/poms/maven-it-support-parent-1.0.pom +${localRepository}/maven/poms/maven-it-support-parent-1.0.pom 1.2 +1 -3 maven-components/maven-core-it/it0007/prebuild.hook Index: prebuild.hook =================================================================== RCS file: /home/cvs/maven-components/maven-core-it/it0007/prebuild.hook,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- prebuild.hook 10 Aug 2004 17:53:37 -0000 1.1 +++ prebuild.hook 2 Sep 2004 12:34:18 -0000 1.2 @@ -1,7 +1,5 @@ #!/bin/sh -repoLocal=`cat $HOME/maven.properties | grep "maven.repo.local" | sed 's/^.*= *//'` - echo "Removing maven-it-support-parent-1.0.pom from the local repository so we can verify its downloading ..." -rm -f $repoLocal/maven/poms/maven-it-support-parent-1.0.pom > /dev/null 2>&1 +rm -f $1/maven/poms/maven-it-support-parent-1.0.pom > /dev/null 2>&1 1.11 +5 -47 maven-components/maven-core-it-verifier/src/main/java/org/apache/maven/it/Verifier.java Index: Verifier.java =================================================================== RCS file: /home/cvs/maven-components/maven-core-it-verifier/src/main/java/org/apache/maven/it/Verifier.java,v retrieving revision 1.10 retrieving revision 1.11 diff -u -r1.10 -r1.11 --- Verifier.java 15 Aug 2004 16:49:32 -0000 1.10 +++ Verifier.java 2 Sep 2004 12:34:18 -0000 1.11 @@ -21,61 +21,19 @@ private String mavenRepoLocal; - public Verifier( String basedir ) + public Verifier( String basedir, String mavenRepoLocal ) { this.basedir = basedir; + this.mavenRepoLocal = mavenRepoLocal; } // ---------------------------------------------------------------------- // // ---------------------------------------------------------------------- - public static String interpolate( String text, Map namespace ) - { - Iterator keys = namespace.keySet().iterator(); - - while ( keys.hasNext() ) - { - String key = keys.next().toString(); - - Object obj = namespace.get( key ); - - String value = obj.toString(); - - text = replace( text, "${" + key + "}", value ); - - if ( key.indexOf( " " ) == -1 ) - { - text = replace( text, "$" + key, value ); - } - } - return text; - } - public void verify() throws VerificationException { - Properties properties = new Properties(); - - try - { - properties.load( new FileInputStream( new File( System.getProperty( "user.home" ), "maven.properties" ) ) ); - - for ( Iterator i = properties.keySet().iterator(); i.hasNext(); ) - { - String key = (String) i.next(); - - properties.setProperty( key, interpolate( properties.getProperty( key ), System.getProperties() ) ); - } - - } - catch ( IOException e ) - { - throw new VerificationException( "Can't find the maven.properties file! Verification can't proceed!" ); - } - - mavenRepoLocal = properties.getProperty( "maven.repo.local" ); - try { BufferedReader reader = new BufferedReader( new FileReader( new File( basedir, "expected-results.txt" ) ) ); @@ -98,7 +56,7 @@ private void verifyExpectedResult( String line ) throws VerificationException { - line = replace( line, "${maven.repo.local}", mavenRepoLocal ); + line = replace( line, "${localRepository}", mavenRepoLocal ); if ( line.indexOf( "!/" ) > 0 ) { @@ -191,7 +149,7 @@ public static void main( String args[] ) { - Verifier verifier = new Verifier( args[0] ); + Verifier verifier = new Verifier( args[0], args[1] ); try { 1.5 +46 -49 maven-components/maven-mboot2/src/main/java/ArtifactDownloader.java Index: ArtifactDownloader.java =================================================================== RCS file: /home/cvs/maven-components/maven-mboot2/src/main/java/ArtifactDownloader.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- ArtifactDownloader.java 14 Aug 2004 06:59:53 -0000 1.4 +++ ArtifactDownloader.java 2 Sep 2004 12:34:18 -0000 1.5 @@ -6,7 +6,6 @@ import java.util.ArrayList; import java.util.Iterator; import java.util.List; -import java.util.Properties; import java.util.StringTokenizer; import java.util.Set; import java.util.HashSet; @@ -21,7 +20,7 @@ private boolean useTimestamp = true; - private boolean ignoreErrors = true; + private boolean ignoreErrors = false; private String proxyHost; @@ -31,26 +30,25 @@ private String proxyPassword; - public ArtifactDownloader( Properties properties ) + public ArtifactDownloader( String localRepository, List remoteRepositories ) throws Exception { - setRemoteRepo( properties.getProperty( "maven.repo.remote" ) ); + setRemoteRepos( remoteRepositories ); - String mavenRepoLocalProperty = properties.getProperty( "maven.repo.local" ); - if ( mavenRepoLocalProperty == null ) + if ( localRepository == null ) { - System.err.println( "maven.repo.local not specified in ~/maven.properties" ); + System.err.println( "local repository not specified" ); System.exit( 1 ); } - mavenRepoLocal = new File( mavenRepoLocalProperty ); + mavenRepoLocal = new File( localRepository ); if ( !mavenRepoLocal.exists() ) { if ( !mavenRepoLocal.mkdirs() ) { - System.err.println( "Cannot create the specified maven.repo.local: " + mavenRepoLocal ); + System.err.println( "Cannot create the specified local repository: " + mavenRepoLocal ); System.exit( 1 ); } @@ -63,7 +61,8 @@ System.exit( 1 ); } - System.out.println( "Using the following for your maven.repo.local: " + mavenRepoLocal ); + System.out.println( "Using the following for your local repository: " + mavenRepoLocal ); + System.out.println( "Using the following for your remote repositories: " + remoteRepos ); } public File getMavenRepoLocal() @@ -78,62 +77,53 @@ { for ( Iterator j = files.iterator(); j.hasNext(); ) { - try + String file = (String) j.next(); + + if ( !downloadedArtifacts.contains( file ) ) { - String file = (String) j.next(); + File destinationFile = new File( mavenRepoLocal, file ); + // The directory structure for this project may + // not exists so create it if missing. + File directory = destinationFile.getParentFile(); - if ( !downloadedArtifacts.contains( file ) ) + if ( directory.exists() == false ) { - File destinationFile = new File( mavenRepoLocal, file ); - // The directory structure for this project may - // not exists so create it if missing. - File directory = destinationFile.getParentFile(); - - if ( directory.exists() == false ) - { - directory.mkdirs(); - } - - if ( destinationFile.exists() && file.indexOf( SNAPSHOT_SIGNATURE ) < 0 ) - { - continue; - } - - getRemoteArtifact( file, destinationFile ); - - if ( !destinationFile.exists() ) - { - throw new Exception( "Failed to download " + file ); - } + directory.mkdirs(); + } - downloadedArtifacts.add( file ); + if ( destinationFile.exists() && file.indexOf( SNAPSHOT_SIGNATURE ) < 0 ) + { + continue; } - } - catch ( Exception e ) - { - throw new Exception( e ); + + getRemoteArtifact( file, destinationFile ); + + if ( !destinationFile.exists() ) + { + throw new Exception( "Failed to download " + file ); + } + + downloadedArtifacts.add( file ); } } } - private void setRemoteRepo( String repos ) + private void setRemoteRepos( List repositories ) { remoteRepos = new ArrayList(); - if ( repos == null ) + if ( repositories != null ) { - remoteRepos.add( "http://www.ibiblio.org/maven/" ); - return; + remoteRepos.addAll( repositories ); } - StringTokenizer st = new StringTokenizer( repos, "," ); - while ( st.hasMoreTokens() ) + if ( repositories.isEmpty() ) { - remoteRepos.add( st.nextToken().trim() ); + remoteRepos.add( "http://www.ibiblio.org/maven/" ); } } - private List getRemoteRepo() + private List getRemoteRepos() { return remoteRepos; } @@ -142,7 +132,7 @@ { boolean fileFound = false; - for ( Iterator i = getRemoteRepo().iterator(); i.hasNext(); ) + for ( Iterator i = getRemoteRepos().iterator(); i.hasNext(); ) { String remoteRepo = (String) i.next(); @@ -162,11 +152,17 @@ url = replace( url, "http:/", "http://" ); } } + else + { + // THe JDK URL for file: should have one or no / instead of // for some reason + url = replace( url, "file://", "file:" ); + } // Attempt to retrieve the artifact and set the checksum if retrieval // of the checksum file was successful. try { + log( "Downloading " + url ); HttpUtils.getFile( url, destinationFile, ignoreErrors, @@ -183,6 +179,7 @@ } catch ( FileNotFoundException e ) { + log( "Artifact not found at [" + url + "]" ); // Ignore } catch ( Exception e ) @@ -204,7 +201,7 @@ // // print a warning, in any case, so user catches on to mistyped // hostnames, or other snafus - log( "Error retrieving artifact from [" + url + "]: " ); + log( "Error retrieving artifact from [" + url + "]: " + e ); } } 1.21 +108 -90 maven-components/maven-mboot2/src/main/java/MBoot.java Index: MBoot.java =================================================================== RCS file: /home/cvs/maven-components/maven-mboot2/src/main/java/MBoot.java,v retrieving revision 1.20 retrieving revision 1.21 diff -u -r1.20 -r1.21 --- MBoot.java 26 Aug 2004 11:50:39 -0000 1.20 +++ MBoot.java 2 Sep 2004 12:34:19 -0000 1.21 @@ -18,7 +18,6 @@ import java.util.Arrays; import java.util.Iterator; import java.util.List; -import java.util.Properties; import java.util.Date; public class MBoot @@ -117,8 +116,6 @@ private ModelReader reader; - private Properties properties; - private String repoLocal; private List mbootDependencies; @@ -142,45 +139,54 @@ public void run( String[] args ) throws Exception { - File mavenPropertiesFile = new File( System.getProperty( "user.home" ), "maven.properties" ); + File userPomFile = new File( System.getProperty( "user.home" ), ".m2/pom.xml" ); - if ( !mavenPropertiesFile.exists() ) + reader = new ModelReader(); + if ( !reader.parse( userPomFile ) ) { - System.out.println( "You must have a ~/maven.properties file and must contain the following entries:" ); - - System.out.println( "maven.home = /path/to/m2/installation" ); - - System.out.println( "maven.repo.local = /path/to/m2/repository" ); + System.out.println( "You must have a ~/.m2/pom.xml file and must contain the following entries:" ); + System.out.println( "<local>\n" ); + System.out.println( " <repository>/path/to/m2/repository</repository> (required)\n" ); + System.out.println( " <online>true</online> (optional)\n" ); + System.out.println( "</local>" ); System.exit( 1 ); } - Date fullStop; + String mavenHome = null; - Date fullStart = new Date(); + if ( args.length == 1 ) + { + mavenHome = args[0]; + } + else + { + mavenHome = System.getProperty( "maven.home" ); + + if ( mavenHome == null ) + { + mavenHome = new File( System.getProperty( "user.home" ), "m2" ).getAbsolutePath(); + } + } - properties = loadProperties( mavenPropertiesFile ); + File dist = new File( mavenHome ); - // Make the system properties override maven.properties - properties.putAll( System.getProperties() ); + System.out.println( "Maven installation directory: " + dist ); - for ( Iterator i = properties.keySet().iterator(); i.hasNext(); ) - { - String key = (String) i.next(); + Date fullStop; - // TODO: the namespace should be "properties" itself to support variables within the same file, - // however, StringUtils would need to support recursive replacement - properties.setProperty( key, StringUtils.interpolate( properties.getProperty( key ), System.getProperties() ) ); - } + Date fullStart = new Date(); - String onlineProperty = properties.getProperty( "maven.online" ); + String onlineProperty = System.getProperty( "maven.online", reader.getLocal().getOnline() ); if ( onlineProperty != null && onlineProperty.equals( "false" ) ) { online = false; } - downloader = new ArtifactDownloader( properties ); + String mavenRepoLocal = System.getProperty( "maven.repo.local", reader.getLocal().getRepository() ); + + downloader = new ArtifactDownloader( mavenRepoLocal, reader.getRemoteRepositories() ); repoLocal = downloader.getMavenRepoLocal().getPath(); @@ -250,24 +256,6 @@ // build the installation - String mavenHome; - - if ( args.length == 1 ) - { - mavenHome = args[0]; - } - else - { - mavenHome = properties.getProperty( "maven.home" ); - - if ( mavenHome == null ) - { - mavenHome = new File( System.getProperty( "user.home" ), "m2" ).getAbsolutePath(); - } - } - - File dist = new File( mavenHome ); - FileUtils.deleteDirectory( dist ); // ---------------------------------------------------------------------- @@ -328,7 +316,8 @@ d.artifactId.equals( "xpp3" ) || d.artifactId.equals( "junit" ) || d.artifactId.equals( "wagon-api" ) || - d.artifactId.equals( "maven-artifact" ) ) + d.artifactId.equals( "maven-artifact" ) +) { continue; } @@ -845,53 +834,6 @@ return d.getArtifactDirectory() + pathSeparator + "jars" + pathSeparator + d.getArtifact(); } - private Properties loadProperties( File file ) - { - try - { - return loadProperties( new FileInputStream( file ) ); - } - catch ( Exception e ) - { - // ignore - } - - return new Properties(); - } - - private static Properties loadProperties( InputStream is ) - { - Properties properties = new Properties(); - - try - { - if ( is != null ) - { - properties.load( is ); - } - } - catch ( IOException e ) - { - // ignore - } - finally - { - try - { - if ( is != null ) - { - is.close(); - } - } - catch ( IOException e ) - { - // ignore - } - } - - return properties; - } - class ModelReader extends DefaultHandler { @@ -911,8 +853,12 @@ private List dependencies = new ArrayList(); + private List remoteRepositories = new ArrayList(); + private UnitTests unitTests; + private Local local = new Local(); + private List resources = new ArrayList(); private Dependency currentDependency; @@ -925,10 +871,14 @@ private boolean insideDependency = false; + private boolean insideLocal = false; + private boolean insideUnitTest = false; private boolean insideResource = false; + private boolean insideRepository = false; + private StringBuffer bodyText = new StringBuffer(); private File file; @@ -938,6 +888,11 @@ dependencies = new ArrayList(); } + public List getRemoteRepositories() + { + return remoteRepositories; + } + public List getDependencies() { return dependencies; @@ -953,6 +908,11 @@ return resources; } + public Local getLocal() + { + return local; + } + public boolean parse( File file ) { this.file = file; @@ -983,6 +943,14 @@ { insideParent = true; } + else if ( rawName.equals( "repository" ) && !insideLocal ) + { + insideRepository = true; + } + else if ( rawName.equals( "local" ) ) + { + insideLocal = true; + } else if ( rawName.equals( "unitTest" ) ) { unitTests = new UnitTests(); @@ -1053,6 +1021,10 @@ insideParent = false; } + else if ( rawName.equals( "local" ) ) + { + insideLocal = false; + } else if ( rawName.equals( "unitTest" ) ) { insideUnitTest = false; @@ -1164,6 +1136,24 @@ { type = getBodyText(); } + else if ( rawName.equals( "repository" ) ) + { + if ( insideLocal ) + { + local.repository = getBodyText(); + } + else + { + insideRepository = false; + } + } + else if ( insideRepository ) + { + if ( rawName.equals( "url" ) ) + { + remoteRepositories.add( getBodyText() ); + } + } bodyText = new StringBuffer(); } @@ -1450,5 +1440,33 @@ {
{'source': 'Apache Software Foundation Public Mail Archives'}