maven2-core-2.2.1/0000755000175000017500000000000011250552246013572 5ustar twernertwernermaven2-core-2.2.1/maven-core/0000755000175000017500000000000011250552241015621 5ustar twernertwernermaven2-core-2.2.1/maven-core/src/0000755000175000017500000000000011250552241016410 5ustar twernertwernermaven2-core-2.2.1/maven-core/src/site/0000755000175000017500000000000011250552241017354 5ustar twernertwernermaven2-core-2.2.1/maven-core/src/site/site.xml0000644000175000017500000000013211002611514021030 0ustar twernertwerner maven2-core-2.2.1/maven-core/src/test/0000755000175000017500000000000011250552240017366 5ustar twernertwernermaven2-core-2.2.1/maven-core/src/test/resources/0000755000175000017500000000000011250552240021400 5ustar twernertwernermaven2-core-2.2.1/maven-core/src/test/resources/remote-repo-1/0000755000175000017500000000000011250552240023774 5ustar twernertwernermaven2-core-2.2.1/maven-core/src/test/resources/remote-repo-1/maven-test/0000755000175000017500000000000011250552240026057 5ustar twernertwernermaven2-core-2.2.1/maven-core/src/test/resources/remote-repo-1/maven-test/poms/0000755000175000017500000000000011250552240027035 5ustar twernertwernermaven2-core-2.2.1/maven-core/src/test/resources/remote-repo-1/maven-test/poms/maven-test-b-1.0.pom0000644000175000017500000000104010213722135032343 0ustar twernertwerner maven-test maven-test-a jar maven-test maven-test-b 1.0 jar compile maven-test maven-test-z 1.0 jar compile maven2-core-2.2.1/maven-core/src/test/resources/remote-repo-1/maven-test/jars/0000755000175000017500000000000011250552240027016 5ustar twernertwerner././@LongLink0000000000000000000000000000014700000000000011567 Lustar rootrootmaven2-core-2.2.1/maven-core/src/test/resources/remote-repo-1/maven-test/jars/maven-test-b-1.0.jar.md5maven2-core-2.2.1/maven-core/src/test/resources/remote-repo-1/maven-test/jars/maven-test-b-1.0.jar.m0000644000175000017500000000004110154505607032547 0ustar twernertwernera5c3b5cd0605bb7331d1846cdc14b13b maven2-core-2.2.1/maven-core/src/test/resources/remote-repo-1/snapshot-test/0000755000175000017500000000000011250552240026610 5ustar twernertwernermaven2-core-2.2.1/maven-core/src/test/resources/remote-repo-1/snapshot-test/jars/0000755000175000017500000000000011250552240027547 5ustar twernertwerner././@LongLink0000000000000000000000000000020400000000000011561 Lustar rootrootmaven2-core-2.2.1/maven-core/src/test/resources/remote-repo-1/snapshot-test/jars/maven-snapshot-b-1.0-SNAPSHOT.jar.snapshot-versionmaven2-core-2.2.1/maven-core/src/test/resources/remote-repo-1/snapshot-test/jars/maven-snapshot-b-1.0000644000175000017500000000001710154505607033075 0ustar twernertwerner20030101.101010././@LongLink0000000000000000000000000000020400000000000011561 Lustar rootrootmaven2-core-2.2.1/maven-core/src/test/resources/remote-repo-1/snapshot-test/jars/maven-snapshot-a-1.0-SNAPSHOT.jar.snapshot-versionmaven2-core-2.2.1/maven-core/src/test/resources/remote-repo-1/snapshot-test/jars/maven-snapshot-a-1.0000644000175000017500000000001710154505607033074 0ustar twernertwerner20050101.101010././@LongLink0000000000000000000000000000020400000000000011561 Lustar rootrootmaven2-core-2.2.1/maven-core/src/test/resources/remote-repo-1/snapshot-test/jars/maven-snapshot-c-1.0-SNAPSHOT.jar.snapshot-versionmaven2-core-2.2.1/maven-core/src/test/resources/remote-repo-1/snapshot-test/jars/maven-snapshot-c-1.0000644000175000017500000000002010154507145033067 0ustar twernertwerner20040101.101010 maven2-core-2.2.1/maven-core/src/test/resources/org/0000755000175000017500000000000011250552240022167 5ustar twernertwernermaven2-core-2.2.1/maven-core/src/test/resources/org/apache/0000755000175000017500000000000011250552240023410 5ustar twernertwernermaven2-core-2.2.1/maven-core/src/test/resources/org/apache/maven/0000755000175000017500000000000011250552240024516 5ustar twernertwernermaven2-core-2.2.1/maven-core/src/test/resources/org/apache/maven/WagonSelectorTest.xml0000644000175000017500000000200111232077172030653 0ustar twernertwerner org.apache.maven.execution.RuntimeInformation org.apache.maven.WagonSelectorTest$TestRuntimeInformation maven2-core-2.2.1/maven-core/src/test/resources/org/apache/maven/plugin/0000755000175000017500000000000011250552240026014 5ustar twernertwerner././@LongLink0000000000000000000000000000016300000000000011565 Lustar rootrootmaven2-core-2.2.1/maven-core/src/test/resources/org/apache/maven/plugin/PluginParameterExpressionEvaluatorTest.xmlmaven2-core-2.2.1/maven-core/src/test/resources/org/apache/maven/plugin/PluginParameterExpressionEva0000644000175000017500000000377310551365651033577 0ustar twernertwerner org.apache.maven.project.MavenProjectBuilder org.apache.maven.project.DefaultMavenProjectBuilder org.apache.maven.project.injection.ModelDefaultsInjector org.apache.maven.project.interpolation.ModelInterpolator org.apache.maven.project.inheritance.ModelInheritanceAssembler org.apache.maven.project.validation.ModelValidator org.apache.maven.project.path.PathTranslator org.apache.maven.artifact.factory.ArtifactFactory org.apache.maven.artifact.resolver.ArtifactResolver org.apache.maven.artifact.repository.ArtifactRepositoryFactory maven2-core-2.2.1/maven-core/src/test/resources/projects/0000755000175000017500000000000011250552240023231 5ustar twernertwernermaven2-core-2.2.1/maven-core/src/test/resources/projects/bad-project.xml0000644000175000017500000000142210551365651026157 0ustar twernertwerneri want to be a POM!maven2-core-2.2.1/maven-core/src/test/resources/projects/child-with-bogus-parent.xml0000644000175000017500000000166310551365651030434 0ustar twernertwerner ${basedir}/bogus.xml maven bogus 1.0-beta-9 maven2-core-2.2.1/maven-core/src/test/resources/projects/fully-populated-child.xml0000644000175000017500000001137410551365651030203 0ustar twernertwerner project.xml maven maven-project-test 1.0-beta-9 3 maven maven Maven 1.0-beta-9 2001 org.apache.maven Description shortDescription http://maven.apache.org/ issueTrackingUrl childDistributionRepositoryId childDistributionRepositoryName childDistributionRepository childSiteDistributionId childSiteDistributionName childSiteDistributionUrl Apache Software Foundation http://apache.org/ /images/jakarta-logo-blue.gif anon-connection developer-connection repository-url Maven User List subscribe unsubscribe archive Jason van Zyl jvanzyl jason@maven.org Zenplex Founder Release Manager Martin van dem Bemt mvdb@mvdb.com g1 d1 1.0 d1-url g2 d2 2.0 d2-url jason@maven.org /sourceDirectory /unitTestSourceDirectory **/*Test.java **/RepositoryTest.java **/JAXPTest.java ${basedir}/src/test **/*.xml /src/conf *.xsd *.dtd *.mod log4j.properties driver.jelly driver.properties /src/messages org/apache/maven/messages messages*.properties maven-jdepend-plugin maven-checkstyle-plugin maven-changelog-plugin maven-file-activity-plugin maven-developer-activity-plugin maven-javadoc-plugin maven-jxr-plugin maven-junit-report-plugin maven-tasklist-plugin maven-jellydoc-plugin maven2-core-2.2.1/maven-core/src/test/resources/projects/build.properties0000644000175000017500000000143710551365651026466 0ustar twernertwerner# Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. The ASF licenses this file # to you under the Apache License, Version 2.0 (the # "License"); you may not use this file except in compliance # with the License. You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed on an # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY # KIND, either express or implied. See the License for the # specific language governing permissions and limitations # under the License. name = sarel maven2-core-2.2.1/maven-core/src/test/resources/projects/child-which-inherits-from-super-model.xml0000644000175000017500000000167410551365651033177 0ustar twernertwerner foo bar Babar 4.5 maven2-core-2.2.1/maven-core/src/test/resources/projects/child.xml0000644000175000017500000000203510551365651025051 0ustar twernertwerner project.xml maven maven-project-test 1.0-beta-9 child-artifact maven 1.0-beta-9 maven2-core-2.2.1/maven-core/src/test/resources/projects/project.xml0000644000175000017500000001110610551365651025433 0ustar twernertwerner 3 maven maven-project-test Maven 1.0-beta-9 2001 org.apache.maven Description shortDescription http://maven.apache.org/ issueTrackingUrl distributionRepositoryId distributionRepositoryName distributionRepository siteDistributionId siteDistributionName siteDistributionUrl Apache Software Foundation http://apache.org/ /images/jakarta-logo-blue.gif anon-connection developer-connection repository-url Maven User List subscribe unsubscribe archive Jason van Zyl jvanzyl jason@maven.org Zenplex Founder Release Manager Martin van dem Bemt mvdb@mvdb.com g1 d1 1.0 d1-url g2 d2 2.0 d2-url jason@maven.org /sourceDirectory /unitTestSourceDirectory **/*Test.java **/RepositoryTest.java **/JAXPTest.java ${basedir}/src/test **/*.xml /src/conf *.xsd *.dtd *.mod log4j.properties driver.jelly driver.properties /src/messages org/apache/maven/messages messages*.properties maven-jdepend-plugin maven-checkstyle-plugin maven-changelog-plugin maven-file-activity-plugin maven-developer-activity-plugin maven-javadoc-plugin maven-jxr-plugin maven-junit-report-plugin maven-tasklist-plugin maven-jellydoc-plugin maven2-core-2.2.1/maven-core/src/test/resources/remote-repo-2/0000755000175000017500000000000011250552240023775 5ustar twernertwernermaven2-core-2.2.1/maven-core/src/test/resources/remote-repo-2/maven-test/0000755000175000017500000000000011250552240026060 5ustar twernertwernermaven2-core-2.2.1/maven-core/src/test/resources/remote-repo-2/maven-test/jars/0000755000175000017500000000000011250552240027017 5ustar twernertwernermaven2-core-2.2.1/maven-core/src/test/resources/pom.xml0000644000175000017500000000330210551365651022726 0ustar twernertwerner 4.0.0 org.apache.maven maven-core jar Maven 2.0-SNAPSHOT 2001 org.apache.maven maven-model 2.0-SNAPSHOT jar compile org.apache.maven maven-plugin 2.0-SNAPSHOT jar compile scm-connection maven2-core-2.2.1/maven-core/src/test/java/0000755000175000017500000000000011250552240020307 5ustar twernertwernermaven2-core-2.2.1/maven-core/src/test/java/org/0000755000175000017500000000000011250552240021076 5ustar twernertwernermaven2-core-2.2.1/maven-core/src/test/java/org/apache/0000755000175000017500000000000011250552240022317 5ustar twernertwernermaven2-core-2.2.1/maven-core/src/test/java/org/apache/maven/0000755000175000017500000000000011250552240023425 5ustar twernertwernermaven2-core-2.2.1/maven-core/src/test/java/org/apache/maven/MavenTestUtils.java0000644000175000017500000000400110551365651027225 0ustar twernertwernerpackage org.apache.maven; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import org.codehaus.classworlds.ClassRealm; import org.codehaus.classworlds.ClassWorld; import org.codehaus.plexus.DefaultPlexusContainer; import org.codehaus.plexus.PlexusContainer; import java.io.File; /** * This is a utility class for helping to configure a PlexusTestCase for testing with maven. * * @author Trygve Laugstøl * @version $Id: MavenTestUtils.java 495147 2007-01-11 07:47:53Z jvanzyl $ */ public class MavenTestUtils { private MavenTestUtils() { } public static PlexusContainer getContainerInstance() { return new DefaultPlexusContainer(); } public static void customizeContext( PlexusContainer container, File basedir, File mavenHome, File mavenHomeLocal ) throws Exception { ClassWorld classWorld = new ClassWorld(); ClassRealm rootClassRealm = classWorld.newRealm( "root", Thread.currentThread().getContextClassLoader() ); container.addContextValue( "rootClassRealm", rootClassRealm ); container.addContextValue( "maven.home", mavenHome.getAbsolutePath() ); container.addContextValue( "maven.home.local", mavenHomeLocal.getAbsolutePath() ); } } maven2-core-2.2.1/maven-core/src/test/java/org/apache/maven/cli/0000755000175000017500000000000011250552240024174 5ustar twernertwernermaven2-core-2.2.1/maven-core/src/test/java/org/apache/maven/cli/ConsoleDownloadMonitorTest.java0000644000175000017500000000633611147433541032360 0ustar twernertwernerpackage org.apache.maven.cli; import org.apache.maven.wagon.resource.Resource; import org.apache.maven.wagon.WagonConstants; import java.io.ByteArrayOutputStream; import java.io.PrintWriter; import java.io.PrintStream; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ /** * Test for {@link ConsoleDownloadMonitor} * * @author Carlos Sanchez * @version $Id: ConsoleDownloadMonitorTest.java 746136 2009-02-20 04:53:53Z brett $ */ public class ConsoleDownloadMonitorTest extends AbstractConsoleDownloadMonitorTest { ByteArrayOutputStream bout; protected void setUp() throws Exception { super.setMonitor( new ConsoleDownloadMonitor() ); super.setUp(); bout = new ByteArrayOutputStream(); monitor.out = new PrintStream(bout); } public void testTransferProgress() throws Exception { byte[] buffer = new byte[1024]; monitor.transferProgress( new TransferEventMock(new Resource(), 10000), buffer, 1024 ); assertEquals("1/9K\r", new String(bout.toByteArray())); } public void testTransferProgressTwoFiles() throws Exception { byte[] buffer = new byte[2048]; monitor.transferProgress( new TransferEventMock(new Resource("foo"), 10000), buffer, 1024 ); assertEquals("1/9K\r", new String(bout.toByteArray())); bout.reset(); monitor.transferProgress( new TransferEventMock(new Resource("bar"), 10000), buffer, 2048 ); assertEquals("1/9K 2/9K\r", new String(bout.toByteArray())); bout.reset(); monitor.transferProgress( new TransferEventMock(new Resource("bar"), 10000), buffer, 2048 ); assertEquals("1/9K 4/9K\r", new String(bout.toByteArray())); bout.reset(); monitor.transferProgress( new TransferEventMock(new Resource("foo"), 10000), buffer, 2048 ); assertEquals("3/9K 4/9K\r", new String(bout.toByteArray())); } public void testGetDownloadStatusForResource() { ConsoleDownloadMonitor cm = (ConsoleDownloadMonitor)monitor; assertEquals("200/400b", cm.getDownloadStatusForResource(200, 400)); assertEquals("1/2K", cm.getDownloadStatusForResource(1024, 2048)); assertEquals("0/2K", cm.getDownloadStatusForResource(10, 2048)); assertEquals("10/?", cm.getDownloadStatusForResource(10, WagonConstants.UNKNOWN_LENGTH)); assertEquals("1024/?", cm.getDownloadStatusForResource(1024, WagonConstants.UNKNOWN_LENGTH)); } } maven2-core-2.2.1/maven-core/src/test/java/org/apache/maven/cli/MavenCliTest.java0000644000175000017500000000646411221205616027407 0ustar twernertwernerpackage org.apache.maven.cli; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import java.util.Properties; import junit.framework.TestCase; /** * Test method for 'org.apache.maven.cli.MavenCli.main(String[], ClassWorld)' * * @author Vincent Siveton * @version $Id: MavenCliTest.java 788791 2009-06-26 17:55:26Z jdcasey $ */ public class MavenCliTest extends TestCase { public void testGetExecutionProperties() throws Exception { System.setProperty( "test.property.1", "1.0" ); System.setProperty( "test.property.2", "2.0" ); Properties execProperties = new Properties(); Properties userProperties = new Properties(); MavenCli.populateProperties( ( new CLIManager() ).parse( new String[] { "-Dtest.property.2=2.1", "-Dtest.property.3=3.0" } ), execProperties, userProperties ); System.out.println( "Execution properties:\n\n" ); execProperties.list( System.out ); System.out.println( "\n\nUser properties:\n\n" ); userProperties.list( System.out ); // assume that everybody has a PATH env var String envPath = execProperties.getProperty( "env.PATH" ); String envPath2 = userProperties.getProperty( "env.PATH" ); if ( envPath == null ) { envPath = execProperties.getProperty( "env.Path" ); envPath2 = userProperties.getProperty( "env.Path" ); } assertNotNull( envPath ); assertNull( envPath2 ); assertEquals( "1.0", execProperties.getProperty( "test.property.1" ) ); assertNull( userProperties.getProperty( "test.property.1" ) ); assertEquals( "3.0", execProperties.getProperty( "test.property.3" ) ); assertEquals( "3.0", userProperties.getProperty( "test.property.3" ) ); // sys props should override cmdline props //assertEquals( "2.0", p.getProperty( "test.property.2" ) ); } public void testGetBuildProperties() throws Exception { Properties properties = MavenCli.getBuildProperties(); assertNotNull( properties.getProperty( "version" ) ); assertNotNull( properties.getProperty( "buildNumber" ) ); assertNotNull( properties.getProperty( "timestamp" ) ); assertFalse( properties.getProperty( "version" ).equals( "${project.version}" ) ); assertFalse( properties.getProperty( "buildNumber" ).equals( "${buildNumber}" ) ); assertFalse( properties.getProperty( "timestamp" ).equals( "${timestamp}" ) ); } } ././@LongLink0000000000000000000000000000015000000000000011561 Lustar rootrootmaven2-core-2.2.1/maven-core/src/test/java/org/apache/maven/cli/AbstractConsoleDownloadMonitorTest.javamaven2-core-2.2.1/maven-core/src/test/java/org/apache/maven/cli/AbstractConsoleDownloadMonitorTest.j0000644000175000017500000000775111147434570033361 0ustar twernertwernerpackage org.apache.maven.cli; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import junit.framework.TestCase; import org.apache.maven.wagon.ConnectionException; import org.apache.maven.wagon.authentication.AuthenticationException; import org.apache.maven.wagon.events.TransferEvent; import org.apache.maven.wagon.providers.file.FileWagon; import org.apache.maven.wagon.repository.Repository; import org.apache.maven.wagon.resource.Resource; /** * Test for {@link AbstractConsoleDownloadMonitor} * * @author Carlos Sanchez * @version $Id: AbstractConsoleDownloadMonitorTest.java 746138 2009-02-20 05:02:48Z brett $ */ public abstract class AbstractConsoleDownloadMonitorTest extends TestCase { protected AbstractConsoleDownloadMonitor monitor; public AbstractConsoleDownloadMonitorTest() { super(); } public void setMonitor( AbstractConsoleDownloadMonitor monitor ) { this.monitor = monitor; } public AbstractConsoleDownloadMonitor getMonitor() { return monitor; } public void testTransferInitiated() throws Exception { monitor.transferInitiated( new TransferEventMock() ); } public void testTransferStarted() throws Exception { monitor.transferStarted( new TransferEventMock() ); } public void testTransferProgress() throws Exception { byte[] buffer = new byte[1000]; monitor.transferProgress( new TransferEventMock(), buffer, 1000 ); } public void testTransferCompleted() throws Exception { monitor.transferCompleted( new TransferEventMock() ); } public void testTransferError() throws Exception { monitor.transferError( new TransferEventMock( new RuntimeException() ) ); } public void testDebug() throws Exception { monitor.debug( "msg" ); } static class TransferEventMock extends TransferEvent { public TransferEventMock() throws ConnectionException, AuthenticationException { super( new FileWagon(), new Resource(), TransferEvent.TRANSFER_INITIATED, TransferEvent.REQUEST_GET ); getResource().setContentLength( 100000 ); getResource().setName( "foo.bar" ); Repository repository = new Repository(); getWagon().connect( repository ); } public TransferEventMock( Resource resource, int length ) throws ConnectionException, AuthenticationException { super( new FileWagon(), resource, TransferEvent.TRANSFER_INITIATED, TransferEvent.REQUEST_GET ); getResource().setContentLength( length ); Repository repository = new Repository(); getWagon().connect( repository ); } public TransferEventMock( Exception exception ) throws ConnectionException, AuthenticationException { super( new FileWagon(), new Resource(), exception, TransferEvent.REQUEST_GET ); getResource().setContentLength( 100000 ); getResource().setName( "foo.bar" ); Repository repository = new Repository(); getWagon().connect( repository ); } } } maven2-core-2.2.1/maven-core/src/test/java/org/apache/maven/cli/BatchModeDownloadMonitorTest.java0000644000175000017500000000241410772004567032602 0ustar twernertwernerpackage org.apache.maven.cli; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ /** * Test for {@link BatchModeDownloadMonitor} * * @author Carlos Sanchez * @version $Id: BatchModeDownloadMonitorTest.java 640549 2008-03-24 20:05:11Z bentmann $ */ public class BatchModeDownloadMonitorTest extends AbstractConsoleDownloadMonitorTest { protected void setUp() throws Exception { super.setMonitor( new BatchModeDownloadMonitor() ); super.setUp(); } } maven2-core-2.2.1/maven-core/src/test/java/org/apache/maven/usability/0000755000175000017500000000000011250552240025432 5ustar twernertwernermaven2-core-2.2.1/maven-core/src/test/java/org/apache/maven/usability/PluginErrorDiagnoserTest.java0000644000175000017500000002157110772004567033263 0ustar twernertwernerpackage org.apache.maven.usability; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import junit.framework.TestCase; import org.apache.maven.plugin.PluginConfigurationException; import org.apache.maven.plugin.PluginParameterException; import org.apache.maven.plugin.descriptor.DuplicateParameterException; import org.apache.maven.plugin.descriptor.MojoDescriptor; import org.apache.maven.plugin.descriptor.Parameter; import org.apache.maven.plugin.descriptor.PluginDescriptor; import org.codehaus.plexus.component.configurator.ComponentConfigurationException; import java.util.ArrayList; import java.util.Collections; import java.util.List; public class PluginErrorDiagnoserTest extends TestCase { private PluginConfigurationDiagnoser diagnoser = new PluginConfigurationDiagnoser(); private PluginParameterException buildException( String prefix, String goal, List params ) throws DuplicateParameterException { PluginDescriptor pluginDescriptor = new PluginDescriptor(); pluginDescriptor.setArtifactId( "maven-test-plugin" ); pluginDescriptor.setGroupId( "org.apache.maven.plugins" ); pluginDescriptor.setVersion( "1.0" ); pluginDescriptor.setGoalPrefix( prefix ); MojoDescriptor mojoDescriptor = new MojoDescriptor(); mojoDescriptor.setGoal( goal ); mojoDescriptor.setPluginDescriptor( pluginDescriptor ); mojoDescriptor.setParameters( params ); return new PluginParameterException( mojoDescriptor, params ); } public void testShouldDiagnoseInvalidPluginConfiguration() { printMethodHeader(); ComponentConfigurationException cce = new ComponentConfigurationException( "Class \'org.apache.maven.plugin.jar.JarMojo\' does not contain a field named \'addClasspath\'" ); PluginDescriptor pd = new PluginDescriptor(); pd.setGroupId("testGroup"); pd.setArtifactId("testArtifact"); PluginConfigurationException pce = new PluginConfigurationException( pd, "test", cce ); assertTrue( diagnoser.canDiagnose( pce ) ); String userMessage = diagnoser.diagnose( pce ); System.out.println( userMessage ); assertNotNull( userMessage ); } public void testShouldBeAbleToDiagnosePluginParameterExceptions() throws DuplicateParameterException { Parameter param = new Parameter(); param.setName( "testName" ); param.setAlias( "testAlias" ); param.setExpression( "${project.build.finalName}" ); param.setEditable( true ); PluginParameterException error = buildException( "test", "test", Collections.singletonList( param ) ); assertTrue( diagnoser.canDiagnose( error ) ); } public void testParamWithOneReportsExpressionAndOneProjectBasedExpression() throws DuplicateParameterException { printMethodHeader(); List params = new ArrayList(); Parameter param = new Parameter(); param.setName( "param1" ); param.setExpression( "${reports}" ); param.setEditable( false ); params.add( param ); Parameter param2 = new Parameter(); param2.setName( "param2" ); param2.setExpression( "${project.build.finalName}" ); param2.setEditable( false ); params.add( param2 ); PluginParameterException error = buildException( "test", "test", params ); String userMessage = diagnoser.diagnose( error ); System.out.println( userMessage ); assertNotNull( userMessage ); } public void testParamWithNonActiveExpression() throws DuplicateParameterException { printMethodHeader(); Parameter param = new Parameter(); param.setName( "testName" ); param.setAlias( "testAlias" ); param.setExpression( "${project.build.finalName" ); param.setEditable( true ); PluginParameterException error = buildException( "test", "test", Collections.singletonList( param ) ); String userMessage = diagnoser.diagnose( error ); System.out.println( userMessage ); assertNotNull( userMessage ); } public void testParamWithoutExpression() throws DuplicateParameterException { printMethodHeader(); Parameter param = new Parameter(); param.setName( "testName" ); param.setAlias( "testAlias" ); param.setEditable( true ); PluginParameterException error = buildException( "test", "test", Collections.singletonList( param ) ); String userMessage = diagnoser.diagnose( error ); System.out.println( userMessage ); assertNotNull( userMessage ); } public void testParamWithOneLocalRepositoryExpression() throws DuplicateParameterException { printMethodHeader(); Parameter param = new Parameter(); param.setName( "testName" ); param.setAlias( "testAlias" ); param.setExpression( "${localRepository}" ); param.setEditable( false ); PluginParameterException error = buildException( "test", "test", Collections.singletonList( param ) ); String userMessage = diagnoser.diagnose( error ); System.out.println( userMessage ); assertNotNull( userMessage ); } public void testParamWithOneSystemPropertyExpression() throws DuplicateParameterException { printMethodHeader(); Parameter param = new Parameter(); param.setName( "testName" ); param.setAlias( "testAlias" ); param.setExpression( "${maven.mode.online}" ); param.setEditable( false ); PluginParameterException error = buildException( "test", "test", Collections.singletonList( param ) ); String userMessage = diagnoser.diagnose( error ); System.out.println( userMessage ); assertNotNull( userMessage ); } public void testParamWithOneProjectBasedExpression() throws DuplicateParameterException { printMethodHeader(); Parameter param = new Parameter(); param.setName( "testName" ); param.setAlias( "testAlias" ); param.setExpression( "${project.build.finalName}" ); param.setEditable( true ); PluginParameterException error = buildException( "test", "test", Collections.singletonList( param ) ); String userMessage = diagnoser.diagnose( error ); System.out.println( userMessage ); assertNotNull( userMessage ); } public void testParamWithOneProjectAPIBasedExpression() throws DuplicateParameterException { printMethodHeader(); Parameter param = new Parameter(); param.setName( "testName" ); param.setExpression( "${project.distributionManagementArtifactRepository}" ); param.setRequired( true ); param.setEditable( false ); PluginParameterException error = buildException( "test", "test", Collections.singletonList( param ) ); String userMessage = diagnoser.diagnose( error ); System.out.println( userMessage ); assertNotNull( userMessage ); } public void testNonEditableParamWithOneProjectBasedExpression() throws DuplicateParameterException { printMethodHeader(); Parameter param = new Parameter(); param.setName( "testName" ); param.setAlias( "testAlias" ); param.setExpression( "${project.build.finalName}" ); param.setEditable( false ); PluginParameterException error = buildException( "test", "test", Collections.singletonList( param ) ); String userMessage = diagnoser.diagnose( error ); System.out.println( userMessage ); assertNotNull( userMessage ); } private void printMethodHeader() { IllegalArgumentException marker = new IllegalArgumentException(); System.out.println( "---------------------------------------------------------------------\n" + "Visual output for " + marker.getStackTrace()[1].getMethodName() + ":\n---------------------------------------------------------------------" ); } } ././@LongLink0000000000000000000000000000015500000000000011566 Lustar rootrootmaven2-core-2.2.1/maven-core/src/test/java/org/apache/maven/usability/MojoFailureExceptionDiagnoserTest.javamaven2-core-2.2.1/maven-core/src/test/java/org/apache/maven/usability/MojoFailureExceptionDiagnoserT0000644000175000017500000000126210772004567033445 0ustar twernertwernerpackage org.apache.maven.usability; import junit.framework.TestCase; import org.apache.maven.plugin.MojoFailureException; /** * @author Brian Fox * */ public class MojoFailureExceptionDiagnoserTest extends TestCase { public void testDiag() { MojoFailureExceptionDiagnoser diag = new MojoFailureExceptionDiagnoser(); Exception e = new NullPointerException("Test"); assertFalse( diag.canDiagnose( e ) ); MojoFailureException me = new MojoFailureException(null); assertTrue( diag.canDiagnose( me ) ); diag.diagnose( me ); } } ././@LongLink0000000000000000000000000000015700000000000011570 Lustar rootrootmaven2-core-2.2.1/maven-core/src/test/java/org/apache/maven/usability/MojoExecutionExceptionDiagnoserTest.javamaven2-core-2.2.1/maven-core/src/test/java/org/apache/maven/usability/MojoExecutionExceptionDiagnose0000644000175000017500000000127610772004567033520 0ustar twernertwernerpackage org.apache.maven.usability; import org.apache.maven.plugin.MojoExecutionException; import junit.framework.TestCase; /** * @author Brian Fox * */ public class MojoExecutionExceptionDiagnoserTest extends TestCase { public void testDiag() { MojoExecutionExceptionDiagnoser diag = new MojoExecutionExceptionDiagnoser(); Exception e = new NullPointerException("Test"); assertFalse( diag.canDiagnose( e ) ); MojoExecutionException me = new MojoExecutionException(null); assertTrue( diag.canDiagnose( me ) ); diag.diagnose( me ); } } ././@LongLink0000000000000000000000000000015100000000000011562 Lustar rootrootmaven2-core-2.2.1/maven-core/src/test/java/org/apache/maven/usability/ArtifactResolverDiagnoserTest.javamaven2-core-2.2.1/maven-core/src/test/java/org/apache/maven/usability/ArtifactResolverDiagnoserTest.0000644000175000017500000000341411226327403033414 0ustar twernertwernerpackage org.apache.maven.usability; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import java.io.IOException; import org.apache.maven.artifact.resolver.ArtifactResolutionException; import org.apache.maven.usability.diagnostics.ErrorDiagnoser; import org.codehaus.plexus.PlexusTestCase; /** * @author Benjamin Bentmann * @version $Id: ArtifactResolverDiagnoserTest.java 793305 2009-07-12 09:38:11Z bentmann $ */ public class ArtifactResolverDiagnoserTest extends PlexusTestCase { /** * Tests that inner IOException without detail message does not crash diagnoser. * * @throws Exception */ public void testNullMessage() throws Exception { ErrorDiagnoser diagnoser = (ArtifactResolverDiagnoser) lookup( ErrorDiagnoser.ROLE, "ArtifactResolverDiagnoser" ); Throwable error = new ArtifactResolutionException( null, null, null, null, null, null, new IOException() ); assertTrue( diagnoser.canDiagnose( error ) ); diagnoser.diagnose( error ); } } ././@LongLink0000000000000000000000000000015000000000000011561 Lustar rootrootmaven2-core-2.2.1/maven-core/src/test/java/org/apache/maven/usability/InvalidArtifactDiagnoserTest.javamaven2-core-2.2.1/maven-core/src/test/java/org/apache/maven/usability/InvalidArtifactDiagnoserTest.j0000644000175000017500000000660110772004567033364 0ustar twernertwernerpackage org.apache.maven.usability; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.factory.ArtifactFactory; import org.codehaus.plexus.PlexusTestCase; public class InvalidArtifactDiagnoserTest extends PlexusTestCase { private InvalidArtifactDiagnoser diagnoser = new InvalidArtifactDiagnoser(); public void testShouldDiagnoseArtifactWithMissingGroupId() throws Throwable { testDiagnosis( "Test diagnosis for missing groupId", null, "test-artifact", "1.0", "jar" ); } public void testShouldDiagnoseArtifactWithMissingArtifactId() throws Throwable { testDiagnosis( "Test diagnosis for missing artifactId", "test.group.id", null, "1.0", "jar" ); } public void testShouldDiagnoseArtifactWithMissingVersion() throws Throwable { testDiagnosis( "Test diagnosis for missing version", "test.group.id", "test-artifact", null, "jar" ); } public void testShouldDiagnoseArtifactWithMissingType() throws Throwable { testDiagnosis( "Test diagnosis for missing type", "test.group.id", "test-artifact", "1.0", null ); } public void testShouldDiagnoseArtifactWithMissingGroupIdAndArtifactId() throws Throwable { testDiagnosis( "Test diagnosis for missing groupId and artifactId", null, null, "1.0", "jar" ); } private void testDiagnosis( String testHeader, String groupId, String artifactId, String version, String type ) throws Throwable { System.out.println( "------------------------------------------------------------" ); System.out.println( "| " + testHeader ); System.out.println( "------------------------------------------------------------" ); System.out.println(); try { createArtifact( groupId, artifactId, version, type ); fail( "artifact creation did not fail; nothing to diagnose." ); } catch ( Throwable error ) { assertTrue( "Unexpected error while constructing artifact: " + error, diagnoser.canDiagnose( error ) ); if ( diagnoser.canDiagnose( error ) ) { System.out.println( diagnoser.diagnose( error ) ); } else { throw error; } } } private Artifact createArtifact( String groupId, String artifactId, String version, String type ) throws Exception { ArtifactFactory artifactFactory = (ArtifactFactory) lookup( ArtifactFactory.ROLE ); return artifactFactory.createBuildArtifact( groupId, artifactId, version, type ); } } maven2-core-2.2.1/maven-core/src/test/java/org/apache/maven/WagonSelectorTest.java0000644000175000017500000001767211233662172027730 0ustar twernertwernerpackage org.apache.maven; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import org.apache.maven.artifact.manager.WagonConfigurationException; import org.apache.maven.artifact.manager.WagonManager; import org.apache.maven.artifact.manager.WagonProviderMapping; import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.artifact.repository.DefaultArtifactRepository; import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout; import org.apache.maven.artifact.versioning.ArtifactVersion; import org.apache.maven.artifact.versioning.DefaultArtifactVersion; import org.apache.maven.execution.DefaultMavenExecutionRequest; import org.apache.maven.execution.MavenExecutionRequest; import org.apache.maven.execution.RuntimeInformation; import org.apache.maven.model.Model; import org.apache.maven.model.io.xpp3.MavenXpp3Writer; import org.apache.maven.monitor.event.DefaultEventDispatcher; import org.apache.maven.monitor.event.EventDispatcher; import org.apache.maven.profiles.DefaultProfileManager; import org.apache.maven.profiles.ProfileManager; import org.apache.maven.reactor.MavenExecutionException; import org.apache.maven.settings.Settings; import org.apache.maven.wagon.UnsupportedProtocolException; import org.apache.maven.wagon.Wagon; import org.apache.maven.wagon.providers.http.HttpWagon; import org.apache.maven.wagon.providers.http.LightweightHttpWagon; import org.apache.maven.wagon.providers.http.LightweightHttpsWagon; import org.apache.maven.wagon.repository.Repository; import org.codehaus.plexus.PlexusTestCase; import org.codehaus.plexus.util.FileUtils; import org.codehaus.plexus.util.IOUtil; import org.codehaus.plexus.util.xml.Xpp3Dom; import java.io.File; import java.io.FileWriter; import java.io.IOException; import java.util.ArrayList; import java.util.List; import java.util.Properties; public class WagonSelectorTest extends PlexusTestCase { private WagonProviderMapping mapping; private WagonManager manager; private ArtifactRepository localRepository; private Maven maven; private File dir; public void setUp() throws Exception { super.setUp(); mapping = (WagonProviderMapping) lookup( WagonProviderMapping.ROLE ); manager = (WagonManager) lookup( WagonManager.ROLE ); ArtifactRepositoryLayout layout = (ArtifactRepositoryLayout) lookup( ArtifactRepositoryLayout.class.getName(), "default" ); localRepository = new DefaultArtifactRepository( "local", System.getProperty( "java.io.tmpdir" ), layout ); maven = (Maven) lookup( Maven.class.getName() ); } public void tearDown() throws Exception { release( mapping ); release( manager ); super.tearDown(); if ( dir != null ) { try { FileUtils.forceDelete( dir ); } catch ( IOException e ) { } } } public void testSelectHttpWagonFromDefault() throws Exception { Properties executionProperties = new Properties(); MavenExecutionRequest req = createMavenRequest( executionProperties ); Wagon wagon = manager.getWagon( new Repository( "id", "http://www.google.com/" ) ); assertTrue( "Should use " + LightweightHttpWagon.class.getName(), wagon instanceof LightweightHttpWagon ); } public void testSelectHttpsWagonFromDefault() throws Exception { Properties executionProperties = new Properties(); MavenExecutionRequest req = createMavenRequest( executionProperties ); Wagon wagon = manager.getWagon( new Repository( "id", "https://www.google.com/" ) ); assertTrue( "Should use " + LightweightHttpsWagon.class.getName(), wagon instanceof LightweightHttpsWagon ); } public void testSelectHttpclientWagonFromSimulatedMavenCliConfiguration() throws WagonConfigurationException, UnsupportedProtocolException { mapping.setWagonProvider( "http", "httpclient" ); Wagon wagon = manager.getWagon( new Repository( "id", "http://www.google.com/" ) ); assertTrue( "Should use " + HttpWagon.class.getName(), wagon instanceof HttpWagon ); } public void testSelectHttpclientWagonFromServerConfiguration() throws WagonConfigurationException, UnsupportedProtocolException { Xpp3Dom config = new Xpp3Dom( "configuration" ); Xpp3Dom provider = new Xpp3Dom( "wagonProvider" ); provider.setValue( "httpclient" ); config.addChild( provider ); manager.addConfiguration( "id", config ); Wagon wagon = manager.getWagon( new Repository( "id", "http://www.google.com/" ) ); assertTrue( "Should use " + HttpWagon.class.getName(), wagon instanceof HttpWagon ); } public void testSelectHttpclientWagonFromMavenCLIParameter() throws WagonConfigurationException, UnsupportedProtocolException, MavenExecutionException, IOException { Properties executionProperties = new Properties(); executionProperties.setProperty( "maven.wagon.provider.http", "httpclient" ); MavenExecutionRequest req = createMavenRequest( executionProperties ); Wagon wagon = manager.getWagon( new Repository( "id", "http://www.google.com/" ) ); assertTrue( "Should use " + HttpWagon.class.getName(), wagon instanceof HttpWagon ); } public MavenExecutionRequest createMavenRequest( Properties executionProperties ) throws IOException, MavenExecutionException { Settings settings = new Settings(); EventDispatcher eventDispatcher = new DefaultEventDispatcher(); List goals = new ArrayList(); goals.add( "validate" ); dir = File.createTempFile( "WagonSelectorTest.", ".dir" ); dir.delete(); dir.mkdirs(); File pom = new File( dir, "pom.xml" ); Model model = new Model(); model.setModelVersion( "4.0.0" ); model.setGroupId( "wagon.selector.test" ); model.setArtifactId( "wagon-selector-test" ); model.setVersion( "1" ); model.setPackaging( "pom" ); FileWriter writer = null; try { writer = new FileWriter( pom ); new MavenXpp3Writer().write( writer, model ); } finally { IOUtil.close( writer ); } String baseDirectory = dir.getAbsolutePath(); ProfileManager globalProfileManager = new DefaultProfileManager( getContainer(), new Properties() ); boolean showErrors = false; Properties userProperties = new Properties(); MavenExecutionRequest req = new DefaultMavenExecutionRequest( localRepository, settings, eventDispatcher, goals, baseDirectory, globalProfileManager, executionProperties, userProperties, showErrors ); req.setPomFile( pom.getAbsolutePath() ); maven.execute( req ); return req; } public static final class TestRuntimeInformation implements RuntimeInformation { public ArtifactVersion getApplicationVersion() { return new DefaultArtifactVersion( "TEST" ); } } } maven2-core-2.2.1/maven-core/src/test/java/org/apache/maven/plugin/0000755000175000017500000000000011250552240024723 5ustar twernertwerner././@LongLink0000000000000000000000000000015700000000000011570 Lustar rootrootmaven2-core-2.2.1/maven-core/src/test/java/org/apache/maven/plugin/PluginParameterExpressionEvaluatorTest.javamaven2-core-2.2.1/maven-core/src/test/java/org/apache/maven/plugin/PluginParameterExpressionEvaluato0000644000175000017500000002474511053051031033533 0ustar twernertwernerpackage org.apache.maven.plugin; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.factory.ArtifactFactory; import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.artifact.repository.DefaultArtifactRepository; import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout; import org.apache.maven.execution.MavenSession; import org.apache.maven.execution.ReactorManager; import org.apache.maven.model.Build; import org.apache.maven.model.Model; import org.apache.maven.monitor.event.DefaultEventDispatcher; import org.apache.maven.plugin.descriptor.MojoDescriptor; import org.apache.maven.plugin.descriptor.PluginDescriptor; import org.apache.maven.project.DuplicateProjectException; import org.apache.maven.project.MavenProject; import org.apache.maven.project.MissingProjectException; import org.apache.maven.settings.Settings; import org.codehaus.plexus.PlexusContainer; import org.codehaus.plexus.PlexusTestCase; import org.codehaus.plexus.component.configurator.expression.ExpressionEvaluator; import org.codehaus.plexus.util.dag.CycleDetectedException; import java.io.File; import java.util.Collections; import java.util.Date; import java.util.List; import java.util.Properties; /** * @author Jason van Zyl * @version $Id: PluginParameterExpressionEvaluatorTest.java,v 1.5 2005/03/08 * 06:06:21 jdcasey Exp $ */ public class PluginParameterExpressionEvaluatorTest extends PlexusTestCase { private static final String FS = System.getProperty( "file.separator" ); public void testValueExtractionWithAPomValueContainingAPath() throws Exception { String expected = getTestFile( "target/test-classes/target/classes" ).getCanonicalPath(); Build build = new Build(); build.setDirectory( expected.substring( 0, expected.length() - "/classes".length() ) ); Model model = new Model(); model.setBuild( build ); MavenProject project = new MavenProject( model ); project.setFile( new File( "pom.xml" ).getCanonicalFile() ); ExpressionEvaluator expressionEvaluator = createExpressionEvaluator( project, null, new Properties() ); Object value = expressionEvaluator.evaluate( "${project.build.directory}/classes" ); String actual = new File( value.toString() ).getCanonicalPath(); assertEquals( expected, actual ); } public void testEscapedVariablePassthrough() throws Exception { String var = "${var}"; Model model = new Model(); model.setVersion( "1" ); MavenProject project = new MavenProject( model ); ExpressionEvaluator ee = createExpressionEvaluator( project, null, new Properties() ); Object value = ee.evaluate( "$" + var ); assertEquals( var, value ); } public void testEscapedVariablePassthroughInLargerExpression() throws Exception { String var = "${var}"; String key = var + " with version: ${project.version}"; Model model = new Model(); model.setVersion( "1" ); MavenProject project = new MavenProject( model ); ExpressionEvaluator ee = createExpressionEvaluator( project, null, new Properties() ); Object value = ee.evaluate( "$" + key ); assertEquals( "${var} with version: 1", value ); } public void testMultipleSubExpressionsInLargerExpression() throws Exception { String key = "${project.artifactId} with version: ${project.version}"; Model model = new Model(); model.setArtifactId( "test" ); model.setVersion( "1" ); MavenProject project = new MavenProject( model ); ExpressionEvaluator ee = createExpressionEvaluator( project, null, new Properties() ); Object value = ee.evaluate( key ); assertEquals( "test with version: 1", value ); } public void testPOMPropertyExtractionWithMissingProject_WithDotNotation() throws Exception { String key = "m2.name"; String checkValue = "value"; Properties properties = new Properties(); properties.setProperty( key, checkValue ); Model model = new Model(); model.setProperties( properties ); MavenProject project = new MavenProject( model ); ExpressionEvaluator ee = createExpressionEvaluator( project, null, new Properties() ); Object value = ee.evaluate( "${" + key + "}" ); assertEquals( checkValue, value ); } public void testBasedirExtractionWithMissingProject() throws Exception { ExpressionEvaluator ee = createExpressionEvaluator( null, null, new Properties() ); Object value = ee.evaluate( "${basedir}" ); assertEquals( System.getProperty( "user.dir" ), value ); } public void testValueExtractionFromSystemPropertiesWithMissingProject() throws Exception { String sysprop = "PPEET_sysprop1"; Properties executionProperties = new Properties(); if ( executionProperties.getProperty( sysprop ) == null ) { executionProperties.setProperty( sysprop, "value" ); } ExpressionEvaluator ee = createExpressionEvaluator( null, null, executionProperties ); Object value = ee.evaluate( "${" + sysprop + "}" ); assertEquals( "value", value ); } public void testValueExtractionFromSystemPropertiesWithMissingProject_WithDotNotation() throws Exception { String sysprop = "PPEET.sysprop2"; Properties executionProperties = new Properties(); if ( executionProperties.getProperty( sysprop ) == null ) { executionProperties.setProperty( sysprop, "value" ); } ExpressionEvaluator ee = createExpressionEvaluator( null, null, executionProperties ); Object value = ee.evaluate( "${" + sysprop + "}" ); assertEquals( "value", value ); } private static MavenSession createSession( PlexusContainer container, ArtifactRepository repo ) throws CycleDetectedException, DuplicateProjectException, MissingProjectException { return new MavenSession( container, new Settings(), repo, new DefaultEventDispatcher(), new ReactorManager( Collections.EMPTY_LIST ), Collections.EMPTY_LIST, ".", new Properties(), new Date() ); } public void testLocalRepositoryExtraction() throws Exception { ExpressionEvaluator expressionEvaluator = createExpressionEvaluator( createDefaultProject(), null, new Properties() ); Object value = expressionEvaluator.evaluate( "${localRepository}" ); assertEquals( "local", ( (DefaultArtifactRepository) value ).getId() ); } public void testTwoExpressions() throws Exception { Build build = new Build(); build.setDirectory( "expected-directory" ); build.setFinalName( "expected-finalName" ); Model model = new Model(); model.setBuild( build ); ExpressionEvaluator expressionEvaluator = createExpressionEvaluator( new MavenProject( model ), null, new Properties() ); Object value = expressionEvaluator.evaluate( "${project.build.directory}" + FS + "${project.build.finalName}" ); assertEquals( "expected-directory" + FS + "expected-finalName", value ); } public void testShouldExtractPluginArtifacts() throws Exception { PluginDescriptor pd = new PluginDescriptor(); Artifact artifact = createArtifact( "testGroup", "testArtifact", "1.0" ); pd.setArtifacts( Collections.singletonList( artifact ) ); ExpressionEvaluator ee = createExpressionEvaluator( createDefaultProject(), pd, new Properties() ); Object value = ee.evaluate( "${plugin.artifacts}" ); assertTrue( value instanceof List ); List artifacts = (List) value; assertEquals( 1, artifacts.size() ); Artifact result = (Artifact) artifacts.get( 0 ); assertEquals( "testGroup", result.getGroupId() ); } private MavenProject createDefaultProject() { return new MavenProject( new Model() ); } private ExpressionEvaluator createExpressionEvaluator( MavenProject project, PluginDescriptor pluginDescriptor, Properties executionProperties ) throws Exception { ArtifactRepositoryLayout repoLayout = (ArtifactRepositoryLayout) lookup( ArtifactRepositoryLayout.ROLE, "legacy" ); ArtifactRepository repo = new DefaultArtifactRepository( "local", "target/repo", repoLayout ); PlexusContainer container = getContainer(); MavenSession session = createSession( container, repo ); MojoDescriptor mojo = new MojoDescriptor(); mojo.setPluginDescriptor( pluginDescriptor ); mojo.setGoal( "goal" ); MojoExecution mojoExecution = new MojoExecution( mojo ); return new PluginParameterExpressionEvaluator( session, mojoExecution, null, container.getLogger(), project, executionProperties ); } protected Artifact createArtifact( String groupId, String artifactId, String version ) throws Exception { ArtifactFactory artifactFactory = (ArtifactFactory) lookup( ArtifactFactory.ROLE ); // TODO: used to be SCOPE_COMPILE, check return artifactFactory.createBuildArtifact( groupId, artifactId, version, "jar" ); } } maven2-core-2.2.1/maven-core/src/test/java/org/apache/maven/plugin/version/0000755000175000017500000000000011250552240026410 5ustar twernertwernermaven2-core-2.2.1/maven-core/src/test/java/org/apache/maven/plugin/version/IntervalUtilsTest.java0000644000175000017500000000616010772004567032737 0ustar twernertwernerpackage org.apache.maven.plugin.version; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import junit.framework.TestCase; import java.util.Calendar; import java.util.Date; public class IntervalUtilsTest extends TestCase { private static final long ONE_MINUTE = 60 * 1000; private static final long ONE_HOUR = 60 * ONE_MINUTE; private static final long ONE_DAY = 24 * ONE_HOUR; private static final long ONE_WEEK = 7 * ONE_DAY; public void testOneWeek() { assertEquals( ONE_WEEK, IntervalUtils.parseInterval( "1w" ) ); } public void testTwoWeeks() { assertEquals( ( 2 * ONE_WEEK ), IntervalUtils.parseInterval( "2w" ) ); } public void testOneDay() { assertEquals( ONE_DAY, IntervalUtils.parseInterval( "1d" ) ); } public void testOneHour() { assertEquals( ONE_HOUR, IntervalUtils.parseInterval( "1h" ) ); } public void testOneMinute() { assertEquals( ONE_MINUTE, IntervalUtils.parseInterval( "1m" ) ); } public void testTwoDaysThreeHoursAndOneMinute() { assertEquals( 2 * ONE_DAY + 3 * ONE_HOUR + ONE_MINUTE, IntervalUtils.parseInterval( "2d 3h 1m" ) ); } public void testTwoDaysThreeHoursAndOneMinuteCondensed() { assertEquals( 2 * ONE_DAY + 3 * ONE_HOUR + ONE_MINUTE, IntervalUtils.parseInterval( "2d3h1m" ) ); } public void testTwoDaysThreeHoursAndOneMinuteCommaSeparated() { assertEquals( 2 * ONE_DAY + 3 * ONE_HOUR + ONE_MINUTE, IntervalUtils.parseInterval( "2d,3h,1m" ) ); } public void testTwoDaysThreeHoursAndOneMinuteRearranged() { assertEquals( 2 * ONE_DAY + 3 * ONE_HOUR + ONE_MINUTE, IntervalUtils.parseInterval( "1m 2d 3h" ) ); } public void testThreeDaysPoorlySpecified() { assertEquals( 3 * ONE_DAY, IntervalUtils.parseInterval( "1d 2d" ) ); } public void testNeverInterval() { assertFalse( IntervalUtils.isExpired( "never", null ) ); } public void testAlwaysInterval() { assertTrue( IntervalUtils.isExpired( "always", null ) ); } public void testOneMinuteIntervalShouldBeExpired() { Calendar cal = Calendar.getInstance(); cal.add( Calendar.MINUTE, -2 ); Date lastChecked = cal.getTime(); assertTrue( IntervalUtils.isExpired( "interval:1m", lastChecked ) ); } } maven2-core-2.2.1/maven-core/src/main/0000755000175000017500000000000011250552241017334 5ustar twernertwernermaven2-core-2.2.1/maven-core/src/main/resources/0000755000175000017500000000000011250552241021346 5ustar twernertwernermaven2-core-2.2.1/maven-core/src/main/resources/org/0000755000175000017500000000000011250552241022135 5ustar twernertwernermaven2-core-2.2.1/maven-core/src/main/resources/org/apache/0000755000175000017500000000000011250552241023356 5ustar twernertwernermaven2-core-2.2.1/maven-core/src/main/resources/org/apache/maven/0000755000175000017500000000000011250552241024464 5ustar twernertwernermaven2-core-2.2.1/maven-core/src/main/resources/org/apache/maven/messages/0000755000175000017500000000000011250552241026273 5ustar twernertwernermaven2-core-2.2.1/maven-core/src/main/resources/org/apache/maven/messages/messages_pl.properties0000644000175000017500000000410310551365651032723 0ustar twernertwerner# Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. The ASF licenses this file # to you under the Apache License, Version 2.0 (the # "License"); you may not use this file except in compliance # with the License. You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed on an # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY # KIND, either express or implied. See the License for the # specific language governing permissions and limitations # under the License. # -------------------------------------------------------------------------- # Project Verifier # -------------------------------------------------------------------------- failed.download.warning=UWAGA: Nie uda\u0142o si\u0119 pobra\u0107 {0}. remote.repository.disabled.warning=Korzystanie ze zdalnego repozytorium jest wy\u0142\u0105czone. directory.nonexistant.warning=Katalog {0} nie istnieje. Pr\u00f3buj\u0119 utworzy\u0107. not.directory.warning={0} nie jest katalogiem. not.writable.warning=Nie mo\u017cna zapisa\u0107 {0}. cannot.create.directory.warning=Nie mo\u017cna utworzy\u0107 katalogu {0}. maven.repo.local.unset.warning=maven.repo.local nie jest zdefiniowane. single.unsatisfied.dependency.error=Budowanie przerwane z powodu nast\u0119puj\u0105cej niespe\u0142nionej zale\u017cno\u015bci: multiple.unsatisfied.dependency.error=Budowanie przerwane z powodu nast\u0119puj\u0105cych niespe\u0142nionych zale\u017cno\u015bci: offline.snapshot.warning=Pracujesz w trybie offline. Budowanie b\u0119dzie kontynuowane, cho\u0107 {0} mo\u017ce by\u0107 nieaktualny! download.message=Pr\u00f3buj\u0119 pobra\u0107 {0}. plugin.loading.error=Nie uda\u0142o si\u0119 uaktywni\u0107 wtyczki {0}. empty.descriptor.error=Plik {0} jest pusty. checksum.verification.error=Nast\u0119puj?cy artefakt jest b\u0142\u0119dny: {0}. maven2-core-2.2.1/maven-core/src/main/resources/org/apache/maven/messages/messages_el.properties0000644000175000017500000001042310551365651032712 0ustar twernertwerner# Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. The ASF licenses this file # to you under the Apache License, Version 2.0 (the # "License"); you may not use this file except in compliance # with the License. You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed on an # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY # KIND, either express or implied. See the License for the # specific language governing permissions and limitations # under the License. # -------------------------------------------------------------------------- # \u00c5\u00eb\u00e5\u00e3\u00ea\u00f4\u00de\u00f2 \u00d3\u00f7\u00e5\u00e4\u00df\u00ef\u00f5 # -------------------------------------------------------------------------- failed.download.warning=\u00d0\u00f1\u00ef\u00f3\u00f9\u00f7\u00de! \u00c1\u00e4\u00fd\u00ed\u00e1\u00f4\u00f9\u00ed \u00e7 \u00ec\u00e5\u00f4\u00e1\u00f6\u00ef\u00f1\u00dc \u00f4\u00ef\u00f5 {0}! remote.repository.disabled.warning=\u00c7 \u00f7\u00f1\u00de\u00f3\u00e7 \u00e1\u00f0\u00ef\u00ec\u00e1\u00ea\u00f1\u00f5\u00f3\u00ec\u00dd\u00ed\u00f9\u00ed \u00e1\u00f0\u00ef\u00e8\u00e7\u00ea\u00fe\u00ed \u00dd\u00f7\u00e5\u00e9 \u00e1\u00f0\u00e5\u00ed\u00e5\u00f1\u00e3\u00ef\u00f0\u00ef\u00e9\u00e7\u00e8\u00e5\u00df.. directory.nonexistant.warning=\u00cf \u00ea\u00e1\u00f4\u00dc\u00eb\u00ef\u00e3\u00ef\u00f2 {0} \u00e4\u00e5\u00ed \u00f5\u00f0\u00dc\u00f1\u00f7\u00e5\u00e9! \u00c4\u00ef\u00ea\u00e9\u00ec\u00dc\u00e6\u00f9 \u00e4\u00e7\u00ec\u00e9\u00ef\u00fd\u00f1\u00e3\u00e7\u00f3\u00e7... not.directory.warning={0} \u00e4\u00e5\u00ed \u00e5\u00df\u00ed\u00e1\u00e9 \u00ea\u00e1\u00f4\u00dc\u00eb\u00ef\u00e3\u00ef\u00f2! not.writable.warning=\u00c1\u00e4\u00fd\u00ed\u00e1\u00f4\u00f9\u00ed \u00e7 \u00e4\u00e9\u00e5\u00e3\u00e3\u00f1\u00e1\u00f6\u00de \u00f3\u00f4\u00ef {0}! cannot.create.directory.warning=\u00c1\u00e4\u00fd\u00ed\u00e1\u00f4\u00f9\u00ed \u00e7 \u00e4\u00e7\u00ec\u00e9\u00ef\u00f5\u00f1\u00e3\u00e5\u00df\u00e1 \u00f4\u00ef\u00fd \u00ea\u00e1\u00f4\u00e1\u00eb\u00fc\u00e3\u00ef\u00f5 {0}! maven.repo.local.unset.warning=maven.repo.local \u00e4\u00e5\u00ed \u00dd\u00f7\u00e5\u00e9 \u00ef\u00f1\u00e9\u00f3\u00f4\u00e5\u00df. single.unsatisfied.dependency.error= \u00c7 \u00e4\u00e9\u00e1\u00e4\u00e9\u00ea\u00e1\u00f3\u00df\u00e1 \u00e4\u00e5\u00ed \u00ec\u00f0\u00ef\u00f1\u00e5\u00df \u00ed\u00e1 \u00f3\u00f5\u00ed\u00e5\u00f7\u00e9\u00f3\u00f4\u00e5\u00df! \u00cb\u00e5\u00df\u00f0\u00e5\u00e9 \u00e7 \u00e1\u00ea\u00fc\u00eb\u00ef\u00f5\u00e8\u00e7 \u00e5\u00ee\u00dc\u00f1\u00f4\u00e7\u00f3\u00e5\u00e9: multiple.unsatisfied.dependency.error=\u00c7 \u00e4\u00e9\u00e1\u00e4\u00e9\u00ea\u00e1\u00f3\u00df\u00e1 \u00e4\u00e5\u00ed \u00ec\u00f0\u00ef\u00f1\u00e5\u00df \u00ed\u00e1 \u00f3\u00f5\u00ed\u00e5\u00f7\u00e9\u00f3\u00f4\u00e5\u00df! \u00cb\u00e5\u00df\u00f0\u00ef\u00f5\u00ed \u00e7 \u00e1\u00ea\u00fc\u00eb\u00ef\u00f5\u00e8\u00e5\u00f2 \u00e5\u00ee\u00e1\u00f1\u00f4\u00de\u00f3\u00e5\u00e9\u00f2: offline.snapshot.warning=\u00c5\u00f1\u00e3\u00dc\u00e6\u00e5\u00f3\u00e1\u00e9 \u00e1\u00f0\u00ef\u00f3\u00f5\u00ed\u00e4\u00e5\u00e4\u00ef\u00ec\u00dd\u00ed\u00ef\u00f2! \u00c7 \u00e4\u00e9\u00e1\u00e4\u00e9\u00ea\u00e1\u00f3\u00df\u00e1 \u00e8\u00e1 \u00f3\u00f5\u00ed\u00e5\u00f7\u00df\u00f3\u00e5\u00e9 \u00e1\u00eb\u00eb\u00dc \u00e5\u00df\u00ed\u00e1\u00e9 \u00e4\u00f5\u00ed\u00e1\u00f4\u00fe\u00ed {0} \u00ed\u00e1 \u00ec\u00e7\u00ed \u00e5\u00df\u00ed\u00e1\u00e9 \u00e5\u00ed\u00e7\u00ec\u00e5\u00f1\u00f9\u00ec\u00dd\u00ed\u00ef! download.message=\u00d0\u00f1\u00f9\u00f3\u00f0\u00e1\u00e8\u00fe \u00ed\u00e1 \u00ec\u00e5\u00f4\u00e1\u00f6\u00dd\u00f1\u00f9 {0}. plugin.loading.error=\u00c1\u00e4\u00fd\u00ed\u00e1\u00f4\u00f9\u00ed \u00ed\u00e1 \u00f6\u00ef\u00f1\u00f4\u00f9\u00e8\u00e5\u00df \u00f4\u00ef plugin {0}! empty.descriptor.error=\u00d4\u00ef \u00e1\u00f1\u00f7\u00e5\u00df\u00ef {0} \u00f0\u00ef\u00fd \u00ea\u00e1\u00e8\u00ef\u00f1\u00df\u00f3\u00e1\u00f4\u00e5 \u00dd\u00f7\u00e5\u00e9 \u00ec\u00dd\u00e3\u00e5\u00e8\u00ef\u00f2 \u00ec\u00e7\u00e4\u00dd\u00ed. maven2-core-2.2.1/maven-core/src/main/resources/org/apache/maven/messages/messages_fr.properties0000644000175000017500000000414710551365651032727 0ustar twernertwerner# Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. The ASF licenses this file # to you under the Apache License, Version 2.0 (the # "License"); you may not use this file except in compliance # with the License. You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed on an # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY # KIND, either express or implied. See the License for the # specific language governing permissions and limitations # under the License. # -------------------------------------------------------------------------- # Project Verifier # -------------------------------------------------------------------------- failed.download.warning=ATTENTION: Impossible de t\u00e9l\u00e9charger {0}. remote.repository.disabled.warning=L'utilisation du d\u00e9p\u00f4t distant est d\u00e9sactiv\u00e9e. directory.nonexistant.warning=Le r\u00e9pertoire {0} n'existe pas. Tentative de cr\u00e9ation. not.directory.warning={0} n'est pas un r\u00e9pertoire. not.writable.warning=Impossible d'\u00e9crire sur {0}. cannot.create.directory.warning=Impossible de cr\u00e9er le r\u00e9pertoire {0}. maven.repo.local.unset.warning=maven.repo.local n'est pas d\u00e9fini. single.unsatisfied.dependency.error=Le processus ne peut continuer \u00e0 cause de la d\u00e9pendance manquante suivante: multiple.unsatisfied.dependency.error=Le processus ne peut continuer \u00e0 cause des d\u00e9pendances manquantes suivantes: offline.snapshot.warning=Vous travaillez hors-connexion, alors le processus va continuer, mais {0} peut ne pas \u00eatre \u00e0 jour! download.message=Tentative de t\u00e9l\u00e9chargement de {0}. plugin.loading.error=Impossible de charger le plugin {0}. empty.descriptor.error=Le fichier {0} que vous avez sp\u00e9cifi\u00e9 est vide. checksum.verification.error=L'art\u00e9fact suivante est corrompue: {0}. maven2-core-2.2.1/maven-core/src/main/resources/org/apache/maven/messages/messages_es.properties0000644000175000017500000000373510551365651032731 0ustar twernertwerner# Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. The ASF licenses this file # to you under the Apache License, Version 2.0 (the # "License"); you may not use this file except in compliance # with the License. You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed on an # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY # KIND, either express or implied. See the License for the # specific language governing permissions and limitations # under the License. # -------------------------------------------------------------------------- # Verificador de Proyecto # -------------------------------------------------------------------------- failed.download.warning=\u00a1ATENCION!: \u00a1Imposible descargar {0}! remote.repository.disabled.warning=El uso de repositorios remotos est\u00e1 desactivado.. directory.nonexistant.warning=\u00a1El directorio {0} no existe! Intentando crear... not.directory.warning=\u00a1{0} no es un directorio! not.writable.warning=\u00a1Imposible escribir en {0}! cannot.create.directory.warning=\u00a1Imposible crear el directorio {0}! maven.repo.local.unset.warning=\u00a1maven.repo.local no est\u00e1 definido! single.unsatisfied.dependency.error=\u00a1El proceso no puede seguir! Falta la siguiente dependencia: multiple.unsatisfied.dependency.error=\u00a1El proceso no puede seguir! Faltan las siguientes dependencias: offline.snapshot.warning=\u00a1Est\u00e1s trabajando fuera de linea! \u00a1El proceso seguir\u00e1, pero es posible que {0} no est\u00e9 actualizado! download.message=Intentando descargar {0}. plugin.loading.error=\u00a1No se ha podido cargar el plugin {0}! empty.descriptor.error=El fichero especificado, {0} , tiene longitud cero. maven2-core-2.2.1/maven-core/src/main/resources/org/apache/maven/messages/messages_ko.properties0000644000175000017500000000601011000635706032707 0ustar twernertwerner# Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. The ASF licenses this file # to you under the Apache License, Version 2.0 (the # "License"); you may not use this file except in compliance # with the License. You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed on an # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY # KIND, either express or implied. See the License for the # specific language governing permissions and limitations # under the License. # -------------------------------------------------------------------------- # Project Verifier # -------------------------------------------------------------------------- cannot.create.directory.warning = \uB514\uB809\uD130\uB9AC {0} \uC744/\uB97C \uC0DD\uC131\uD560 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4. checksum.verification.error = \uB2E4\uC74C\uC758 \uC544\uB9AC\uD329\uD2B8(artifact)\uC5D0\uC11C \uC5D0\uB7EC\uAC00 \uBC1C\uC0DD\uD569\uB2C8\uB2E4: {0} directory.nonexistant.warning = \uB514\uB809\uD130\uB9AC {0} \uC774/\uAC00 \uC5C6\uC2B5\uB2C8\uB2E4. \uC0DD\uC131\uC744 \uC2DC\uB3C4\uD569\uB2C8\uB2E4. download.message = {0} \uC744/\uB97C \uB2E4\uC6B4\uB85C\uB4DC \uD569\uB2C8\uB2E4. empty.descriptor.error = \uD30C\uC77C {0} \uC758 \uAE38\uC774\uAC00 0\uC785\uB2C8\uB2E4. failed.download.warning = \uACBD\uACE0: {0} \uC744/\uB97C \uB2E4\uC6B4\uB85C\uB4DC \uD558\uC9C0 \uBABB\uD588\uC2B5\uB2C8\uB2E4. maven.repo.local.unset.warning = maven.repo.local \uC774 \uC124\uC815\uB418\uC5B4\uC788\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4. multiple.unsatisfied.dependency.error = \uB2E4\uC74C\uC758 \uC758\uC874\uC131\uB4E4\uC744 \uB9CC\uC871\uC2DC\uD0A4\uC9C0 \uBABB\uD588\uAE30 \uB54C\uBB38\uC5D0, \uBE4C\uB4DC\uB97C \uACC4\uC18D \uC9C4\uD589\uD560 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4. not.directory.warning = {0} \uC740/\uB294 \uB514\uB809\uD130\uB9AC\uAC00 \uC544\uB2D9\uB2C8\uB2E4. not.writable.warning = {0} \uC740/\uB294 \uC4F0\uAE30\uB97C \uD5C8\uC6A9\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4. offline.snapshot.warning = \uC624\uD504\uB77C\uC778\uC73C\uB85C \uC791\uC5C5\uD558\uACE0 \uC788\uAE30 \uB54C\uBB38\uC5D0 \uBE4C\uB4DC\uB294 \uACC4\uC18D \uC9C4\uD589\uD558\uC9C0\uB9CC, {0} \uC740/\uB294 \uCD5C\uC2E0 \uBC84\uC804\uC774 \uC544\uB2D0 \uC218\uB3C4 \uC788\uC2B5\uB2C8\uB2E4! plugin.loading.error = \uD50C\uB7EC\uADF8\uC778 {0} \uC744/\uB97C \uC77D\uC5B4\uC62C \uC218 \uC5C6\uC2B5\uB2C8\uB2E4. remote.repository.disabled.warning = \uC6D0\uACA9 \uC800\uC7A5\uC18C \uC0AC\uC6A9\uC744 \uD5C8\uAC00\uD558\uC9C0 \uC54A\uC740(disabled) \uC0C1\uD0DC\uC785\uB2C8\uB2E4. single.unsatisfied.dependency.error = \uB2E4\uC74C\uC758 \uC758\uC874\uC131\uB4E4\uC744 \uB9CC\uC871\uC2DC\uD0A4\uC9C0 \uBABB\uD588\uAE30 \uB54C\uBB38\uC5D0, \uBE4C\uB4DC\uB97C \uACC4\uC18D \uC9C4\uD589\uD560 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4. maven2-core-2.2.1/maven-core/src/main/resources/org/apache/maven/messages/messages_zh_CN.properties0000644000175000017500000000321310551365651033312 0ustar twernertwerner# Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. The ASF licenses this file # to you under the Apache License, Version 2.0 (the # "License"); you may not use this file except in compliance # with the License. You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed on an # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY # KIND, either express or implied. See the License for the # specific language governing permissions and limitations # under the License. # -------------------------------------------------------------------------- # ÏîÄ¿ÑéÖ¤ # -------------------------------------------------------------------------- failed.download.warning=¾¯¸æ£º {0} ÏÂÔØÊ§°Ü¡£ remote.repository.disabled.warning=½ûֹʹÓÃÔ¶³Ì×ÊÔ´²Ö¿â¡£ directory.nonexistant.warning=Ŀ¼ {0} ²»´æÔÚ¡£ ³¢ÊÔн¨ÖС­¡­ not.directory.warning={0} ²»ÊÇĿ¼¡£ not.writable.warning={0} Ö»¶Á¡£ cannot.create.directory.warning=´´½¨Ä¿Â¼ {0} ʧ°Ü¡£ maven.repo.local.unset.warning=ûÓÐÉèÖà maven.repo.local ÊôÐÔ¡£ single.unsatisfied.dependency.error=ÓÉÓÚÒÔϵÄÒÀÀµÈ±ÉÙ£¬´´½¨²»ÄܽøÐУº multiple.unsatisfied.dependency.error=ÓÉÓÚÒÔϵÄÒÀÀµÈ±ÉÙ£¬´´½¨²»ÄܽøÐУº offline.snapshot.warning=ÀëÏßʱ´´½¨£¬¿ÉÄÜ {0} ¹ýÆÚ£¡ download.message=³¢ÊÔÏÂÔØ {0}¡­¡­ plugin.loading.error=×°Èë plugin {0} ʧ°Ü¡£ empty.descriptor.error=Îļþ {0} µÄ³¤¶ÈΪ0¡£ checksum.verification.error=ÒÔÏÂ×ÊÔ´Òѱ»ÆÆ»µ£º{0}¡£ maven2-core-2.2.1/maven-core/src/main/resources/org/apache/maven/messages/messages_no.properties0000644000175000017500000000356510551365651032737 0ustar twernertwerner# Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. The ASF licenses this file # to you under the Apache License, Version 2.0 (the # "License"); you may not use this file except in compliance # with the License. You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed on an # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY # KIND, either express or implied. See the License for the # specific language governing permissions and limitations # under the License. # -------------------------------------------------------------------------- # Project Verifier # -------------------------------------------------------------------------- failed.download.warning=ADVARSEL: Mislykket nedlasting av {0}. remote.repository.disabled.warning=Bruk av fjernlager er deaktivert. directory.nonexistant.warning=Mappen {0} finnes ikke. Fors\u00f8ker \u00e5 opprette. not.directory.warning={0} er ikke en mappe. not.writable.warning=Kan ikke skirve til {0}. cannot.create.directory.warning=Kan ikke opprette mappen {0}. maven.repo.local.unset.warning=maven.repo.local er ikke definert. single.unsatisfied.dependency.error=Byggeprosessen kan ikke fortsette p\u00e5 grunn av f\u00f8lgende mislykkede avhengighet: multiple.unsatisfied.dependency.error=The build cannot continue because of the following unsatisfied dependencies: offline.snapshot.warning=Du arbeider frakoblet. Byggeprosessen vil fortsette, men {0} kan bli utdatert! download.message=Fors\u00f8ker \u00e5 laste ned {0}. plugin.loading.error=Plugin {0} kunne ikke lastes. empty.descriptor.error=The {0} file you specified has zero length. maven2-core-2.2.1/maven-core/src/main/resources/org/apache/maven/messages/build.properties0000644000175000017500000000011511122500615031501 0ustar twernertwernerbuildNumber=${buildNumber} timestamp=${timestamp} version=${project.version} maven2-core-2.2.1/maven-core/src/main/resources/org/apache/maven/messages/messages_de.properties0000644000175000017500000000372011122676504032701 0ustar twernertwerner# Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. The ASF licenses this file # to you under the Apache License, Version 2.0 (the # "License"); you may not use this file except in compliance # with the License. You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed on an # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY # KIND, either express or implied. See the License for the # specific language governing permissions and limitations # under the License. # -------------------------------------------------------------------------- # Project Verifier # -------------------------------------------------------------------------- failed.download.warning=WARNUNG: Herunterladen von {0} fehlgeschlagen. remote.repository.disabled.warning=Verwendung entfernter Repositories deaktiviert. directory.nonexistant.warning=Verzeichnis {0} existiert nicht, es wird erstellt. not.directory.warning={0} ist kein Verzeichnis. not.writable.warning=Kann {0} nicht schreiben. cannot.create.directory.warning=Kann Verzeichnis {0} nicht erstellen. maven.repo.local.unset.warning=maven.repo.local ist nicht gesetzt. single.unsatisfied.dependency.error=Der Vorgang wurde aufgrund der folgenden nicht erf\u00FCllten Abh\u00E4ngigkeit abgebrochen: multiple.unsatisfied.dependency.error=Der Vorgang wurde aufgrund der folgenden nicht erf\u00FCllten Abh\u00E4ngigkeiten abgebrochen: offline.snapshot.warning={0} ist unter Umst\u00E4nden veraltet. Da Sie offline arbeiten, wird der Vorgang fortgesetzt. download.message=Versuche {0} herunterzuladen. plugin.loading.error=Kann Plugin {0} nicht laden. empty.descriptor.error=Datei {0} ist leer. checksum.verification.error=Artefakt {0} ist defekt. maven2-core-2.2.1/maven-core/src/main/resources/org/apache/maven/messages/messages_ja.properties0000644000175000017500000000604310772004567032710 0ustar twernertwerner# Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. The ASF licenses this file # to you under the Apache License, Version 2.0 (the # "License"); you may not use this file except in compliance # with the License. You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed on an # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY # KIND, either express or implied. See the License for the # specific language governing permissions and limitations # under the License. # -------------------------------------------------------------------------- # Project Verifier # -------------------------------------------------------------------------- failed.download.warning=WARNING: {0} \u306e\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9\u306b\u5931\u6557\u3057\u307e\u3057\u305f. remote.repository.disabled.warning=\u30ea\u30e2\u30fc\u30c8\u30ea\u30dd\u30b8\u30c8\u30ea\u304c\u7121\u52b9\u3067\u3059. directory.nonexistant.warning=\u30c7\u30a3\u30ec\u30af\u30c8\u30ea {0} \u304c\u5b58\u5728\u3057\u307e\u305b\u3093. \u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u3092\u4f5c\u6210\u3057\u307e\u3059. not.directory.warning={0} \u306f\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u3067\u306f\u3042\u308a\u307e\u305b\u3093. not.writable.warning={0} \u306f\u66f8\u304d\u8fbc\u307f\u53ef\u80fd\u3067\u306f\u3042\u308a\u307e\u305b\u3093. cannot.create.directory.warning=\u30c7\u30a3\u30ec\u30af\u30c8\u30ea {0} \u3092\u4f5c\u6210\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u305b\u3093. maven.repo.local.unset.warning=maven.repo.local \u304c\u8a2d\u5b9a\u3055\u308c\u3066\u3044\u307e\u305b\u3093. single.unsatisfied.dependency.error=\u4ee5\u4e0b\u306e\u4f9d\u5b58\u95a2\u4fc2\u304c\u6e80\u305f\u3055\u308c\u306a\u304b\u3063\u305f\u305f\u3081\u3001\u30d3\u30eb\u30c9\u3092\u7d9a\u884c\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u305b\u3093: multiple.unsatisfied.dependency.error=\u4ee5\u4e0b\u306e\u3044\u304f\u3064\u304b\u306e\u4f9d\u5b58\u95a2\u4fc2\u304c\u6e80\u305f\u3055\u308c\u306a\u304b\u3063\u305f\u305f\u3081\u3001\u30d3\u30eb\u30c9\u3092\u7d9a\u884c\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u305b\u3093: offline.snapshot.warning=\u30aa\u30d5\u30e9\u30a4\u30f3\u30e2\u30fc\u30c9\u3067\u30d3\u30eb\u30c9\u3092\u5b9f\u884c\u3057\u307e\u3059. {0} \u306f\u53e4\u3044\u30d0\u30fc\u30b8\u30e7\u30f3\u304c\u5229\u7528\u3055\u308c\u307e\u3059. download.message={0} \u3092\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9\u3057\u307e\u3059. plugin.loading.error=\u30d7\u30e9\u30b0\u30a4\u30f3 {0} \u3092\u30ed\u30fc\u30c9\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u305b\u3093. empty.descriptor.error=\u6307\u5b9a\u3057\u305f\u30d5\u30a1\u30a4\u30eb {0} \u306f\u7a7a\u306e\u30d5\u30a1\u30a4\u30eb\u3067\u3059. checksum.verification.error=\u30a2\u30fc\u30c6\u30a3\u30d5\u30a1\u30af\u30c8 {0} \u304c\u4e0d\u6b63\u3067\u3059. maven2-core-2.2.1/maven-core/src/main/resources/org/apache/maven/messages/messages.properties0000644000175000017500000000365610764010505032233 0ustar twernertwerner# Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. The ASF licenses this file # to you under the Apache License, Version 2.0 (the # "License"); you may not use this file except in compliance # with the License. You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed on an # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY # KIND, either express or implied. See the License for the # specific language governing permissions and limitations # under the License. # -------------------------------------------------------------------------- # Project Verifier # -------------------------------------------------------------------------- failed.download.warning=WARNING: Failed to download {0}. remote.repository.disabled.warning=The use of the remote repository has been disabled. directory.nonexistant.warning=Directory {0} does not exist. Attempting to create. not.directory.warning={0} is not a directory. not.writable.warning={0} is not writable. cannot.create.directory.warning=Unable to create directory {0} maven.repo.local.unset.warning=maven.repo.local is not set. single.unsatisfied.dependency.error=The build cannot continue because of the following unsatisfied dependency: multiple.unsatisfied.dependency.error=The build cannot continue because of the following unsatisfied dependencies: offline.snapshot.warning=You are working offline so the build will continue, but {0} may be out of date! download.message=Attempting to download {0}. plugin.loading.error=The plugin {0} could not be loaded. empty.descriptor.error=The file {0} you specified has zero length. checksum.verification.error=The following artifact is corrupted: {0}. maven2-core-2.2.1/maven-core/src/main/resources/org/apache/maven/messages/messages_en.properties0000644000175000017500000000227511122676504032717 0ustar twernertwerner# Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. The ASF licenses this file # to you under the Apache License, Version 2.0 (the # "License"); you may not use this file except in compliance # with the License. You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed on an # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY # KIND, either express or implied. See the License for the # specific language governing permissions and limitations # under the License. # NOTE: # This bundle is intentionally empty because English strings are provided by the base bundle via the parent chain. It # must be provided nevertheless such that a request for locale "en" will not erroneously pick up the bundle for the # JVM's default locale (which need not be "en"). See the method javadoc about # ResourceBundle.getBundle(String, Locale, ClassLoader) # for a full description of the lookup strategy. maven2-core-2.2.1/maven-core/src/main/resources/org/apache/maven/messages/messages_nl.properties0000644000175000017500000000365510551365651032734 0ustar twernertwerner# Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. The ASF licenses this file # to you under the Apache License, Version 2.0 (the # "License"); you may not use this file except in compliance # with the License. You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed on an # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY # KIND, either express or implied. See the License for the # specific language governing permissions and limitations # under the License. # -------------------------------------------------------------------------- # Project Verifier # -------------------------------------------------------------------------- failed.download.warning=WAARSCHUWING: Kan {0} niet downloaden. remote.repository.disabled.warning=Het gebruik van de remote repository is uitgezet. directory.nonexistant.warning=Directory {0} bestaat niet. Probeer hem aan te maken. not.directory.warning={0} is geen directory. not.writable.warning={0} is niet schrijfbaar. cannot.create.directory.warning=Kan {0} directory niet aanmaken maven.repo.local.unset.warning=maven.repo.local is niet ingesteld. single.unsatisfied.dependency.error=Het bouwen kan niet doorgaan, omdat de volgende afhankelijkheid niet achterhaald kan worden: multiple.unsatisfied.dependency.error=Het bouwen kan niet doorgaan, omdat de volgende afhankelijkheden niet achterhaald kunnen worden: offline.snapshot.warning=Je werkt offline, dus het bouwen gaat verder, maar {0} kan eventueel niet up-to-date zijn! download.message=Probeer {0} te downloaden. plugin.loading.error=De {0} plugin kan niet worden geladen. empty.descriptor.error=The {0} file you specified has zero length. maven2-core-2.2.1/maven-core/src/main/resources/META-INF/0000755000175000017500000000000011250552241022506 5ustar twernertwernermaven2-core-2.2.1/maven-core/src/main/resources/META-INF/plexus/0000755000175000017500000000000011250552241024026 5ustar twernertwernermaven2-core-2.2.1/maven-core/src/main/resources/META-INF/plexus/components.xml0000644000175000017500000006544711233662172026763 0ustar twernertwerner org.apache.maven.plugin.PluginManager org.apache.maven.plugin.DefaultPluginManager org.apache.maven.project.path.PathTranslator org.apache.maven.plugin.MavenPluginCollector org.apache.maven.plugin.version.PluginVersionManager org.apache.maven.artifact.factory.ArtifactFactory org.apache.maven.artifact.resolver.ArtifactResolver org.apache.maven.artifact.metadata.ArtifactMetadataSource org.apache.maven.plugin.PluginMappingManager org.apache.maven.execution.RuntimeInformation org.apache.maven.project.MavenProjectBuilder org.apache.maven.extension.ExtensionManager org.apache.maven.extension.DefaultExtensionManager org.apache.maven.artifact.resolver.ArtifactResolver org.apache.maven.artifact.factory.ArtifactFactory org.apache.maven.artifact.metadata.ArtifactMetadataSource org.apache.maven.artifact.manager.WagonManager org.apache.maven.plugin.PluginMappingManager org.apache.maven.plugin.DefaultPluginMappingManager org.apache.maven.artifact.repository.metadata.RepositoryMetadataManager org.apache.maven.project.path.PathTranslator org.apache.maven.project.path.DefaultPathTranslator org.apache.maven.Maven org.apache.maven.DefaultMaven org.apache.maven.project.MavenProjectBuilder org.apache.maven.lifecycle.LifecycleExecutor org.apache.maven.usability.diagnostics.ErrorDiagnostics org.apache.maven.execution.RuntimeInformation org.apache.maven.execution.RuntimeInformation org.apache.maven.execution.DefaultRuntimeInformation org.apache.maven.usability.diagnostics.ErrorDiagnoser MojoExecutionExceptionDiagnoser org.apache.maven.usability.MojoExecutionExceptionDiagnoser org.apache.maven.usability.diagnostics.ErrorDiagnoser MojoFailureExceptionDiagnoser org.apache.maven.usability.MojoFailureExceptionDiagnoser org.apache.maven.usability.diagnostics.ErrorDiagnoser ProjectBuildDiagnoser org.apache.maven.usability.ProjectBuildDiagnoser org.apache.maven.usability.diagnostics.ErrorDiagnoser ProfileActivationDiagnoser org.apache.maven.usability.ProfileActivationDiagnoser org.apache.maven.usability.diagnostics.ErrorDiagnoser PluginConfigurationDiagnoser org.apache.maven.usability.PluginConfigurationDiagnoser org.apache.maven.usability.diagnostics.ErrorDiagnoser ArtifactNotFoundDiagnoser org.apache.maven.usability.ArtifactNotFoundDiagnoser org.apache.maven.artifact.manager.WagonManager org.apache.maven.usability.diagnostics.ErrorDiagnoser ArtifactResolverDiagnoser org.apache.maven.usability.ArtifactResolverDiagnoser org.apache.maven.artifact.manager.WagonManager org.apache.maven.usability.diagnostics.ErrorDiagnoser InvalidArtifactDiagnoser org.apache.maven.usability.InvalidArtifactDiagnoser org.apache.maven.ConfigurationInterpolator org.apache.maven.ReflectionConfigurationInterpolator org.apache.maven.project.path.PathTranslator org.apache.maven.lifecycle.LifecycleExecutor org.apache.maven.lifecycle.DefaultLifecycleExecutor org.apache.maven.plugin.PluginManager org.apache.maven.extension.ExtensionManager org.apache.maven.artifact.handler.manager.ArtifactHandlerManager org.apache.maven.project.MavenProjectBuilder org.apache.maven.project.interpolation.ModelInterpolator org.apache.maven.ConfigurationInterpolator default validate initialize generate-sources process-sources generate-resources process-resources compile process-classes generate-test-sources process-test-sources generate-test-resources process-test-resources test-compile process-test-classes test prepare-package package pre-integration-test integration-test post-integration-test verify install deploy clean pre-clean clean post-clean org.apache.maven.plugins:maven-clean-plugin:clean site pre-site site post-site site-deploy org.apache.maven.plugins:maven-site-plugin:site org.apache.maven.plugins:maven-site-plugin:deploy org.apache.maven.plugins:maven-project-info-reports-plugin:2.1 org.apache.maven.lifecycle.mapping.LifecycleMapping pom org.apache.maven.lifecycle.mapping.DefaultLifecycleMapping default org.apache.maven.plugins:maven-site-plugin:attach-descriptor org.apache.maven.plugins:maven-install-plugin:install org.apache.maven.plugins:maven-deploy-plugin:deploy org.apache.maven.plugins:maven-site-plugin:attach-descriptor org.apache.maven.lifecycle.mapping.LifecycleMapping jar org.apache.maven.lifecycle.mapping.DefaultLifecycleMapping default org.apache.maven.plugins:maven-resources-plugin:resources org.apache.maven.plugins:maven-compiler-plugin:compile org.apache.maven.plugins:maven-resources-plugin:testResources org.apache.maven.plugins:maven-compiler-plugin:testCompile org.apache.maven.plugins:maven-surefire-plugin:test org.apache.maven.plugins:maven-jar-plugin:jar org.apache.maven.plugins:maven-install-plugin:install org.apache.maven.plugins:maven-deploy-plugin:deploy org.apache.maven.lifecycle.mapping.LifecycleMapping maven-plugin org.apache.maven.lifecycle.mapping.DefaultLifecycleMapping default org.apache.maven.plugins:maven-plugin-plugin:descriptor org.apache.maven.plugins:maven-resources-plugin:resources org.apache.maven.plugins:maven-compiler-plugin:compile org.apache.maven.plugins:maven-resources-plugin:testResources org.apache.maven.plugins:maven-compiler-plugin:testCompile org.apache.maven.plugins:maven-surefire-plugin:test org.apache.maven.plugins:maven-jar-plugin:jar, org.apache.maven.plugins:maven-plugin-plugin:addPluginArtifactMetadata org.apache.maven.plugins:maven-install-plugin:install org.apache.maven.plugins:maven-deploy-plugin:deploy org.apache.maven.lifecycle.mapping.LifecycleMapping ejb org.apache.maven.lifecycle.mapping.DefaultLifecycleMapping default org.apache.maven.plugins:maven-resources-plugin:resources org.apache.maven.plugins:maven-compiler-plugin:compile org.apache.maven.plugins:maven-resources-plugin:testResources org.apache.maven.plugins:maven-compiler-plugin:testCompile org.apache.maven.plugins:maven-surefire-plugin:test org.apache.maven.plugins:maven-ejb-plugin:ejb org.apache.maven.plugins:maven-install-plugin:install org.apache.maven.plugins:maven-deploy-plugin:deploy org.apache.maven.lifecycle.mapping.LifecycleMapping war org.apache.maven.lifecycle.mapping.DefaultLifecycleMapping default org.apache.maven.plugins:maven-resources-plugin:resources org.apache.maven.plugins:maven-compiler-plugin:compile org.apache.maven.plugins:maven-resources-plugin:testResources org.apache.maven.plugins:maven-compiler-plugin:testCompile org.apache.maven.plugins:maven-surefire-plugin:test org.apache.maven.plugins:maven-war-plugin:war org.apache.maven.plugins:maven-install-plugin:install org.apache.maven.plugins:maven-deploy-plugin:deploy org.apache.maven.lifecycle.mapping.LifecycleMapping ear org.apache.maven.lifecycle.mapping.DefaultLifecycleMapping default org.apache.maven.plugins:maven-ear-plugin:generate-application-xml org.apache.maven.plugins:maven-resources-plugin:resources org.apache.maven.plugins:maven-ear-plugin:ear org.apache.maven.plugins:maven-install-plugin:install org.apache.maven.plugins:maven-deploy-plugin:deploy org.apache.maven.lifecycle.mapping.LifecycleMapping rar org.apache.maven.lifecycle.mapping.DefaultLifecycleMapping default org.apache.maven.plugins:maven-resources-plugin:resources org.apache.maven.plugins:maven-compiler-plugin:compile org.apache.maven.plugins:maven-resources-plugin:testResources org.apache.maven.plugins:maven-compiler-plugin:testCompile org.apache.maven.plugins:maven-surefire-plugin:test org.apache.maven.plugins:maven-rar-plugin:rar org.apache.maven.plugins:maven-install-plugin:install org.apache.maven.plugins:maven-deploy-plugin:deploy org.apache.maven.lifecycle.mapping.LifecycleMapping par org.apache.maven.lifecycle.mapping.DefaultLifecycleMapping org.apache.maven.plugins:maven-resources-plugin:resources org.apache.maven.plugins:maven-compiler-plugin:compile org.apache.maven.plugins:maven-resources-plugin:testResources org.apache.maven.plugins:maven-compiler-plugin:testCompile org.apache.maven.plugins:maven-surefire-plugin:test org.apache.maven.plugins:maven-par-plugin:par org.apache.maven.plugins:maven-install-plugin:install org.apache.maven.plugins:maven-deploy-plugin:deploy org.apache.maven.lifecycle.mapping.LifecycleMapping ejb3 org.apache.maven.lifecycle.mapping.DefaultLifecycleMapping org.apache.maven.plugins:maven-resources-plugin:resources org.apache.maven.plugins:maven-compiler-plugin:compile org.apache.maven.plugins:maven-resources-plugin:testResources org.apache.maven.plugins:maven-compiler-plugin:testCompile org.apache.maven.plugins:maven-surefire-plugin:test org.apache.maven.plugins:maven-ejb3-plugin:ejb3 org.apache.maven.plugins:maven-install-plugin:install org.apache.maven.plugins:maven-deploy-plugin:deploy org.apache.maven.plugin.version.PluginVersionManager default org.apache.maven.plugin.version.DefaultPluginVersionManager per-lookup org.apache.maven.artifact.metadata.ArtifactMetadataSource org.apache.maven.plugin.registry.MavenPluginRegistryBuilder org.apache.maven.artifact.factory.ArtifactFactory org.codehaus.plexus.components.interactivity.InputHandler org.apache.maven.project.MavenProjectBuilder org.apache.maven.execution.RuntimeInformation org.sonatype.plexus.components.sec.dispatcher.SecDispatcher maven org.sonatype.plexus.components.sec.dispatcher.DefaultSecDispatcher Maven Security dispatcher org.sonatype.plexus.components.cipher.PlexusCipher _cipher org.sonatype.plexus.components.sec.dispatcher.PasswordDecryptor _decryptors <_configuration-file>~/.m2/settings-security.xml org.apache.maven.wagon.Wagon http-lightweight org.apache.maven.wagon.providers.http.LightweightHttpWagon per-lookup LightweightHttpWagon org.apache.maven.wagon.Wagon https-lightweight org.apache.maven.wagon.providers.http.LightweightHttpsWagon per-lookup LIghtweightHttpsWagon org.apache.maven.wagon.Wagon https-httpclient org.apache.maven.wagon.providers.http.HttpWagon per-lookup org.apache.maven.wagon.Wagon http-httpclient org.apache.maven.wagon.providers.http.HttpWagon per-lookup maven2-core-2.2.1/maven-core/src/main/resources/META-INF/plexus/plexus.xml0000644000175000017500000000276510551365651026114 0ustar twernertwerner org.apache.maven.plugin.MavenPluginCollector org.apache.maven.plugin.MavenPluginCollector org.apache.maven.plugin.MavenPluginCollector maven2-core-2.2.1/maven-core/src/main/resources/META-INF/maven/0000755000175000017500000000000011250552241023614 5ustar twernertwernermaven2-core-2.2.1/maven-core/src/main/resources/META-INF/maven/plugin-expressions/0000755000175000017500000000000011250552241027472 5ustar twernertwerner././@LongLink0000000000000000000000000000015000000000000011561 Lustar rootrootmaven2-core-2.2.1/maven-core/src/main/resources/META-INF/maven/plugin-expressions/settings.paramdoc.xmlmaven2-core-2.2.1/maven-core/src/main/resources/META-INF/maven/plugin-expressions/settings.paramdoc.0000644000175000017500000000402410772004567033133 0ustar twernertwerner settings.offline true ]]> settings.interactiveMode true ]]> ././@LongLink0000000000000000000000000000015000000000000011561 Lustar rootrootmaven2-core-2.2.1/maven-core/src/main/resources/META-INF/maven/plugin-expressions/rootless.paramdoc.xmlmaven2-core-2.2.1/maven-core/src/main/resources/META-INF/maven/plugin-expressions/rootless.paramdoc.0000644000175000017500000000353310772004567033151 0ustar twernertwerner localRepository /path/to/local/repository ]]> The ArtifactRepository instance referencing the local artifact repository. -Dmaven.repo.local=/path/to/local/repo Override the local repository location on a per-build basis. reactorProjects This is the current list of projects being built by Maven. ././@LongLink0000000000000000000000000000014700000000000011567 Lustar rootrootmaven2-core-2.2.1/maven-core/src/main/resources/META-INF/maven/plugin-expressions/project.paramdoc.xmlmaven2-core-2.2.1/maven-core/src/main/resources/META-INF/maven/plugin-expressions/project.paramdoc.x0000644000175000017500000001312010772004567033126 0ustar twernertwerner project.distributionManagementArtifactRepository repo Repository Name scp://host/path/to/repo repo Repository Name scp://host/path/to/repo ]]> This is the ArtifactRepository used to deploy artifacts built by this Maven. project.artifact project.group project-artifact 0.0.0.0 type ]]> This is the Artifact instance created from the essential project attributes: groupId, artifactId, version, and packaging (with a default packaging of 'jar'). project.parent project.group project-artifact 0.0.0.0 ]]> This is the MavenProject instance for the parent of the current POM. project.file This is the File instance that refers to the location of the current POM on disk. project.artifacts ... ]]> project.parentArtifact project.group project-artifact 0.0.0.0 ]]> This is the Artifact instance for the parent of the current POM. project.pluginArtifacts ... ]]> project.remoteArtifactRepositories ... ]]> project.pluginArtifactRepositories ... ]]> project.attachedArtifacts maven2-core-2.2.1/maven-core/src/main/java/0000755000175000017500000000000011250552240020254 5ustar twernertwernermaven2-core-2.2.1/maven-core/src/main/java/org/0000755000175000017500000000000011250552240021043 5ustar twernertwernermaven2-core-2.2.1/maven-core/src/main/java/org/apache/0000755000175000017500000000000011250552240022264 5ustar twernertwernermaven2-core-2.2.1/maven-core/src/main/java/org/apache/maven/0000755000175000017500000000000011250552241023373 5ustar twernertwernermaven2-core-2.2.1/maven-core/src/main/java/org/apache/maven/reactor/0000755000175000017500000000000011250552240025031 5ustar twernertwernermaven2-core-2.2.1/maven-core/src/main/java/org/apache/maven/reactor/MavenExecutionException.java0000644000175000017500000000260010551365651032516 0ustar twernertwernerpackage org.apache.maven.reactor; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ /** * @author Jason van Zyl * @version $Id: MavenExecutionException.java 495147 2007-01-11 07:47:53Z jvanzyl $ */ public class MavenExecutionException extends Exception { public MavenExecutionException() { } public MavenExecutionException( String message ) { super( message ); } public MavenExecutionException( Throwable cause ) { super( cause ); } public MavenExecutionException( String message, Throwable cause ) { super( message, cause ); } } maven2-core-2.2.1/maven-core/src/main/java/org/apache/maven/extension/0000755000175000017500000000000011250552241025407 5ustar twernertwernermaven2-core-2.2.1/maven-core/src/main/java/org/apache/maven/extension/DefaultExtensionManager.java0000644000175000017500000003442411231706256033043 0ustar twernertwernerpackage org.apache.maven.extension; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import static org.apache.maven.container.ContainerUtils.findChildComponentHints; import org.apache.maven.MavenArtifactFilterManager; import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.ArtifactUtils; import org.apache.maven.artifact.factory.ArtifactFactory; import org.apache.maven.artifact.handler.ArtifactHandler; import org.apache.maven.artifact.manager.WagonManager; import org.apache.maven.artifact.metadata.ArtifactMetadataRetrievalException; import org.apache.maven.artifact.metadata.ArtifactMetadataSource; import org.apache.maven.artifact.metadata.ResolutionGroup; import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.artifact.resolver.ArtifactNotFoundException; import org.apache.maven.artifact.resolver.ArtifactResolutionException; import org.apache.maven.artifact.resolver.ArtifactResolutionResult; import org.apache.maven.artifact.resolver.ArtifactResolver; import org.apache.maven.artifact.resolver.filter.ArtifactFilter; import org.apache.maven.model.Extension; import org.apache.maven.plugin.DefaultPluginManager; import org.apache.maven.project.MavenProject; import org.apache.maven.wagon.Wagon; import org.codehaus.classworlds.ClassRealm; import org.codehaus.classworlds.ClassWorld; import org.codehaus.classworlds.DuplicateRealmException; import org.codehaus.classworlds.NoSuchRealmException; import org.codehaus.plexus.DefaultPlexusContainer; import org.codehaus.plexus.PlexusConstants; import org.codehaus.plexus.PlexusContainer; import org.codehaus.plexus.PlexusContainerException; import org.codehaus.plexus.component.repository.exception.ComponentLookupException; import org.codehaus.plexus.context.Context; import org.codehaus.plexus.context.ContextException; import org.codehaus.plexus.logging.AbstractLogEnabled; import org.codehaus.plexus.personality.plexus.lifecycle.phase.Contextualizable; import org.codehaus.plexus.util.xml.Xpp3Dom; import org.codehaus.plexus.util.xml.Xpp3DomBuilder; import java.io.File; import java.io.InputStream; import java.io.InputStreamReader; import java.util.Collections; import java.util.HashMap; import java.util.Iterator; import java.util.LinkedHashSet; import java.util.Map; import java.util.Set; import java.util.jar.JarFile; /** * Used to locate extensions. * * @author Brett Porter * @author Jason van Zyl * @version $Id: DefaultExtensionManager.java 796891 2009-07-22 22:03:26Z jdcasey $ */ public class DefaultExtensionManager extends AbstractLogEnabled implements ExtensionManager, Contextualizable { private ArtifactResolver artifactResolver; private ArtifactFactory artifactFactory; private ArtifactMetadataSource artifactMetadataSource; private DefaultPlexusContainer container; private ArtifactFilter artifactFilter = MavenArtifactFilterManager.createExtensionFilter(); private WagonManager wagonManager; private PlexusContainer extensionContainer; private static final String CONTAINER_NAME = "extensions"; public void addExtension( Extension extension, MavenProject project, ArtifactRepository localRepository ) throws ArtifactResolutionException, PlexusContainerException, ArtifactNotFoundException { String extensionId = ArtifactUtils.versionlessKey( extension.getGroupId(), extension.getArtifactId() ); getLogger().debug( "Initialising extension: " + extensionId ); Artifact artifact = (Artifact) project.getExtensionArtifactMap().get( extensionId ); if ( artifact != null ) { ArtifactFilter filter = new ProjectArtifactExceptionFilter( artifactFilter, project.getArtifact() ); ResolutionGroup resolutionGroup; try { resolutionGroup = artifactMetadataSource.retrieve( artifact, localRepository, project.getRemoteArtifactRepositories() ); } catch ( ArtifactMetadataRetrievalException e ) { throw new ArtifactResolutionException( "Unable to download metadata from repository for plugin '" + artifact.getId() + "': " + e.getMessage(), artifact, e ); } // We use the same hack here to make sure that plexus 1.1 is available for extensions that do // not declare plexus-utils but need it. MNG-2900 Set rgArtifacts = resolutionGroup.getArtifacts(); rgArtifacts = DefaultPluginManager.checkPlexusUtils( rgArtifacts, artifactFactory ); Set dependencies = new LinkedHashSet(); dependencies.add( artifact ); dependencies.addAll( rgArtifacts ); // Make sure that we do not influence the dependenecy resolution of extensions with the project's // dependencyManagement ArtifactResolutionResult result = artifactResolver.resolveTransitively( dependencies, project.getArtifact(), Collections.EMPTY_MAP, //project.getManagedVersionMap(), localRepository, project.getRemoteArtifactRepositories(), artifactMetadataSource, filter ); // gross hack for some backwards compat (MNG-2749) // if it is a lone artifact, then we assume it to be a resource package, and put it in the main container // as before. If it has dependencies, that's when we risk conflict and exile to the child container // jvz: we have to make this 2 because plexus is always added now. Set artifacts = result.getArtifacts(); // Lifecycles are loaded by the Lifecycle executor by looking up lifecycle definitions from the // core container. So we need to look if an extension has a lifecycle mapping and use the container // and not an extension container. (MNG-2831) if ( extensionContainsLifeycle( artifact.getFile() ) ) { for ( Iterator i = artifacts.iterator(); i.hasNext(); ) { Artifact a = (Artifact) i.next(); if ( artifactFilter.include( a ) ) { getLogger().debug( "Adding extension to core container: " + a.getFile() ); container.addJarResource( a.getFile() ); } } } else if ( artifacts.size() == 2 ) { for ( Iterator i = artifacts.iterator(); i.hasNext(); ) { Artifact a = (Artifact) i.next(); if ( !a.getArtifactId().equals( "plexus-utils" ) ) { a = project.replaceWithActiveArtifact( a ); getLogger().debug( "Adding extension to core container: " + a.getFile() ); container.addJarResource( a.getFile() ); } } } else { // create a child container for the extension // TODO: this could surely be simpler/different on trunk with the new classworlds if ( extensionContainer == null ) { extensionContainer = createContainer(); } for ( Iterator i = result.getArtifacts().iterator(); i.hasNext(); ) { Artifact a = (Artifact) i.next(); a = project.replaceWithActiveArtifact( a ); getLogger().debug( "Adding to extension classpath: " + a.getFile() ); extensionContainer.addJarResource( a.getFile() ); } if ( getLogger().isDebugEnabled() ) { getLogger().debug( "Extension container contents:" ); extensionContainer.getContainerRealm().display(); } } } } private PlexusContainer createContainer() throws PlexusContainerException { DefaultPlexusContainer child = new DefaultPlexusContainer(); ClassWorld classWorld = container.getClassWorld(); child.setClassWorld( classWorld ); ClassRealm childRealm = null; // note: ideally extensions would live in their own realm, but this would mean that things like wagon-scm would // have no way to obtain SCM extensions String childRealmId = "plexus.core.child-container[" + CONTAINER_NAME + "]"; try { childRealm = classWorld.getRealm( childRealmId ); } catch ( NoSuchRealmException e ) { try { childRealm = classWorld.newRealm( childRealmId ); } catch ( DuplicateRealmException impossibleError ) { getLogger().error( "An impossible error has occurred. After getRealm() failed, newRealm() " + "produced duplication error on same id!", impossibleError ); } } childRealm.setParent( container.getContainerRealm() ); child.setCoreRealm( childRealm ); child.setName( CONTAINER_NAME ); // This is what we are skipping - we use the parent realm, but not the parent container since otherwise // we won't reload component descriptors that already exist in there // child.setParentPlexusContainer( this ); // ---------------------------------------------------------------------- // Set all the child elements from the parent that were set // programmatically. // ---------------------------------------------------------------------- child.setLoggerManager( container.getLoggerManager() ); child.initialize(); child.start(); return child; } public void registerWagons() { if ( extensionContainer != null ) { Set wagons = findChildComponentHints( Wagon.ROLE, container, extensionContainer ); if ( wagons != null && !wagons.isEmpty() ) { getLogger().debug( "Wagons to register: " + wagons ); wagonManager.registerWagons( wagons, extensionContainer ); } } else { getLogger().debug( "Wagons could not be registered as the extension container was never created" ); } } @SuppressWarnings( "unchecked" ) public Map getArtifactTypeHandlers() { Map result = new HashMap(); if ( extensionContainer != null ) { try { result.putAll( extensionContainer.lookupMap( ArtifactHandler.ROLE ) ); } catch ( ComponentLookupException e ) { getLogger().debug( "ArtifactHandler extensions could not be loaded: " + e.getMessage(), e ); } } else { try { result.putAll( container.lookupMap( ArtifactHandler.ROLE ) ); } catch ( ComponentLookupException e ) { getLogger().debug( "ArtifactHandler extensions could not be loaded: " + e.getMessage(), e ); } } return result; } public void contextualize( Context context ) throws ContextException { container = (DefaultPlexusContainer) context.get( PlexusConstants.PLEXUS_KEY ); } private static final class ProjectArtifactExceptionFilter implements ArtifactFilter { private ArtifactFilter passThroughFilter; private String projectDependencyConflictId; ProjectArtifactExceptionFilter( ArtifactFilter passThroughFilter, Artifact projectArtifact ) { this.passThroughFilter = passThroughFilter; projectDependencyConflictId = projectArtifact.getDependencyConflictId(); } public boolean include( Artifact artifact ) { String depConflictId = artifact.getDependencyConflictId(); return projectDependencyConflictId.equals( depConflictId ) || passThroughFilter.include( artifact ); } } private boolean extensionContainsLifeycle( File extension ) { JarFile f; try { f = new JarFile( extension ); InputStream is = f.getInputStream( f.getEntry( "META-INF/plexus/components.xml" ) ); if ( is == null ) { return false; } Xpp3Dom dom = Xpp3DomBuilder.build( new InputStreamReader( is ) ); Xpp3Dom[] components = dom.getChild( "components" ).getChildren( "component" ); for ( int i = 0; i < components.length; i++ ) { if ( components[i].getChild( "role" ).getValue().equals( "org.apache.maven.lifecycle.mapping.LifecycleMapping" ) ) { return true; } } } catch( Exception e ) { // do nothing } return false; } } maven2-core-2.2.1/maven-core/src/main/java/org/apache/maven/extension/ExtensionManager.java0000644000175000017500000000336211226741032031526 0ustar twernertwernerpackage org.apache.maven.extension; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import org.apache.maven.artifact.handler.ArtifactHandler; import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.artifact.resolver.ArtifactNotFoundException; import org.apache.maven.artifact.resolver.ArtifactResolutionException; import org.apache.maven.model.Extension; import org.apache.maven.project.MavenProject; import org.codehaus.plexus.PlexusContainerException; import java.util.Map; /** * Used to locate extensions. * * @author Brett Porter * @version $Id: ExtensionManager.java 793745 2009-07-13 23:24:10Z jdcasey $ */ public interface ExtensionManager { void addExtension( Extension extension, MavenProject project, ArtifactRepository localRepository ) throws ArtifactResolutionException, PlexusContainerException, ArtifactNotFoundException; void registerWagons(); Map getArtifactTypeHandlers(); } maven2-core-2.2.1/maven-core/src/main/java/org/apache/maven/DefaultMaven.java0000644000175000017500000011473111233662172026626 0ustar twernertwernerpackage org.apache.maven; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import java.io.File; import java.io.FileNotFoundException; import java.io.IOException; import java.text.DateFormat; import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Collections; import java.util.Date; import java.util.HashSet; import java.util.Iterator; import java.util.List; import java.util.Properties; import java.util.Set; import java.util.TimeZone; import org.apache.maven.artifact.manager.DefaultWagonManager; import org.apache.maven.artifact.manager.WagonManager; import org.apache.maven.artifact.manager.WagonProviderMapping; import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.artifact.resolver.ArtifactResolutionException; import org.apache.maven.artifact.resolver.ArtifactResolver; import org.apache.maven.artifact.resolver.DefaultArtifactResolver; import org.apache.maven.artifact.versioning.ArtifactVersion; import org.apache.maven.artifact.versioning.DefaultArtifactVersion; import org.apache.maven.execution.BuildFailure; import org.apache.maven.execution.DefaultMavenExecutionRequest; import org.apache.maven.execution.MavenExecutionRequest; import org.apache.maven.execution.MavenSession; import org.apache.maven.execution.ReactorManager; import org.apache.maven.execution.RuntimeInformation; import org.apache.maven.lifecycle.LifecycleExecutionException; import org.apache.maven.lifecycle.LifecycleExecutor; import org.apache.maven.model.Profile; import org.apache.maven.monitor.event.DefaultEventDispatcher; import org.apache.maven.monitor.event.EventDispatcher; import org.apache.maven.monitor.event.MavenEvents; import org.apache.maven.profiles.ProfileManager; import org.apache.maven.profiles.activation.ProfileActivationException; import org.apache.maven.project.DuplicateProjectException; import org.apache.maven.project.MavenProject; import org.apache.maven.project.MavenProjectBuilder; import org.apache.maven.project.MissingProjectException; import org.apache.maven.project.ProjectBuildingException; import org.apache.maven.reactor.MavenExecutionException; import org.apache.maven.settings.Mirror; import org.apache.maven.settings.Proxy; import org.apache.maven.settings.Server; import org.apache.maven.settings.Settings; import org.apache.maven.usability.SystemWarnings; import org.apache.maven.usability.diagnostics.ErrorDiagnostics; import org.codehaus.plexus.PlexusConstants; import org.codehaus.plexus.PlexusContainer; import org.codehaus.plexus.component.repository.exception.ComponentLifecycleException; import org.codehaus.plexus.component.repository.exception.ComponentLookupException; import org.codehaus.plexus.context.Context; import org.codehaus.plexus.context.ContextException; import org.codehaus.plexus.logging.AbstractLogEnabled; import org.codehaus.plexus.personality.plexus.lifecycle.phase.Contextualizable; import org.codehaus.plexus.util.FileUtils; import org.codehaus.plexus.util.Os; import org.codehaus.plexus.util.StringUtils; import org.codehaus.plexus.util.dag.CycleDetectedException; import org.codehaus.plexus.util.xml.Xpp3Dom; import org.sonatype.plexus.components.sec.dispatcher.SecDispatcher; import org.sonatype.plexus.components.sec.dispatcher.SecDispatcherException; /** * @author Jason van Zyl * @version $Id: DefaultMaven.java 798706 2009-07-28 20:50:02Z brett $ */ public class DefaultMaven extends AbstractLogEnabled implements Maven, Contextualizable { // ---------------------------------------------------------------------- // Components // ---------------------------------------------------------------------- protected MavenProjectBuilder projectBuilder; protected LifecycleExecutor lifecycleExecutor; protected PlexusContainer container; protected ErrorDiagnostics errorDiagnostics; protected RuntimeInformation runtimeInformation; private static final long MB = 1024 * 1024; private static final int MS_PER_SEC = 1000; private static final int SEC_PER_MIN = 60; // ---------------------------------------------------------------------- // Project execution // ---------------------------------------------------------------------- public void execute( MavenExecutionRequest request ) throws MavenExecutionException { // if ( request.getLocalRepository() == null ) // { // request.setLocalRepository( mavenTools.createLocalRepository( request.getLocalRepositoryPath() ) ); // } EventDispatcher dispatcher = request.getEventDispatcher(); String event = MavenEvents.REACTOR_EXECUTION; dispatcher.dispatchStart( event, request.getBaseDirectory() ); ReactorManager rm; try { rm = doExecute( request, dispatcher ); } catch ( LifecycleExecutionException e ) { dispatcher.dispatchError( event, request.getBaseDirectory(), e ); logError( e, request.isShowErrors() ); stats( request.getStartTime() ); line(); throw new MavenExecutionException( e.getMessage(), e ); } catch ( BuildFailureException e ) { dispatcher.dispatchError( event, request.getBaseDirectory(), e ); logFailure( e, request.isShowErrors() ); stats( request.getStartTime() ); line(); throw new MavenExecutionException( e.getMessage(), e ); } catch ( Throwable t ) { dispatcher.dispatchError( event, request.getBaseDirectory(), t ); logFatal( t ); stats( request.getStartTime() ); line(); throw new MavenExecutionException( "Error executing project within the reactor", t ); } // Either the build was successful, or it was a fail_at_end/fail_never reactor build // TODO: should all the logging be left to the CLI? logReactorSummary( rm ); if ( rm.hasBuildFailures() ) { logErrors( rm, request.isShowErrors() ); if ( !ReactorManager.FAIL_NEVER.equals( rm.getFailureBehavior() ) ) { dispatcher.dispatchError( event, request.getBaseDirectory(), null ); getLogger().info( "BUILD ERRORS" ); line(); stats( request.getStartTime() ); line(); throw new MavenExecutionException( "Some builds failed" ); } else { getLogger().info( " + Ignoring failures" ); } } logSuccess( rm ); stats( request.getStartTime() ); line(); dispatcher.dispatchEnd( event, request.getBaseDirectory() ); } private void logErrors( ReactorManager rm, boolean showErrors ) { for ( Iterator it = rm.getSortedProjects().iterator(); it.hasNext(); ) { MavenProject project = (MavenProject) it.next(); if ( rm.hasBuildFailure( project ) ) { BuildFailure buildFailure = rm.getBuildFailure( project ); getLogger().info( "Error for project: " + project.getName() + " (during " + buildFailure.getTask() + ")" ); line(); logDiagnostics( buildFailure.getCause() ); logTrace( buildFailure.getCause(), showErrors ); } } if ( !showErrors ) { getLogger().info( "For more information, run Maven with the -e switch" ); line(); } } private ReactorManager doExecute( MavenExecutionRequest request, EventDispatcher dispatcher ) throws MavenExecutionException, BuildFailureException, LifecycleExecutionException { try { resolveParameters( request.getSettings(), request.getExecutionProperties() ); } catch ( ComponentLookupException e ) { throw new MavenExecutionException( "Unable to configure Maven for execution", e ); } catch ( ComponentLifecycleException e ) { throw new MavenExecutionException( "Unable to configure Maven for execution", e ); } catch ( SettingsConfigurationException e ) { throw new MavenExecutionException( "Unable to configure Maven for execution", e ); } ProfileManager globalProfileManager = request.getGlobalProfileManager(); globalProfileManager.loadSettingsProfiles( request.getSettings() ); getLogger().info( "Scanning for projects..." ); boolean foundProjects = true; List projects = getProjects( request ); if ( projects.isEmpty() ) { projects.add( getSuperProject( request ) ); foundProjects = false; } ReactorManager rm; try { String resumeFrom = request.getResumeFrom(); List projectList = request.getSelectedProjects(); String makeBehavior = request.getMakeBehavior(); rm = new ReactorManager( projects, projectList, resumeFrom, makeBehavior ); rm.setFailureBehavior( request.getFailureBehavior() ); } catch ( CycleDetectedException e ) { throw new BuildFailureException( "The projects in the reactor contain a cyclic reference: " + e.getMessage(), e ); } catch ( DuplicateProjectException e ) { throw new BuildFailureException( e.getMessage(), e ); } catch ( MissingProjectException e ) { throw new BuildFailureException( e.getMessage(), e ); } // -------------------------------------------------------------------------------- // MNG-3641: print a warning if one of the profiles to be activated explicitly // was not activated validateActivatedProfiles( globalProfileManager, projects ); if ( rm.hasMultipleProjects() ) { getLogger().info( "Reactor build order: " ); for ( Iterator i = rm.getSortedProjects().iterator(); i.hasNext(); ) { MavenProject project = (MavenProject) i.next(); getLogger().info( " " + project.getName() ); } } MavenSession session = createSession( request, rm ); session.setUsingPOMsFromFilesystem( foundProjects ); lifecycleExecutor.execute( session, rm, dispatcher ); return rm; } private void validateActivatedProfiles( ProfileManager globalProfileManager, List projects ) { if ( globalProfileManager != null ) { // get all activated profile ids Set activeProfileIds = new HashSet(); for ( Iterator i = projects.iterator(); i.hasNext(); ) { MavenProject project = (MavenProject) i.next(); do { for ( Iterator j = project.getActiveProfiles().iterator(); j.hasNext(); ) { activeProfileIds.add( ( (Profile) j.next() ).getId() ); } project = project.getParent(); } while ( project != null ); } for ( Iterator i = globalProfileManager.getExplicitlyActivatedIds().iterator(); i.hasNext(); ) { String explicitProfileId = (String) i.next(); if ( !activeProfileIds.contains( explicitProfileId ) ) { getLogger().warn( "\n\tProfile with id: \'" + explicitProfileId + "\' has not been activated.\n" ); } } } } private MavenProject getSuperProject( MavenExecutionRequest request ) throws MavenExecutionException { MavenProject superProject; try { superProject = projectBuilder.buildStandaloneSuperProject( request.getLocalRepository(), request.getGlobalProfileManager() ); } catch ( ProjectBuildingException e ) { throw new MavenExecutionException( e.getMessage(), e ); } return superProject; } private List getProjects( MavenExecutionRequest request ) throws MavenExecutionException, BuildFailureException { List projects; try { List files = getProjectFiles( request ); projects = collectProjects( files, request, !request.isReactorActive() ); } catch ( IOException e ) { throw new MavenExecutionException( "Error processing projects for the reactor: " + e.getMessage(), e ); } catch ( ArtifactResolutionException e ) { throw new MavenExecutionException( e.getMessage(), e ); } catch ( ProjectBuildingException e ) { throw new MavenExecutionException( e.getMessage(), e ); } catch ( ProfileActivationException e ) { throw new MavenExecutionException( e.getMessage(), e ); } return projects; } private void logReactorSummaryLine( String name, String status ) { logReactorSummaryLine( name, status, -1 ); } private void logReactorSummaryLine( String name, String status, long time ) { StringBuffer messageBuffer = new StringBuffer(); messageBuffer.append( name ); int dotCount = 54; dotCount -= name.length(); messageBuffer.append( " " ); for ( int i = 0; i < dotCount; i++ ) { messageBuffer.append( '.' ); } messageBuffer.append( " " ); messageBuffer.append( status ); if ( time >= 0 ) { messageBuffer.append( " [" ); messageBuffer.append( getFormattedTime( time ) ); messageBuffer.append( "]" ); } getLogger().info( messageBuffer.toString() ); } private static String getFormattedTime( long time ) { String pattern = "s.SSS's'"; if ( time / 60000L > 0 ) { pattern = "m:s" + pattern; if ( time / 3600000L > 0 ) { pattern = "H:m" + pattern; } } DateFormat fmt = new SimpleDateFormat( pattern ); fmt.setTimeZone( TimeZone.getTimeZone( "UTC" ) ); return fmt.format( new Date( time ) ); } private List collectProjects( List files, MavenExecutionRequest request, boolean isRoot ) throws ArtifactResolutionException, ProjectBuildingException, ProfileActivationException, MavenExecutionException, BuildFailureException { // .getLocalRepository(), request.isRecursive(), // request.getSettings(), request.getUserProperties(), requ, !request.isReactorActive() List projects = new ArrayList( files.size() ); for ( Iterator iterator = files.iterator(); iterator.hasNext(); ) { File file = (File) iterator.next(); boolean usingReleasePom = false; if ( RELEASE_POMv4.equals( file.getName() ) ) { getLogger().info( "NOTE: Using release-pom: " + file + " in reactor build." ); usingReleasePom = true; } MavenProject project = getProject( file, request ); if ( isRoot ) { project.setExecutionRoot( true ); } if ( ( project.getPrerequisites() != null ) && ( project.getPrerequisites().getMaven() != null ) ) { DefaultArtifactVersion version = new DefaultArtifactVersion( project.getPrerequisites().getMaven() ); if ( runtimeInformation.getApplicationVersion().compareTo( version ) < 0 ) { throw new BuildFailureException( "Unable to build project '" + project.getFile() + "; it requires Maven version " + version.toString() ); } } if ( ( project.getModules() != null ) && !project.getModules().isEmpty() && request.isRecursive() ) { // TODO: Really should fail if it was not? What if it is aggregating - eg "ear"? project.setPackaging( "pom" ); File basedir = file.getParentFile(); // Initial ordering is as declared in the modules section List moduleFiles = new ArrayList( project.getModules().size() ); for ( Iterator i = project.getModules().iterator(); i.hasNext(); ) { String name = (String) i.next(); if ( StringUtils.isEmpty( StringUtils.trim( name ) ) ) { getLogger().warn( "Empty module detected. Please check you don't have any empty module definitions in your POM." ); continue; } File moduleFile = new File( basedir, name ); if ( moduleFile.exists() && moduleFile.isDirectory() ) { if ( usingReleasePom ) { moduleFile = new File( basedir, name + "/" + Maven.RELEASE_POMv4 ); } else { moduleFile = new File( basedir, name + "/" + Maven.POMv4 ); } } if ( Os.isFamily( "windows" ) ) { // we don't canonicalize on unix to avoid interfering with symlinks try { moduleFile = moduleFile.getCanonicalFile(); } catch ( IOException e ) { throw new MavenExecutionException( "Unable to canonicalize file name " + moduleFile, e ); } } else { moduleFile = new File( moduleFile.toURI().normalize() ); } moduleFiles.add( moduleFile ); } List collectedProjects = collectProjects( moduleFiles, request, false ); projects.addAll( collectedProjects ); project.setCollectedProjects( collectedProjects ); } projects.add( project ); } return projects; } /** * @deprecated Use {@link DefaultMaven#getProject(File, MavenExecutionRequest)} instead. */ public MavenProject getProject( File pom, ArtifactRepository localRepository, Settings settings, Properties userProperties, ProfileManager globalProfileManager ) throws ProjectBuildingException, ArtifactResolutionException, ProfileActivationException { MavenExecutionRequest request = new DefaultMavenExecutionRequest( localRepository, settings, new DefaultEventDispatcher(), Collections.EMPTY_LIST, pom.getParentFile() .getAbsolutePath(), globalProfileManager, globalProfileManager.getRequestProperties(), new Properties(), false ); return getProject( pom, request ); } public MavenProject getProject( File pom, MavenExecutionRequest request ) throws ProjectBuildingException, ArtifactResolutionException, ProfileActivationException { if ( pom.exists() ) { if ( pom.length() == 0 ) { throw new ProjectBuildingException( "unknown", "The file " + pom.getAbsolutePath() + " you specified has zero length." ); } } return projectBuilder.build( pom, request.getProjectBuilderConfiguration() ); } // ---------------------------------------------------------------------- // Methods used by all execution request handlers // ---------------------------------------------------------------------- //!! We should probably have the execution request handler create the // session as // the session type would be specific to the request i.e. having a project // or not. protected MavenSession createSession( MavenExecutionRequest request, ReactorManager rpm ) { return new MavenSession( container, request.getSettings(), request.getLocalRepository(), request.getEventDispatcher(), rpm, request.getGoals(), request.getBaseDirectory(), request.getExecutionProperties(), request.getUserProperties(), request.getStartTime() ); } /** * @todo [BP] this might not be required if there is a better way to pass * them in. It doesn't feel quite right. * @todo [JC] we should at least provide a mapping of protocol-to-proxy for * the wagons, shouldn't we? */ private void resolveParameters( Settings settings, Properties executionProperties ) throws ComponentLookupException, ComponentLifecycleException, SettingsConfigurationException { WagonManager wagonManager = (WagonManager) container.lookup( WagonManager.ROLE ); try { if ( settings.isOffline() ) { getLogger().info( SystemWarnings.getOfflineWarning() ); wagonManager.setOnline( false ); } try { DefaultWagonManager wm = (DefaultWagonManager) wagonManager; String oldUserAgent = wm.getHttpUserAgent(); int firstSpace = oldUserAgent == null ? -1 : oldUserAgent.indexOf( " " ); StringBuffer buffer = new StringBuffer(); buffer.append( "Apache-Maven/" ); ArtifactVersion version = runtimeInformation.getApplicationVersion(); if ( version != null ) { buffer.append( version.getMajorVersion() ); buffer.append( '.' ); buffer.append( version.getMinorVersion() ); } else { buffer.append( "unknown" ); } buffer.append( ' ' ); if ( firstSpace > -1 ) { buffer.append( oldUserAgent.substring( firstSpace + 1 ) ); buffer.append( ' ' ); buffer.append( oldUserAgent.substring( 0, firstSpace ) ); } else { buffer.append( oldUserAgent ); } wm.setHttpUserAgent( buffer.toString() ); } catch ( ClassCastException e ) { // ignore } SecDispatcher sd = null; try { Proxy proxy = settings.getActiveProxy(); try { sd = (SecDispatcher) container.lookup( SecDispatcher.ROLE, "maven" ); } catch (Exception e) { getLogger().warn( "Security features are disabled. Cannot find plexus component "+SecDispatcher.ROLE + ":maven" ); line(); } if ( proxy != null ) { if ( proxy.getHost() == null ) { throw new SettingsConfigurationException( "Proxy in settings.xml has no host" ); } String pass = proxy.getPassword(); if ( sd != null ) { try { pass = sd.decrypt( pass ); } catch ( SecDispatcherException e ) { reportSecurityConfigurationError( "password for proxy '" + proxy.getId() + "'", e ); } } wagonManager.addProxy( proxy.getProtocol(), proxy.getHost(), proxy.getPort(), proxy.getUsername(), pass, proxy.getNonProxyHosts() ); } for ( Iterator i = settings.getServers().iterator(); i.hasNext(); ) { Server server = (Server) i.next(); String passWord = server.getPassword(); if ( sd != null ) { try { passWord = sd.decrypt( passWord ); } catch ( SecDispatcherException e ) { reportSecurityConfigurationError( "password for server '" + server.getId() + "'", e ); } } String passPhrase = server.getPassphrase(); if ( sd != null ) { try { passPhrase = sd.decrypt( passPhrase ); } catch ( SecDispatcherException e ) { reportSecurityConfigurationError( "passphrase for server '" + server.getId() + "'", e ); } } wagonManager.addAuthenticationInfo( server.getId(), server.getUsername(), passWord, server.getPrivateKey(), passPhrase ); wagonManager.addPermissionInfo( server.getId(), server.getFilePermissions(), server.getDirectoryPermissions() ); if ( server.getConfiguration() != null ) { wagonManager.addConfiguration( server.getId(), (Xpp3Dom) server.getConfiguration() ); } } for ( Iterator i = settings.getMirrors().iterator(); i.hasNext(); ) { Mirror mirror = (Mirror) i.next(); wagonManager.addMirror( mirror.getId(), mirror.getMirrorOf(), mirror.getUrl() ); } } finally { if ( sd != null ) { container.release( sd ); } } } finally { container.release( wagonManager ); } WagonProviderMapping mapping = (WagonProviderMapping) container.lookup( WagonProviderMapping.ROLE ); try { // set defaults mapping.setWagonProvider( "http", "lightweight" ); mapping.setWagonProvider( "https", "lightweight" ); for ( Object k: executionProperties.keySet() ) { String key = (String) k; if ( key.startsWith( "maven.wagon.provider." ) ) { String provider = executionProperties.getProperty( key ); key = key.substring( "maven.wagon.provider.".length() ); mapping.setWagonProvider( key, provider ); } } } finally { container.release( mapping ); } // Would be better in settings.xml, but it is not extensible yet String numThreads = System.getProperty( "maven.artifact.threads" ); if ( numThreads != null ) { int threads = 0; try { threads = Integer.valueOf( numThreads ).intValue(); if ( threads < 1 ) { getLogger().warn( "Invalid number of threads '" + threads + "' will be ignored" ); } } catch ( NumberFormatException e ) { getLogger().warn( "Invalid number of threads '" + numThreads + "' will be ignored: " + e.getMessage() ); } if ( threads > 0 ) { DefaultArtifactResolver artifactResolver = (DefaultArtifactResolver) container.lookup( ArtifactResolver.ROLE ); try { artifactResolver.configureNumberOfThreads( threads ); getLogger().debug( "Resolution thread pool size set to: " + threads ); } finally { container.release( artifactResolver ); } } } } private void reportSecurityConfigurationError( String affectedConfiguration, SecDispatcherException e ) { Throwable cause = e; String msg = "Not decrypting " + affectedConfiguration + " due to exception in security handler."; // Drop to the actual cause, it wraps multiple times while ( cause.getCause() != null ) { cause = cause.getCause(); } // common cause is missing settings-security.xml if ( cause instanceof FileNotFoundException ) { msg += "\nEnsure that you have configured your master password file (and relocation if appropriate)\nSee the installation instructions for details."; } getLogger().warn( msg + "\nCause: " + cause.getMessage() ); getLogger().debug( "Full trace follows", e ); } // ---------------------------------------------------------------------- // Lifecylce Management // ---------------------------------------------------------------------- public void contextualize( Context context ) throws ContextException { container = (PlexusContainer) context.get( PlexusConstants.PLEXUS_KEY ); } // ---------------------------------------------------------------------- // Reporting / Logging // ---------------------------------------------------------------------- protected void logFatal( Throwable error ) { line(); getLogger().error( "FATAL ERROR" ); line(); logDiagnostics( error ); logTrace( error, true ); } protected void logError( Exception e, boolean showErrors ) { line(); getLogger().error( "BUILD ERROR" ); line(); logDiagnostics( e ); logTrace( e, showErrors ); if ( !showErrors ) { getLogger().info( "For more information, run Maven with the -e switch" ); line(); } } protected void logFailure( BuildFailureException e, boolean showErrors ) { line(); getLogger().error( "BUILD FAILURE" ); line(); logDiagnostics( e ); logTrace( e, showErrors ); if ( !showErrors ) { getLogger().info( "For more information, run Maven with the -e switch" ); line(); } } private void logTrace( Throwable t, boolean showErrors ) { if ( getLogger().isDebugEnabled() ) { getLogger().debug( "Trace", t ); line(); } else if ( showErrors ) { getLogger().info( "Trace", t ); line(); } } private void logDiagnostics( Throwable t ) { String message = null; if ( errorDiagnostics != null ) { message = errorDiagnostics.diagnose( t ); } if ( message == null ) { message = t.getMessage(); } getLogger().info( message ); line(); } protected void logSuccess( ReactorManager rm ) { line(); getLogger().info( "BUILD SUCCESSFUL" ); line(); } private void logReactorSummary( ReactorManager rm ) { if ( rm.hasMultipleProjects() && rm.executedMultipleProjects() ) { getLogger().info( "" ); getLogger().info( "" ); // ------------------------- // Reactor Summary: // ------------------------- // o project-name...........FAILED // o project2-name..........SKIPPED (dependency build failed or was skipped) // o project-3-name.........SUCCESS line(); getLogger().info( "Reactor Summary:" ); line(); for ( Iterator it = rm.getSortedProjects().iterator(); it.hasNext(); ) { MavenProject project = (MavenProject) it.next(); if ( rm.hasBuildFailure( project ) ) { logReactorSummaryLine( project.getName(), "FAILED", rm.getBuildFailure( project ).getTime() ); } else if ( rm.isBlackListed( project ) ) { logReactorSummaryLine( project.getName(), "SKIPPED (dependency build failed or was skipped)" ); } else if ( rm.hasBuildSuccess( project ) ) { logReactorSummaryLine( project.getName(), "SUCCESS", rm.getBuildSuccess( project ).getTime() ); } else { logReactorSummaryLine( project.getName(), "NOT BUILT" ); } } line(); } } protected void stats( Date start ) { Date finish = new Date(); long time = finish.getTime() - start.getTime(); getLogger().info( "Total time: " + formatTime( time ) ); getLogger().info( "Finished at: " + finish ); //noinspection CallToSystemGC System.gc(); Runtime r = Runtime.getRuntime(); getLogger().info( "Final Memory: " + ( r.totalMemory() - r.freeMemory() ) / MB + "M/" + r.totalMemory() / MB + "M" ); } protected void line() { getLogger().info( "------------------------------------------------------------------------" ); } protected static String formatTime( long ms ) { long secs = ms / MS_PER_SEC; long min = secs / SEC_PER_MIN; secs = secs % SEC_PER_MIN; String msg = ""; if ( min > 1 ) { msg = min + " minutes "; } else if ( min == 1 ) { msg = "1 minute "; } if ( secs > 1 ) { msg += secs + " seconds"; } else if ( secs == 1 ) { msg += "1 second"; } else if ( min == 0 ) { msg += "< 1 second"; } return msg; } private List getProjectFiles( MavenExecutionRequest request ) throws IOException { List files = Collections.EMPTY_LIST; File userDir = new File( System.getProperty( "user.dir" ) ); if ( request.isReactorActive() ) { // TODO: should we now include the pom.xml in the current directory? // String includes = System.getProperty( "maven.reactor.includes", "**/" + POMv4 ); // String excludes = System.getProperty( "maven.reactor.excludes", POMv4 ); String includes = System.getProperty( "maven.reactor.includes", "**/" + POMv4 + ",**/" + RELEASE_POMv4 ); String excludes = System.getProperty( "maven.reactor.excludes", POMv4 + "," + RELEASE_POMv4 ); files = FileUtils.getFiles( userDir, includes, excludes ); filterOneProjectFilePerDirectory( files ); // make sure there is consistent ordering on all platforms, rather than using the filesystem ordering Collections.sort( files ); } else if ( request.getPomFile() != null ) { File projectFile = new File( request.getPomFile() ).getAbsoluteFile(); if ( projectFile.exists() ) { files = Collections.singletonList( projectFile ); } } else { File projectFile = new File( userDir, RELEASE_POMv4 ); if ( !projectFile.exists() ) { projectFile = new File( userDir, POMv4 ); } if ( projectFile.exists() ) { files = Collections.singletonList( projectFile ); } } return files; } private void filterOneProjectFilePerDirectory( List files ) { List releaseDirs = new ArrayList(); for ( Iterator it = files.iterator(); it.hasNext(); ) { File projectFile = (File) it.next(); if ( RELEASE_POMv4.equals( projectFile.getName() ) ) { releaseDirs.add( projectFile.getParentFile() ); } } for ( Iterator it = files.iterator(); it.hasNext(); ) { File projectFile = (File) it.next(); // remove pom.xml files where there is a sibling release-pom.xml file... if ( !RELEASE_POMv4.equals( projectFile.getName() ) && releaseDirs.contains( projectFile.getParentFile() ) ) { it.remove(); } } } } ././@LongLink0000000000000000000000000000014500000000000011565 Lustar rootrootmaven2-core-2.2.1/maven-core/src/main/java/org/apache/maven/ReflectionConfigurationInterpolator.javamaven2-core-2.2.1/maven-core/src/main/java/org/apache/maven/ReflectionConfigurationInterpolator.java0000644000175000017500000000177511101576551033502 0ustar twernertwernerpackage org.apache.maven; import org.apache.maven.project.MavenProject; import org.apache.maven.project.ProjectBuilderConfiguration; import org.apache.maven.project.interpolation.ModelInterpolationException; import org.apache.maven.project.interpolation.StringSearchModelInterpolator; public class ReflectionConfigurationInterpolator extends StringSearchModelInterpolator implements ConfigurationInterpolator { public Object interpolate( Object configObject, MavenProject project, ProjectBuilderConfiguration config ) throws ConfigurationInterpolationException { try { interpolateObject( configObject, project.getModel(), project.getBasedir(), config, getLogger().isDebugEnabled() ); } catch ( ModelInterpolationException e ) { throw new ConfigurationInterpolationException( "Error interpolating configuration for project: " + project.getId() + "\n\n" + configObject, e ); } return configObject; } } maven2-core-2.2.1/maven-core/src/main/java/org/apache/maven/MavenArtifactFilterManager.java0000644000175000017500000000706411221205616031431 0ustar twernertwernerpackage org.apache.maven; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import org.apache.maven.artifact.resolver.filter.ArtifactFilter; import org.apache.maven.artifact.resolver.filter.ExclusionSetFilter; import java.util.Set; import java.util.HashSet; /** * @author Jason van Zyl * @version $Id: MavenArtifactFilterManager.java 788791 2009-06-26 17:55:26Z jdcasey $ * @todo this should probably be a component with some dynamic control of filtering */ public class MavenArtifactFilterManager { public static ArtifactFilter createStandardFilter() { Set artifacts = createBaseArtifactSet(); artifacts.add( "wagon-file" ); artifacts.add( "wagon-http-lightweight" ); artifacts.add( "wagon-webdav" ); artifacts.add( "wagon-ssh" ); artifacts.add( "wagon-ssh-external" ); artifacts.add( "wagon-ssh-common" ); artifacts.add( "wagon-http-shared" ); artifacts.add( "wagon-webdav-jackrabbit" ); return new ExclusionSetFilter( artifacts ); } public static ArtifactFilter createExtensionFilter() { Set artifacts = createBaseArtifactSet(); // It should be safe to include wagon implementations, and since this is used by the extension manager they would // get filtered out otherwise return new ExclusionSetFilter( artifacts ); } private static Set createBaseArtifactSet() { // TODO: configure this from bootstrap or scan lib Set artifacts = new HashSet(); artifacts.add( "classworlds" ); artifacts.add( "jsch" ); // artifacts.add( "commons-cli" ); artifacts.add( "doxia-sink-api" ); artifacts.add( "doxia-logging-api" ); artifacts.add( "maven-artifact" ); artifacts.add( "maven-artifact-manager" ); artifacts.add( "maven-core" ); artifacts.add( "maven-error-diagnoser" ); artifacts.add( "maven-model" ); artifacts.add( "maven-monitor" ); artifacts.add( "maven-plugin-api" ); artifacts.add( "maven-plugin-descriptor" ); artifacts.add( "maven-plugin-parameter-documenter" ); artifacts.add( "maven-plugin-registry" ); artifacts.add( "maven-profile" ); artifacts.add( "maven-project" ); artifacts.add( "maven-reporting-api" ); artifacts.add( "maven-repository-metadata" ); artifacts.add( "maven-settings" ); artifacts.add( "plexus-container-default" ); artifacts.add( "plexus-interactivity-api" ); artifacts.add( "maven-toolchain" ); artifacts.add( "wagon-provider-api" ); // drop the component-api - even though we don't use it directly it is included in out container-default artifacts.add( "plexus-component-api" ); return artifacts; } } maven2-core-2.2.1/maven-core/src/main/java/org/apache/maven/monitor/0000755000175000017500000000000011250552240025061 5ustar twernertwernermaven2-core-2.2.1/maven-core/src/main/java/org/apache/maven/monitor/logging/0000755000175000017500000000000011250552240026507 5ustar twernertwernermaven2-core-2.2.1/maven-core/src/main/java/org/apache/maven/monitor/logging/DefaultLog.java0000644000175000017500000000562410551365651031422 0ustar twernertwernerpackage org.apache.maven.monitor.logging; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import org.apache.maven.plugin.logging.Log; import org.codehaus.plexus.logging.Logger; /** * @author jdcasey */ public class DefaultLog implements Log { private final Logger logger; public DefaultLog( Logger logger ) { this.logger = logger; } public void debug( CharSequence content ) { logger.debug( toString( content ) ); } private String toString( CharSequence content ) { if ( content == null ) { return ""; } else { return content.toString(); } } public void debug( CharSequence content, Throwable error ) { logger.debug( toString( content ), error ); } public void debug( Throwable error ) { logger.debug( "", error ); } public void info( CharSequence content ) { logger.info( toString( content ) ); } public void info( CharSequence content, Throwable error ) { logger.info( toString( content ), error ); } public void info( Throwable error ) { logger.info( "", error ); } public void warn( CharSequence content ) { logger.warn( toString( content ) ); } public void warn( CharSequence content, Throwable error ) { logger.warn( toString( content ), error ); } public void warn( Throwable error ) { logger.warn( "", error ); } public void error( CharSequence content ) { logger.error( toString( content ) ); } public void error( CharSequence content, Throwable error ) { logger.error( toString( content ), error ); } public void error( Throwable error ) { logger.error( "", error ); } public boolean isDebugEnabled() { return logger.isDebugEnabled(); } public boolean isInfoEnabled() { return logger.isInfoEnabled(); } public boolean isWarnEnabled() { return logger.isWarnEnabled(); } public boolean isErrorEnabled() { return logger.isErrorEnabled(); } }maven2-core-2.2.1/maven-core/src/main/java/org/apache/maven/monitor/event/0000755000175000017500000000000011250552240026202 5ustar twernertwernermaven2-core-2.2.1/maven-core/src/main/java/org/apache/maven/monitor/event/DefaultEventMonitor.java0000644000175000017500000000260410551365651033020 0ustar twernertwernerpackage org.apache.maven.monitor.event; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import org.codehaus.plexus.logging.Logger; /** * @author jdcasey */ public class DefaultEventMonitor extends AbstractSelectiveEventMonitor { private static final String[] START_EVENTS = {MavenEvents.MOJO_EXECUTION}; private final Logger logger; public DefaultEventMonitor( Logger logger ) { super( START_EVENTS, MavenEvents.NO_EVENTS, MavenEvents.NO_EVENTS ); this.logger = logger; } protected void doStartEvent( String event, String target, long time ) { logger.info( "[" + target + "]" ); } }maven2-core-2.2.1/maven-core/src/main/java/org/apache/maven/container/0000755000175000017500000000000011250552240025354 5ustar twernertwernermaven2-core-2.2.1/maven-core/src/main/java/org/apache/maven/container/ContainerUtils.java0000644000175000017500000000515611232100305031160 0ustar twernertwernerpackage org.apache.maven.container; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import org.codehaus.plexus.PlexusContainer; import org.codehaus.plexus.component.repository.ComponentDescriptor; import java.util.HashMap; import java.util.LinkedHashMap; import java.util.Map; import java.util.Set; public class ContainerUtils { public static Set findChildComponentHints( String role, PlexusContainer parent, PlexusContainer child ) { return findChildComponents( role, parent, child ).keySet(); } @SuppressWarnings( "unchecked" ) public static Map findChildComponents( String role, PlexusContainer parent, PlexusContainer child ) { Map parentComponents = parent.getComponentDescriptorMap( role ); if ( parentComponents != null ) { parentComponents = new LinkedHashMap( parentComponents ); } Map childComponents = child.getComponentDescriptorMap( role ); if ( childComponents == null ) { return new HashMap(); } else { childComponents = new LinkedHashMap( childComponents ); if ( parentComponents != null && !parentComponents.isEmpty() ) { for ( Map.Entry entry : parentComponents.entrySet() ) { String hint = entry.getKey(); if ( childComponents.containsKey( hint ) && entry.getValue() == childComponents.get( hint ) ) { childComponents.remove( hint ); } } } } return childComponents; } } maven2-core-2.2.1/maven-core/src/main/java/org/apache/maven/cli/0000755000175000017500000000000011250552241024142 5ustar twernertwernermaven2-core-2.2.1/maven-core/src/main/java/org/apache/maven/cli/AbstractConsoleDownloadMonitor.java0000644000175000017500000001007211151244441033133 0ustar twernertwernerpackage org.apache.maven.cli; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import org.apache.maven.wagon.WagonConstants; import org.apache.maven.wagon.events.TransferEvent; import org.apache.maven.wagon.events.TransferListener; import org.codehaus.plexus.logging.AbstractLogEnabled; import org.codehaus.plexus.logging.Logger; import java.io.PrintStream; /** * Abstract console download progress meter. * * @author Carlos Sanchez * @version $Id: AbstractConsoleDownloadMonitor.java 747773 2009-02-25 13:35:29Z brett $ * @since 2.0.5 */ public abstract class AbstractConsoleDownloadMonitor extends AbstractLogEnabled implements TransferListener { private Logger logger; PrintStream out = System.out; public AbstractConsoleDownloadMonitor() { } public AbstractConsoleDownloadMonitor( Logger logger ) { this.logger = logger; } public void transferInitiated( TransferEvent transferEvent ) { String message = transferEvent.getRequestType() == TransferEvent.REQUEST_PUT ? "Uploading" : "Downloading"; String url = transferEvent.getWagon().getRepository().getUrl(); // TODO: can't use getLogger() because this isn't currently instantiated as a component out.println( message + ": " + url + "/" + transferEvent.getResource().getName() ); } /** * Do nothing */ public void transferStarted( TransferEvent transferEvent ) { // This space left intentionally blank } /** * Do nothing */ public void transferProgress( TransferEvent transferEvent, byte[] buffer, int length ) { // This space left intentionally blank } public void transferCompleted( TransferEvent transferEvent ) { String line = createCompletionLine( transferEvent ); out.println( line ); } protected String createCompletionLine( TransferEvent transferEvent ) { String line; long contentLength = transferEvent.getResource().getContentLength(); if ( contentLength != WagonConstants.UNKNOWN_LENGTH ) { StringBuffer buf = new StringBuffer(); String type = ( transferEvent.getRequestType() == TransferEvent.REQUEST_PUT ? "uploaded" : "downloaded" ); buf.append( contentLength >= 1024 ? ( contentLength / 1024 ) + "K" : contentLength + "b" ); String name = transferEvent.getResource().getName(); name = name.substring( name.lastIndexOf( '/' ) + 1, name.length() ); buf.append( " " ); buf.append( type ); buf.append( " (" ); buf.append( name ); buf.append( ")" ); line = buf.toString(); } else { line = ""; } return line; } public void transferError( TransferEvent transferEvent ) { // these errors should already be handled elsewhere by Maven since they all result in an exception from Wagon if ( logger != null ) { Exception exception = transferEvent.getException(); logger.debug( exception.getMessage(), exception ); } } /** * Do nothing */ public void debug( String message ) { if ( logger != null ) { logger.debug( message ); } } } maven2-core-2.2.1/maven-core/src/main/java/org/apache/maven/cli/MavenCli.java0000644000175000017500000007227611221205616026520 0ustar twernertwernerpackage org.apache.maven.cli; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import java.io.File; import java.io.IOException; import java.io.InputStream; import java.text.SimpleDateFormat; import java.util.Arrays; import java.util.Date; import java.util.Iterator; import java.util.Locale; import java.util.Properties; import java.util.StringTokenizer; import java.util.Map.Entry; import org.apache.commons.cli.CommandLine; import org.apache.commons.cli.ParseException; import org.apache.maven.Maven; import org.apache.maven.SettingsConfigurationException; import org.apache.maven.artifact.manager.WagonManager; import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.artifact.repository.ArtifactRepositoryFactory; import org.apache.maven.artifact.repository.ArtifactRepositoryPolicy; import org.apache.maven.artifact.repository.DefaultArtifactRepository; import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout; import org.apache.maven.execution.DefaultMavenExecutionRequest; import org.apache.maven.execution.MavenExecutionRequest; import org.apache.maven.execution.ReactorManager; import org.apache.maven.monitor.event.DefaultEventDispatcher; import org.apache.maven.monitor.event.DefaultEventMonitor; import org.apache.maven.monitor.event.EventDispatcher; import org.apache.maven.plugin.Mojo; import org.apache.maven.profiles.DefaultProfileManager; import org.apache.maven.profiles.ProfileManager; import org.apache.maven.reactor.MavenExecutionException; import org.apache.maven.settings.MavenSettingsBuilder; import org.apache.maven.settings.RuntimeInfo; import org.apache.maven.settings.Settings; import org.codehaus.classworlds.ClassWorld; import org.codehaus.plexus.PlexusContainerException; import org.codehaus.plexus.component.repository.exception.ComponentLifecycleException; import org.codehaus.plexus.component.repository.exception.ComponentLookupException; import org.codehaus.plexus.embed.Embedder; import org.codehaus.plexus.logging.Logger; import org.codehaus.plexus.logging.LoggerManager; import org.codehaus.plexus.util.IOUtil; import org.codehaus.plexus.util.Os; import org.codehaus.plexus.util.StringUtils; import org.codehaus.plexus.util.cli.CommandLineUtils; import org.codehaus.plexus.util.xml.pull.XmlPullParserException; import org.sonatype.plexus.components.cipher.DefaultPlexusCipher; import org.sonatype.plexus.components.sec.dispatcher.DefaultSecDispatcher; import org.sonatype.plexus.components.sec.dispatcher.SecDispatcher; import org.sonatype.plexus.components.sec.dispatcher.SecUtil; import org.sonatype.plexus.components.sec.dispatcher.model.SettingsSecurity; /** * @author Jason van Zyl * @version $Id: MavenCli.java 788791 2009-06-26 17:55:26Z jdcasey $ * @noinspection UseOfSystemOutOrSystemErr,ACCESS_STATIC_VIA_INSTANCE */ public class MavenCli { /** @deprecated use {@link Os#OS_NAME} */ public static final String OS_NAME = Os.OS_NAME; /** @deprecated use {@link Os#OS_ARCH} */ public static final String OS_ARCH = Os.OS_ARCH; /** @deprecated use {@link Os#OS_VERSION} */ public static final String OS_VERSION = Os.OS_VERSION; private static Embedder embedder; /** * @deprecated Use {@link Main#main(String[])} instead. */ public static void main( String[] args ) { ClassWorld classWorld = new ClassWorld( "plexus.core", Thread.currentThread().getContextClassLoader() ); int result = main( args, classWorld ); System.exit( result ); } /** * @noinspection ConfusingMainMethod */ public static int main( String[] args, ClassWorld classWorld ) { // ---------------------------------------------------------------------- // Setup the command line parser // ---------------------------------------------------------------------- CLIManager cliManager = new CLIManager(); CommandLine commandLine; try { commandLine = cliManager.parse( args ); } catch ( ParseException e ) { System.err.println( "Unable to parse command line options: " + e.getMessage() ); cliManager.displayHelp(); return 1; } boolean debug = commandLine.hasOption( CLIManager.DEBUG ); boolean showErrors = debug || commandLine.hasOption( CLIManager.ERRORS ); if ( showErrors ) { System.out.println( "+ Error stacktraces are turned on." ); } // ---------------------------------------------------------------------- // Process particular command line options // ---------------------------------------------------------------------- if ( commandLine.hasOption( CLIManager.HELP ) ) { cliManager.displayHelp(); return 0; } if ( commandLine.hasOption( CLIManager.VERSION ) ) { showVersion(); return 0; } else if ( debug || commandLine.hasOption( CLIManager.SHOW_VERSION ) ) { showVersion(); } EventDispatcher eventDispatcher = new DefaultEventDispatcher(); // Make sure the Maven home directory is an absolute path to save us from confusion with say drive-relative // Windows paths. String mavenHome = System.getProperty( "maven.home" ); if ( mavenHome != null ) { System.setProperty( "maven.home", new File( mavenHome ).getAbsolutePath() ); } // ---------------------------------------------------------------------- // Now that we have everything that we need we will fire up plexus and // bring the maven component to life for use. // ---------------------------------------------------------------------- embedder = new Embedder(); try { embedder.start( classWorld ); } catch ( PlexusContainerException e ) { showFatalError( "Unable to start the embedded plexus container", e, showErrors ); return 1; } // wraps the following code to ensure the embedder is stopped no matter what else happens. try { // ---------------------------------------------------------------------- // The execution properties need to be created before the settings // are constructed. // ---------------------------------------------------------------------- Properties executionProperties = new Properties(); Properties userProperties = new Properties(); populateProperties( commandLine, executionProperties, userProperties ); Settings settings; try { settings = buildSettings( commandLine ); } catch ( SettingsConfigurationException e ) { showError( "Error reading settings.xml: " + e.getMessage(), e, showErrors ); return 1; } catch ( ComponentLookupException e ) { showFatalError( "Unable to read settings.xml", e, showErrors ); return 1; } DefaultSecDispatcher dispatcher; try { if ( commandLine.hasOption( CLIManager.ENCRYPT_MASTER_PASSWORD ) ) { String passwd = commandLine.getOptionValue( CLIManager.ENCRYPT_MASTER_PASSWORD ); DefaultPlexusCipher cipher = new DefaultPlexusCipher(); System.out.println( cipher.encryptAndDecorate( passwd, DefaultSecDispatcher.SYSTEM_PROPERTY_SEC_LOCATION ) ); return 0; } else if ( commandLine.hasOption( CLIManager.ENCRYPT_PASSWORD ) ) { String passwd = commandLine.getOptionValue( CLIManager.ENCRYPT_PASSWORD ); dispatcher = (DefaultSecDispatcher) embedder.lookup( SecDispatcher.ROLE ); String configurationFile = dispatcher.getConfigurationFile(); if ( configurationFile.startsWith( "~" ) ) { configurationFile = System.getProperty( "user.home" ) + configurationFile.substring( 1 ); } String file = System.getProperty( DefaultSecDispatcher.SYSTEM_PROPERTY_SEC_LOCATION, configurationFile ); embedder.release( dispatcher ); String master = null; SettingsSecurity sec = SecUtil.read( file, true ); if ( sec != null ) { master = sec.getMaster(); } if ( master == null ) { System.err.println( "Master password is not set in the setting security file" ); return 1; } DefaultPlexusCipher cipher = new DefaultPlexusCipher(); String masterPasswd = cipher.decryptDecorated( master, DefaultSecDispatcher.SYSTEM_PROPERTY_SEC_LOCATION ); System.out.println( cipher.encryptAndDecorate( passwd, masterPasswd ) ); return 0; } } catch ( Exception e ) { showFatalError( "Error encrypting password: " + e.getMessage(), e, showErrors ); return 1; } Maven maven = null; MavenExecutionRequest request = null; LoggerManager loggerManager = null; try { // logger must be created first loggerManager = (LoggerManager) embedder.lookup( LoggerManager.ROLE ); if ( debug ) { loggerManager.setThreshold( Logger.LEVEL_DEBUG ); } else if ( commandLine.hasOption( CLIManager.QUIET ) ) { // TODO: we need to do some more work here. Some plugins use sys out or log errors at info level. // Ideally, we could use Warn across the board loggerManager.setThreshold( Logger.LEVEL_ERROR ); // TODO:Additionally, we can't change the mojo level because the component key includes the version and it isn't known ahead of time. This seems worth changing. } ProfileManager profileManager = new DefaultProfileManager( embedder.getContainer(), executionProperties ); if ( commandLine.hasOption( CLIManager.ACTIVATE_PROFILES ) ) { String [] profileOptionValues = commandLine.getOptionValues( CLIManager.ACTIVATE_PROFILES ); if ( profileOptionValues != null ) { for ( int i=0; i < profileOptionValues.length; ++i ) { StringTokenizer profileTokens = new StringTokenizer( profileOptionValues[i], "," ); while ( profileTokens.hasMoreTokens() ) { String profileAction = profileTokens.nextToken().trim(); if ( profileAction.startsWith( "-" ) || profileAction.startsWith( "!" ) ) { profileManager.explicitlyDeactivate( profileAction.substring( 1 ) ); } else if ( profileAction.startsWith( "+" ) ) { profileManager.explicitlyActivate( profileAction.substring( 1 ) ); } else { profileManager.explicitlyActivate( profileAction ); } } } } } request = createRequest( commandLine, settings, eventDispatcher, loggerManager, profileManager, executionProperties, userProperties, showErrors ); setProjectFileOptions( commandLine, request ); maven = createMavenInstance( settings.isInteractiveMode(), loggerManager.getLoggerForComponent( WagonManager.ROLE ) ); } catch ( ComponentLookupException e ) { showFatalError( "Unable to configure the Maven application", e, showErrors ); return 1; } finally { if ( loggerManager != null ) { try { embedder.release( loggerManager ); } catch ( ComponentLifecycleException e ) { showFatalError( "Error releasing logging manager", e, showErrors ); } } } try { maven.execute( request ); } catch ( MavenExecutionException e ) { return 1; } } finally { try { embedder.stop(); } catch ( Exception e ) { // do nothing; we took our best shot. } } return 0; } private static Settings buildSettings( CommandLine commandLine ) throws ComponentLookupException, SettingsConfigurationException { String userSettingsPath = null; if ( commandLine.hasOption( CLIManager.ALTERNATE_USER_SETTINGS ) ) { userSettingsPath = commandLine.getOptionValue( CLIManager.ALTERNATE_USER_SETTINGS ); } if ( commandLine.hasOption( CLIManager.ALTERNATE_GLOBAL_SETTINGS ) ) { String globalSettingsPath = commandLine.getOptionValue( CLIManager.ALTERNATE_GLOBAL_SETTINGS ); System.setProperty( MavenSettingsBuilder.ALT_GLOBAL_SETTINGS_XML_LOCATION, globalSettingsPath ); } Settings settings = null; MavenSettingsBuilder settingsBuilder = (MavenSettingsBuilder) embedder.lookup( MavenSettingsBuilder.ROLE ); try { if ( userSettingsPath != null ) { File userSettingsFile = new File( userSettingsPath ); if ( userSettingsFile.exists() && !userSettingsFile.isDirectory() ) { settings = settingsBuilder.buildSettings( userSettingsFile ); } else { System.out.println( "WARNING: Alternate user settings file: " + userSettingsPath + " is invalid. Using default path." ); } } if ( settings == null ) { settings = settingsBuilder.buildSettings(); } } catch ( IOException e ) { throw new SettingsConfigurationException( "Error reading settings file", e ); } catch ( XmlPullParserException e ) { throw new SettingsConfigurationException( e.getMessage(), e, e.getLineNumber(), e.getColumnNumber() ); } // why aren't these part of the runtime info? jvz. if ( commandLine.hasOption( CLIManager.BATCH_MODE ) ) { settings.setInteractiveMode( false ); } if ( commandLine.hasOption( CLIManager.SUPPRESS_PLUGIN_REGISTRY ) ) { settings.setUsePluginRegistry( false ); } // Create settings runtime info settings.setRuntimeInfo( createRuntimeInfo( commandLine, settings ) ); return settings; } private static RuntimeInfo createRuntimeInfo( CommandLine commandLine, Settings settings ) { RuntimeInfo runtimeInfo = new RuntimeInfo( settings ); if ( commandLine.hasOption( CLIManager.FORCE_PLUGIN_UPDATES ) || commandLine.hasOption( CLIManager.FORCE_PLUGIN_UPDATES2 ) ) { runtimeInfo.setPluginUpdateOverride( Boolean.TRUE ); } else if ( commandLine.hasOption( CLIManager.SUPPRESS_PLUGIN_UPDATES ) ) { runtimeInfo.setPluginUpdateOverride( Boolean.FALSE ); } return runtimeInfo; } private static void showFatalError( String message, Exception e, boolean show ) { System.err.println( "FATAL ERROR: " + message ); if ( show ) { System.err.println( "Error stacktrace:" ); e.printStackTrace(); } else { System.err.println( "For more information, run with the -e flag" ); } } private static void showError( String message, Exception e, boolean show ) { System.err.println( message ); if ( show ) { System.err.println( "Error stacktrace:" ); e.printStackTrace(); } } private static MavenExecutionRequest createRequest( CommandLine commandLine, Settings settings, EventDispatcher eventDispatcher, LoggerManager loggerManager, ProfileManager profileManager, Properties executionProperties, Properties userProperties, boolean showErrors ) throws ComponentLookupException { MavenExecutionRequest request; ArtifactRepository localRepository = createLocalRepository( embedder, settings, commandLine ); File userDir = new File( System.getProperty( "user.dir" ) ); request = new DefaultMavenExecutionRequest( localRepository, settings, eventDispatcher, commandLine.getArgList(), userDir.getPath(), profileManager, executionProperties, userProperties, showErrors ); // TODO [BP]: do we set one per mojo? where to do it? Logger logger = loggerManager.getLoggerForComponent( Mojo.ROLE ); if ( logger != null ) { request.addEventMonitor( new DefaultEventMonitor( logger ) ); } if ( commandLine.hasOption( CLIManager.NON_RECURSIVE ) ) { request.setRecursive( false ); } if ( commandLine.hasOption( CLIManager.FAIL_FAST ) ) { request.setFailureBehavior( ReactorManager.FAIL_FAST ); } else if ( commandLine.hasOption( CLIManager.FAIL_AT_END ) ) { request.setFailureBehavior( ReactorManager.FAIL_AT_END ); } else if ( commandLine.hasOption( CLIManager.FAIL_NEVER ) ) { request.setFailureBehavior( ReactorManager.FAIL_NEVER ); } return request; } private static void setProjectFileOptions( CommandLine commandLine, MavenExecutionRequest request ) { if ( commandLine.hasOption( CLIManager.REACTOR ) ) { request.setReactorActive( true ); } else if ( commandLine.hasOption( CLIManager.ALTERNATE_POM_FILE ) ) { request.setPomFile( commandLine.getOptionValue( CLIManager.ALTERNATE_POM_FILE ) ); } if ( commandLine.hasOption( CLIManager.RESUME_FROM ) ) { request.setResumeFrom( commandLine.getOptionValue( CLIManager.RESUME_FROM ) ); } if ( commandLine.hasOption( CLIManager.PROJECT_LIST ) ) { String projectList = commandLine.getOptionValue( CLIManager.PROJECT_LIST ); String[] projects = StringUtils.split( projectList, "," ); request.setSelectedProjects( Arrays.asList( projects ) ); } if ( commandLine.hasOption( CLIManager.ALSO_MAKE ) && !commandLine.hasOption( CLIManager.ALSO_MAKE_DEPENDENTS ) ) { request.setMakeBehavior( ReactorManager.MAKE_MODE ); } else if ( !commandLine.hasOption( CLIManager.ALSO_MAKE ) && commandLine.hasOption( CLIManager.ALSO_MAKE_DEPENDENTS ) ) { request.setMakeBehavior( ReactorManager.MAKE_DEPENDENTS_MODE ); } if ( commandLine.hasOption( CLIManager.ALSO_MAKE ) && commandLine.hasOption( CLIManager.ALSO_MAKE_DEPENDENTS ) ) { request.setMakeBehavior( ReactorManager.MAKE_BOTH_MODE ); } } private static Maven createMavenInstance( boolean interactive, Logger logger ) throws ComponentLookupException { // TODO [BP]: doing this here as it is CLI specific, though it doesn't feel like the right place (likewise logger). WagonManager wagonManager = (WagonManager) embedder.lookup( WagonManager.ROLE ); if ( interactive ) { wagonManager.setDownloadMonitor( new ConsoleDownloadMonitor( logger ) ); } else { wagonManager.setDownloadMonitor( new BatchModeDownloadMonitor( logger ) ); } wagonManager.setInteractive( interactive ); return (Maven) embedder.lookup( Maven.ROLE ); } private static ArtifactRepository createLocalRepository( Embedder embedder, Settings settings, CommandLine commandLine ) throws ComponentLookupException { // TODO: release // TODO: something in plexus to show all active hooks? ArtifactRepositoryLayout repositoryLayout = (ArtifactRepositoryLayout) embedder.lookup( ArtifactRepositoryLayout.ROLE, "default" ); ArtifactRepositoryFactory artifactRepositoryFactory = (ArtifactRepositoryFactory) embedder.lookup( ArtifactRepositoryFactory.ROLE ); String url = settings.getLocalRepository(); if ( !url.startsWith( "file:" ) ) { url = "file://" + url; } ArtifactRepository localRepository = new DefaultArtifactRepository( "local", url, repositoryLayout ); boolean snapshotPolicySet = false; if ( commandLine.hasOption( CLIManager.OFFLINE ) ) { settings.setOffline( true ); snapshotPolicySet = true; } if ( !snapshotPolicySet && commandLine.hasOption( CLIManager.UPDATE_SNAPSHOTS ) ) { artifactRepositoryFactory.setGlobalUpdatePolicy( ArtifactRepositoryPolicy.UPDATE_POLICY_ALWAYS ); } if ( commandLine.hasOption( CLIManager.CHECKSUM_FAILURE_POLICY ) ) { System.out.println( "+ Enabling strict checksum verification on all artifact downloads." ); artifactRepositoryFactory.setGlobalChecksumPolicy( ArtifactRepositoryPolicy.CHECKSUM_POLICY_FAIL ); } else if ( commandLine.hasOption( CLIManager.CHECKSUM_WARNING_POLICY ) ) { System.out.println( "+ Disabling strict checksum verification on all artifact downloads." ); artifactRepositoryFactory.setGlobalChecksumPolicy( ArtifactRepositoryPolicy.CHECKSUM_POLICY_WARN ); } return localRepository; } static Properties getBuildProperties() { Properties properties = new Properties(); InputStream resourceAsStream = null; try { resourceAsStream = MavenCli.class.getClassLoader().getResourceAsStream( "org/apache/maven/messages/build.properties" ); if ( resourceAsStream != null ) { properties.load( resourceAsStream ); } } catch ( IOException e ) { System.err.println( "Unable determine version from JAR file: " + e.getMessage() ); } finally { IOUtil.close( resourceAsStream ); } return properties; } private static void showVersion() { Properties properties = getBuildProperties(); String timestamp = reduce( properties.getProperty( "timestamp" ) ); String version = reduce( properties.getProperty( "version" ) ); String rev = reduce( properties.getProperty( "buildNumber" ) ); String msg = "Apache Maven "; msg += ( version != null ? version : "" ); if ( rev != null || timestamp != null ) { msg += " ("; msg += ( rev != null ? "r" + rev : "" ); if ( timestamp != null ) { SimpleDateFormat fmt = new SimpleDateFormat( "yyyy-MM-dd HH:mm:ssZ" ); String ts = fmt.format( new Date( Long.valueOf( timestamp ).longValue() ) ); msg += ( rev != null ? "; " : "" ) + ts; } msg += ")"; } System.out.println( msg ); System.out.println( "Java version: " + System.getProperty( "java.version", "" ) ); System.out.println( "Java home: " + System.getProperty( "java.home", "" ) ); System.out.println( "Default locale: " + Locale.getDefault() + ", platform encoding: " + System.getProperty( "file.encoding", "" ) ); System.out.println( "OS name: \"" + Os.OS_NAME + "\" version: \"" + Os.OS_VERSION + "\" arch: \"" + Os.OS_ARCH + "\" Family: \"" + Os.OS_FAMILY + "\"" ); } private static String reduce( String s ) { return ( s != null ? ( s.startsWith( "${" ) && s.endsWith( "}" ) ? null : s ) : null ); } // ---------------------------------------------------------------------- // System properties handling // ---------------------------------------------------------------------- static void populateProperties( CommandLine commandLine, Properties executionProperties, Properties userProperties ) { // add the env vars to the property set, with the "env." prefix // XXX support for env vars should probably be removed from the ModelInterpolator try { Properties envVars = CommandLineUtils.getSystemEnvVars(); Iterator i = envVars.entrySet().iterator(); while ( i.hasNext() ) { Entry e = (Entry) i.next(); executionProperties.setProperty( "env." + e.getKey().toString(), e.getValue().toString() ); } } catch ( IOException e ) { System.err.println( "Error getting environment vars for profile activation: " + e ); } // ---------------------------------------------------------------------- // Options that are set on the command line become system properties // and therefore are set in the session properties. System properties // are most dominant. // ---------------------------------------------------------------------- if ( commandLine.hasOption( CLIManager.SET_SYSTEM_PROPERTY ) ) { String[] defStrs = commandLine.getOptionValues( CLIManager.SET_SYSTEM_PROPERTY ); if ( defStrs != null ) { for ( int i = 0; i < defStrs.length; ++i ) { setCliProperty( defStrs[i], userProperties ); } } executionProperties.putAll( userProperties ); } executionProperties.putAll( System.getProperties() ); } private static void setCliProperty( String property, Properties requestProperties ) { String name; String value; int i = property.indexOf( "=" ); if ( i <= 0 ) { name = property.trim(); value = "true"; } else { name = property.substring( 0, i ).trim(); value = property.substring( i + 1 ).trim(); } requestProperties.setProperty( name, value ); // ---------------------------------------------------------------------- // I'm leaving the setting of system properties here as not to break // the SystemPropertyProfileActivator. This won't harm embedding. jvz. // ---------------------------------------------------------------------- System.setProperty( name, value ); } } maven2-core-2.2.1/maven-core/src/main/java/org/apache/maven/cli/CLIManager.java0000644000175000017500000003634711151525776026741 0ustar twernertwernerpackage org.apache.maven.cli; import org.apache.commons.cli.CommandLine; import org.apache.commons.cli.CommandLineParser; import org.apache.commons.cli.GnuParser; import org.apache.commons.cli.HelpFormatter; import org.apache.commons.cli.OptionBuilder; import org.apache.commons.cli.Options; import org.apache.commons.cli.ParseException; import java.util.ArrayList; import java.util.List; public class CLIManager { public static final char ALTERNATE_POM_FILE = 'f'; public static final char BATCH_MODE = 'B'; public static final char SET_SYSTEM_PROPERTY = 'D'; public static final char OFFLINE = 'o'; public static final char REACTOR = 'r'; public static final char QUIET = 'q'; public static final char DEBUG = 'X'; public static final char ERRORS = 'e'; public static final char HELP = 'h'; public static final char VERSION = 'v'; public static final char SHOW_VERSION = 'V'; private Options options; public static final char NON_RECURSIVE = 'N'; public static final char UPDATE_SNAPSHOTS = 'U'; public static final char ACTIVATE_PROFILES = 'P'; public static final String FORCE_PLUGIN_UPDATES = "cpu"; public static final String FORCE_PLUGIN_UPDATES2 = "up"; public static final String SUPPRESS_PLUGIN_UPDATES = "npu"; public static final String SUPPRESS_PLUGIN_REGISTRY = "npr"; public static final char CHECKSUM_FAILURE_POLICY = 'C'; public static final char CHECKSUM_WARNING_POLICY = 'c'; public static final char ALTERNATE_USER_SETTINGS = 's'; public static final String ALTERNATE_GLOBAL_SETTINGS = "gs"; public static final String FAIL_FAST = "ff"; public static final String FAIL_AT_END = "fae"; public static final String FAIL_NEVER = "fn"; public static final String RESUME_FROM = "rf"; public static final String PROJECT_LIST = "pl"; public static final String ALSO_MAKE = "am"; public static final String ALSO_MAKE_DEPENDENTS = "amd"; public static final String ENCRYPT_MASTER_PASSWORD = "emp"; public static final String ENCRYPT_PASSWORD = "ep"; public CLIManager() { options = new Options(); options.addOption( OptionBuilder.withLongOpt( "file" ) .hasArg() .withDescription( "Force the use of an alternate POM file." ) .create( ALTERNATE_POM_FILE ) ); options.addOption( OptionBuilder.withLongOpt( "define" ) .hasArg() .withDescription( "Define a system property" ) .create( SET_SYSTEM_PROPERTY ) ); options.addOption( OptionBuilder.withLongOpt( "offline" ).withDescription( "Work offline" ).create( OFFLINE ) ); options.addOption( OptionBuilder.withLongOpt( "help" ) .withDescription( "Display help information" ) .create( HELP ) ); options.addOption( OptionBuilder.withLongOpt( "version" ) .withDescription( "Display version information" ) .create( VERSION ) ); options.addOption( OptionBuilder.withLongOpt( "encrypt-master-password" ) .hasArg() .withDescription( "Encrypt master security password" ) .create( ENCRYPT_MASTER_PASSWORD ) ); options.addOption( OptionBuilder.withLongOpt( "encrypt-password" ) .hasArg() .withDescription( "Encrypt server password" ) .create( ENCRYPT_PASSWORD ) ); options.addOption( OptionBuilder.withLongOpt( "quiet" ) .withDescription( "Quiet output - only show errors" ) .create( QUIET ) ); options.addOption( OptionBuilder.withLongOpt( "debug" ) .withDescription( "Produce execution debug output" ) .create( DEBUG ) ); options.addOption( OptionBuilder.withLongOpt( "errors" ) .withDescription( "Produce execution error messages" ) .create( ERRORS ) ); options.addOption( OptionBuilder.withLongOpt( "reactor" ) .withDescription( "Dynamically build reactor from subdirectories" ) .create( REACTOR ) ); options.addOption( OptionBuilder.withLongOpt( "non-recursive" ) .withDescription( "Do not recurse into sub-projects" ) .create( NON_RECURSIVE ) ); options.addOption( OptionBuilder.withLongOpt( "update-snapshots" ) .withDescription( "Forces a check for updated releases and snapshots on remote repositories" ) .create( UPDATE_SNAPSHOTS ) ); options.addOption( OptionBuilder.withLongOpt( "activate-profiles" ) .withDescription( "Comma-delimited list of profiles to activate" ) .hasArg() .create( ACTIVATE_PROFILES ) ); options.addOption( OptionBuilder.withLongOpt( "batch-mode" ) .withDescription( "Run in non-interactive (batch) mode" ) .create( BATCH_MODE ) ); options.addOption( OptionBuilder.withLongOpt( "check-plugin-updates" ) .withDescription( "Force upToDate check for any relevant registered plugins" ) .create( FORCE_PLUGIN_UPDATES ) ); options.addOption( OptionBuilder.withLongOpt( "update-plugins" ) .withDescription( "Synonym for " + FORCE_PLUGIN_UPDATES ) .create( FORCE_PLUGIN_UPDATES2 ) ); options.addOption( OptionBuilder.withLongOpt( "no-plugin-updates" ) .withDescription( "Suppress upToDate check for any relevant registered plugins" ) .create( SUPPRESS_PLUGIN_UPDATES ) ); options.addOption( OptionBuilder.withLongOpt( "no-plugin-registry" ) .withDescription( "Don't use ~/.m2/plugin-registry.xml for plugin versions" ) .create( SUPPRESS_PLUGIN_REGISTRY ) ); options.addOption( OptionBuilder.withLongOpt( "strict-checksums" ) .withDescription( "Fail the build if checksums don't match" ) .create( CHECKSUM_FAILURE_POLICY ) ); options.addOption( OptionBuilder.withLongOpt( "lax-checksums" ) .withDescription( "Warn if checksums don't match" ) .create( CHECKSUM_WARNING_POLICY ) ); options.addOption( OptionBuilder.withLongOpt( "settings" ) .withDescription( "Alternate path for the user settings file" ) .hasArg() .create( ALTERNATE_USER_SETTINGS ) ); options.addOption( OptionBuilder.withLongOpt( "global-settings" ) .withDescription( "Alternate path for the global settings file" ) .hasArg() .create( ALTERNATE_GLOBAL_SETTINGS ) ); options.addOption( OptionBuilder.withLongOpt( "fail-fast" ) .withDescription( "Stop at first failure in reactorized builds" ) .create( FAIL_FAST ) ); options.addOption( OptionBuilder.withLongOpt( "fail-at-end" ) .withDescription( "Only fail the build afterwards; allow all non-impacted builds to continue" ) .create( FAIL_AT_END ) ); options.addOption( OptionBuilder.withLongOpt( "fail-never" ) .withDescription( "NEVER fail the build, regardless of project result" ) .create( FAIL_NEVER ) ); options.addOption( OptionBuilder.withLongOpt( "show-version" ) .withDescription( "Display version information WITHOUT stopping build" ) .create( SHOW_VERSION ) ); options.addOption( OptionBuilder.withLongOpt( "resume-from" ) .hasArg() .withDescription( "Resume reactor from specified project" ) .create( RESUME_FROM ) ); options.addOption( OptionBuilder.withLongOpt( "projects" ) .withDescription( "Build specified reactor projects instead of all projects" ) .hasArg() .create( PROJECT_LIST ) ); options.addOption( OptionBuilder.withLongOpt( "also-make" ) .withDescription( "If project list is specified, also build projects required by the list" ) .create( ALSO_MAKE ) ); options.addOption( OptionBuilder.withLongOpt( "also-make-dependents" ) .withDescription( "If project list is specified, also build projects that depend on projects on the list" ) .create( ALSO_MAKE_DEPENDENTS ) ); } public CommandLine parse( String[] args ) throws ParseException { // We need to eat any quotes surrounding arguments... String[] cleanArgs = cleanArgs( args ); CommandLineParser parser = new GnuParser(); return parser.parse( options, cleanArgs ); } private String[] cleanArgs( String[] args ) { List cleaned = new ArrayList(); StringBuffer currentArg = null; for ( int i = 0; i < args.length; i++ ) { String arg = args[i]; // System.out.println( "Processing raw arg: " + arg ); boolean addedToBuffer = false; if ( arg.startsWith( "\"" ) ) { // if we're in the process of building up another arg, push it and start over. // this is for the case: "-Dfoo=bar "-Dfoo2=bar two" (note the first unterminated quote) if ( currentArg != null ) { // System.out.println( "Flushing last arg buffer: \'" + currentArg + "\' to cleaned list." ); cleaned.add( currentArg.toString() ); } // start building an argument here. currentArg = new StringBuffer( arg.substring( 1 ) ); addedToBuffer = true; } // this has to be a separate "if" statement, to capture the case of: "-Dfoo=bar" if ( arg.endsWith( "\"" ) ) { String cleanArgPart = arg.substring( 0, arg.length() - 1 ); // if we're building an argument, keep doing so. if ( currentArg != null ) { // if this is the case of "-Dfoo=bar", then we need to adjust the buffer. if ( addedToBuffer ) { // System.out.println( "Adjusting argument already appended to the arg buffer." ); currentArg.setLength( currentArg.length() - 1 ); } // otherwise, we trim the trailing " and append to the buffer. else { // System.out.println( "Appending arg part: \'" + cleanArgPart + "\' with preceding space to arg buffer." ); // TODO: introducing a space here...not sure what else to do but collapse whitespace currentArg.append( ' ' ).append( cleanArgPart ); } // System.out.println( "Flushing completed arg buffer: \'" + currentArg + "\' to cleaned list." ); // we're done with this argument, so add it. cleaned.add( currentArg.toString() ); } else { // System.out.println( "appending cleaned arg: \'" + cleanArgPart + "\' directly to cleaned list." ); // this is a simple argument...just add it. cleaned.add( cleanArgPart ); } // System.out.println( "Clearing arg buffer." ); // the currentArg MUST be finished when this completes. currentArg = null; continue; } // if we haven't added this arg to the buffer, and we ARE building an argument // buffer, then append it with a preceding space...again, not sure what else to // do other than collapse whitespace. // NOTE: The case of a trailing quote is handled by nullifying the arg buffer. if ( !addedToBuffer ) { // append to the argument we're building, collapsing whitespace to a single space. if ( currentArg != null ) { // System.out.println( "Append unquoted arg part: \'" + arg + "\' to arg buffer." ); currentArg.append( ' ' ).append( arg ); } // this is a loner, just add it directly. else { // System.out.println( "Append unquoted arg part: \'" + arg + "\' directly to cleaned list." ); cleaned.add( arg ); } } } // clean up. if ( currentArg != null ) { // System.out.println( "Adding unterminated arg buffer: \'" + currentArg + "\' to cleaned list." ); cleaned.add( currentArg.toString() ); } int cleanedSz = cleaned.size(); String[] cleanArgs = null; if ( cleanedSz == 0 ) { // if we didn't have any arguments to clean, simply pass the original array through cleanArgs = args; } else { // System.out.println( "Cleaned argument list:\n" + cleaned ); cleanArgs = (String[]) cleaned.toArray( new String[cleanedSz] ); } return cleanArgs; } public void displayHelp() { System.out.println(); HelpFormatter formatter = new HelpFormatter(); formatter.printHelp( "mvn [options] [] []", "\nOptions:", options, "\n" ); } } maven2-core-2.2.1/maven-core/src/main/java/org/apache/maven/cli/BatchModeDownloadMonitor.java0000644000175000017500000000326011147433541031702 0ustar twernertwernerpackage org.apache.maven.cli; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import org.apache.maven.wagon.events.TransferEvent; import org.codehaus.plexus.logging.Logger; /** * Console download progress meter. * * @author Brett Porter * @version $Id: BatchModeDownloadMonitor.java 746136 2009-02-20 04:53:53Z brett $ */ public class BatchModeDownloadMonitor extends AbstractConsoleDownloadMonitor { public BatchModeDownloadMonitor( Logger logger ) { super( logger ); } public BatchModeDownloadMonitor() { } public void transferInitiated( TransferEvent transferEvent ) { String message = transferEvent.getRequestType() == TransferEvent.REQUEST_PUT ? "Uploading" : "Downloading"; String url = transferEvent.getWagon().getRepository().getUrl(); out.println( message + ": " + url + "/" + transferEvent.getResource().getName() ); } } maven2-core-2.2.1/maven-core/src/main/java/org/apache/maven/cli/ConsoleDownloadMonitor.java0000644000175000017500000001015311151244441031447 0ustar twernertwernerpackage org.apache.maven.cli; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import java.util.Iterator; import java.util.LinkedHashMap; import java.util.Map; import org.apache.maven.wagon.WagonConstants; import org.apache.maven.wagon.events.TransferEvent; import org.apache.maven.wagon.resource.Resource; import org.codehaus.plexus.logging.Logger; /** * Console download progress meter. Properly handles multiple downloads simultaneously. * * @author Brett Porter * @version $Id: ConsoleDownloadMonitor.java 747773 2009-02-25 13:35:29Z brett $ */ public class ConsoleDownloadMonitor extends AbstractConsoleDownloadMonitor { private Map/* */downloads; private int maxLength; public ConsoleDownloadMonitor( Logger logger ) { super( logger ); downloads = new LinkedHashMap(); } public ConsoleDownloadMonitor() { downloads = new LinkedHashMap(); } public void transferInitiated( TransferEvent transferEvent ) { String message = transferEvent.getRequestType() == TransferEvent.REQUEST_PUT ? "Uploading" : "Downloading"; String url = transferEvent.getWagon().getRepository().getUrl(); out.println( message + ": " + url + "/" + transferEvent.getResource().getName() ); } public void transferStarted( TransferEvent transferEvent ) { // This space left intentionally blank } public synchronized void transferProgress( TransferEvent transferEvent, byte[] buffer, int length ) { Resource resource = transferEvent.getResource(); if ( !downloads.containsKey( resource ) ) { downloads.put( resource, new Long( length ) ); } else { Long complete = (Long) downloads.get( resource ); complete = new Long( complete.longValue() + length ); downloads.put( resource, complete ); } StringBuffer buf = new StringBuffer(); for ( Iterator i = downloads.entrySet().iterator(); i.hasNext(); ) { Map.Entry entry = (Map.Entry) i.next(); Long complete = (Long) entry.getValue(); String status = getDownloadStatusForResource( complete.longValue(), ( (Resource) entry.getKey() ).getContentLength() ); buf.append( status ); if ( i.hasNext() ) { buf.append( " " ); } } if ( buf.length() > maxLength ) { maxLength = buf.length(); } out.print( buf.toString() + "\r" ); } String getDownloadStatusForResource( long progress, long total ) { if ( total >= 1024 ) { return ( progress / 1024 ) + "/" + ( total == WagonConstants.UNKNOWN_LENGTH ? "?" : ( total / 1024 ) + "K" ); } else { return progress + "/" + ( total == WagonConstants.UNKNOWN_LENGTH ? "?" : total + "b" ); } } public synchronized void transferCompleted( TransferEvent transferEvent ) { StringBuffer line = new StringBuffer( createCompletionLine( transferEvent ) ); while ( line.length() < maxLength ) { line.append( " " ); } maxLength = 0; out.println( line ); downloads.remove( transferEvent.getResource() ); } } maven2-core-2.2.1/maven-core/src/main/java/org/apache/maven/BuildFailureException.java0000644000175000017500000000240410551365651030476 0ustar twernertwernerpackage org.apache.maven; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ /** * One or more builds failed. * * @author Brett Porter * @version $Id: BuildFailureException.java 495147 2007-01-11 07:47:53Z jvanzyl $ */ public class BuildFailureException extends Exception { public BuildFailureException( String message ) { super( message ); } public BuildFailureException( String message, Throwable cause ) { super( message, cause ); } } maven2-core-2.2.1/maven-core/src/main/java/org/apache/maven/ConfigurationInterpolator.java0000644000175000017500000000063211175700236031456 0ustar twernertwernerpackage org.apache.maven; import org.apache.maven.project.MavenProject; import org.apache.maven.project.ProjectBuilderConfiguration; public interface ConfigurationInterpolator { String ROLE = ConfigurationInterpolator.class.getName(); Object interpolate( Object configObject, MavenProject project, ProjectBuilderConfiguration config ) throws ConfigurationInterpolationException; } maven2-core-2.2.1/maven-core/src/main/java/org/apache/maven/Maven.java0000644000175000017500000000246210551365651025322 0ustar twernertwernerpackage org.apache.maven; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import org.apache.maven.execution.MavenExecutionRequest; import org.apache.maven.reactor.MavenExecutionException; /** * @author Jason van Zyl * @version $Id: Maven.java 495147 2007-01-11 07:47:53Z jvanzyl $ */ public interface Maven { static String ROLE = Maven.class.getName(); String POMv4 = "pom.xml"; String RELEASE_POMv4 = "release-pom.xml"; void execute( MavenExecutionRequest request ) throws MavenExecutionException; }././@LongLink0000000000000000000000000000014500000000000011565 Lustar rootrootmaven2-core-2.2.1/maven-core/src/main/java/org/apache/maven/ConfigurationInterpolationException.javamaven2-core-2.2.1/maven-core/src/main/java/org/apache/maven/ConfigurationInterpolationException.java0000644000175000017500000000060511101576551033502 0ustar twernertwernerpackage org.apache.maven; public class ConfigurationInterpolationException extends Exception { private static final long serialVersionUID = 1L; public ConfigurationInterpolationException( String message, Throwable cause ) { super( message, cause ); } public ConfigurationInterpolationException( String message ) { super( message ); } } maven2-core-2.2.1/maven-core/src/main/java/org/apache/maven/lifecycle/0000755000175000017500000000000011250552240025331 5ustar twernertwerner././@LongLink0000000000000000000000000000014700000000000011567 Lustar rootrootmaven2-core-2.2.1/maven-core/src/main/java/org/apache/maven/lifecycle/LifecycleExecutionException.javamaven2-core-2.2.1/maven-core/src/main/java/org/apache/maven/lifecycle/LifecycleExecutionException.ja0000644000175000017500000000254410551365651033327 0ustar twernertwernerpackage org.apache.maven.lifecycle; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ /** * @author Jason van Zyl * @version $Id: LifecycleExecutionException.java 495147 2007-01-11 07:47:53Z jvanzyl $ */ public class LifecycleExecutionException extends Exception { public LifecycleExecutionException( String message ) { super( message ); } public LifecycleExecutionException( Throwable cause ) { super( cause ); } public LifecycleExecutionException( String message, Throwable cause ) { super( message, cause ); } } maven2-core-2.2.1/maven-core/src/main/java/org/apache/maven/lifecycle/Lifecycle.java0000644000175000017500000000411410772004567030107 0ustar twernertwernerpackage org.apache.maven.lifecycle; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import java.util.ArrayList; import java.util.List; import java.util.Map; /** * Class Lifecycle. */ public class Lifecycle { /** * Field id */ private String id; /** * Field phases */ private List phases; /** * default phases. */ private Map defaultPhases; /** * Method addPhase * * @param phase */ public void addPhase( String phase ) { getPhases().add( phase ); } //-- void addPhase(Phase) /** * Method getId */ public String getId() { return this.id; } //-- String getId() /** * Method getPhases */ public List getPhases() { if ( this.phases == null ) { this.phases = new ArrayList(); } return this.phases; } //-- java.util.List getPhases() /** * Method setId * * @param id */ public void setId( String id ) { this.id = id; } //-- void setId(String) /** * Method setPhases * * @param phases */ public void setPhases( List phases ) { this.phases = phases; } //-- void setPhases(java.util.List) public Map getDefaultPhases() { return defaultPhases; } } maven2-core-2.2.1/maven-core/src/main/java/org/apache/maven/lifecycle/mapping/0000755000175000017500000000000011250552240026764 5ustar twernertwerner././@LongLink0000000000000000000000000000015300000000000011564 Lustar rootrootmaven2-core-2.2.1/maven-core/src/main/java/org/apache/maven/lifecycle/mapping/DefaultLifecycleMapping.javamaven2-core-2.2.1/maven-core/src/main/java/org/apache/maven/lifecycle/mapping/DefaultLifecycleMappin0000644000175000017500000000536210772004567033302 0ustar twernertwernerpackage org.apache.maven.lifecycle.mapping; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import java.util.HashMap; import java.util.Iterator; import java.util.List; import java.util.Map; /** * Lifecycle mapping for a POM. * * @author Brett Porter * @version $Id: DefaultLifecycleMapping.java 640549 2008-03-24 20:05:11Z bentmann $ */ public class DefaultLifecycleMapping implements LifecycleMapping { private List lifecycles; private Map lifecycleMap; /** @deprecated use lifecycles instead */ private Map phases; public List getOptionalMojos( String lifecycle ) { if ( lifecycleMap == null ) { lifecycleMap = new HashMap(); if ( lifecycles != null ) { for ( Iterator i = lifecycles.iterator(); i.hasNext(); ) { Lifecycle l = (Lifecycle) i.next(); lifecycleMap.put( l.getId(), l ); } } } Lifecycle l = (Lifecycle) lifecycleMap.get( lifecycle ); if ( l != null ) { return l.getOptionalMojos(); } else { return null; } } public Map getPhases( String lifecycle ) { if ( lifecycleMap == null ) { lifecycleMap = new HashMap(); if ( lifecycles != null ) { for ( Iterator i = lifecycles.iterator(); i.hasNext(); ) { Lifecycle l = (Lifecycle) i.next(); lifecycleMap.put( l.getId(), l ); } } } Lifecycle l = (Lifecycle) lifecycleMap.get( lifecycle ); Map mappings = null; if ( l == null ) { if ( "default".equals( lifecycle ) ) { mappings = phases; } } else { mappings = l.getPhases(); } return mappings; } } maven2-core-2.2.1/maven-core/src/main/java/org/apache/maven/lifecycle/mapping/Lifecycle.java0000644000175000017500000000350310772004567031543 0ustar twernertwernerpackage org.apache.maven.lifecycle.mapping; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import java.util.ArrayList; import java.util.List; import java.util.Map; /** * Class Lifecycle. */ public class Lifecycle { /** * Field id */ private String id; /** * Field phases */ private Map phases; private List optionalMojos = new ArrayList(); /** * Method getId */ public String getId() { return this.id; } //-- String getId() /** * Method getPhases */ public Map getPhases() { return this.phases; } /** * Method setId * * @param id */ public void setId( String id ) { this.id = id; } //-- void setId(String) public void addOptionalMojo( String optionalMojo ) { this.optionalMojos.add( optionalMojo ); } public void setOptionalMojos( List optionalMojos ) { this.optionalMojos = optionalMojos; } public List getOptionalMojos() { return this.optionalMojos; } } maven2-core-2.2.1/maven-core/src/main/java/org/apache/maven/lifecycle/mapping/LifecycleMapping.java0000644000175000017500000000231510772004567033057 0ustar twernertwernerpackage org.apache.maven.lifecycle.mapping; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import java.util.List; import java.util.Map; /** * @author Brett Porter * @version $Id: LifecycleMapping.java 640549 2008-03-24 20:05:11Z bentmann $ */ public interface LifecycleMapping { String ROLE = LifecycleMapping.class.getName(); List getOptionalMojos( String lifecycle ); Map getPhases( String lifecycle ); } maven2-core-2.2.1/maven-core/src/main/java/org/apache/maven/lifecycle/LifecycleExecutor.java0000644000175000017500000000277311041724042031622 0ustar twernertwernerpackage org.apache.maven.lifecycle; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import java.util.List; import org.apache.maven.BuildFailureException; import org.apache.maven.execution.MavenSession; import org.apache.maven.execution.ReactorManager; import org.apache.maven.monitor.event.EventDispatcher; /** * @author Jason van Zyl * @version $Id: LifecycleExecutor.java 679206 2008-07-23 21:52:34Z jdcasey $ */ public interface LifecycleExecutor { String ROLE = LifecycleExecutor.class.getName(); void execute( MavenSession session, ReactorManager rm, EventDispatcher dispatcher ) throws LifecycleExecutionException, BuildFailureException; /** * @since 2.0.10 */ List getLifecycles(); } maven2-core-2.2.1/maven-core/src/main/java/org/apache/maven/lifecycle/DefaultLifecycleExecutor.java0000644000175000017500000024304411234667005033136 0ustar twernertwernerpackage org.apache.maven.lifecycle; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import org.apache.maven.BuildFailureException; import org.apache.maven.ConfigurationInterpolationException; import org.apache.maven.ConfigurationInterpolator; import org.apache.maven.artifact.handler.ArtifactHandler; import org.apache.maven.artifact.handler.manager.ArtifactHandlerManager; import org.apache.maven.artifact.resolver.ArtifactNotFoundException; import org.apache.maven.artifact.resolver.ArtifactResolutionException; import org.apache.maven.artifact.versioning.InvalidVersionSpecificationException; import org.apache.maven.execution.MavenSession; import org.apache.maven.execution.ReactorManager; import org.apache.maven.extension.ExtensionManager; import org.apache.maven.lifecycle.mapping.LifecycleMapping; import org.apache.maven.model.Extension; import org.apache.maven.model.Plugin; import org.apache.maven.model.PluginExecution; import org.apache.maven.model.ReportPlugin; import org.apache.maven.model.ReportSet; import org.apache.maven.monitor.event.EventDispatcher; import org.apache.maven.monitor.event.MavenEvents; import org.apache.maven.plugin.InvalidPluginException; import org.apache.maven.plugin.MojoExecution; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.MojoFailureException; import org.apache.maven.plugin.PluginConfigurationException; import org.apache.maven.plugin.PluginManager; import org.apache.maven.plugin.PluginManagerException; import org.apache.maven.plugin.PluginNotFoundException; import org.apache.maven.plugin.descriptor.MojoDescriptor; import org.apache.maven.plugin.descriptor.PluginDescriptor; import org.apache.maven.plugin.lifecycle.Execution; import org.apache.maven.plugin.lifecycle.Phase; import org.apache.maven.plugin.version.PluginVersionNotFoundException; import org.apache.maven.plugin.version.PluginVersionResolutionException; import org.apache.maven.project.MavenProject; import org.apache.maven.project.MavenProjectBuilder; import org.apache.maven.project.artifact.InvalidDependencyVersionException; import org.apache.maven.project.interpolation.ModelInterpolationException; import org.apache.maven.project.interpolation.ModelInterpolator; import org.apache.maven.reporting.MavenReport; import org.apache.maven.settings.Settings; import org.codehaus.plexus.PlexusConstants; import org.codehaus.plexus.PlexusContainer; import org.codehaus.plexus.PlexusContainerException; import org.codehaus.plexus.component.repository.exception.ComponentLookupException; import org.codehaus.plexus.configuration.PlexusConfiguration; import org.codehaus.plexus.context.Context; import org.codehaus.plexus.context.ContextException; import org.codehaus.plexus.logging.AbstractLogEnabled; import org.codehaus.plexus.personality.plexus.lifecycle.phase.Contextualizable; import org.codehaus.plexus.personality.plexus.lifecycle.phase.Initializable; import org.codehaus.plexus.personality.plexus.lifecycle.phase.InitializationException; import org.codehaus.plexus.util.StringUtils; import org.codehaus.plexus.util.xml.Xpp3Dom; import org.codehaus.plexus.util.xml.pull.XmlPullParserException; import java.io.IOException; import java.util.ArrayList; import java.util.Collections; import java.util.HashMap; import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.Stack; import java.util.StringTokenizer; /** * @author Jason van Zyl * @author Brett Porter * @version $Id: DefaultLifecycleExecutor.java 799759 2009-07-31 22:19:49Z jdcasey $ * @todo because of aggregation, we ended up with cli-ish stuff in here (like line() and the project logging, without much of the event handling) */ public class DefaultLifecycleExecutor extends AbstractLogEnabled implements LifecycleExecutor, Initializable, Contextualizable { // ---------------------------------------------------------------------- // Components // ---------------------------------------------------------------------- private PluginManager pluginManager; private ExtensionManager extensionManager; private List lifecycles; private ArtifactHandlerManager artifactHandlerManager; private List defaultReports; private Map phaseToLifecycleMap; private MavenProjectBuilder mavenProjectBuilder; private ModelInterpolator modelInterpolator; private ConfigurationInterpolator configInterpolator; // ---------------------------------------------------------------------- // // ---------------------------------------------------------------------- /** * Execute a task. Each task may be a phase in the lifecycle or the * execution of a mojo. * * @param session * @param rm * @param dispatcher */ public void execute( final MavenSession session, final ReactorManager rm, final EventDispatcher dispatcher ) throws BuildFailureException, LifecycleExecutionException { // TODO: This is dangerous, particularly when it's just a collection of loose-leaf projects being built // within the same reactor (using an inclusion pattern to gather them up)... MavenProject rootProject = rm.getTopLevelProject(); List goals = session.getGoals(); if ( goals.isEmpty() && rootProject != null ) { String goal = rootProject.getDefaultGoal(); if ( goal != null ) { goals = Collections.singletonList( goal ); } } if ( goals.isEmpty() ) { StringBuffer buffer = new StringBuffer( 1024 ); buffer.append( "\n\n" ); buffer.append( "You must specify at least one goal or lifecycle phase to perform build steps.\n" ); buffer.append( "The following list illustrates some commonly used build commands:\n\n" ); buffer.append( " mvn clean\n" ); buffer.append( " Deletes any build output (e.g. class files or JARs).\n" ); buffer.append( " mvn test\n" ); buffer.append( " Runs the unit tests for the project.\n" ); buffer.append( " mvn install\n" ); buffer.append( " Copies the project artifacts into your local repository.\n" ); buffer.append( " mvn deploy\n" ); buffer.append( " Copies the project artifacts into the remote repository.\n" ); buffer.append( " mvn site\n" ); buffer.append( " Creates project documentation (e.g. reports or Javadoc).\n\n" ); buffer.append( "Please see\n" ); buffer.append( "http://maven.apache.org/guides/introduction/introduction-to-the-lifecycle.html\n" ); buffer.append( "for a complete description of available lifecycle phases.\n\n" ); buffer.append( "Use \"mvn --help\" to show general usage information about Maven's command line.\n\n" ); throw new BuildFailureException( buffer.toString() ); } List taskSegments = segmentTaskListByAggregationNeeds( goals, session, rootProject ); // TODO: probably don't want to do all this up front findExtensions( session ); executeTaskSegments( taskSegments, rm, session, rootProject, dispatcher ); } private void findExtensions( final MavenSession session ) throws LifecycleExecutionException { // TODO: MNG-4081. What about extensions within the current reactor?? Map handlers = new HashMap(); for ( MavenProject project : session.getSortedProjects() ) { for ( Iterator j = project.getBuildExtensions().iterator(); j.hasNext(); ) { Extension extension = (Extension) j.next(); try { getLogger().debug( "Adding extension: " + extension ); extensionManager.addExtension( extension, project, session.getLocalRepository() ); } catch ( PlexusContainerException e ) { throw new LifecycleExecutionException( "Unable to initialise extensions", e ); } catch ( ArtifactResolutionException e ) { throw new LifecycleExecutionException( e.getMessage(), e ); } catch ( ArtifactNotFoundException e ) { throw new LifecycleExecutionException( e.getMessage(), e ); } } } extensionManager.registerWagons(); handlers.putAll( extensionManager.getArtifactTypeHandlers() ); for ( MavenProject project : session.getSortedProjects() ) { try { handlers.putAll( findArtifactTypeHandlersInPlugins( project, session ) ); // shudder... for ( ArtifactHandler handler : handlers.values() ) { if ( project.getPackaging().equals( handler.getPackaging() ) ) { project.getArtifact().setArtifactHandler( handler ); // NOTE: Adding this (maven 2.2.1) to short-circuit things. This means first match is used, NOT LAST. break; } } } catch ( PluginNotFoundException e ) { throw new LifecycleExecutionException( e.getMessage(), e ); } } artifactHandlerManager.addHandlers( handlers ); } private void executeTaskSegments( final List taskSegments, final ReactorManager rm, final MavenSession session, final MavenProject rootProject, final EventDispatcher dispatcher ) throws LifecycleExecutionException, BuildFailureException { for ( Iterator it = taskSegments.iterator(); it.hasNext(); ) { TaskSegment segment = (TaskSegment) it.next(); if ( segment.aggregate() ) { if ( !rm.isBlackListed( rootProject ) ) { line(); getLogger().info( "Building " + rootProject.getName() ); getLogger().info( " " + segment ); line(); // !! This is ripe for refactoring to an aspect. // Event monitoring. String event = MavenEvents.PROJECT_EXECUTION; long buildStartTime = System.currentTimeMillis(); String target = rootProject.getId() + " ( " + segment + " )"; dispatcher.dispatchStart( event, target ); try { session.setCurrentProject( rootProject ); // only call once, with the top-level project (assumed to be provided as a parameter)... for ( Iterator goalIterator = segment.getTasks().iterator(); goalIterator.hasNext(); ) { String task = (String) goalIterator.next(); executeGoalAndHandleFailures( task, session, rootProject, dispatcher, event, rm, buildStartTime, target ); } rm.registerBuildSuccess( rootProject, System.currentTimeMillis() - buildStartTime ); } finally { session.setCurrentProject( null ); } dispatcher.dispatchEnd( event, target ); } else { line(); getLogger().info( "SKIPPING " + rootProject.getName() ); getLogger().info( " " + segment ); getLogger().info( "This project has been banned from further executions due to previous failures." ); line(); } } else { List sortedProjects = session.getSortedProjects(); // iterate over projects, and execute on each... for ( Iterator projectIterator = sortedProjects.iterator(); projectIterator.hasNext(); ) { MavenProject currentProject = (MavenProject) projectIterator.next(); if ( !rm.isBlackListed( currentProject ) ) { line(); getLogger().info( "Building " + currentProject.getName() ); getLogger().info( " " + segment ); line(); // !! This is ripe for refactoring to an aspect. // Event monitoring. String event = MavenEvents.PROJECT_EXECUTION; long buildStartTime = System.currentTimeMillis(); String target = currentProject.getId() + " ( " + segment + " )"; dispatcher.dispatchStart( event, target ); try { session.setCurrentProject( currentProject ); for ( Iterator goalIterator = segment.getTasks().iterator(); goalIterator.hasNext(); ) { String task = (String) goalIterator.next(); executeGoalAndHandleFailures( task, session, currentProject, dispatcher, event, rm, buildStartTime, target ); } } finally { session.setCurrentProject( null ); } rm.registerBuildSuccess( currentProject, System.currentTimeMillis() - buildStartTime ); dispatcher.dispatchEnd( event, target ); } else { line(); getLogger().info( "SKIPPING " + currentProject.getName() ); getLogger().info( " " + segment ); getLogger().info( "This project has been banned from further executions due to previous failures." ); line(); } } } } } private void executeGoalAndHandleFailures( final String task, final MavenSession session, final MavenProject project, final EventDispatcher dispatcher, final String event, final ReactorManager rm, final long buildStartTime, final String target ) throws BuildFailureException, LifecycleExecutionException { try { executeGoal( task, session, project ); } catch ( LifecycleExecutionException e ) { dispatcher.dispatchError( event, target, e ); if ( handleExecutionFailure( rm, project, e, task, buildStartTime ) ) { throw e; } } catch ( BuildFailureException e ) { dispatcher.dispatchError( event, target, e ); if ( handleExecutionFailure( rm, project, e, task, buildStartTime ) ) { throw e; } } } private boolean handleExecutionFailure( final ReactorManager rm, final MavenProject project, final Exception e, final String task, final long buildStartTime ) { rm.registerBuildFailure( project, e, task, System.currentTimeMillis() - buildStartTime ); if ( ReactorManager.FAIL_FAST.equals( rm.getFailureBehavior() ) ) { return true; } else if ( ReactorManager.FAIL_AT_END.equals( rm.getFailureBehavior() ) ) { rm.blackList( project ); } // if NEVER, don't blacklist return false; } private List segmentTaskListByAggregationNeeds( final List tasks, final MavenSession session, final MavenProject project ) throws LifecycleExecutionException, BuildFailureException { List segments = new ArrayList(); if ( project != null ) { TaskSegment currentSegment = null; for ( Iterator it = tasks.iterator(); it.hasNext(); ) { String task = (String) it.next(); // if it's a phase, then we don't need to check whether it's an aggregator. // simply add it to the current task partition. if ( getPhaseToLifecycleMap().containsKey( task ) ) { if ( currentSegment != null && currentSegment.aggregate() ) { segments.add( currentSegment ); currentSegment = null; } if ( currentSegment == null ) { currentSegment = new TaskSegment(); } currentSegment.add( task ); } else { MojoDescriptor mojo = null; try { // definitely a CLI goal, can use prefix mojo = getMojoDescriptor( task, session, project, task, true, false ); } catch ( PluginNotFoundException e ) { // TODO: shouldn't hit this, investigate using the same resolution logic as otheres for plugins in the reactor getLogger().info( "Cannot find mojo descriptor for: \'" + task + "\' - Treating as non-aggregator." ); getLogger().debug( "", e ); } // if the mojo descriptor was found, determine aggregator status according to: // 1. whether the mojo declares itself an aggregator // 2. whether the mojo DOES NOT require a project to function (implicitly avoid reactor) if ( mojo != null && ( mojo.isAggregator() || !mojo.isProjectRequired() ) ) { if ( currentSegment != null && !currentSegment.aggregate() ) { segments.add( currentSegment ); currentSegment = null; } if ( currentSegment == null ) { currentSegment = new TaskSegment( true ); } currentSegment.add( task ); } else { if ( currentSegment != null && currentSegment.aggregate() ) { segments.add( currentSegment ); currentSegment = null; } if ( currentSegment == null ) { currentSegment = new TaskSegment(); } currentSegment.add( task ); } } } segments.add( currentSegment ); } else { TaskSegment segment = new TaskSegment( false ); for ( Iterator i = tasks.iterator(); i.hasNext(); ) { segment.add( (String) i.next() ); } segments.add( segment ); } return segments; } private void executeGoal( final String task, final MavenSession session, final MavenProject project ) throws LifecycleExecutionException, BuildFailureException { try { Stack forkEntryPoints = new Stack(); if ( getPhaseToLifecycleMap().containsKey( task ) ) { Lifecycle lifecycle = getLifecycleForPhase( task ); // we have a lifecycle phase, so lets bind all the necessary goals Map lifecycleMappings = constructLifecycleMappings( session, task, project, lifecycle ); executeGoalWithLifecycle( task, forkEntryPoints, session, lifecycleMappings, project, lifecycle ); } else { executeStandaloneGoal( task, forkEntryPoints, session, project ); } } catch ( PluginNotFoundException e ) { throw new BuildFailureException( "A required plugin was not found: " + e.getMessage(), e ); } } private void executeGoalWithLifecycle( final String task, final Stack forkEntryPoints, final MavenSession session, final Map lifecycleMappings, final MavenProject project, final Lifecycle lifecycle ) throws LifecycleExecutionException, BuildFailureException, PluginNotFoundException { List goals = processGoalChain( task, lifecycleMappings, lifecycle ); if ( !goals.isEmpty() ) { executeGoals( goals, forkEntryPoints, session, project ); } else { getLogger().info( "No goals needed for project - skipping" ); } } private void executeStandaloneGoal( final String task, final Stack forkEntryPoints, final MavenSession session, final MavenProject project ) throws LifecycleExecutionException, BuildFailureException, PluginNotFoundException { // guaranteed to come from the CLI and not be part of a phase MojoDescriptor mojoDescriptor = getMojoDescriptor( task, session, project, task, true, false ); executeGoals( Collections.singletonList( new MojoExecution( mojoDescriptor, MojoExecution.CLI_EXECUTION_ID ) ), forkEntryPoints, session, project ); } private void executeGoals( final List goals, final Stack forkEntryPoints, final MavenSession session, final MavenProject project ) throws LifecycleExecutionException, BuildFailureException, PluginNotFoundException { for ( Iterator i = goals.iterator(); i.hasNext(); ) { MojoExecution mojoExecution = (MojoExecution) i.next(); MojoDescriptor mojoDescriptor = mojoExecution.getMojoDescriptor(); PlexusConfiguration configuration = mojoDescriptor.getMojoConfiguration(); boolean usesReactorProjects = mojoDescriptor.isAggregator() || usesSessionOrReactorProjects( configuration ); if ( usesReactorProjects ) { calculateAllConcreteStates( session ); } else { calculateConcreteState( project, session, true ); } calculateConcreteConfiguration( mojoExecution, project, session ); List reportExecutions = null; if ( mojoDescriptor.isRequiresReports() ) { reportExecutions = getReportExecutions( project, forkEntryPoints, mojoExecution, session ); } boolean hasFork = false; if ( mojoDescriptor.getExecutePhase() != null || mojoDescriptor.getExecuteGoal() != null ) { hasFork = true; } else if ( reportExecutions != null ) { for ( Iterator it = reportExecutions.iterator(); it.hasNext(); ) { MojoExecution reportExecution = (MojoExecution) it.next(); MojoDescriptor reportDescriptor = reportExecution.getMojoDescriptor(); if ( reportDescriptor.getExecutePhase() != null || reportDescriptor.getExecuteGoal() != null ) { hasFork = true; } } } if ( hasFork ) { // NOTE: This must always happen, regardless of treatment of reactorProjects below, because // if we're in a forked execution right now, the current project will itself be an execution project of // something in the reactorProjects list, and won't have a next-stage executionProject created // for it otherwise, which leaves the project == null for the upcoming forked execution. createExecutionProject( project, session, true ); if ( usesReactorProjects ) { List reactorProjects = session.getSortedProjects(); for ( Iterator it = reactorProjects.iterator(); it.hasNext(); ) { MavenProject reactorProject = (MavenProject) it.next(); createExecutionProject( reactorProject, session, false ); } } } if ( mojoDescriptor.getExecutePhase() != null || mojoDescriptor.getExecuteGoal() != null ) { forkEntryPoints.push( mojoDescriptor ); forkLifecycle( mojoDescriptor, forkEntryPoints, session, project, mojoExecution.getExecutionId() ); forkEntryPoints.pop(); } if ( mojoDescriptor.isRequiresReports() ) { List reports = getReports( reportExecutions, project, mojoExecution, session ); mojoExecution.setReports( reports ); for ( Iterator j = mojoExecution.getForkedExecutions().iterator(); j.hasNext(); ) { MojoExecution forkedExecution = (MojoExecution) j.next(); MojoDescriptor descriptor = forkedExecution.getMojoDescriptor(); if ( descriptor.getExecutePhase() != null ) { forkEntryPoints.push( descriptor ); forkLifecycle( descriptor, forkEntryPoints, session, project, forkedExecution.getExecutionId() ); forkEntryPoints.pop(); } } } if ( hasFork ) { // NOTE: This must always happen, regardless of treatment of reactorProjects below, because // if we're in a forked execution right now, the current project will itself be an execution project of // something in the reactorProjects list, and may not have had its own executionProject instance reset to // a concrete state again after the previous forked executions. calculateConcreteState( project.getExecutionProject(), session, true ); // FIXME: Would be nice to find a way to cause the execution project to stay in a concrete state... // TODO: Test this! It should be fixed, but I don't want to destabilize until I have the issue I'm working on fixed. if ( usesReactorProjects ) { calculateAllConcreteStates( session ); List reactorProjects = session.getSortedProjects(); for ( Iterator it = reactorProjects.iterator(); it.hasNext(); ) { MavenProject reactorProject = (MavenProject) it.next(); calculateConcreteState( reactorProject.getExecutionProject(), session, false ); } } } try { pluginManager.executeMojo( project, mojoExecution, session ); } catch ( PluginManagerException e ) { throw new LifecycleExecutionException( "Internal error in the plugin manager executing goal '" + mojoDescriptor.getId() + "': " + e.getMessage(), e ); } catch ( ArtifactNotFoundException e ) { throw new LifecycleExecutionException( e.getMessage(), e ); } catch ( InvalidDependencyVersionException e ) { throw new LifecycleExecutionException( e.getMessage(), e ); } catch ( ArtifactResolutionException e ) { throw new LifecycleExecutionException( e.getMessage(), e ); } catch ( MojoFailureException e ) { throw new BuildFailureException( e.getMessage(), e ); } catch ( MojoExecutionException e ) { throw new LifecycleExecutionException( e.getMessage(), e ); } catch ( PluginConfigurationException e ) { throw new LifecycleExecutionException( e.getMessage(), e ); } } } private void createExecutionProject( final MavenProject project, final MavenSession session, final boolean processProjectReferences ) throws LifecycleExecutionException { MavenProject executionProject = new MavenProject( project ); calculateConcreteState( executionProject, session, processProjectReferences ); project.setExecutionProject( executionProject ); } private boolean usesSessionOrReactorProjects( final PlexusConfiguration configuration ) { String value = configuration != null ? String.valueOf( configuration ) : null; if ( value != null ) { if ( value.indexOf( "${session" ) > -1 || value.indexOf( "${reactorProjects}" ) > -1 ) { return true; } } return false; } private void calculateConcreteConfiguration( final MojoExecution mojoExecution, final MavenProject project, final MavenSession session ) throws LifecycleExecutionException { if ( mojoExecution.getConfiguration() == null ) { return; } try { mojoExecution.setConfiguration( (Xpp3Dom) configInterpolator.interpolate( mojoExecution.getConfiguration(), project, session.getProjectBuilderConfiguration() ) ); } catch ( ConfigurationInterpolationException e ) { throw new LifecycleExecutionException( "Error interpolating configuration for: '" + mojoExecution.getMojoDescriptor().getRoleHint() + "' (execution: '" + mojoExecution.getExecutionId() + "')", e ); } } private void calculateAllConcreteStates( final MavenSession session ) throws LifecycleExecutionException { List projects = session.getSortedProjects(); if ( projects != null ) { for ( Iterator it = projects.iterator(); it.hasNext(); ) { calculateConcreteState( (MavenProject) it.next(), session, false ); } } } private void calculateConcreteState( final MavenProject project, final MavenSession session, final boolean processReferences ) throws LifecycleExecutionException { if ( mavenProjectBuilder != null && project != null ) { try { mavenProjectBuilder.calculateConcreteState( project, session.getProjectBuilderConfiguration(), processReferences ); } catch ( ModelInterpolationException e ) { throw new LifecycleExecutionException( "Failed to calculate concrete state for project: " + project, e ); } } } // private void restoreAllDynamicStates( MavenSession session ) // throws LifecycleExecutionException // { // List reactorProjects = session.getSortedProjects(); // if ( reactorProjects != null ) // { // for ( Iterator it = reactorProjects.iterator(); it.hasNext(); ) // { // MavenProject project = (MavenProject) it.next(); // restoreDynamicState( project, session, false ); // } // } // } // // private void restoreDynamicState( MavenProject project, MavenSession session, boolean processReferences ) // throws LifecycleExecutionException // { // try // { // mavenProjectBuilder.restoreDynamicState( project, session.getProjectBuilderConfiguration(), processReferences ); // } // catch ( ModelInterpolationException e ) // { // throw new LifecycleExecutionException( "Failed to restore dynamic state for project: " + project, e ); // } // } private List getReportExecutions( final MavenProject project, final Stack forkEntryPoints, final MojoExecution mojoExecution, final MavenSession session ) throws LifecycleExecutionException, PluginNotFoundException { List reportPlugins = project.getReportPlugins(); if ( project.getModel().getReports() != null ) { getLogger().error( "Plugin contains a section: this is IGNORED - please use instead." ); } if ( project.getReporting() == null || !project.getReporting().isExcludeDefaults() ) { if ( reportPlugins == null ) { reportPlugins = new ArrayList(); } else { reportPlugins = new ArrayList( reportPlugins ); } for ( Iterator i = defaultReports.iterator(); i.hasNext(); ) { String report = (String) i.next(); StringTokenizer tok = new StringTokenizer( report, ":" ); int count = tok.countTokens(); if ( count != 2 && count != 3 ) { getLogger().warn( "Invalid default report ignored: '" + report + "' (must be groupId:artifactId[:version])" ); } else { String groupId = tok.nextToken(); String artifactId = tok.nextToken(); String version = tok.hasMoreTokens() ? tok.nextToken() : null; boolean found = false; for ( Iterator j = reportPlugins.iterator(); j.hasNext() && !found; ) { ReportPlugin reportPlugin = (ReportPlugin) j.next(); if ( reportPlugin.getGroupId().equals( groupId ) && reportPlugin.getArtifactId().equals( artifactId ) ) { found = true; } } if ( !found ) { ReportPlugin reportPlugin = new ReportPlugin(); reportPlugin.setGroupId( groupId ); reportPlugin.setArtifactId( artifactId ); reportPlugin.setVersion( version ); reportPlugins.add( reportPlugin ); } } } } List reports = new ArrayList(); if ( reportPlugins != null ) { for ( Iterator it = reportPlugins.iterator(); it.hasNext(); ) { ReportPlugin reportPlugin = (ReportPlugin) it.next(); List reportSets = reportPlugin.getReportSets(); if ( reportSets == null || reportSets.isEmpty() ) { reports.addAll( getReportExecutions( reportPlugin, forkEntryPoints, null, project, session, mojoExecution ) ); } else { for ( Iterator j = reportSets.iterator(); j.hasNext(); ) { ReportSet reportSet = (ReportSet) j.next(); reports.addAll( getReportExecutions( reportPlugin, forkEntryPoints, reportSet, project, session, mojoExecution ) ); } } } } return reports; } private List getReportExecutions( final ReportPlugin reportPlugin, final Stack forkEntryPoints, final ReportSet reportSet, final MavenProject project, final MavenSession session, final MojoExecution mojoExecution ) throws LifecycleExecutionException, PluginNotFoundException { PluginDescriptor pluginDescriptor = verifyReportPlugin( reportPlugin, project, session ); List reports = new ArrayList(); for ( Iterator i = pluginDescriptor.getMojos().iterator(); i.hasNext(); ) { MojoDescriptor mojoDescriptor = (MojoDescriptor) i.next(); if ( forkEntryPoints.contains( mojoDescriptor ) ) { getLogger().debug( "Omitting report: " + mojoDescriptor.getFullGoalName() + " from reports list. It initiated part of the fork currently executing." ); continue; } // TODO: check ID is correct for reports // if the POM configured no reports, give all from plugin if ( reportSet == null || reportSet.getReports().contains( mojoDescriptor.getGoal() ) ) { String id = null; if ( reportSet != null ) { id = reportSet.getId(); } else { id = mojoExecution.getExecutionId(); } MojoExecution reportExecution; if ( id.startsWith( MojoExecution.DEFAULT_EXEC_ID_PREFIX ) ) { reportExecution = new MojoExecution( mojoDescriptor ); } else { reportExecution = new MojoExecution( mojoDescriptor, id ); } reports.add( reportExecution ); } } return reports; } private List getReports( final List reportExecutions, final MavenProject project, final MojoExecution mojoExecution, final MavenSession session ) throws LifecycleExecutionException { List reports = new ArrayList(); for ( Iterator it = reportExecutions.iterator(); it.hasNext(); ) { MojoExecution reportExecution = (MojoExecution) it.next(); PluginDescriptor pluginDescriptor = reportExecution.getMojoDescriptor().getPluginDescriptor(); try { MavenReport reportMojo = pluginManager.getReport( project, reportExecution, session ); // Comes back null if it was a plugin, not a report - these are mojos in the reporting plugins that are not reports if ( reportMojo != null ) { reports.add( reportMojo ); mojoExecution.addMojoExecution( reportExecution ); } } catch ( PluginManagerException e ) { throw new LifecycleExecutionException( "Error getting reports from the plugin '" + pluginDescriptor.getId() + "': " + e.getMessage(), e ); } catch ( PluginConfigurationException e ) { throw new LifecycleExecutionException( "Error getting reports from the plugin '" + pluginDescriptor.getId() + "'", e ); } catch ( ArtifactNotFoundException e ) { throw new LifecycleExecutionException( e.getMessage(), e ); } catch ( ArtifactResolutionException e ) { throw new LifecycleExecutionException( e.getMessage(), e ); } } return reports; } private void forkLifecycle( final MojoDescriptor mojoDescriptor, final Stack ancestorLifecycleForkers, final MavenSession session, final MavenProject project, final String executionId ) throws LifecycleExecutionException, BuildFailureException, PluginNotFoundException { PluginDescriptor pluginDescriptor = mojoDescriptor.getPluginDescriptor(); getLogger().info( "Preparing " + pluginDescriptor.getGoalPrefix() + ":" + mojoDescriptor.getGoal() ); if ( mojoDescriptor.isAggregator() ) { for ( Iterator i = session.getSortedProjects().iterator(); i.hasNext(); ) { MavenProject reactorProject = (MavenProject) i.next(); line(); getLogger().info( "Building " + reactorProject.getName() ); line(); forkProjectLifecycle( mojoDescriptor, ancestorLifecycleForkers, session, reactorProject, executionId ); } } else { forkProjectLifecycle( mojoDescriptor, ancestorLifecycleForkers, session, project, executionId ); } } private void forkProjectLifecycle( final MojoDescriptor mojoDescriptor, final Stack forkEntryPoints, final MavenSession session, MavenProject project, final String executionId ) throws LifecycleExecutionException, BuildFailureException, PluginNotFoundException { project = project.getExecutionProject(); forkEntryPoints.push( mojoDescriptor ); PluginDescriptor pluginDescriptor = mojoDescriptor.getPluginDescriptor(); String targetPhase = mojoDescriptor.getExecutePhase(); Map lifecycleMappings = null; if ( targetPhase != null ) { Lifecycle lifecycle = getLifecycleForPhase( targetPhase ); // Create new lifecycle lifecycleMappings = constructLifecycleMappings( session, targetPhase, project, lifecycle ); String executeLifecycle = mojoDescriptor.getExecuteLifecycle(); if ( executeLifecycle != null ) { org.apache.maven.plugin.lifecycle.Lifecycle lifecycleOverlay; try { lifecycleOverlay = pluginDescriptor.getLifecycleMapping( executeLifecycle ); } catch ( IOException e ) { throw new LifecycleExecutionException( "Unable to read lifecycle mapping file: " + e.getMessage(), e ); } catch ( XmlPullParserException e ) { throw new LifecycleExecutionException( "Unable to parse lifecycle mapping file: " + e.getMessage(), e ); } if ( lifecycleOverlay == null ) { throw new LifecycleExecutionException( "Lifecycle '" + executeLifecycle + "' not found in plugin" ); } for ( Iterator i = lifecycleOverlay.getPhases().iterator(); i.hasNext(); ) { Phase phase = (Phase) i.next(); for ( Iterator j = phase.getExecutions().iterator(); j.hasNext(); ) { Execution exec = (Execution) j.next(); for ( Iterator k = exec.getGoals().iterator(); k.hasNext(); ) { String goal = (String) k.next(); PluginDescriptor lifecyclePluginDescriptor; String lifecycleGoal; // Here we are looking to see if we have a mojo from an external plugin. // If we do then we need to lookup the plugin descriptor for the externally // referenced plugin so that we can overly the execution into the lifecycle. // An example of this is the corbertura plugin that needs to call the surefire // plugin in forking mode. // // // test // // // // org.apache.maven.plugins:maven-surefire-plugin:test // // // ${project.build.directory}/generated-classes/cobertura // true // once // // // // // ---------------------------------------------------------------------- // // ---------------------------------------------------------------------- if ( goal.indexOf( ":" ) > 0 ) { String[] s = StringUtils.split( goal, ":" ); String groupId = s[0]; String artifactId = s[1]; lifecycleGoal = s[2]; Plugin plugin = new Plugin(); plugin.setGroupId( groupId ); plugin.setArtifactId( artifactId ); lifecyclePluginDescriptor = verifyPlugin( plugin, project, session ); if ( lifecyclePluginDescriptor == null ) { throw new LifecycleExecutionException( "Unable to find plugin " + groupId + ":" + artifactId ); } } else { lifecyclePluginDescriptor = pluginDescriptor; lifecycleGoal = goal; } Xpp3Dom configuration = (Xpp3Dom) exec.getConfiguration(); // NOTE: This seems to be duplicated below. Why?? if ( phase.getConfiguration() != null ) { configuration = Xpp3Dom.mergeXpp3Dom( new Xpp3Dom( (Xpp3Dom) phase.getConfiguration() ), configuration ); } MojoDescriptor desc = getMojoDescriptor( lifecyclePluginDescriptor, lifecycleGoal ); MojoExecution mojoExecution; if ( executionId.startsWith( MojoExecution.DEFAULT_EXEC_ID_PREFIX ) ) { mojoExecution = new MojoExecution( desc, configuration ); } else { mojoExecution = new MojoExecution( desc, configuration, executionId ); } addToLifecycleMappings( lifecycleMappings, phase.getId(), mojoExecution, session.getSettings() ); } } if ( phase.getConfiguration() != null ) { // Merge in general configuration for a phase. // TODO: this is all kind of backwards from the POMM. Let's align it all under 2.1. // We should create a new lifecycle executor for modelVersion >5.0.0 for ( Iterator j = lifecycleMappings.values().iterator(); j.hasNext(); ) { List tasks = (List) j.next(); for ( Iterator k = tasks.iterator(); k.hasNext(); ) { MojoExecution exec = (MojoExecution) k.next(); Xpp3Dom configuration = Xpp3Dom.mergeXpp3Dom( new Xpp3Dom( (Xpp3Dom) phase.getConfiguration() ), exec.getConfiguration() ); exec.setConfiguration( configuration ); } } } } } removeFromLifecycle( forkEntryPoints, lifecycleMappings ); } if ( targetPhase != null ) { Lifecycle lifecycle = getLifecycleForPhase( targetPhase ); executeGoalWithLifecycle( targetPhase, forkEntryPoints, session, lifecycleMappings, project, lifecycle ); } else { String goal = mojoDescriptor.getExecuteGoal(); MojoDescriptor desc = getMojoDescriptor( pluginDescriptor, goal ); executeGoals( Collections.singletonList( new MojoExecution( desc, goal ) ), forkEntryPoints, session, project ); } } private Lifecycle getLifecycleForPhase( final String phase ) throws BuildFailureException, LifecycleExecutionException { Lifecycle lifecycle = (Lifecycle) getPhaseToLifecycleMap().get( phase ); if ( lifecycle == null ) { throw new BuildFailureException( "Unable to find lifecycle for phase '" + phase + "'" ); } return lifecycle; } private MojoDescriptor getMojoDescriptor( final PluginDescriptor pluginDescriptor, final String goal ) throws LifecycleExecutionException { MojoDescriptor desc = pluginDescriptor.getMojo( goal ); if ( desc == null ) { String message = "Required goal '" + goal + "' not found in plugin '" + pluginDescriptor.getGoalPrefix() + "'"; int index = goal.indexOf( ':' ); if ( index >= 0 ) { String prefix = goal.substring( index + 1 ); if ( prefix.equals( pluginDescriptor.getGoalPrefix() ) ) { message = message + " (goals should not be prefixed - try '" + prefix + "')"; } } throw new LifecycleExecutionException( message ); } return desc; } private void removeFromLifecycle( final Stack lifecycleForkers, final Map lifecycleMappings ) { for ( Iterator lifecycleIterator = lifecycleMappings.values().iterator(); lifecycleIterator.hasNext(); ) { List tasks = (List) lifecycleIterator.next(); for ( Iterator taskIterator = tasks.iterator(); taskIterator.hasNext(); ) { MojoExecution execution = (MojoExecution) taskIterator.next(); if ( lifecycleForkers.contains( execution.getMojoDescriptor() ) ) { taskIterator.remove(); getLogger().warn( "Removing: " + execution.getMojoDescriptor().getGoal() + " from forked lifecycle, to prevent recursive invocation." ); } } } } private Map constructLifecycleMappings( final MavenSession session, final String selectedPhase, final MavenProject project, final Lifecycle lifecycle ) throws LifecycleExecutionException, BuildFailureException, PluginNotFoundException { // first, bind those associated with the packaging Map lifecycleMappings = bindLifecycleForPackaging( session, selectedPhase, project, lifecycle ); // next, loop over plugins and for any that have a phase, bind it for ( Iterator i = project.getBuildPlugins().iterator(); i.hasNext(); ) { Plugin plugin = (Plugin) i.next(); bindPluginToLifecycle( plugin, session, lifecycleMappings, project ); } return lifecycleMappings; } private Map bindLifecycleForPackaging( final MavenSession session, final String selectedPhase, final MavenProject project, final Lifecycle lifecycle ) throws LifecycleExecutionException, BuildFailureException, PluginNotFoundException { Map mappings = findMappingsForLifecycle( session, project, lifecycle ); List optionalMojos = findOptionalMojosForLifecycle( session, project, lifecycle ); Map lifecycleMappings = new HashMap(); for ( Iterator i = lifecycle.getPhases().iterator(); i.hasNext(); ) { String phase = (String) i.next(); String phaseTasks = (String) mappings.get( phase ); if ( phaseTasks != null ) { for ( StringTokenizer tok = new StringTokenizer( phaseTasks, "," ); tok.hasMoreTokens(); ) { String goal = tok.nextToken().trim(); // Not from the CLI, don't use prefix MojoDescriptor mojoDescriptor = getMojoDescriptor( goal, session, project, selectedPhase, false, optionalMojos.contains( goal ) ); if ( mojoDescriptor == null ) { continue; } if ( mojoDescriptor.isDirectInvocationOnly() ) { throw new LifecycleExecutionException( "Mojo: \'" + goal + "\' requires direct invocation. It cannot be used as part of lifecycle: \'" + project.getPackaging() + "\'." ); } addToLifecycleMappings( lifecycleMappings, phase, new MojoExecution( mojoDescriptor ), session.getSettings() ); } } if ( phase.equals( selectedPhase ) ) { break; } } return lifecycleMappings; } private Map findMappingsForLifecycle( final MavenSession session, final MavenProject project, final Lifecycle lifecycle ) throws LifecycleExecutionException, PluginNotFoundException { String packaging = project.getPackaging(); Map mappings = null; LifecycleMapping m = (LifecycleMapping) findExtension( project, LifecycleMapping.ROLE, packaging, session ); if ( m != null ) { mappings = m.getPhases( lifecycle.getId() ); } Map defaultMappings = lifecycle.getDefaultPhases(); if ( mappings == null ) { try { m = (LifecycleMapping) session.lookup( LifecycleMapping.ROLE, packaging ); mappings = m.getPhases( lifecycle.getId() ); } catch ( ComponentLookupException e ) { if ( defaultMappings == null ) { throw new LifecycleExecutionException( "Cannot find lifecycle mapping for packaging: \'" + packaging + "\'.", e ); } } } if ( mappings == null ) { if ( defaultMappings == null ) { throw new LifecycleExecutionException( "Cannot find lifecycle mapping for packaging: \'" + packaging + "\', and there is no default" ); } else { mappings = defaultMappings; } } return mappings; } private List findOptionalMojosForLifecycle( final MavenSession session, final MavenProject project, final Lifecycle lifecycle ) throws LifecycleExecutionException, PluginNotFoundException { String packaging = project.getPackaging(); List optionalMojos = null; LifecycleMapping m = (LifecycleMapping) findExtension( project, LifecycleMapping.ROLE, packaging, session ); if ( m != null ) { optionalMojos = m.getOptionalMojos( lifecycle.getId() ); } if ( optionalMojos == null ) { try { m = (LifecycleMapping) session.lookup( LifecycleMapping.ROLE, packaging ); optionalMojos = m.getOptionalMojos( lifecycle.getId() ); } catch ( ComponentLookupException e ) { getLogger().debug( "Error looking up lifecycle mapping to retrieve optional mojos. Lifecycle ID: " + lifecycle.getId() + ". Error: " + e.getMessage(), e ); } } if ( optionalMojos == null ) { optionalMojos = Collections.EMPTY_LIST; } return optionalMojos; } private Object findExtension( final MavenProject project, final String role, final String roleHint, final MavenSession session ) throws LifecycleExecutionException, PluginNotFoundException { Object pluginComponent = null; for ( Iterator i = project.getBuildPlugins().iterator(); i.hasNext() && pluginComponent == null; ) { Plugin plugin = (Plugin) i.next(); if ( plugin.isExtensions() ) { loadPluginFully( plugin, project, session ); // TODO: if moved to the plugin manager we already have the descriptor from above and so do can lookup the container directly try { pluginComponent = pluginManager.getPluginComponent( plugin, role, roleHint ); } catch ( ComponentLookupException e ) { getLogger().debug( "Unable to find the lifecycle component in the extension", e ); } catch ( PluginManagerException e ) { throw new LifecycleExecutionException( "Error getting extensions from the plugin '" + plugin.getKey() + "': " + e.getMessage(), e ); } } } return pluginComponent; } /** * @todo Not particularly happy about this. Would like WagonManager and ArtifactTypeHandlerManager to be able to * lookup directly, or have them passed in */ private Map findArtifactTypeHandlersInPlugins( final MavenProject project, final MavenSession session ) throws LifecycleExecutionException, PluginNotFoundException { Map map = new HashMap(); for ( Iterator i = project.getBuildPlugins().iterator(); i.hasNext(); ) { Plugin plugin = (Plugin) i.next(); if ( plugin.isExtensions() ) { loadPluginFully( plugin, project, session ); // TODO: if moved to the plugin manager we already have the descriptor from above and so do can lookup the container directly try { Map components = pluginManager.getPluginComponents( plugin, ArtifactHandler.ROLE ); map.putAll( components ); } catch ( ComponentLookupException e ) { getLogger().debug( "Unable to find the lifecycle component in the extension", e ); } catch ( PluginManagerException e ) { throw new LifecycleExecutionException( "Error looking up available components from plugin '" + plugin.getKey() + "': " + e.getMessage(), e ); } } } return map; } /** * Take each mojo contained with a plugin, look to see whether it contributes to a * phase in the lifecycle and if it does place it at the end of the list of goals * to execute for that given phase. * * @param project * @param session */ private void bindPluginToLifecycle( final Plugin plugin, final MavenSession session, final Map phaseMap, final MavenProject project ) throws LifecycleExecutionException, PluginNotFoundException { Settings settings = session.getSettings(); PluginDescriptor pluginDescriptor = verifyPlugin( plugin, project, session ); if ( pluginDescriptor.getMojos() != null && !pluginDescriptor.getMojos().isEmpty() ) { // use the plugin if inherit was true in a base class, or it is in the current POM, otherwise use the default inheritence setting if ( plugin.isInheritanceApplied() || pluginDescriptor.isInheritedByDefault() ) { if ( plugin.getGoals() != null ) { getLogger().error( "Plugin contains a section: this is IGNORED - please use instead." ); } List executions = plugin.getExecutions(); if ( executions != null ) { for ( Iterator it = executions.iterator(); it.hasNext(); ) { PluginExecution execution = (PluginExecution) it.next(); bindExecutionToLifecycle( pluginDescriptor, phaseMap, execution, settings ); } } } } } private PluginDescriptor verifyPlugin( final Plugin plugin, final MavenProject project, final MavenSession session ) throws LifecycleExecutionException, PluginNotFoundException { PluginDescriptor pluginDescriptor; try { // TODO: MNG-4081...need to flush this plugin once we look at it, to avoid using an external // version of a plugin when a newer version will be created in the current reactor... pluginDescriptor = pluginManager.loadPluginDescriptor( plugin, project, session ); } catch ( PluginManagerException e ) { throw new LifecycleExecutionException( "Internal error in the plugin manager getting plugin '" + plugin.getKey() + "': " + e.getMessage(), e ); } catch ( PluginVersionResolutionException e ) { throw new LifecycleExecutionException( e.getMessage(), e ); } catch ( InvalidVersionSpecificationException e ) { throw new LifecycleExecutionException( e.getMessage(), e ); } catch ( InvalidPluginException e ) { throw new LifecycleExecutionException( e.getMessage(), e ); } catch ( ArtifactNotFoundException e ) { throw new LifecycleExecutionException( e.getMessage(), e ); } catch ( ArtifactResolutionException e ) { throw new LifecycleExecutionException( e.getMessage(), e ); } catch ( PluginVersionNotFoundException e ) { throw new LifecycleExecutionException( e.getMessage(), e ); } return pluginDescriptor; } private PluginDescriptor loadPluginFully( final Plugin plugin, final MavenProject project, final MavenSession session ) throws LifecycleExecutionException, PluginNotFoundException { PluginDescriptor pluginDescriptor; try { // TODO: MNG-4081...need to flush this plugin once we look at it, to avoid using an external // version of a plugin when a newer version will be created in the current reactor... pluginDescriptor = pluginManager.loadPluginFully( plugin, project, session ); } catch ( PluginManagerException e ) { throw new LifecycleExecutionException( "Internal error in the plugin manager getting plugin '" + plugin.getKey() + "': " + e.getMessage(), e ); } catch ( PluginVersionResolutionException e ) { throw new LifecycleExecutionException( e.getMessage(), e ); } catch ( InvalidVersionSpecificationException e ) { throw new LifecycleExecutionException( e.getMessage(), e ); } catch ( InvalidPluginException e ) { throw new LifecycleExecutionException( e.getMessage(), e ); } catch ( ArtifactNotFoundException e ) { throw new LifecycleExecutionException( e.getMessage(), e ); } catch ( ArtifactResolutionException e ) { throw new LifecycleExecutionException( e.getMessage(), e ); } catch ( PluginVersionNotFoundException e ) { throw new LifecycleExecutionException( e.getMessage(), e ); } return pluginDescriptor; } private PluginDescriptor verifyReportPlugin( final ReportPlugin plugin, final MavenProject project, final MavenSession session ) throws LifecycleExecutionException, PluginNotFoundException { PluginDescriptor pluginDescriptor; try { pluginDescriptor = pluginManager.verifyReportPlugin( plugin, project, session ); } catch ( PluginManagerException e ) { throw new LifecycleExecutionException( "Internal error in the plugin manager getting report '" + plugin.getKey() + "': " + e.getMessage(), e ); } catch ( PluginVersionResolutionException e ) { throw new LifecycleExecutionException( e.getMessage(), e ); } catch ( InvalidVersionSpecificationException e ) { throw new LifecycleExecutionException( e.getMessage(), e ); } catch ( InvalidPluginException e ) { throw new LifecycleExecutionException( e.getMessage(), e ); } catch ( ArtifactNotFoundException e ) { throw new LifecycleExecutionException( e.getMessage(), e ); } catch ( ArtifactResolutionException e ) { throw new LifecycleExecutionException( e.getMessage(), e ); } catch ( PluginVersionNotFoundException e ) { throw new LifecycleExecutionException( e.getMessage(), e ); } return pluginDescriptor; } private void bindExecutionToLifecycle( final PluginDescriptor pluginDescriptor, final Map phaseMap, final PluginExecution execution, final Settings settings ) throws LifecycleExecutionException { for ( Iterator i = execution.getGoals().iterator(); i.hasNext(); ) { String goal = (String) i.next(); MojoDescriptor mojoDescriptor = pluginDescriptor.getMojo( goal ); if ( mojoDescriptor == null ) { throw new LifecycleExecutionException( "'" + goal + "' was specified in an execution, but not found in the plugin" ); } // We have to check to see that the inheritance rules have been applied before binding this mojo. if ( execution.isInheritanceApplied() || mojoDescriptor.isInheritedByDefault() ) { MojoExecution mojoExecution = new MojoExecution( mojoDescriptor, execution.getId() ); String phase = execution.getPhase(); if ( phase == null ) { // if the phase was not in the configuration, use the phase in the descriptor phase = mojoDescriptor.getPhase(); } if ( phase != null ) { if ( mojoDescriptor.isDirectInvocationOnly() ) { throw new LifecycleExecutionException( "Mojo: \'" + goal + "\' requires direct invocation. It cannot be used as part of the lifecycle (it was included via the POM)." ); } addToLifecycleMappings( phaseMap, phase, mojoExecution, settings ); } } } } private void addToLifecycleMappings( final Map lifecycleMappings, final String phase, final MojoExecution mojoExecution, final Settings settings ) { List goals = (List) lifecycleMappings.get( phase ); if ( goals == null ) { goals = new ArrayList(); lifecycleMappings.put( phase, goals ); } MojoDescriptor mojoDescriptor = mojoExecution.getMojoDescriptor(); if ( settings.isOffline() && mojoDescriptor.isOnlineRequired() ) { String goal = mojoDescriptor.getGoal(); getLogger().warn( goal + " requires online mode, but maven is currently offline. Disabling " + goal + "." ); } else { goals.add( mojoExecution ); } } private List processGoalChain( final String task, final Map phaseMap, final Lifecycle lifecycle ) { List goals = new ArrayList(); // only execute up to the given phase int index = lifecycle.getPhases().indexOf( task ); for ( int i = 0; i <= index; i++ ) { String p = (String) lifecycle.getPhases().get( i ); List phaseGoals = (List) phaseMap.get( p ); if ( phaseGoals != null ) { goals.addAll( phaseGoals ); } } return goals; } private MojoDescriptor getMojoDescriptor( final String task, final MavenSession session, final MavenProject project, final String invokedVia, final boolean canUsePrefix, final boolean isOptionalMojo ) throws BuildFailureException, LifecycleExecutionException, PluginNotFoundException { String goal; Plugin plugin = null; PluginDescriptor pluginDescriptor = null; try { StringTokenizer tok = new StringTokenizer( task, ":" ); int numTokens = tok.countTokens(); if ( numTokens == 2 ) { if ( !canUsePrefix ) { String msg = "Mapped-prefix lookup of mojos are only supported from direct invocation. " + "Please use specification of the form groupId:artifactId[:version]:goal instead. " + "(Offending mojo: \'" + task + "\', invoked via: \'" + invokedVia + "\')"; throw new LifecycleExecutionException( msg ); } String prefix = tok.nextToken(); goal = tok.nextToken(); // Steps for retrieving the plugin model instance: // 1. request directly from the plugin collector by prefix pluginDescriptor = pluginManager.getPluginDescriptorForPrefix( prefix ); if ( pluginDescriptor != null ) { plugin = new Plugin(); plugin.setGroupId( pluginDescriptor.getGroupId() ); plugin.setArtifactId( pluginDescriptor.getArtifactId() ); plugin.setVersion( pluginDescriptor.getVersion() ); } // 2. search plugins in the current POM if ( plugin == null ) { for ( Iterator i = project.getBuildPlugins().iterator(); i.hasNext(); ) { Plugin buildPlugin = (Plugin) i.next(); PluginDescriptor desc = verifyPlugin( buildPlugin, project, session ); if ( prefix.equals( desc.getGoalPrefix() ) ) { plugin = buildPlugin; pluginDescriptor = desc; break; } } } // 3. look in the repository via search groups if ( plugin == null ) { plugin = pluginManager.getPluginDefinitionForPrefix( prefix, session, project ); } // 4. default to o.a.m.plugins and maven--plugin if ( plugin == null ) { plugin = new Plugin(); plugin.setGroupId( PluginDescriptor.getDefaultPluginGroupId() ); plugin.setArtifactId( PluginDescriptor.getDefaultPluginArtifactId( prefix ) ); } } else if ( numTokens == 3 || numTokens == 4 ) { plugin = new Plugin(); plugin.setGroupId( tok.nextToken() ); plugin.setArtifactId( tok.nextToken() ); if ( numTokens == 4 ) { plugin.setVersion( tok.nextToken() ); } goal = tok.nextToken(); } else { String message = "Invalid task '" + task + "': you must specify a valid lifecycle phase, or" + " a goal in the format plugin:goal or pluginGroupId:pluginArtifactId:pluginVersion:goal"; throw new BuildFailureException( message ); } if ( plugin.getVersion() == null ) { for ( Iterator i = project.getBuildPlugins().iterator(); i.hasNext(); ) { Plugin buildPlugin = (Plugin) i.next(); if ( buildPlugin.getKey().equals( plugin.getKey() ) ) { plugin = buildPlugin; break; } } project.injectPluginManagementInfo( plugin ); } if ( pluginDescriptor == null ) { pluginDescriptor = verifyPlugin( plugin, project, session ); } // this has been simplified from the old code that injected the plugin management stuff, since // pluginManagement injection is now handled by the project method. project.addPlugin( plugin ); MojoDescriptor mojoDescriptor = pluginDescriptor.getMojo( goal ); if ( mojoDescriptor == null ) { if ( isOptionalMojo ) { getLogger().info( "Skipping missing optional mojo: " + task ); } else { throw new BuildFailureException( "Required goal not found: " + task + " in " + pluginDescriptor.getId() ); } } return mojoDescriptor; } catch ( PluginNotFoundException e ) { if ( isOptionalMojo ) { getLogger().info( "Skipping missing optional mojo: " + task ); getLogger().debug( "Mojo: " + task + " could not be found. Reason: " + e.getMessage(), e ); } else { throw e; } } return null; } protected void line() { getLogger().info( "------------------------------------------------------------------------" ); } public Map getPhaseToLifecycleMap() throws LifecycleExecutionException { if ( phaseToLifecycleMap == null ) { phaseToLifecycleMap = new HashMap(); for ( Iterator i = lifecycles.iterator(); i.hasNext(); ) { Lifecycle lifecycle = (Lifecycle) i.next(); for ( Iterator p = lifecycle.getPhases().iterator(); p.hasNext(); ) { String phase = (String) p.next(); if ( phaseToLifecycleMap.containsKey( phase ) ) { Lifecycle prevLifecycle = (Lifecycle) phaseToLifecycleMap.get( phase ); throw new LifecycleExecutionException( "Phase '" + phase + "' is defined in more than one lifecycle: '" + lifecycle.getId() + "' and '" + prevLifecycle.getId() + "'" ); } else { phaseToLifecycleMap.put( phase, lifecycle ); } } } } return phaseToLifecycleMap; } private static class TaskSegment { private boolean aggregate; private final List tasks = new ArrayList(); TaskSegment() { } TaskSegment( final boolean aggregate ) { this.aggregate = aggregate; } public String toString() { StringBuffer message = new StringBuffer(); message.append( " task-segment: [" ); for ( Iterator it = tasks.iterator(); it.hasNext(); ) { String task = (String) it.next(); message.append( task ); if ( it.hasNext() ) { message.append( ", " ); } } message.append( "]" ); if ( aggregate ) { message.append( " (aggregator-style)" ); } return message.toString(); } boolean aggregate() { return aggregate; } void add( final String task ) { tasks.add( task ); } List getTasks() { return tasks; } } public List getLifecycles() { return lifecycles; } // ------------------------------------------------------------------------- // TODO: The methods and fields below are only needed for products like Hudson, // that provide their own LifecycleExecutor and component configuration that extend // default implementation, and which may become out-of-date as component requirements // are updated within Maven itself. public void initialize() throws InitializationException { if ( mavenProjectBuilder == null ) { warnOfIncompleteComponentConfiguration( MavenProjectBuilder.ROLE ); try { mavenProjectBuilder = (MavenProjectBuilder) container.lookup( MavenProjectBuilder.ROLE ); } catch ( ComponentLookupException e ) { throw new InitializationException( "Failed to lookup project builder after it was NOT injected via component requirement." ); } } if ( modelInterpolator == null ) { warnOfIncompleteComponentConfiguration( ModelInterpolator.ROLE ); try { modelInterpolator = (ModelInterpolator) container.lookup( ModelInterpolator.ROLE ); } catch ( ComponentLookupException e ) { throw new InitializationException( "Failed to lookup model interpolator after it was NOT injected via component requirement." ); } } if ( configInterpolator == null ) { warnOfIncompleteComponentConfiguration( ConfigurationInterpolator.ROLE ); try { configInterpolator = (ConfigurationInterpolator) container.lookup( ConfigurationInterpolator.ROLE ); } catch ( ComponentLookupException e ) { throw new InitializationException( "Failed to lookup plugin-configuration interpolator after it was NOT injected via component requirement." ); } } } private void warnOfIncompleteComponentConfiguration( final String role ) { StringBuffer buffer = new StringBuffer(); buffer.append( "\n************ WARNING ************" ); buffer.append( "\n\nThis Maven runtime contains a LifecycleExecutor component with an incomplete configuration." ); buffer.append( "\n\nLifecycleExecutor class: " ).append( getClass().getName() ); buffer.append( "\nMissing component requirement: " ).append( role ); buffer.append( "\n" ); buffer.append( "\nNOTE: This seems to be a third-party Maven derivative you are using. If so, please" ); buffer.append( "\nnotify the developers for this derivative project of the problem. The Apache Maven team is not" ); buffer.append( "\nresponsible for maintaining the integrity of third-party component overrides." ); buffer.append( "\n\n" ); getLogger().warn( buffer.toString() ); } private PlexusContainer container; public void contextualize( final Context context ) throws ContextException { container = (PlexusContainer) context.get( PlexusConstants.PLEXUS_KEY ); } } maven2-core-2.2.1/maven-core/src/main/java/org/apache/maven/execution/0000755000175000017500000000000011250552240025375 5ustar twernertwerner././@LongLink0000000000000000000000000000014500000000000011565 Lustar rootrootmaven2-core-2.2.1/maven-core/src/main/java/org/apache/maven/execution/DefaultRuntimeInformation.javamaven2-core-2.2.1/maven-core/src/main/java/org/apache/maven/execution/DefaultRuntimeInformation.java0000644000175000017500000000572110772004567033417 0ustar twernertwernerpackage org.apache.maven.execution; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import org.apache.maven.artifact.versioning.ArtifactVersion; import org.apache.maven.artifact.versioning.DefaultArtifactVersion; import org.codehaus.plexus.personality.plexus.lifecycle.phase.Initializable; import org.codehaus.plexus.personality.plexus.lifecycle.phase.InitializationException; import org.codehaus.plexus.util.IOUtil; import java.io.IOException; import java.io.InputStream; import java.util.Properties; /** * Describes runtime information about the application. * * @author Brett Porter * @version $Id: DefaultRuntimeInformation.java 640549 2008-03-24 20:05:11Z bentmann $ */ public class DefaultRuntimeInformation implements RuntimeInformation, Initializable { private static final String MAVEN_GROUPID = "org.apache.maven"; private static final String MAVEN_PROPERTIES = "META-INF/maven/" + MAVEN_GROUPID + "/maven-core/pom.properties"; private ArtifactVersion applicationVersion; public ArtifactVersion getApplicationVersion() { return applicationVersion; } public void initialize() throws InitializationException { InputStream resourceAsStream = null; try { Properties properties = new Properties(); resourceAsStream = getClass().getClassLoader().getResourceAsStream( MAVEN_PROPERTIES ); if ( resourceAsStream == null ) { throw new IllegalStateException( "Unable to find Maven properties in classpath: " + MAVEN_PROPERTIES ); } properties.load( resourceAsStream ); String property = properties.getProperty( "version" ); if ( property == null ) { throw new InitializationException( "maven-core properties did not include the version" ); } applicationVersion = new DefaultArtifactVersion( property ); } catch ( IOException e ) { throw new InitializationException( "Unable to read properties file from maven-core", e ); } finally { IOUtil.close( resourceAsStream ); } } } ././@LongLink0000000000000000000000000000015000000000000011561 Lustar rootrootmaven2-core-2.2.1/maven-core/src/main/java/org/apache/maven/execution/DefaultMavenExecutionRequest.javamaven2-core-2.2.1/maven-core/src/main/java/org/apache/maven/execution/DefaultMavenExecutionRequest.j0000644000175000017500000001456311053051031033362 0ustar twernertwernerpackage org.apache.maven.execution; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.monitor.event.EventDispatcher; import org.apache.maven.monitor.event.EventMonitor; import org.apache.maven.profiles.ProfileManager; import org.apache.maven.project.DefaultProjectBuilderConfiguration; import org.apache.maven.project.ProjectBuilderConfiguration; import org.apache.maven.settings.Settings; import java.util.Date; import java.util.List; import java.util.Properties; /** * @author Jason van Zyl * @version $Id: DefaultMavenExecutionRequest.java 687388 2008-08-20 17:19:21Z dfabulich $ */ public class DefaultMavenExecutionRequest implements MavenExecutionRequest { /** * @todo [BP] is this required? This hands off to MavenSession, but could be passed through the handler.handle function (+ createSession). */ private final ArtifactRepository localRepository; private final List goals; protected MavenSession session; private final EventDispatcher eventDispatcher; private final Settings settings; private final String baseDirectory; private boolean recursive = true; private boolean reactorActive; private String pomFilename; private String failureBehavior; private final ProfileManager globalProfileManager; private final Properties executionProperties; private final Properties userProperties; private final Date startTime; private final boolean showErrors; private String makeBehavior; private String resumeFrom; private List selectedProjects; public DefaultMavenExecutionRequest( ArtifactRepository localRepository, Settings settings, EventDispatcher eventDispatcher, List goals, String baseDirectory, ProfileManager globalProfileManager, Properties executionProperties, Properties userProperties, boolean showErrors ) { this.localRepository = localRepository; this.settings = settings; this.goals = goals; this.eventDispatcher = eventDispatcher; this.baseDirectory = baseDirectory; this.globalProfileManager = globalProfileManager; this.executionProperties = executionProperties; this.userProperties = userProperties; startTime = new Date(); this.showErrors = showErrors; } public Settings getSettings() { return settings; } public String getBaseDirectory() { return baseDirectory; } public boolean isRecursive() { return recursive; } public void setRecursive( boolean recursive ) { this.recursive = false; } public ArtifactRepository getLocalRepository() { return localRepository; } public List getGoals() { return goals; } public Properties getExecutionProperties() { return executionProperties; } // ---------------------------------------------------------------------- // Putting the session here but it can probably be folded right in here. // ---------------------------------------------------------------------- public MavenSession getSession() { return session; } public void setSession( MavenSession session ) { session = session; } public void addEventMonitor( EventMonitor monitor ) { eventDispatcher.addEventMonitor( monitor ); } public EventDispatcher getEventDispatcher() { return eventDispatcher; } public void setReactorActive( boolean reactorActive ) { this.reactorActive = reactorActive; } public boolean isReactorActive() { return reactorActive; } public void setPomFile( String pomFilename ) { this.pomFilename = pomFilename; } public String getPomFile() { return pomFilename; } public void setFailureBehavior( String failureBehavior ) { this.failureBehavior = failureBehavior; } public String getFailureBehavior() { return failureBehavior; } public ProfileManager getGlobalProfileManager() { return globalProfileManager; } public Date getStartTime() { return startTime; } public boolean isShowErrors() { return showErrors; } public Properties getUserProperties() { return userProperties; } public ProjectBuilderConfiguration getProjectBuilderConfiguration() { ProjectBuilderConfiguration config = new DefaultProjectBuilderConfiguration(); config.setLocalRepository( getLocalRepository() ) .setGlobalProfileManager( getGlobalProfileManager() ) .setExecutionProperties( getExecutionProperties() ) .setUserProperties( getUserProperties() ) .setBuildStartTime( startTime ); return config; } public String getMakeBehavior() { return makeBehavior; } public void setMakeBehavior( String makeBehavior ) { this.makeBehavior = makeBehavior; } public String getResumeFrom() { return resumeFrom; } public void setResumeFrom( String resumeFrom ) { this.resumeFrom = resumeFrom; } public List getSelectedProjects() { return selectedProjects; } public void setSelectedProjects( List selectedProjects ) { this.selectedProjects = selectedProjects; } } maven2-core-2.2.1/maven-core/src/main/java/org/apache/maven/execution/BuildFailure.java0000644000175000017500000000274110772004567030627 0ustar twernertwernerpackage org.apache.maven.execution; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ /** * Describe a build failure in the reactor. * * @author Brett Porter * @version $Id: BuildFailure.java 640549 2008-03-24 20:05:11Z bentmann $ */ public class BuildFailure { private final Exception cause; private final String task; private final long time; BuildFailure( Exception cause, String task, long time ) { this.cause = cause; this.task = task; this.time = time; } public String getTask() { return task; } public Exception getCause() { return cause; } public long getTime() { return time; } } maven2-core-2.2.1/maven-core/src/main/java/org/apache/maven/execution/ReactorManager.java0000644000175000017500000001667411226741032031152 0ustar twernertwernerpackage org.apache.maven.execution; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import org.apache.maven.artifact.ArtifactUtils; import org.apache.maven.plugin.descriptor.PluginDescriptor; import org.apache.maven.project.DuplicateProjectException; import org.apache.maven.project.MavenProject; import org.apache.maven.project.MissingProjectException; import org.apache.maven.project.ProjectSorter; import org.codehaus.plexus.util.dag.CycleDetectedException; import java.util.ArrayList; import java.util.HashMap; import java.util.Iterator; import java.util.List; import java.util.Map; public class ReactorManager { public static final String FAIL_FAST = "fail-fast"; public static final String FAIL_AT_END = "fail-at-end"; public static final String FAIL_NEVER = "fail-never"; public static final String MAKE_MODE = "make"; public static final String MAKE_DEPENDENTS_MODE = "make-dependents"; // make projects that depend on me, and projects that I depend on public static final String MAKE_BOTH_MODE = "make-both"; private List blackList = new ArrayList(); private Map buildFailuresByProject = new HashMap(); private Map pluginContextsByProjectAndPluginKey = new HashMap(); private String failureBehavior = FAIL_FAST; private final ProjectSorter sorter; private Map buildSuccessesByProject = new HashMap(); public ReactorManager( List projects ) throws CycleDetectedException, DuplicateProjectException, MissingProjectException { this.sorter = new ProjectSorter( projects ); } public ReactorManager( List projects, List selectedProjects, String resumeFrom, String makeBehavior ) throws CycleDetectedException, DuplicateProjectException, MissingProjectException { boolean make, makeDependents; if ( makeBehavior == null ) { make = false; makeDependents = false; } else if ( MAKE_MODE.equals( makeBehavior ) ) { make = true; makeDependents = false; } else if ( MAKE_DEPENDENTS_MODE.equals( makeBehavior ) ) { make = false; makeDependents = true; } else if ( MAKE_BOTH_MODE.equals( makeBehavior ) ) { make = true; makeDependents = true; } else { throw new IllegalArgumentException( "Invalid make behavior (must be one of: \'" + MAKE_MODE + "\', \'" + MAKE_DEPENDENTS_MODE + "\', \'" + MAKE_BOTH_MODE + "\')." ); } this.sorter = new ProjectSorter( projects, selectedProjects, resumeFrom, make, makeDependents ); } public Map getPluginContext( PluginDescriptor plugin, MavenProject project ) { Map pluginContextsByKey = (Map) pluginContextsByProjectAndPluginKey.get( project.getId() ); if ( pluginContextsByKey == null ) { pluginContextsByKey = new HashMap(); pluginContextsByProjectAndPluginKey.put( project.getId(), pluginContextsByKey ); } Map pluginContext = (Map) pluginContextsByKey.get( plugin.getPluginLookupKey() ); if ( pluginContext == null ) { pluginContext = new HashMap(); pluginContextsByKey.put( plugin.getPluginLookupKey(), pluginContext ); } return pluginContext; } public void setFailureBehavior( String failureBehavior ) { if ( failureBehavior == null ) { this.failureBehavior = FAIL_FAST; // default return; } if ( FAIL_FAST.equals( failureBehavior ) || FAIL_AT_END.equals( failureBehavior ) || FAIL_NEVER.equals( failureBehavior ) ) { this.failureBehavior = failureBehavior; } else { throw new IllegalArgumentException( "Invalid failure behavior (must be one of: \'" + FAIL_FAST + "\', \'" + FAIL_AT_END + "\', \'" + FAIL_NEVER + "\')." ); } } public String getFailureBehavior() { return failureBehavior; } public void blackList( MavenProject project ) { blackList( getProjectKey( project ) ); } private void blackList( String id ) { if ( !blackList.contains( id ) ) { blackList.add( id ); List dependents = sorter.getDependents( id ); if ( dependents != null && !dependents.isEmpty() ) { for ( Iterator it = dependents.iterator(); it.hasNext(); ) { String dependentId = (String) it.next(); if ( !buildSuccessesByProject.containsKey( dependentId ) && !buildFailuresByProject.containsKey( dependentId ) ) { blackList( dependentId ); } } } } } public boolean isBlackListed( MavenProject project ) { return blackList.contains( getProjectKey( project ) ); } private static String getProjectKey( MavenProject project ) { return ArtifactUtils.versionlessKey( project.getGroupId(), project.getArtifactId() ); } public void registerBuildFailure( MavenProject project, Exception error, String task, long time ) { buildFailuresByProject.put( getProjectKey( project ), new BuildFailure( error, task, time ) ); } public boolean hasBuildFailures() { return !buildFailuresByProject.isEmpty(); } public boolean hasBuildFailure( MavenProject project ) { return buildFailuresByProject.containsKey( getProjectKey( project ) ); } public boolean hasMultipleProjects() { return sorter.hasMultipleProjects(); } public List getSortedProjects() { return sorter.getSortedProjects(); } public MavenProject getTopLevelProject() { return sorter.getTopLevelProject(); } public boolean hasBuildSuccess( MavenProject project ) { return buildSuccessesByProject.containsKey( getProjectKey( project ) ); } public void registerBuildSuccess( MavenProject project, long time ) { buildSuccessesByProject.put( getProjectKey( project ), new BuildSuccess( project, time ) ); } public BuildFailure getBuildFailure( MavenProject project ) { return (BuildFailure) buildFailuresByProject.get( getProjectKey( project ) ); } public BuildSuccess getBuildSuccess( MavenProject project ) { return (BuildSuccess) buildSuccessesByProject.get( getProjectKey( project ) ); } public boolean executedMultipleProjects() { return buildFailuresByProject.size() + buildSuccessesByProject.size() > 1; } } maven2-core-2.2.1/maven-core/src/main/java/org/apache/maven/execution/MavenSession.java0000644000175000017500000001457211226741032030665 0ustar twernertwernerpackage org.apache.maven.execution; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.monitor.event.EventDispatcher; import org.apache.maven.plugin.descriptor.PluginDescriptor; import org.apache.maven.project.DefaultProjectBuilderConfiguration; import org.apache.maven.project.MavenProject; import org.apache.maven.project.ProjectBuilderConfiguration; import org.apache.maven.settings.Settings; import org.codehaus.plexus.PlexusContainer; import org.codehaus.plexus.component.repository.exception.ComponentLookupException; import java.util.Date; import java.util.List; import java.util.Map; import java.util.Properties; /** * @author Jason van Zyl * @version $Id: MavenSession.java 793745 2009-07-13 23:24:10Z jdcasey $ */ public class MavenSession { private PlexusContainer container; private ArtifactRepository localRepository; private List goals; private EventDispatcher eventDispatcher; // TODO: make this the central one, get rid of build settings... private final Settings settings; private ReactorManager reactorManager; private final String executionRootDir; private boolean usingPOMsFromFilesystem = true; private final Properties executionProperties; private Properties userProperties; private final Date startTime; private MavenProject currentProject; public MavenSession( PlexusContainer container, Settings settings, ArtifactRepository localRepository, EventDispatcher eventDispatcher, ReactorManager reactorManager, List goals, String executionRootDir, Properties executionProperties, Date startTime ) { this( container, settings, localRepository, eventDispatcher, reactorManager, goals, executionRootDir, executionProperties, null, startTime ); } public MavenSession( PlexusContainer container, Settings settings, ArtifactRepository localRepository, EventDispatcher eventDispatcher, ReactorManager reactorManager, List goals, String executionRootDir, Properties executionProperties, Properties userProperties, Date startTime ) { this.container = container; this.settings = settings; this.localRepository = localRepository; this.eventDispatcher = eventDispatcher; this.reactorManager = reactorManager; this.goals = goals; this.executionRootDir = executionRootDir; this.executionProperties = executionProperties; this.userProperties = userProperties; this.startTime = startTime; } public Map getPluginContext( PluginDescriptor pluginDescriptor, MavenProject project ) { return reactorManager.getPluginContext( pluginDescriptor, project ); } public PlexusContainer getContainer() { return container; } public ArtifactRepository getLocalRepository() { return localRepository; } public List getGoals() { return goals; } public Properties getExecutionProperties() { return executionProperties; } // ---------------------------------------------------------------------- // // ---------------------------------------------------------------------- public Object lookup( String role ) throws ComponentLookupException { return container.lookup( role ); } public Object lookup( String role, String roleHint ) throws ComponentLookupException { return container.lookup( role, roleHint ); } public List lookupList( String role ) throws ComponentLookupException { return container.lookupList( role ); } public Map lookupMap( String role ) throws ComponentLookupException { return container.lookupMap( role ); } public EventDispatcher getEventDispatcher() { return eventDispatcher; } public Settings getSettings() { return settings; } public List getSortedProjects() { return reactorManager.getSortedProjects(); } public String getExecutionRootDirectory() { return executionRootDir; } public void setUsingPOMsFromFilesystem( boolean usingPOMsFromFilesystem ) { this.usingPOMsFromFilesystem = usingPOMsFromFilesystem; } public boolean isUsingPOMsFromFilesystem() { return usingPOMsFromFilesystem; } public Date getStartTime() { return startTime; } public void setCurrentProject( MavenProject currentProject ) { this.currentProject = currentProject; } /** * Return the current project for use in a mojo execution. */ public MavenProject getCurrentProject() { return currentProject; } public Properties getUserProperties() { return userProperties; } public void setUserProperties( Properties userProperties ) { this.userProperties = userProperties; } /** * NOTE: This varies from {@link DefaultMavenExecutionRequest#getProjectBuilderConfiguration()} in that * it doesn't supply a global profile manager. */ public ProjectBuilderConfiguration getProjectBuilderConfiguration() { ProjectBuilderConfiguration config = new DefaultProjectBuilderConfiguration(); config.setLocalRepository( getLocalRepository() ) .setExecutionProperties( getExecutionProperties() ) .setUserProperties( getUserProperties() ) .setBuildStartTime( getStartTime() ); return config; } }maven2-core-2.2.1/maven-core/src/main/java/org/apache/maven/execution/RuntimeInformation.java0000644000175000017500000000226110772004567032106 0ustar twernertwernerpackage org.apache.maven.execution; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import org.apache.maven.artifact.versioning.ArtifactVersion; /** * Describes runtime information about the application. * * @author Brett Porter * @version $Id: RuntimeInformation.java 640549 2008-03-24 20:05:11Z bentmann $ */ public interface RuntimeInformation { ArtifactVersion getApplicationVersion(); } maven2-core-2.2.1/maven-core/src/main/java/org/apache/maven/execution/BuildSuccess.java0000644000175000017500000000264710772004567030655 0ustar twernertwernerpackage org.apache.maven.execution; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import org.apache.maven.project.MavenProject; /** * Describe a build success in the reactor. * * @author Brett Porter * @version $Id: BuildSuccess.java 640549 2008-03-24 20:05:11Z bentmann $ */ public class BuildSuccess { private final MavenProject project; private final long time; public BuildSuccess( MavenProject project, long time ) { this.project = project; this.time = time; } public MavenProject getProject() { return project; } public long getTime() { return time; } } maven2-core-2.2.1/maven-core/src/main/java/org/apache/maven/execution/MavenExecutionRequest.java0000644000175000017500000000500211053051031032531 0ustar twernertwernerpackage org.apache.maven.execution; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.monitor.event.EventDispatcher; import org.apache.maven.monitor.event.EventMonitor; import org.apache.maven.profiles.ProfileManager; import org.apache.maven.project.ProjectBuilderConfiguration; import org.apache.maven.settings.Settings; import java.util.Date; import java.util.List; import java.util.Properties; /** * @author Jason van Zyl * @version $Id: MavenExecutionRequest.java 687388 2008-08-20 17:19:21Z dfabulich $ */ public interface MavenExecutionRequest { ArtifactRepository getLocalRepository(); List getGoals(); void setSession( MavenSession session ); MavenSession getSession(); void addEventMonitor( EventMonitor monitor ); EventDispatcher getEventDispatcher(); Settings getSettings(); String getBaseDirectory(); void setRecursive( boolean recursive ); boolean isRecursive(); void setReactorActive( boolean reactorActive ); boolean isReactorActive(); void setResumeFrom( String resumeFrom ); String getResumeFrom(); void setSelectedProjects( List projects ); List getSelectedProjects(); void setMakeBehavior( String makeBehavior ); String getMakeBehavior(); void setPomFile( String pomFile ); String getPomFile(); void setFailureBehavior( String failureBehavior ); String getFailureBehavior(); ProfileManager getGlobalProfileManager(); Properties getExecutionProperties(); Properties getUserProperties(); Date getStartTime(); boolean isShowErrors(); ProjectBuilderConfiguration getProjectBuilderConfiguration(); } maven2-core-2.2.1/maven-core/src/main/java/org/apache/maven/SettingsConfigurationException.java0000644000175000017500000000357310772004567032470 0ustar twernertwernerpackage org.apache.maven; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ /** * If there was an error in the settings file. * * @author Brett Porter * @version $Id: SettingsConfigurationException.java 640549 2008-03-24 20:05:11Z bentmann $ */ public class SettingsConfigurationException extends Exception { private int lineNumber; private int columnNumber; public SettingsConfigurationException( String message ) { super( message ); } public SettingsConfigurationException( String message, Throwable cause ) { super( message, cause ); } public SettingsConfigurationException( String message, Throwable cause, int lineNumber, int columnNumber ) { super( message + ( lineNumber > 0 ? "\n Line: " + lineNumber : "" ) + ( columnNumber > 0 ? "\n Column: " + columnNumber : "" ), cause ); this.lineNumber = lineNumber; this.columnNumber = columnNumber; } public int getColumnNumber() { return columnNumber; } public int getLineNumber() { return lineNumber; } } maven2-core-2.2.1/maven-core/src/main/java/org/apache/maven/usability/0000755000175000017500000000000011250552241025400 5ustar twernertwerner././@LongLink0000000000000000000000000000014500000000000011565 Lustar rootrootmaven2-core-2.2.1/maven-core/src/main/java/org/apache/maven/usability/ArtifactResolverDiagnoser.javamaven2-core-2.2.1/maven-core/src/main/java/org/apache/maven/usability/ArtifactResolverDiagnoser.java0000644000175000017500000000446611226327403033373 0ustar twernertwernerpackage org.apache.maven.usability; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import org.apache.maven.artifact.manager.WagonManager; import org.apache.maven.artifact.resolver.ArtifactResolutionException; import org.apache.maven.usability.diagnostics.DiagnosisUtils; import org.apache.maven.usability.diagnostics.ErrorDiagnoser; import java.io.IOException; public class ArtifactResolverDiagnoser implements ErrorDiagnoser { private WagonManager wagonManager; public boolean canDiagnose( Throwable error ) { return DiagnosisUtils.containsInCausality( error, ArtifactResolutionException.class ); } public String diagnose( Throwable error ) { ArtifactResolutionException exception = (ArtifactResolutionException) DiagnosisUtils.getFromCausality( error, ArtifactResolutionException.class ); StringBuffer message = new StringBuffer(); message.append( "Failed to resolve artifact." ); message.append( "\n\n" ); message.append( exception.getMessage() ); IOException ioe = (IOException) DiagnosisUtils.getFromCausality( exception, IOException.class ); if ( ioe != null && ioe.getMessage() != null && exception.getMessage().indexOf( ioe.getMessage() ) < 0 ) { message.append( "\n\nCaused by I/O exception: " ).append( ioe.getMessage() ); } if ( !wagonManager.isOnline() ) { message.append( "\n" ).append( SystemWarnings.getOfflineWarning() ); } message.append( "\n" ); return message.toString(); } } maven2-core-2.2.1/maven-core/src/main/java/org/apache/maven/usability/SystemWarnings.java0000644000175000017500000000210311103153436031234 0ustar twernertwernerpackage org.apache.maven.usability; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ public class SystemWarnings { public static String getOfflineWarning() { return "\nNOTE: Maven is executing in offline mode. Any artifacts not already in your local\n" + "repository will be inaccessible.\n"; } } ././@LongLink0000000000000000000000000000015300000000000011564 Lustar rootrootmaven2-core-2.2.1/maven-core/src/main/java/org/apache/maven/usability/MojoExecutionExceptionDiagnoser.javamaven2-core-2.2.1/maven-core/src/main/java/org/apache/maven/usability/MojoExecutionExceptionDiagnose0000644000175000017500000000561211157716765033473 0ustar twernertwernerpackage org.apache.maven.usability; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.usability.diagnostics.DiagnosisUtils; import org.apache.maven.usability.diagnostics.ErrorDiagnoser; public class MojoExecutionExceptionDiagnoser implements ErrorDiagnoser { public boolean canDiagnose( Throwable error ) { return DiagnosisUtils.containsInCausality( error, MojoExecutionException.class ); } public String diagnose( Throwable error ) { MojoExecutionException mee = (MojoExecutionException) DiagnosisUtils.getFromCausality( error, MojoExecutionException.class ); StringBuffer message = new StringBuffer(); Object source = mee.getSource(); if ( source != null ) { message.append( ": " ).append( mee.getSource() ).append( "\n" ); } String shortMessage = mee.getMessage(); if ( shortMessage != null ) { message.append( shortMessage ); } String longMessage = mee.getLongMessage(); // the indexOf bit is very strange, but the compiler output for 1.5 source compiled using JDK 1.4 presents this case! // duplicating here for consistency, just in case there's another goofy plugin output I don't know of. if ( longMessage != null && !longMessage.equals( shortMessage ) && shortMessage.indexOf( longMessage ) < 0 ) { message.append( "\n\n" ).append( longMessage ); } Throwable directCause = mee.getCause(); if ( directCause != null ) { message.append( "\n" ); String directCauseMessage = directCause.getMessage(); String meeMessage = mee.getMessage(); if ( ( directCauseMessage != null ) && ( meeMessage != null ) && meeMessage.indexOf( directCauseMessage ) < 0 ) { message.append( "\nEmbedded error: " ).append( directCauseMessage ); } DiagnosisUtils.appendRootCauseIfPresentAndUnique( directCause, message, false ); } return message.toString(); } } maven2-core-2.2.1/maven-core/src/main/java/org/apache/maven/usability/InvalidArtifactDiagnoser.java0000644000175000017500000000441410772004567033161 0ustar twernertwernerpackage org.apache.maven.usability; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import org.apache.maven.artifact.InvalidArtifactRTException; import org.apache.maven.usability.diagnostics.ErrorDiagnoser; public class InvalidArtifactDiagnoser implements ErrorDiagnoser { public boolean canDiagnose( Throwable error ) { return error instanceof InvalidArtifactRTException; } public String diagnose( Throwable error ) { StringBuffer diagnosis = new StringBuffer(); InvalidArtifactRTException e = (InvalidArtifactRTException) error; diagnosis.append( "An invalid artifact was detected.\n\n" ) .append( "This artifact might be in your project's POM, " ) .append( "or it might have been included transitively during the resolution process. " ) .append( "Here is the information we do have for this artifact:\n" ) .append( "\n o GroupID: " ).append( maybeFlag( e.getGroupId() ) ) .append( "\n o ArtifactID: " ).append( maybeFlag( e.getArtifactId() ) ) .append( "\n o Version: " ).append( maybeFlag( e.getVersion() ) ) .append( "\n o Type: " ).append( maybeFlag( e.getType() ) ) .append( "\n" ); return diagnosis.toString(); } private String maybeFlag( String value ) { if ( value == null || value.trim().length() < 1 ) { return "<<< MISSING >>>"; } else { return value; } } } ././@LongLink0000000000000000000000000000015000000000000011561 Lustar rootrootmaven2-core-2.2.1/maven-core/src/main/java/org/apache/maven/usability/PluginConfigurationDiagnoser.javamaven2-core-2.2.1/maven-core/src/main/java/org/apache/maven/usability/PluginConfigurationDiagnoser.j0000644000175000017500000000434710772004567033420 0ustar twernertwernerpackage org.apache.maven.usability; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import org.apache.maven.plugin.PluginConfigurationException; import org.apache.maven.plugin.PluginParameterException; import org.apache.maven.usability.diagnostics.DiagnosisUtils; import org.apache.maven.usability.diagnostics.ErrorDiagnoser; import org.codehaus.plexus.component.configurator.ComponentConfigurationException; public class PluginConfigurationDiagnoser implements ErrorDiagnoser { public boolean canDiagnose( Throwable error ) { return DiagnosisUtils.containsInCausality( error, PluginConfigurationException.class ); } public String diagnose( Throwable error ) { PluginConfigurationException pce = (PluginConfigurationException) DiagnosisUtils.getFromCausality( error, PluginConfigurationException.class ); if ( pce instanceof PluginParameterException ) { PluginParameterException exception = (PluginParameterException) pce; return exception.buildDiagnosticMessage(); } else if ( DiagnosisUtils.containsInCausality( pce, ComponentConfigurationException.class ) ) { ComponentConfigurationException cce = (ComponentConfigurationException) DiagnosisUtils.getFromCausality( pce, ComponentConfigurationException.class ); return pce.buildConfigurationDiagnosticMessage( cce ); } else { return pce.getMessage(); } } } ././@LongLink0000000000000000000000000000014600000000000011566 Lustar rootrootmaven2-core-2.2.1/maven-core/src/main/java/org/apache/maven/usability/ProfileActivationDiagnoser.javamaven2-core-2.2.1/maven-core/src/main/java/org/apache/maven/usability/ProfileActivationDiagnoser.jav0000644000175000017500000000447010772004567033400 0ustar twernertwernerpackage org.apache.maven.usability; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import org.apache.maven.profiles.activation.ProfileActivationException; import org.apache.maven.usability.diagnostics.DiagnosisUtils; import org.apache.maven.usability.diagnostics.ErrorDiagnoser; import org.codehaus.plexus.component.repository.exception.ComponentLookupException; public class ProfileActivationDiagnoser implements ErrorDiagnoser { public boolean canDiagnose( Throwable error ) { return DiagnosisUtils.containsInCausality( error, ProfileActivationException.class ); } public String diagnose( Throwable error ) { ProfileActivationException activationException = (ProfileActivationException) DiagnosisUtils.getFromCausality( error, ProfileActivationException.class ); StringBuffer messageBuffer = new StringBuffer(); messageBuffer.append( "Error activating profiles." ); messageBuffer.append( "\n\nReason: " ).append( activationException.getMessage() ); if ( DiagnosisUtils.containsInCausality( activationException, ComponentLookupException.class ) ) { ComponentLookupException cle = (ComponentLookupException) DiagnosisUtils.getFromCausality( activationException, ComponentLookupException.class ); messageBuffer.append( "\n\nThere was a problem retrieving one or more profile activators." ); messageBuffer.append( "\n" ).append( cle.getMessage() ); } messageBuffer.append( "\n" ); return messageBuffer.toString(); } } maven2-core-2.2.1/maven-core/src/main/java/org/apache/maven/usability/ProjectBuildDiagnoser.java0000644000175000017500000000464710772004567032513 0ustar twernertwernerpackage org.apache.maven.usability; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import org.apache.maven.project.InvalidProjectModelException; import org.apache.maven.project.ProjectBuildingException; import org.apache.maven.project.validation.ModelValidationResult; import org.apache.maven.usability.diagnostics.DiagnosisUtils; import org.apache.maven.usability.diagnostics.ErrorDiagnoser; public class ProjectBuildDiagnoser implements ErrorDiagnoser { public boolean canDiagnose( Throwable error ) { return DiagnosisUtils.containsInCausality( error, ProjectBuildingException.class ); } public String diagnose( Throwable error ) { ProjectBuildingException pbe = (ProjectBuildingException) DiagnosisUtils.getFromCausality( error, ProjectBuildingException.class ); StringBuffer message = new StringBuffer(); message.append( "Error building POM (may not be this project's POM)." ).append( "\n\n" ); message.append( "\nProject ID: " ).append( pbe.getProjectId() ); if ( pbe instanceof InvalidProjectModelException ) { InvalidProjectModelException ipme = (InvalidProjectModelException) pbe; message.append( "\nPOM Location: " ).append( ipme.getPomLocation() ); ModelValidationResult result = ipme.getValidationResult(); if ( result != null ) { message.append( "\nValidation Messages:\n\n" ).append( ipme.getValidationResult().render( " " ) ); } } message.append( "\n\n" ).append( "Reason: " ).append( pbe.getMessage() ); message.append( "\n\n" ); return message.toString(); } } ././@LongLink0000000000000000000000000000015100000000000011562 Lustar rootrootmaven2-core-2.2.1/maven-core/src/main/java/org/apache/maven/usability/MojoFailureExceptionDiagnoser.javamaven2-core-2.2.1/maven-core/src/main/java/org/apache/maven/usability/MojoFailureExceptionDiagnoser.0000644000175000017500000000430111157716765033351 0ustar twernertwernerpackage org.apache.maven.usability; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import org.apache.maven.plugin.MojoFailureException; import org.apache.maven.usability.diagnostics.DiagnosisUtils; import org.apache.maven.usability.diagnostics.ErrorDiagnoser; public class MojoFailureExceptionDiagnoser implements ErrorDiagnoser { public boolean canDiagnose( Throwable error ) { return DiagnosisUtils.containsInCausality( error, MojoFailureException.class ); } public String diagnose( Throwable error ) { MojoFailureException mfe = (MojoFailureException) DiagnosisUtils.getFromCausality( error, MojoFailureException.class ); StringBuffer message = new StringBuffer(); Object source = mfe.getSource(); if ( source != null ) { message.append( ": " ).append( mfe.getSource() ).append( "\n" ); } String shortMessage = mfe.getMessage(); if ( shortMessage != null ) { message.append( shortMessage ); } String longMessage = mfe.getLongMessage(); // the indexOf bit is very strange, but the compiler output for 1.5 source compiled using JDK 1.4 presents this case! if ( longMessage != null && !longMessage.equals( shortMessage ) && shortMessage.indexOf( longMessage ) < 0 ) { message.append( "\n\n" ).append( longMessage ); } return message.toString(); } } maven2-core-2.2.1/maven-core/src/main/java/org/apache/maven/usability/plugin/0000755000175000017500000000000011250552241026676 5ustar twernertwerner././@LongLink0000000000000000000000000000014700000000000011567 Lustar rootrootmaven2-core-2.2.1/maven-core/src/main/java/org/apache/maven/usability/plugin/ExpressionDocumenter.javamaven2-core-2.2.1/maven-core/src/main/java/org/apache/maven/usability/plugin/ExpressionDocumenter.ja0000644000175000017500000001342611103153436033405 0ustar twernertwernerpackage org.apache.maven.usability.plugin; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import org.apache.maven.usability.plugin.io.xpp3.ParamdocXpp3Reader; import org.codehaus.plexus.util.IOUtil; import org.codehaus.plexus.util.ReaderFactory; import org.codehaus.plexus.util.xml.pull.XmlPullParserException; import java.io.BufferedReader; import java.io.File; import java.io.IOException; import java.io.InputStream; import java.io.Reader; import java.net.MalformedURLException; import java.net.URL; import java.net.URLClassLoader; import java.util.HashMap; import java.util.Iterator; import java.util.List; import java.util.Map; public class ExpressionDocumenter { private static final String[] EXPRESSION_ROOTS = { "project", "settings", "session", "plugin", "rootless" }; private static final String EXPRESSION_DOCO_ROOTPATH = "META-INF/maven/plugin-expressions/"; private static Map expressionDocumentation; public static Map load() throws ExpressionDocumentationException { if ( expressionDocumentation == null ) { expressionDocumentation = new HashMap(); ClassLoader docLoader = initializeDocLoader(); for ( int i = 0; i < EXPRESSION_ROOTS.length; i++ ) { InputStream docStream = null; try { docStream = docLoader .getResourceAsStream( EXPRESSION_DOCO_ROOTPATH + EXPRESSION_ROOTS[i] + ".paramdoc.xml" ); if ( docStream != null ) { Map doco = parseExpressionDocumentation( docStream ); expressionDocumentation.putAll( doco ); } } catch ( IOException e ) { throw new ExpressionDocumentationException( "Failed to read documentation for expression root: " + EXPRESSION_ROOTS[i], e ); } catch ( XmlPullParserException e ) { throw new ExpressionDocumentationException( "Failed to parse documentation for expression root: " + EXPRESSION_ROOTS[i], e ); } finally { IOUtil.close( docStream ); } } } return expressionDocumentation; } /** * * * project.distributionManagementArtifactRepository * * * some-repo * scp://host/path * * * some-snap-repo * scp://host/snapshot-path * * * ]]> * * * * @throws IOException * @throws XmlPullParserException */ private static Map parseExpressionDocumentation( InputStream docStream ) throws IOException, XmlPullParserException { Reader reader = new BufferedReader( ReaderFactory.newXmlReader( docStream ) ); ParamdocXpp3Reader paramdocReader = new ParamdocXpp3Reader(); ExpressionDocumentation documentation = paramdocReader.read( reader, true ); List expressions = documentation.getExpressions(); Map bySyntax = new HashMap(); if ( expressions != null && !expressions.isEmpty() ) { for ( Iterator it = expressions.iterator(); it.hasNext(); ) { Expression expr = (Expression) it.next(); bySyntax.put( expr.getSyntax(), expr ); } } return bySyntax; } private static ClassLoader initializeDocLoader() throws ExpressionDocumentationException { String myResourcePath = ExpressionDocumenter.class.getName().replace( '.', '/' ) + ".class"; URL myResource = ExpressionDocumenter.class.getClassLoader().getResource( myResourcePath ); String myClasspathEntry = myResource.getPath(); myClasspathEntry = myClasspathEntry.substring( 0, myClasspathEntry.length() - ( myResourcePath.length() + 2 ) ); if ( myClasspathEntry.startsWith( "file:" ) ) { myClasspathEntry = myClasspathEntry.substring( "file:".length() ); } URL docResource; try { docResource = new File( myClasspathEntry ).toURL(); } catch ( MalformedURLException e ) { throw new ExpressionDocumentationException( "Cannot construct expression documentation classpath resource base.", e ); } return new URLClassLoader( new URL[] { docResource } ); } } ././@LongLink0000000000000000000000000000016300000000000011565 Lustar rootrootmaven2-core-2.2.1/maven-core/src/main/java/org/apache/maven/usability/plugin/ExpressionDocumentationException.javamaven2-core-2.2.1/maven-core/src/main/java/org/apache/maven/usability/plugin/ExpressionDocumentation0000644000175000017500000000225311103153436033514 0ustar twernertwernerpackage org.apache.maven.usability.plugin; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ public class ExpressionDocumentationException extends Exception { static final long serialVersionUID = 1; public ExpressionDocumentationException( String message, Throwable cause ) { super( message, cause ); } public ExpressionDocumentationException( String message ) { super( message ); } } ././@LongLink0000000000000000000000000000014500000000000011565 Lustar rootrootmaven2-core-2.2.1/maven-core/src/main/java/org/apache/maven/usability/ArtifactNotFoundDiagnoser.javamaven2-core-2.2.1/maven-core/src/main/java/org/apache/maven/usability/ArtifactNotFoundDiagnoser.java0000644000175000017500000000430010772004567033321 0ustar twernertwernerpackage org.apache.maven.usability; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import org.apache.maven.artifact.manager.WagonManager; import org.apache.maven.artifact.resolver.ArtifactNotFoundException; import org.apache.maven.usability.diagnostics.DiagnosisUtils; import org.apache.maven.usability.diagnostics.ErrorDiagnoser; public class ArtifactNotFoundDiagnoser implements ErrorDiagnoser { private WagonManager wagonManager; public boolean canDiagnose( Throwable error ) { return DiagnosisUtils.containsInCausality( error, ArtifactNotFoundException.class ); } public String diagnose( Throwable error ) { ArtifactNotFoundException exception = (ArtifactNotFoundException) DiagnosisUtils.getFromCausality( error, ArtifactNotFoundException.class ); StringBuffer message = new StringBuffer(); message.append( "Failed to resolve artifact.\n" ); message.append( "\nGroupId: " ).append( exception.getGroupId() ); message.append( "\nArtifactId: " ).append( exception.getArtifactId() ); message.append( "\nVersion: " ).append( exception.getVersion() ); message.append( "\n\n" ); message.append( "Reason: " ).append( exception.getMessage() ); if ( !wagonManager.isOnline() ) { message.append( "\n" ).append( SystemWarnings.getOfflineWarning() ); } message.append( "\n" ); return message.toString(); } } maven2-core-2.2.1/maven-core/src/main/java/org/apache/maven/plugin/0000755000175000017500000000000011250552240024670 5ustar twernertwerner././@LongLink0000000000000000000000000000014500000000000011565 Lustar rootrootmaven2-core-2.2.1/maven-core/src/main/java/org/apache/maven/plugin/PluginConfigurationException.javamaven2-core-2.2.1/maven-core/src/main/java/org/apache/maven/plugin/PluginConfigurationException.java0000644000175000017500000002322010551365651033412 0ustar twernertwernerpackage org.apache.maven.plugin; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import org.apache.maven.plugin.descriptor.PluginDescriptor; import org.apache.maven.usability.plugin.Expression; import org.apache.maven.usability.plugin.ExpressionDocumentationException; import org.apache.maven.usability.plugin.ExpressionDocumenter; import org.codehaus.plexus.component.configurator.ComponentConfigurationException; import org.codehaus.plexus.configuration.PlexusConfiguration; import java.io.PrintWriter; import java.io.StringWriter; import java.util.Arrays; import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.Properties; import java.util.StringTokenizer; import java.util.regex.Matcher; import java.util.regex.Pattern; /** * @author Jason van Zyl * @version $Id: PluginConfigurationException.java 495147 2007-01-11 07:47:53Z jvanzyl $ */ public class PluginConfigurationException extends Exception { private final PluginDescriptor pluginDescriptor; private String originalMessage; private static final List UNMODIFIABLE_EXPRESSIONS = Arrays.asList( new String[]{"localRepository", "reactorProjects", "settings", "project", "session", "plugin", "basedir"} ); public PluginConfigurationException( PluginDescriptor pluginDescriptor, String message ) { super( "Error configuring: " + pluginDescriptor.getPluginLookupKey() + ". Reason: " + message ); this.pluginDescriptor = pluginDescriptor; this.originalMessage = message; } public PluginConfigurationException( PluginDescriptor pluginDescriptor, Throwable cause ) { super( "Error configuring: " + pluginDescriptor.getPluginLookupKey() + ".", cause ); this.pluginDescriptor = pluginDescriptor; } public PluginConfigurationException( PluginDescriptor pluginDescriptor, String message, Throwable cause ) { super( "Error configuring: " + pluginDescriptor.getPluginLookupKey() + ". Reason: " + message, cause ); this.pluginDescriptor = pluginDescriptor; this.originalMessage = message; } public PluginDescriptor getPluginDescriptor() { return pluginDescriptor; } public String getOriginalMessage() { return originalMessage; } protected static void addParameterUsageInfo( String expression, StringBuffer messageBuffer ) { StringBuffer expressionMessageBuffer = new StringBuffer(); Matcher exprMatcher = Pattern.compile( "\\$\\{(.+)\\}" ).matcher( expression ); boolean unmodifiableElementsFound = false; boolean activeElementsFound = false; int elementCount = 0; while ( exprMatcher.find() ) { elementCount++; activeElementsFound = true; String subExpression = exprMatcher.group( 1 ); StringTokenizer expressionParts = new StringTokenizer( subExpression, "." ); String firstPart = expressionParts.nextToken(); Map expressions = null; try { expressions = ExpressionDocumenter.load(); } catch ( ExpressionDocumentationException e ) { expressionMessageBuffer.append( "\n\nERROR!! Failed to load expression documentation!" ); StringWriter sWriter = new StringWriter(); PrintWriter pWriter = new PrintWriter( sWriter ); e.printStackTrace( pWriter ); expressionMessageBuffer.append( "\n\nException:\n\n" ).append( sWriter.toString() ); } if ( expressions != null ) { Expression expr = (Expression) expressions.get( subExpression ); if ( expr != null ) { if ( !expr.isEditable() ) { unmodifiableElementsFound = true; } else { addParameterConfigDocumentation( firstPart, exprMatcher.group( 0 ), subExpression, expressionMessageBuffer, expressions ); } } else if ( UNMODIFIABLE_EXPRESSIONS.contains( subExpression ) ) { unmodifiableElementsFound = true; } else { expressionMessageBuffer.append( "on the command line, specify: \'-D" ).append( subExpression ) .append( "=VALUE\'" ); } } } if ( activeElementsFound ) { messageBuffer.append( expressionMessageBuffer ); } else { messageBuffer.append( " (found static expression: \'" + expression + "\' which may act as a default value).\n" ); } if ( unmodifiableElementsFound ) { if ( elementCount > 1 ) { messageBuffer.append( " " ); } messageBuffer .append( "NOTE: One or more purely derived expression elements were detected in \'" + expression + "\'.\n If you continue to get this error after any other expression elements are specified correctly," + "\n please report this issue to the Maven development team.\n" ); } } private static void addParameterConfigDocumentation( String firstPart, String wholeExpression, String subExpression, StringBuffer expressionMessageBuffer, Map expressionDoco ) { Expression expr = (Expression) expressionDoco.get( subExpression ); if ( expr != null ) { expressionMessageBuffer.append( "check that the following section of " ); if ( "project".equals( firstPart ) ) { expressionMessageBuffer.append( "the pom.xml " ); } else if ( "settings".equals( firstPart ) ) { expressionMessageBuffer.append( "your ~/.m2/settings.xml file " ); } expressionMessageBuffer.append( "is present and correct:\n\n" ); String message = expr.getConfiguration(); if ( message == null ) { message = expr.getDescription(); } expressionMessageBuffer.append( message ); Properties cliConfig = expr.getCliOptions(); if ( cliConfig != null && !cliConfig.isEmpty() ) { expressionMessageBuffer.append( "\n\n-OR-\n\nUse the following command-line switches:\n" ); prettyPrintCommandLineSwitches( cliConfig, '.', expressionMessageBuffer ); } } else { expressionMessageBuffer.append( "ensure that the expression: \'" + wholeExpression + "\' is satisfied" ); } } private static void prettyPrintCommandLineSwitches( Properties switches, char filler, StringBuffer expressionMessageBuffer ) { int maxKeyLen = 0; for ( Iterator it = switches.entrySet().iterator(); it.hasNext(); ) { Map.Entry entry = (Map.Entry) it.next(); String key = (String) entry.getKey(); int keyLen = key.length(); if ( keyLen > maxKeyLen ) { maxKeyLen = keyLen; } } final int minFillerCount = 4; for ( Iterator it = switches.entrySet().iterator(); it.hasNext(); ) { Map.Entry entry = (Map.Entry) it.next(); String key = (String) entry.getKey(); int keyLen = key.length(); int fillerCount = maxKeyLen - keyLen + minFillerCount; expressionMessageBuffer.append( '\n' ).append( key ).append( ' ' ); for ( int i = 0; i < fillerCount; i++ ) { expressionMessageBuffer.append( filler ); } expressionMessageBuffer.append( ' ' ).append( entry.getValue() ); } expressionMessageBuffer.append( '\n' ); } public String buildConfigurationDiagnosticMessage( ComponentConfigurationException cce ) { StringBuffer message = new StringBuffer(); PluginDescriptor descriptor = getPluginDescriptor(); PlexusConfiguration failedConfiguration = cce.getFailedConfiguration(); message.append( "Failed to configure plugin parameters for: " + descriptor.getId() + "\n\n" ); if ( failedConfiguration != null ) { String value = failedConfiguration.getValue( null ); if ( value != null ) { addParameterUsageInfo( value, message ); } } message.append( "\n\nCause: " ).append( cce.getMessage() ); return message.toString(); } } maven2-core-2.2.1/maven-core/src/main/java/org/apache/maven/plugin/MavenPluginDiscoverer.java0000644000175000017500000000364410551365651032030 0ustar twernertwernerpackage org.apache.maven.plugin; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import org.apache.maven.plugin.descriptor.PluginDescriptorBuilder; import org.codehaus.plexus.component.discovery.AbstractComponentDiscoverer; import org.codehaus.plexus.component.repository.ComponentSetDescriptor; import org.codehaus.plexus.configuration.PlexusConfigurationException; import java.io.Reader; /** * @author Jason van Zyl * @author Trygve Laugstøl * @version $Id: MavenPluginDiscoverer.java 495147 2007-01-11 07:47:53Z jvanzyl $ */ public class MavenPluginDiscoverer extends AbstractComponentDiscoverer { private PluginDescriptorBuilder builder; public MavenPluginDiscoverer() { builder = new PluginDescriptorBuilder(); } public String getComponentDescriptorLocation() { return "META-INF/maven/plugin.xml"; } public ComponentSetDescriptor createComponentDescriptors( Reader componentDescriptorConfiguration, String source ) throws PlexusConfigurationException { return builder.build( componentDescriptorConfiguration, source ); } } maven2-core-2.2.1/maven-core/src/main/java/org/apache/maven/plugin/DebugConfigurationListener.java0000644000175000017500000000543511112343763033033 0ustar twernertwernerpackage org.apache.maven.plugin; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import java.lang.reflect.Array; import org.codehaus.plexus.component.configurator.ConfigurationListener; import org.codehaus.plexus.logging.Logger; /** * Log at debug level the mojo configuration. * * @author Brett Porter * @version $Id: DebugConfigurationListener.java 720043 2008-11-23 21:15:31Z bentmann $ */ public class DebugConfigurationListener implements ConfigurationListener { private Logger logger; public DebugConfigurationListener( Logger logger ) { this.logger = logger; } public void notifyFieldChangeUsingSetter( String fieldName, Object value, Object target ) { if ( logger.isDebugEnabled() ) { logger.debug( " (s) " + fieldName + " = " + toString( value ) ); } } public void notifyFieldChangeUsingReflection( String fieldName, Object value, Object target ) { if ( logger.isDebugEnabled() ) { logger.debug( " (f) " + fieldName + " = " + toString( value ) ); } } /** * Creates a human-friendly string represenation of the specified object. * * @param obj The object to create a string representation for, may be null. * @return The string representation, never null. */ private String toString( Object obj ) { String str; if ( obj != null && obj.getClass().isArray() ) { int n = Array.getLength( obj ); StringBuffer buf = new StringBuffer( 256 ); buf.append( '[' ); for ( int i = 0; i < n; i++ ) { if ( i > 0 ) { buf.append( ", " ); } buf.append( String.valueOf( Array.get( obj, i ) ) ); } buf.append( ']' ); str = buf.toString(); } else { str = String.valueOf( obj ); } return str; } } maven2-core-2.2.1/maven-core/src/main/java/org/apache/maven/plugin/PluginManagerException.java0000644000175000017500000000241511151272437032154 0ustar twernertwernerpackage org.apache.maven.plugin; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ /** * Exception in the plugin manager. * * @author Brett Porter * @version $Id: PluginManagerException.java 747855 2009-02-25 16:43:11Z jdcasey $ */ public class PluginManagerException extends Exception { public PluginManagerException( String message ) { super( message ); } public PluginManagerException( String message, Throwable e ) { super( message, e ); } } maven2-core-2.2.1/maven-core/src/main/java/org/apache/maven/plugin/PluginNotFoundException.java0000644000175000017500000000310210606222572032327 0ustar twernertwernerpackage org.apache.maven.plugin; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import org.apache.maven.artifact.resolver.AbstractArtifactResolutionException; import org.apache.maven.artifact.resolver.ArtifactNotFoundException; /** * Exception occurring trying to resolve a plugin. * * @author Brett Porter * @version $Id: PluginNotFoundException.java 526578 2007-04-08 17:25:14Z brianf $ */ public class PluginNotFoundException extends AbstractArtifactResolutionException { public PluginNotFoundException( ArtifactNotFoundException e ) { super( "Plugin could not be found - check that the goal name is correct: " + e.getMessage(), e.getGroupId(), e.getArtifactId(), e.getVersion(), "maven-plugin",null, e.getRemoteRepositories(), null, e.getCause() ); } } maven2-core-2.2.1/maven-core/src/main/java/org/apache/maven/plugin/PluginParameterException.java0000644000175000017500000000776110772004567032540 0ustar twernertwernerpackage org.apache.maven.plugin; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import org.apache.maven.plugin.descriptor.MojoDescriptor; import org.apache.maven.plugin.descriptor.Parameter; import org.codehaus.plexus.util.StringUtils; import java.util.Iterator; import java.util.List; public class PluginParameterException extends PluginConfigurationException { private final List parameters; private final MojoDescriptor mojo; public PluginParameterException( MojoDescriptor mojo, List parameters ) { super( mojo.getPluginDescriptor(), "Invalid or missing parameters: " + parameters + " for mojo: " + mojo.getRoleHint() ); this.mojo = mojo; this.parameters = parameters; } public PluginParameterException( MojoDescriptor mojo, List parameters, Throwable cause ) { super( mojo.getPluginDescriptor(), "Invalid or missing parameters: " + parameters + " for mojo: " + mojo.getRoleHint(), cause ); this.mojo = mojo; this.parameters = parameters; } public MojoDescriptor getMojoDescriptor() { return mojo; } public List getParameters() { return parameters; } private static void decomposeParameterIntoUserInstructions( MojoDescriptor mojo, Parameter param, StringBuffer messageBuffer ) { String expression = param.getExpression(); if ( param.isEditable() ) { messageBuffer.append( "Inside the definition for plugin \'" + mojo.getPluginDescriptor().getArtifactId() + "\' specify the following:\n\n\n ...\n <" + param.getName() + ">VALUE\n" ); String alias = param.getAlias(); if ( StringUtils.isNotEmpty( alias ) && !alias.equals( param.getName() ) ) { messageBuffer.append( "\n\n-OR-\n\n\n ...\n <" + alias + ">VALUE\n\n" ); } } if ( StringUtils.isEmpty( expression ) ) { messageBuffer.append( "." ); } else { if ( param.isEditable() ) { messageBuffer.append( "\n\n-OR-\n\n" ); } addParameterUsageInfo( expression, messageBuffer ); } } public String buildDiagnosticMessage() { StringBuffer messageBuffer = new StringBuffer(); List params = getParameters(); MojoDescriptor mojo = getMojoDescriptor(); messageBuffer.append( "One or more required plugin parameters are invalid/missing for \'" ) .append( mojo.getPluginDescriptor().getGoalPrefix() ).append( ":" ).append( mojo.getGoal() ) .append( "\'\n" ); int idx = 0; for ( Iterator it = params.iterator(); it.hasNext(); idx++ ) { Parameter param = (Parameter) it.next(); messageBuffer.append( "\n[" ).append( idx ).append( "] " ); decomposeParameterIntoUserInstructions( mojo, param, messageBuffer ); messageBuffer.append( "\n" ); } return messageBuffer.toString(); } } maven2-core-2.2.1/maven-core/src/main/java/org/apache/maven/plugin/PluginUtils.java0000644000175000017500000000604511145545252030027 0ustar twernertwernerpackage org.apache.maven.plugin; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import org.apache.maven.artifact.ArtifactUtils; import org.apache.maven.model.Plugin; import org.apache.maven.plugin.descriptor.PluginDescriptor; import org.codehaus.plexus.util.StringUtils; /** * Provides utility methods for plugin management. * * @author Benjamin Bentmann */ class PluginUtils { /** * Creates a lookup key for the specified plugin. * * @param plugin The plugin, must not be null. * @return The lookup key for the plugin in the form groupId:artifactId:baseVersion, never null. */ public static String constructVersionedKey( Plugin plugin ) { return constructVersionedKey( plugin.getGroupId(), plugin.getArtifactId(), plugin.getVersion() ); } /** * Creates a lookup key for the specified plugin. * * @param plugin The plugin's descriptor, must not be null. * @return The lookup key for the plugin in the form groupId:artifactId:baseVersion, never null. */ public static String constructVersionedKey( PluginDescriptor plugin ) { return constructVersionedKey( plugin.getGroupId(), plugin.getArtifactId(), plugin.getVersion() ); } /** * Creates a lookup key from the specified plugin coordinates. * * @param groupId The group id of the plugin, must not be null or empty. * @param artifactId The artifact id of the plugin, must not be null or empty. * @param version The (possibly) timestamped version of the plugin, must not be null or empty. * @return The lookup key for the plugin in the form groupId:artifactId:baseVersion, never null. */ private static String constructVersionedKey( String groupId, String artifactId, String version ) { if ( StringUtils.isEmpty( version ) ) { throw new IllegalStateException( "version for plugin " + groupId + ":" + artifactId + " is not set" ); } String baseVersion = ArtifactUtils.toSnapshotVersion( version ); StringBuffer key = new StringBuffer( 128 ); key.append( groupId ).append( ':' ).append( artifactId ).append( ':' ).append( baseVersion ); return key.toString(); } } maven2-core-2.2.1/maven-core/src/main/java/org/apache/maven/plugin/MojoExecution.java0000644000175000017500000000644211221205616030331 0ustar twernertwernerpackage org.apache.maven.plugin; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import org.apache.maven.plugin.descriptor.MojoDescriptor; import org.codehaus.plexus.util.xml.Xpp3Dom; import java.util.ArrayList; import java.util.List; /** * Describes a single mojo invocation. * * @author Brett Porter * @version $Id: MojoExecution.java 788791 2009-06-26 17:55:26Z jdcasey $ */ public class MojoExecution { public static final String DEFAULT_EXEC_ID_PREFIX = "default-"; public static final String CLI_EXECUTION_ID = DEFAULT_EXEC_ID_PREFIX + "cli"; // Execution ID needs to default to "default" to allow configuration of that execution alongside // other executions. private final String executionId; private final MojoDescriptor mojoDescriptor; private Xpp3Dom configuration; private List forkedExecutions = new ArrayList(); private List reports; public MojoExecution( MojoDescriptor mojoDescriptor ) { this.mojoDescriptor = mojoDescriptor; this.configuration = null; this.executionId = DEFAULT_EXEC_ID_PREFIX + mojoDescriptor.getGoal(); } public MojoExecution( MojoDescriptor mojoDescriptor, String executionId ) { this.mojoDescriptor = mojoDescriptor; this.executionId = executionId; this.configuration = null; } public MojoExecution( MojoDescriptor mojoDescriptor, Xpp3Dom configuration ) { this.mojoDescriptor = mojoDescriptor; this.configuration = configuration; this.executionId = DEFAULT_EXEC_ID_PREFIX + mojoDescriptor.getGoal(); } public MojoExecution( MojoDescriptor mojoDescriptor, Xpp3Dom configuration, String executionId ) { this.mojoDescriptor = mojoDescriptor; this.configuration = configuration; this.executionId = executionId; } public String getExecutionId() { return executionId; } public MojoDescriptor getMojoDescriptor() { return mojoDescriptor; } public Xpp3Dom getConfiguration() { return configuration; } public void addMojoExecution( MojoExecution execution ) { forkedExecutions.add( execution ); } public void setReports( List reports ) { this.reports = reports; } public List getReports() { return reports; } public List getForkedExecutions() { return forkedExecutions; } public void setConfiguration( Xpp3Dom configuration ) { this.configuration = configuration; } } maven2-core-2.2.1/maven-core/src/main/java/org/apache/maven/plugin/InvalidPluginException.java0000644000175000017500000000230410551365651032171 0ustar twernertwernerpackage org.apache.maven.plugin; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ /** * Thrown when a plugin is not internally consistent. * * @author Brett Porter * @version $Id: InvalidPluginException.java 495147 2007-01-11 07:47:53Z jvanzyl $ */ public class InvalidPluginException extends Exception { public InvalidPluginException( String message, Exception e ) { super( message, e ); } } maven2-core-2.2.1/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginManager.java0000644000175000017500000021533211234666772031621 0ustar twernertwernerpackage org.apache.maven.plugin; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import static org.apache.maven.container.ContainerUtils.findChildComponentHints; import org.apache.maven.MavenArtifactFilterManager; import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.factory.ArtifactFactory; import org.apache.maven.artifact.metadata.ArtifactMetadataRetrievalException; import org.apache.maven.artifact.metadata.ArtifactMetadataSource; import org.apache.maven.artifact.metadata.ResolutionGroup; import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.artifact.resolver.ArtifactNotFoundException; import org.apache.maven.artifact.resolver.ArtifactResolutionException; import org.apache.maven.artifact.resolver.ArtifactResolutionResult; import org.apache.maven.artifact.resolver.ArtifactResolver; import org.apache.maven.artifact.resolver.MultipleArtifactsNotFoundException; import org.apache.maven.artifact.resolver.filter.ArtifactFilter; import org.apache.maven.artifact.resolver.filter.ScopeArtifactFilter; import org.apache.maven.artifact.versioning.DefaultArtifactVersion; import org.apache.maven.artifact.versioning.InvalidVersionSpecificationException; import org.apache.maven.artifact.versioning.VersionRange; import org.apache.maven.execution.MavenSession; import org.apache.maven.execution.RuntimeInformation; import org.apache.maven.model.Plugin; import org.apache.maven.model.ReportPlugin; import org.apache.maven.monitor.event.EventDispatcher; import org.apache.maven.monitor.event.MavenEvents; import org.apache.maven.monitor.logging.DefaultLog; import org.apache.maven.plugin.descriptor.MojoDescriptor; import org.apache.maven.plugin.descriptor.Parameter; import org.apache.maven.plugin.descriptor.PluginDescriptor; import org.apache.maven.plugin.descriptor.PluginDescriptorBuilder; import org.apache.maven.plugin.logging.Log; import org.apache.maven.plugin.version.PluginVersionManager; import org.apache.maven.plugin.version.PluginVersionNotFoundException; import org.apache.maven.plugin.version.PluginVersionResolutionException; import org.apache.maven.project.MavenProject; import org.apache.maven.project.MavenProjectBuilder; import org.apache.maven.project.ProjectBuildingException; import org.apache.maven.project.artifact.InvalidDependencyVersionException; import org.apache.maven.project.artifact.MavenMetadataSource; import org.apache.maven.project.path.PathTranslator; import org.apache.maven.reporting.MavenReport; import org.apache.maven.settings.Settings; import org.apache.maven.wagon.Wagon; import org.codehaus.classworlds.ClassRealm; import org.codehaus.classworlds.NoSuchRealmException; import org.codehaus.plexus.PlexusConstants; import org.codehaus.plexus.PlexusContainer; import org.codehaus.plexus.PlexusContainerException; import org.codehaus.plexus.component.configurator.ComponentConfigurationException; import org.codehaus.plexus.component.configurator.ComponentConfigurator; import org.codehaus.plexus.component.configurator.ConfigurationListener; import org.codehaus.plexus.component.configurator.expression.ExpressionEvaluationException; import org.codehaus.plexus.component.configurator.expression.ExpressionEvaluator; import org.codehaus.plexus.component.discovery.ComponentDiscoveryListener; import org.codehaus.plexus.component.repository.ComponentDescriptor; import org.codehaus.plexus.component.repository.exception.ComponentLifecycleException; import org.codehaus.plexus.component.repository.exception.ComponentLookupException; import org.codehaus.plexus.configuration.PlexusConfiguration; import org.codehaus.plexus.configuration.xml.XmlPlexusConfiguration; import org.codehaus.plexus.context.Context; import org.codehaus.plexus.context.ContextException; import org.codehaus.plexus.logging.AbstractLogEnabled; import org.codehaus.plexus.personality.plexus.lifecycle.phase.Contextualizable; import org.codehaus.plexus.personality.plexus.lifecycle.phase.Initializable; import org.codehaus.plexus.util.StringUtils; import org.codehaus.plexus.util.xml.Xpp3Dom; import java.io.File; import java.net.URL; import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; import java.util.Collections; import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; import java.util.LinkedHashMap; import java.util.LinkedHashSet; import java.util.List; import java.util.Map; import java.util.Set; public class DefaultPluginManager extends AbstractLogEnabled implements PluginManager, Initializable, Contextualizable { protected PlexusContainer container; protected PluginDescriptorBuilder pluginDescriptorBuilder; protected ArtifactFilter artifactFilter; private Log mojoLogger; private Map resolvedCoreArtifactFiles = new HashMap(); // component requirements protected PathTranslator pathTranslator; protected MavenPluginCollector pluginCollector; protected PluginVersionManager pluginVersionManager; protected ArtifactFactory artifactFactory; protected ArtifactResolver artifactResolver; protected ArtifactMetadataSource artifactMetadataSource; protected RuntimeInformation runtimeInformation; protected MavenProjectBuilder mavenProjectBuilder; protected PluginMappingManager pluginMappingManager; // END component requirements public DefaultPluginManager() { pluginDescriptorBuilder = new PluginDescriptorBuilder(); } // ---------------------------------------------------------------------- // // ---------------------------------------------------------------------- public PluginDescriptor getPluginDescriptorForPrefix( String prefix ) { return pluginCollector.getPluginDescriptorForPrefix( prefix ); } public Plugin getPluginDefinitionForPrefix( String prefix, MavenSession session, MavenProject project ) { // TODO: since this is only used in the lifecycle executor, maybe it should be moved there? There is no other // use for the mapping manager in here return pluginMappingManager.getByPrefix( prefix, session.getSettings().getPluginGroups(), project.getPluginArtifactRepositories(), session.getLocalRepository() ); } /** * {@inheritDoc} */ public PluginDescriptor verifyPlugin( Plugin plugin, MavenProject project, Settings settings, ArtifactRepository localRepository ) throws ArtifactResolutionException, PluginVersionResolutionException, ArtifactNotFoundException, InvalidVersionSpecificationException, InvalidPluginException, PluginManagerException, PluginNotFoundException, PluginVersionNotFoundException { // TODO: this should be possibly outside // All version-resolution logic has been moved to DefaultPluginVersionManager. if ( plugin.getVersion() == null ) { String version = pluginVersionManager.resolvePluginVersion( plugin.getGroupId(), plugin.getArtifactId(), project, settings, localRepository ); plugin.setVersion( version ); } return verifyVersionedPlugin( plugin, project, localRepository ); } private PluginDescriptor verifyVersionedPlugin( Plugin plugin, MavenProject project, ArtifactRepository localRepository ) throws PluginVersionResolutionException, ArtifactNotFoundException, ArtifactResolutionException, InvalidVersionSpecificationException, InvalidPluginException, PluginManagerException, PluginNotFoundException { // TODO: this might result in an artifact "RELEASE" being resolved continuously // FIXME: need to find out how a plugin gets marked as 'installed' // and no ChildContainer exists. The check for that below fixes // the 'Can't find plexus container for plugin: xxx' error. try { VersionRange versionRange = VersionRange.createFromVersionSpec( plugin.getVersion() ); List remoteRepositories = new ArrayList(); remoteRepositories.addAll( project.getPluginArtifactRepositories() ); remoteRepositories.addAll( project.getRemoteArtifactRepositories() ); checkRequiredMavenVersion( plugin, localRepository, remoteRepositories ); Artifact pluginArtifact = artifactFactory.createPluginArtifact( plugin.getGroupId(), plugin.getArtifactId(), versionRange ); pluginArtifact = project.replaceWithActiveArtifact( pluginArtifact ); artifactResolver.resolve( pluginArtifact, project.getPluginArtifactRepositories(), localRepository ); plugin.setVersion( pluginArtifact.getBaseVersion() ); String pluginKey = PluginUtils.constructVersionedKey( plugin ); PlexusContainer pluginContainer = container.getChildContainer( pluginKey ); File pluginFile = pluginArtifact.getFile(); if ( !pluginCollector.isPluginInstalled( plugin ) || ( pluginContainer == null ) ) { addPlugin( plugin, pluginArtifact, project, localRepository ); } else if ( pluginFile.lastModified() > pluginContainer.getCreationDate().getTime() ) { getLogger().info( "Reloading plugin container for: " + pluginKey + ". The plugin artifact has changed." ); pluginContainer.dispose(); pluginCollector.flushPluginDescriptor( plugin ); addPlugin( plugin, pluginArtifact, project, localRepository ); } project.addPlugin( plugin ); } catch ( ArtifactNotFoundException e ) { String groupId = plugin.getGroupId(); String artifactId = plugin.getArtifactId(); String version = plugin.getVersion(); if ( ( groupId == null ) || ( artifactId == null ) || ( version == null ) ) { throw new PluginNotFoundException( e ); } else if ( groupId.equals( e.getGroupId() ) && artifactId.equals( e.getArtifactId() ) && version.equals( e.getVersion() ) && "maven-plugin".equals( e.getType() ) ) { throw new PluginNotFoundException( e ); } else { throw e; } } return pluginCollector.getPluginDescriptor( plugin ); } /** * @todo would be better to store this in the plugin descriptor, but then it won't be available to the version * manager which executes before the plugin is instantiated */ private void checkRequiredMavenVersion( Plugin plugin, ArtifactRepository localRepository, List remoteRepositories ) throws PluginVersionResolutionException, InvalidPluginException { try { Artifact artifact = artifactFactory.createProjectArtifact( plugin.getGroupId(), plugin.getArtifactId(), plugin.getVersion() ); MavenProject project = mavenProjectBuilder.buildFromRepository( artifact, remoteRepositories, localRepository, false ); // if we don't have the required Maven version, then ignore an update if ( ( project.getPrerequisites() != null ) && ( project.getPrerequisites().getMaven() != null ) ) { DefaultArtifactVersion requiredVersion = new DefaultArtifactVersion( project.getPrerequisites().getMaven() ); if ( runtimeInformation.getApplicationVersion().compareTo( requiredVersion ) < 0 ) { throw new PluginVersionResolutionException( plugin.getGroupId(), plugin.getArtifactId(), "Plugin requires Maven version " + requiredVersion ); } } } catch ( ProjectBuildingException e ) { throw new InvalidPluginException( "Unable to build project for plugin '" + plugin.getKey() + "': " + e.getMessage(), e ); } } protected void addPlugin( Plugin plugin, Artifact pluginArtifact, MavenProject project, ArtifactRepository localRepository ) throws PluginManagerException, InvalidPluginException { PlexusContainer child; try { MavenPluginValidator validator = new MavenPluginValidator( pluginArtifact ); String key = PluginUtils.constructVersionedKey( plugin ).intern(); child = container.createChildContainer( key, Collections.singletonList( pluginArtifact.getFile() ), Collections.EMPTY_MAP, Arrays.asList( new ComponentDiscoveryListener[] { validator, pluginCollector } ) ); // remove listeners for efficiency since they are only needed for the initial stage and // should not be applied to the plugin's dependencies child.removeComponentDiscoveryListener( validator ); child.removeComponentDiscoveryListener( pluginCollector ); if ( validator.hasErrors() ) { String msg = "Plugin '" + key + "' has an invalid descriptor:"; int count = 1; for ( Iterator i = validator.getErrors().iterator(); i.hasNext(); ) { msg += "\n" + count + ") " + i.next(); count++; } throw new PluginManagerException( msg ); } try { child.getContainerRealm().importFrom( "plexus.core", "org.codehaus.plexus.util.xml.Xpp3Dom" ); child.getContainerRealm().importFrom( "plexus.core", "org.codehaus.plexus.util.xml.pull.XmlPullParser" ); child.getContainerRealm().importFrom( "plexus.core", "org.codehaus.plexus.util.xml.pull.XmlPullParserException" ); child.getContainerRealm().importFrom( "plexus.core", "org.codehaus.plexus.util.xml.pull.XmlSerializer" ); // MNG-2878 child.getContainerRealm().importFrom( "plexus.core", "/default-report.xml" ); } catch ( NoSuchRealmException e ) { // won't happen } } catch ( PlexusContainerException e ) { throw new PluginManagerException( "Failed to create plugin container for plugin '" + plugin + "': " + e.getMessage(), e ); } // this plugin's descriptor should have been discovered in the child creation, so we should be able to // circle around and set the artifacts and class realm PluginDescriptor addedPlugin = pluginCollector.getPluginDescriptor( plugin ); if ( addedPlugin == null ) { throw new IllegalStateException( "The plugin descriptor for the plugin " + plugin + " was not found." + " Please verify that the plugin JAR " + pluginArtifact.getFile() + " is intact." ); } addedPlugin.setClassRealm( child.getContainerRealm() ); // we're only setting the plugin's artifact itself as the artifact list, to allow it to be retrieved // later when the plugin is first invoked. Retrieving this artifact will in turn allow us to // transitively resolve its dependencies, and add them to the plugin container... addedPlugin.setArtifacts( Collections.singletonList( pluginArtifact ) ); addedPlugin.setPluginArtifact( pluginArtifact ); try { // the only Plugin instance which will have dependencies is the one specified in the project. // We need to look for a Plugin instance there, in case the instance we're using didn't come from // the project. Plugin projectPlugin = (Plugin) project.getBuild().getPluginsAsMap().get( plugin.getKey() ); if ( projectPlugin == null ) { projectPlugin = plugin; } Set artifacts = MavenMetadataSource.createArtifacts( artifactFactory, projectPlugin.getDependencies(), null, null, project ); // Set artifacts = // MavenMetadataSource.createArtifacts( artifactFactory, plugin.getDependencies(), null, null, project ); addedPlugin.setIntroducedDependencyArtifacts( artifacts ); } catch ( InvalidDependencyVersionException e ) { throw new InvalidPluginException( "Plugin '" + plugin + "' is invalid: " + e.getMessage(), e ); } } // ---------------------------------------------------------------------- // Mojo execution // ---------------------------------------------------------------------- public void executeMojo( MavenProject project, MojoExecution mojoExecution, MavenSession session ) throws ArtifactResolutionException, MojoExecutionException, MojoFailureException, ArtifactNotFoundException, InvalidDependencyVersionException, PluginManagerException, PluginConfigurationException { MojoDescriptor mojoDescriptor = mojoExecution.getMojoDescriptor(); // NOTE: I'm putting these checks in here, since this is the central point of access for // anything that wants to execute a mojo. if ( mojoDescriptor.isProjectRequired() && !session.isUsingPOMsFromFilesystem() ) { throw new MojoExecutionException( "Cannot execute mojo: " + mojoDescriptor.getGoal() + ". It requires a project with an existing pom.xml, but the build is not using one." ); } if ( mojoDescriptor.isOnlineRequired() && session.getSettings().isOffline() ) { // TODO: Should we error out, or simply warn and skip?? throw new MojoExecutionException( "Mojo: " + mojoDescriptor.getGoal() + " requires online mode for execution. Maven is currently offline." ); } if ( mojoDescriptor.isDependencyResolutionRequired() != null ) { Collection projects; if ( mojoDescriptor.isAggregator() ) { projects = session.getSortedProjects(); } else { projects = Collections.singleton( project ); } for ( Iterator i = projects.iterator(); i.hasNext(); ) { MavenProject p = (MavenProject) i.next(); resolveTransitiveDependencies( session, artifactResolver, mojoDescriptor.isDependencyResolutionRequired(), artifactFactory, p, mojoDescriptor.isAggregator() ); } downloadDependencies( project, session, artifactResolver ); } String goalName = mojoDescriptor.getFullGoalName(); Mojo plugin; PluginDescriptor pluginDescriptor = mojoDescriptor.getPluginDescriptor(); String goalId = mojoDescriptor.getGoal(); String groupId = pluginDescriptor.getGroupId(); String artifactId = pluginDescriptor.getArtifactId(); String executionId = mojoExecution.getExecutionId(); Xpp3Dom dom = project.getGoalConfiguration( groupId, artifactId, executionId, goalId ); Xpp3Dom reportDom = project.getReportConfiguration( groupId, artifactId, executionId ); dom = Xpp3Dom.mergeXpp3Dom( dom, reportDom ); if ( mojoExecution.getConfiguration() != null ) { dom = Xpp3Dom.mergeXpp3Dom( dom, mojoExecution.getConfiguration() ); } plugin = getConfiguredMojo( session, dom, project, false, mojoExecution ); // Event monitoring. String event = MavenEvents.MOJO_EXECUTION; EventDispatcher dispatcher = session.getEventDispatcher(); String goalExecId = goalName; if ( mojoExecution.getExecutionId() != null ) { goalExecId += " {execution: " + mojoExecution.getExecutionId() + "}"; } dispatcher.dispatchStart( event, goalExecId ); ClassLoader oldClassLoader = Thread.currentThread().getContextClassLoader(); try { Thread.currentThread().setContextClassLoader( mojoDescriptor.getPluginDescriptor().getClassRealm().getClassLoader() ); plugin.execute(); dispatcher.dispatchEnd( event, goalExecId ); } catch ( MojoExecutionException e ) { session.getEventDispatcher().dispatchError( event, goalExecId, e ); throw e; } catch ( MojoFailureException e ) { session.getEventDispatcher().dispatchError( event, goalExecId, e ); throw e; } catch ( LinkageError e ) { if ( getLogger().isFatalErrorEnabled() ) { getLogger().fatalError( plugin.getClass().getName() + "#execute() caused a linkage error (" + e.getClass().getName() + ") and may be out-of-date. Check the realms:" ); ClassRealm pluginRealm = mojoDescriptor.getPluginDescriptor().getClassRealm(); StringBuffer sb = new StringBuffer(); sb.append( "Plugin realm = " + pluginRealm.getId() ).append( '\n' ); for ( int i = 0; i < pluginRealm.getConstituents().length; i++ ) { sb.append( "urls[" + i + "] = " + pluginRealm.getConstituents()[i] ); if ( i != ( pluginRealm.getConstituents().length - 1 ) ) { sb.append( '\n' ); } } getLogger().fatalError( sb.toString() ); ClassRealm containerRealm = container.getContainerRealm(); sb = new StringBuffer(); sb.append( "Container realm = " + containerRealm.getId() ).append( '\n' ); for ( int i = 0; i < containerRealm.getConstituents().length; i++ ) { sb.append( "urls[" + i + "] = " + containerRealm.getConstituents()[i] ); if ( i != ( containerRealm.getConstituents().length - 1 ) ) { sb.append( '\n' ); } } getLogger().fatalError( sb.toString() ); } session.getEventDispatcher().dispatchError( event, goalExecId, e ); throw e; } finally { Thread.currentThread().setContextClassLoader( oldClassLoader ); try { PlexusContainer pluginContainer = getPluginContainer( mojoDescriptor.getPluginDescriptor() ); pluginContainer.release( plugin ); } catch ( ComponentLifecycleException e ) { if ( getLogger().isErrorEnabled() ) { getLogger().error( "Error releasing plugin - ignoring.", e ); } } } } public MavenReport getReport( MavenProject project, MojoExecution mojoExecution, MavenSession session ) throws ArtifactNotFoundException, PluginConfigurationException, PluginManagerException, ArtifactResolutionException { MojoDescriptor mojoDescriptor = mojoExecution.getMojoDescriptor(); PluginDescriptor descriptor = mojoDescriptor.getPluginDescriptor(); Xpp3Dom dom = project.getReportConfiguration( descriptor.getGroupId(), descriptor.getArtifactId(), mojoExecution.getExecutionId() ); if ( mojoExecution.getConfiguration() != null ) { dom = Xpp3Dom.mergeXpp3Dom( dom, mojoExecution.getConfiguration() ); } MavenReport report = (MavenReport) getConfiguredMojo( session, dom, project, true, mojoExecution ); return report; } public PluginDescriptor verifyReportPlugin( ReportPlugin reportPlugin, MavenProject project, MavenSession session ) throws PluginVersionResolutionException, ArtifactResolutionException, ArtifactNotFoundException, InvalidVersionSpecificationException, InvalidPluginException, PluginManagerException, PluginNotFoundException, PluginVersionNotFoundException { String version = reportPlugin.getVersion(); if ( version == null ) { version = pluginVersionManager.resolveReportPluginVersion( reportPlugin.getGroupId(), reportPlugin.getArtifactId(), project, session.getSettings(), session.getLocalRepository() ); reportPlugin.setVersion( version ); } Plugin forLookup = new Plugin(); forLookup.setGroupId( reportPlugin.getGroupId() ); forLookup.setArtifactId( reportPlugin.getArtifactId() ); forLookup.setVersion( version ); return verifyVersionedPlugin( forLookup, project, session.getLocalRepository() ); } private PlexusContainer getPluginContainer( PluginDescriptor pluginDescriptor ) throws PluginManagerException { String pluginKey = PluginUtils.constructVersionedKey( pluginDescriptor ); PlexusContainer pluginContainer = container.getChildContainer( pluginKey ); if ( pluginContainer == null ) { throw new PluginManagerException( "Cannot find Plexus container for plugin: " + pluginKey ); } return pluginContainer; } private Mojo getConfiguredMojo( MavenSession session, Xpp3Dom dom, MavenProject project, boolean report, MojoExecution mojoExecution ) throws PluginConfigurationException, ArtifactNotFoundException, PluginManagerException, ArtifactResolutionException { MojoDescriptor mojoDescriptor = mojoExecution.getMojoDescriptor(); PluginDescriptor pluginDescriptor = mojoDescriptor.getPluginDescriptor(); PlexusContainer pluginContainer = getPluginContainer( pluginDescriptor ); // if this is the first time this plugin has been used, the plugin's container will only // contain the plugin's artifact in isolation; we need to finish resolving the plugin's // dependencies, and add them to the container. ensurePluginContainerIsComplete( pluginDescriptor, pluginContainer, project, session ); Mojo plugin; try { plugin = (Mojo) pluginContainer.lookup( Mojo.ROLE, mojoDescriptor.getRoleHint() ); if ( report && !( plugin instanceof MavenReport ) ) { // TODO: the mojoDescriptor should actually capture this information so we don't get this far return null; } } catch ( ComponentLookupException e ) { Throwable cause = e.getCause(); while( cause != null && !(cause instanceof NoClassDefFoundError ) ) { cause = cause.getCause(); } if ( cause != null && ( cause instanceof NoClassDefFoundError ) ) { throw new PluginManagerException( "Unable to load the mojo '" + mojoDescriptor.getRoleHint() + "' in the plugin '" + pluginDescriptor.getPluginLookupKey() + "'. A required class is missing: " + cause.getMessage(), e ); } throw new PluginManagerException( "Unable to find the mojo '" + mojoDescriptor.getGoal() + "' (or one of its required components) in the plugin '" + pluginDescriptor.getPluginLookupKey() + "'", e ); } catch ( NoClassDefFoundError e ) { throw new PluginManagerException( "Unable to load the mojo '" + mojoDescriptor.getRoleHint() + "' in the plugin '" + pluginDescriptor.getPluginLookupKey() + "'. A required class is missing: " + e.getMessage(), e ); } if ( plugin instanceof ContextEnabled ) { Map pluginContext = session.getPluginContext( pluginDescriptor, project ); ( (ContextEnabled) plugin ).setPluginContext( pluginContext ); } plugin.setLog( mojoLogger ); XmlPlexusConfiguration pomConfiguration; if ( dom == null ) { pomConfiguration = new XmlPlexusConfiguration( "configuration" ); } else { pomConfiguration = new XmlPlexusConfiguration( dom ); } // Validate against non-editable (@readonly) parameters, to make sure users aren't trying to // override in the POM. validatePomConfiguration( mojoDescriptor, pomConfiguration ); PlexusConfiguration mergedConfiguration = mergeMojoConfiguration( pomConfiguration, mojoDescriptor ); // TODO: plexus changes to make this more like the component descriptor so this can be used instead // PlexusConfiguration mergedConfiguration = mergeConfiguration( pomConfiguration, // mojoDescriptor.getConfiguration() ); ExpressionEvaluator expressionEvaluator = new PluginParameterExpressionEvaluator( session, mojoExecution, pathTranslator, getLogger(), project, session.getExecutionProperties() ); PlexusConfiguration extractedMojoConfiguration = extractMojoConfiguration( mergedConfiguration, mojoDescriptor ); checkRequiredParameters( mojoDescriptor, extractedMojoConfiguration, expressionEvaluator ); populatePluginFields( plugin, mojoDescriptor, extractedMojoConfiguration, pluginContainer, expressionEvaluator ); return plugin; } private void ensurePluginContainerIsComplete( PluginDescriptor pluginDescriptor, PlexusContainer pluginContainer, MavenProject project, MavenSession session ) throws ArtifactNotFoundException, PluginManagerException, ArtifactResolutionException { // if the plugin's already been used once, don't re-do this step... // otherwise, we have to finish resolving the plugin's classpath and start the container. if ( ( pluginDescriptor.getArtifacts() != null ) && ( pluginDescriptor.getArtifacts().size() == 1 ) ) { Artifact pluginArtifact = (Artifact) pluginDescriptor.getArtifacts().get( 0 ); ArtifactRepository localRepository = session.getLocalRepository(); ResolutionGroup resolutionGroup; try { resolutionGroup = artifactMetadataSource.retrieve( pluginArtifact, localRepository, project.getPluginArtifactRepositories() ); } catch ( ArtifactMetadataRetrievalException e ) { throw new ArtifactResolutionException( "Unable to download metadata from repository for plugin '" + pluginArtifact.getId() + "': " + e.getMessage(), pluginArtifact, e ); } Set rgArtifacts = resolutionGroup.getArtifacts(); rgArtifacts = checkPlexusUtils( rgArtifacts, artifactFactory ); // [jdcasey; 20-March-2008]: // This is meant to eliminate the introduction of duplicated artifacts. // Since much of the reasoning for reversing the order of introduction of // plugin dependencies rests on the notion that we need to be able to // introduce upgraded versions of plugin dependencies on a case-by-case // basis, we need to remove the original version prior to artifact // resolution. This is consistent with recent thinking on duplicated // dependency specifications within a POM, where that case should // throw a model validation exception. // // Here, we just want to remove any chance that the ArtifactCollector // could make a bad choice, and use the old version in spite of our // explicit preference otherwise. // First, we're going to accumulate plugin dependencies in an ordered map, // keyed by dependencyConflictId (the ordered map is meant to preserve relative // ordering of the dependencies that do make the cut). Map dependencyMap = new LinkedHashMap(); // Next, we need to accumulate all dependencies in a List, to make it // simpler to iterate through them all and add them to the map. List all = new ArrayList(); // plugin-level dependencies from the consuming POM override dependencies // from the plugin's own POM. all.addAll( pluginDescriptor.getIntroducedDependencyArtifacts() ); // add in the deps from the plugin POM now. all.addAll( rgArtifacts ); for ( Iterator it = all.iterator(); it.hasNext(); ) { Artifact artifact = (Artifact) it.next(); String conflictId = artifact.getDependencyConflictId(); // if the map already contains this dependencyConflictId, it constitutes an // overridden dependency. Don't use the old one (we know it's old from the // order in which dependencies were added to this list). if ( !dependencyMap.containsKey( conflictId ) ) { dependencyMap.put( conflictId, artifact ); } } // Create an ordered set of dependencies from the ordered map we used above, to feed into the resolver. Set dependencies = new LinkedHashSet( dependencyMap.values() ); if ( getLogger().isDebugEnabled() ) { // list all dependencies to be used by this plugin (first-level deps, not transitive ones). getLogger().debug( "Plugin dependencies for:\n\n" + pluginDescriptor.getId() + "\n\nare:\n\n" + StringUtils.join( dependencies.iterator(), "\n" ) + "\n\n" ); } List repositories = new ArrayList(); repositories.addAll( resolutionGroup.getResolutionRepositories() ); repositories.addAll( project.getRemoteArtifactRepositories() ); /* get plugin managed versions */ Map pluginManagedDependencies = new HashMap(); try { MavenProject pluginProject = mavenProjectBuilder.buildFromRepository( pluginArtifact, project.getRemoteArtifactRepositories(), localRepository ); if ( pluginProject != null ) { pluginManagedDependencies = pluginProject.getManagedVersionMap(); } } catch ( ProjectBuildingException e ) { // this can't happen, it would have blowed up at artifactMetadataSource.retrieve() } ArtifactResolutionResult result = artifactResolver.resolveTransitively( dependencies, pluginArtifact, pluginManagedDependencies, localRepository, repositories, artifactMetadataSource, artifactFilter ); Set resolved = result.getArtifacts(); for ( Iterator it = resolved.iterator(); it.hasNext(); ) { Artifact artifact = (Artifact) it.next(); if ( !artifact.equals( pluginArtifact ) ) { artifact = project.replaceWithActiveArtifact( artifact ); try { pluginContainer.addJarResource( artifact.getFile() ); } catch ( PlexusContainerException e ) { throw new PluginManagerException( "Error adding plugin dependency '" + artifact.getDependencyConflictId() + "' into plugin manager: " + e.getMessage(), e ); } } } pluginDescriptor.setClassRealm( pluginContainer.getContainerRealm() ); List unresolved = new ArrayList( dependencies ); unresolved.removeAll( resolved ); if ( getLogger().isDebugEnabled() ) { // list all artifacts that were filtered out during the resolution process. // these are already present in the core container. getLogger().debug( " The following artifacts were filtered out for plugin: " + pluginDescriptor.getId() + " because they're already in the core of Maven:\n\n" + StringUtils.join( unresolved.iterator(), "\n" ) + "\n\nThese will use the artifact files already in the core ClassRealm instead, to allow them to be included in PluginDescriptor.getArtifacts().\n\n" ); } // Grab a file for all filtered artifacts, even if it means resolving them. This // is necessary in order to present a full complement of a plugin's transitive // dependencies to anyone who calls PluginDescriptor.getArtifacts(). resolveCoreArtifacts( unresolved, localRepository, resolutionGroup.getResolutionRepositories() ); // Re-join resolved and filtered-but-now-resolved artifacts. // NOTE: The process of filtering then re-adding some artifacts will // result in different ordering within the PluginDescriptor.getArtifacts() // List than should have happened if none had been filtered. All filtered // artifacts will be listed last... List allResolved = new ArrayList( resolved.size() + unresolved.size() ); allResolved.addAll( resolved ); allResolved.addAll( unresolved ); pluginDescriptor.setArtifacts( allResolved ); } } public static Set checkPlexusUtils( Set dependencyArtifacts, ArtifactFactory artifactFactory ) { // ---------------------------------------------------------------------------- // If the plugin already declares a dependency on plexus-utils then we're all // set as the plugin author is aware of its use. If we don't have a dependency // on plexus-utils then we must protect users from stupid plugin authors who // did not declare a direct dependency on plexus-utils because the version // Maven uses is hidden from downstream use. We will also bump up any // anything below 1.1 to 1.1 as this mimics the behaviour in 2.0.5 where // plexus-utils 1.1 was being forced into use. // ---------------------------------------------------------------------------- VersionRange vr = null; try { vr = VersionRange.createFromVersionSpec( "[1.1,)" ); } catch ( InvalidVersionSpecificationException e ) { // Won't happen } boolean plexusUtilsPresent = false; for ( Iterator i = dependencyArtifacts.iterator(); i.hasNext(); ) { Artifact a = (Artifact) i.next(); if ( a.getArtifactId().equals( "plexus-utils" ) && vr.containsVersion( new DefaultArtifactVersion( a.getVersion() ) ) ) { plexusUtilsPresent = true; break; } } if ( !plexusUtilsPresent ) { // We will add plexus-utils as every plugin was getting this anyway from Maven itself. We will set the // version to the latest version we know that works as of the 2.0.6 release. We set the scope to runtime // as this is what's implicitly happening in 2.0.6. Set result = new LinkedHashSet(); if ( !dependencyArtifacts.isEmpty() ) { result.addAll( dependencyArtifacts ); } result.add( artifactFactory.createArtifact( "org.codehaus.plexus", "plexus-utils", "1.1", Artifact.SCOPE_RUNTIME, "jar" ) ); return result; } else { return dependencyArtifacts; } } private void resolveCoreArtifacts( List unresolved, ArtifactRepository localRepository, List resolutionRepositories ) throws ArtifactResolutionException, ArtifactNotFoundException { for ( Iterator it = unresolved.iterator(); it.hasNext(); ) { Artifact artifact = (Artifact) it.next(); File artifactFile = (File) resolvedCoreArtifactFiles.get( artifact.getId() ); if ( artifactFile == null ) { String resource = "/META-INF/maven/" + artifact.getGroupId() + "/" + artifact.getArtifactId() + "/pom.xml"; URL resourceUrl = container.getContainerRealm().getResource( resource ); if ( resourceUrl == null ) { artifactResolver.resolve( artifact, resolutionRepositories, localRepository ); artifactFile = artifact.getFile(); } else { String artifactPath = resourceUrl.getPath(); if ( artifactPath.startsWith( "file:" ) ) { artifactPath = artifactPath.substring( "file:".length() ); } artifactPath = artifactPath.substring( 0, artifactPath.length() - resource.length() ); if ( artifactPath.endsWith( "/" ) ) { artifactPath = artifactPath.substring( 0, artifactPath.length() - 1 ); } if ( artifactPath.endsWith( "!" ) ) { artifactPath = artifactPath.substring( 0, artifactPath.length() - 1 ); } artifactFile = new File( artifactPath ).getAbsoluteFile(); } resolvedCoreArtifactFiles.put( artifact.getId(), artifactFile ); } artifact.setFile( artifactFile ); } } private PlexusConfiguration extractMojoConfiguration( PlexusConfiguration mergedConfiguration, MojoDescriptor mojoDescriptor ) { Map parameterMap = mojoDescriptor.getParameterMap(); PlexusConfiguration[] mergedChildren = mergedConfiguration.getChildren(); XmlPlexusConfiguration extractedConfiguration = new XmlPlexusConfiguration( "configuration" ); for ( int i = 0; i < mergedChildren.length; i++ ) { PlexusConfiguration child = mergedChildren[i]; if ( parameterMap.containsKey( child.getName() ) ) { extractedConfiguration.addChild( copyConfiguration( child ) ); } else { // TODO: I defy anyone to find these messages in the '-X' output! Do we need a new log level? // ideally, this would be elevated above the true debug output, but below the default INFO level... // [BP] (2004-07-18): need to understand the context more but would prefer this could be either WARN or // removed - shouldn't need DEBUG to diagnose a problem most of the time. getLogger().debug( "*** WARNING: Configuration \'" + child.getName() + "\' is not used in goal \'" + mojoDescriptor.getFullGoalName() + "; this may indicate a typo... ***" ); } } return extractedConfiguration; } private void checkRequiredParameters( MojoDescriptor goal, PlexusConfiguration configuration, ExpressionEvaluator expressionEvaluator ) throws PluginConfigurationException { // TODO: this should be built in to the configurator, as we presently double process the expressions List parameters = goal.getParameters(); if ( parameters == null ) { return; } List invalidParameters = new ArrayList(); for ( int i = 0; i < parameters.size(); i++ ) { Parameter parameter = (Parameter) parameters.get( i ); if ( parameter.isRequired() ) { // the key for the configuration map we're building. String key = parameter.getName(); Object fieldValue = null; String expression = null; PlexusConfiguration value = configuration.getChild( key, false ); try { if ( value != null ) { expression = value.getValue( null ); fieldValue = expressionEvaluator.evaluate( expression ); if ( fieldValue == null ) { fieldValue = value.getAttribute( "default-value", null ); } } if ( ( fieldValue == null ) && StringUtils.isNotEmpty( parameter.getAlias() ) ) { value = configuration.getChild( parameter.getAlias(), false ); if ( value != null ) { expression = value.getValue( null ); fieldValue = expressionEvaluator.evaluate( expression ); if ( fieldValue == null ) { fieldValue = value.getAttribute( "default-value", null ); } } } } catch ( ExpressionEvaluationException e ) { throw new PluginConfigurationException( goal.getPluginDescriptor(), e.getMessage(), e ); } // only mark as invalid if there are no child nodes if ( ( fieldValue == null ) && ( ( value == null ) || ( value.getChildCount() == 0 ) ) ) { parameter.setExpression( expression ); invalidParameters.add( parameter ); } } } if ( !invalidParameters.isEmpty() ) { throw new PluginParameterException( goal, invalidParameters ); } } private void validatePomConfiguration( MojoDescriptor goal, PlexusConfiguration pomConfiguration ) throws PluginConfigurationException { List parameters = goal.getParameters(); if ( parameters == null ) { return; } for ( int i = 0; i < parameters.size(); i++ ) { Parameter parameter = (Parameter) parameters.get( i ); // the key for the configuration map we're building. String key = parameter.getName(); PlexusConfiguration value = pomConfiguration.getChild( key, false ); if ( ( value == null ) && StringUtils.isNotEmpty( parameter.getAlias() ) ) { key = parameter.getAlias(); value = pomConfiguration.getChild( key, false ); } if ( value != null ) { // Make sure the parameter is either editable/configurable, or else is NOT specified in the POM if ( !parameter.isEditable() ) { StringBuffer errorMessage = new StringBuffer() .append( "ERROR: Cannot override read-only parameter: " ); errorMessage.append( key ); errorMessage.append( " in goal: " ).append( goal.getFullGoalName() ); throw new PluginConfigurationException( goal.getPluginDescriptor(), errorMessage.toString() ); } String deprecated = parameter.getDeprecated(); if ( StringUtils.isNotEmpty( deprecated ) ) { getLogger().warn( "DEPRECATED [" + parameter.getName() + "]: " + deprecated ); } } } } private PlexusConfiguration mergeMojoConfiguration( XmlPlexusConfiguration fromPom, MojoDescriptor mojoDescriptor ) { XmlPlexusConfiguration result = new XmlPlexusConfiguration( fromPom.getName() ); result.setValue( fromPom.getValue( null ) ); if ( mojoDescriptor.getParameters() != null ) { PlexusConfiguration fromMojo = mojoDescriptor.getMojoConfiguration(); for ( Iterator it = mojoDescriptor.getParameters().iterator(); it.hasNext(); ) { Parameter parameter = (Parameter) it.next(); String paramName = parameter.getName(); String alias = parameter.getAlias(); String implementation = parameter.getImplementation(); PlexusConfiguration pomConfig = fromPom.getChild( paramName ); PlexusConfiguration aliased = null; if ( alias != null ) { aliased = fromPom.getChild( alias ); } PlexusConfiguration mojoConfig = fromMojo.getChild( paramName, false ); // first we'll merge configurations from the aliased and real params. // TODO: Is this the right thing to do? if ( aliased != null ) { if ( pomConfig == null ) { pomConfig = new XmlPlexusConfiguration( paramName ); } pomConfig = buildTopDownMergedConfiguration( pomConfig, aliased ); } PlexusConfiguration toAdd = null; if ( pomConfig != null ) { pomConfig = buildTopDownMergedConfiguration( pomConfig, mojoConfig ); if ( StringUtils.isNotEmpty( pomConfig.getValue( null ) ) || ( pomConfig.getChildCount() > 0 ) ) { toAdd = pomConfig; } } if ( ( toAdd == null ) && ( mojoConfig != null ) ) { toAdd = copyConfiguration( mojoConfig ); } if ( toAdd != null ) { if ( ( implementation != null ) && ( toAdd.getAttribute( "implementation", null ) == null ) ) { XmlPlexusConfiguration implementationConf = new XmlPlexusConfiguration( paramName ); implementationConf.setAttribute( "implementation", parameter.getImplementation() ); toAdd = buildTopDownMergedConfiguration( toAdd, implementationConf ); } result.addChild( toAdd ); } } } return result; } private XmlPlexusConfiguration buildTopDownMergedConfiguration( PlexusConfiguration dominant, PlexusConfiguration recessive ) { XmlPlexusConfiguration result = new XmlPlexusConfiguration( dominant.getName() ); String value = dominant.getValue( null ); if ( StringUtils.isEmpty( value ) && ( recessive != null ) ) { value = recessive.getValue( null ); } if ( StringUtils.isNotEmpty( value ) ) { result.setValue( value ); } String[] attributeNames = dominant.getAttributeNames(); for ( int i = 0; i < attributeNames.length; i++ ) { String attributeValue = dominant.getAttribute( attributeNames[i], null ); result.setAttribute( attributeNames[i], attributeValue ); } if ( recessive != null ) { attributeNames = recessive.getAttributeNames(); for ( int i = 0; i < attributeNames.length; i++ ) { String attributeValue = recessive.getAttribute( attributeNames[i], null ); // TODO: recessive seems to be dominant here? result.setAttribute( attributeNames[i], attributeValue ); } } PlexusConfiguration[] children = dominant.getChildren(); for ( int i = 0; i < children.length; i++ ) { PlexusConfiguration childDom = children[i]; PlexusConfiguration childRec = recessive == null ? null : recessive.getChild( childDom.getName(), false ); if ( childRec != null ) { result.addChild( buildTopDownMergedConfiguration( childDom, childRec ) ); } else { // FIXME: copy, or use reference? result.addChild( copyConfiguration( childDom ) ); } } return result; } public static PlexusConfiguration copyConfiguration( PlexusConfiguration src ) { // TODO: shouldn't be necessary XmlPlexusConfiguration dom = new XmlPlexusConfiguration( src.getName() ); dom.setValue( src.getValue( null ) ); String[] attributeNames = src.getAttributeNames(); for ( int i = 0; i < attributeNames.length; i++ ) { String attributeName = attributeNames[i]; dom.setAttribute( attributeName, src.getAttribute( attributeName, null ) ); } PlexusConfiguration[] children = src.getChildren(); for ( int i = 0; i < children.length; i++ ) { dom.addChild( copyConfiguration( children[i] ) ); } return dom; } // ---------------------------------------------------------------------- // Mojo Parameter Handling // ---------------------------------------------------------------------- private void populatePluginFields( Mojo plugin, MojoDescriptor mojoDescriptor, PlexusConfiguration configuration, PlexusContainer pluginContainer, ExpressionEvaluator expressionEvaluator ) throws PluginConfigurationException { ComponentConfigurator configurator = null; try { String configuratorId = mojoDescriptor.getComponentConfigurator(); // TODO: could the configuration be passed to lookup and the configurator known to plexus via the descriptor // so that this meethod could entirely be handled by a plexus lookup? if ( StringUtils.isNotEmpty( configuratorId ) ) { configurator = (ComponentConfigurator) pluginContainer.lookup( ComponentConfigurator.ROLE, configuratorId ); } else { configurator = (ComponentConfigurator) pluginContainer.lookup( ComponentConfigurator.ROLE ); } ConfigurationListener listener = new DebugConfigurationListener( getLogger() ); getLogger().debug( "Configuring mojo '" + mojoDescriptor.getId() + "' -->" ); configurator.configureComponent( plugin, configuration, expressionEvaluator, pluginContainer.getContainerRealm(), listener ); getLogger().debug( "-- end configuration --" ); } catch ( ComponentConfigurationException e ) { throw new PluginConfigurationException( mojoDescriptor.getPluginDescriptor(), "Unable to parse the created DOM for plugin configuration", e ); } catch ( ComponentLookupException e ) { throw new PluginConfigurationException( mojoDescriptor.getPluginDescriptor(), "Unable to retrieve component configurator for plugin configuration", e ); } catch ( NoClassDefFoundError e ) { throw new PluginConfigurationException( mojoDescriptor.getPluginDescriptor(), "A required class was missing during mojo configuration: " + e.getMessage(), e ); } catch ( LinkageError e ) { if ( getLogger().isFatalErrorEnabled() ) { getLogger().fatalError( configurator.getClass().getName() + "#configureComponent(...) caused a linkage error (" + e.getClass().getName() + ") and may be out-of-date. Check the realms:" ); ClassRealm pluginRealm = mojoDescriptor.getPluginDescriptor().getClassRealm(); StringBuffer sb = new StringBuffer(); sb.append( "Plugin realm = " + pluginRealm.getId() ).append( '\n' ); for ( int i = 0; i < pluginRealm.getConstituents().length; i++ ) { sb.append( "urls[" + i + "] = " + pluginRealm.getConstituents()[i] ); if ( i != ( pluginRealm.getConstituents().length - 1 ) ) { sb.append( '\n' ); } } getLogger().fatalError( sb.toString() ); ClassRealm containerRealm = container.getContainerRealm(); sb = new StringBuffer(); sb.append( "Container realm = " + containerRealm.getId() ).append( '\n' ); for ( int i = 0; i < containerRealm.getConstituents().length; i++ ) { sb.append( "urls[" + i + "] = " + containerRealm.getConstituents()[i] ); if ( i != ( containerRealm.getConstituents().length - 1 ) ) { sb.append( '\n' ); } } getLogger().fatalError( sb.toString() ); } throw new PluginConfigurationException( mojoDescriptor.getPluginDescriptor(), e.getClass().getName() + ": " + e.getMessage(), e ); } finally { if ( configurator != null ) { try { pluginContainer.release( configurator ); } catch ( ComponentLifecycleException e ) { getLogger().debug( "Failed to release plugin container - ignoring." ); } } } } public static String createPluginParameterRequiredMessage( MojoDescriptor mojo, Parameter parameter, String expression ) { StringBuffer message = new StringBuffer(); message.append( "The '" ); message.append( parameter.getName() ); message.append( "' parameter is required for the execution of the " ); message.append( mojo.getFullGoalName() ); message.append( " mojo and cannot be null." ); if ( expression != null ) { message.append( " The retrieval expression was: " ).append( expression ); } return message.toString(); } // ---------------------------------------------------------------------- // Lifecycle // ---------------------------------------------------------------------- public void contextualize( Context context ) throws ContextException { container = (PlexusContainer) context.get( PlexusConstants.PLEXUS_KEY ); mojoLogger = new DefaultLog( container.getLoggerManager().getLoggerForComponent( Mojo.ROLE ) ); } public void initialize() { artifactFilter = MavenArtifactFilterManager.createStandardFilter(); } // ---------------------------------------------------------------------- // Artifact resolution // ---------------------------------------------------------------------- private void resolveTransitiveDependencies( MavenSession context, ArtifactResolver artifactResolver, String scope, ArtifactFactory artifactFactory, MavenProject project, boolean isAggregator ) throws ArtifactResolutionException, ArtifactNotFoundException, InvalidDependencyVersionException { ArtifactFilter filter = new ScopeArtifactFilter( scope ); // TODO: such a call in MavenMetadataSource too - packaging not really the intention of type Artifact artifact = artifactFactory.createBuildArtifact( project.getGroupId(), project.getArtifactId(), project.getVersion(), project.getPackaging() ); // TODO: we don't need to resolve over and over again, as long as we are sure that the parameters are the same // check this with yourkit as a hot spot. // Don't recreate if already created - for effeciency, and because clover plugin adds to it if ( project.getDependencyArtifacts() == null ) { project.setDependencyArtifacts( project.createArtifacts( artifactFactory, null, null ) ); } else { project.resolveActiveArtifacts(); } Set resolvedArtifacts; try { ArtifactResolutionResult result = artifactResolver.resolveTransitively( project.getDependencyArtifacts(), artifact, project.getManagedVersionMap(), context.getLocalRepository(), project.getRemoteArtifactRepositories(), artifactMetadataSource, filter ); resolvedArtifacts = result.getArtifacts(); } catch (MultipleArtifactsNotFoundException me) { /*only do this if we are an aggregating plugin: MNG-2277 if the dependency doesn't yet exist but is in the reactor, then all we can do is warn and skip it. A better fix can be inserted into 2.1*/ if (isAggregator && checkMissingArtifactsInReactor( context.getSortedProjects(), me.getMissingArtifacts() )) { resolvedArtifacts = new HashSet(me.getResolvedArtifacts()); } else { //we can't find all the artifacts in the reactor so bubble the exception up. throw me; } } project.setArtifacts( resolvedArtifacts ); } /** * This method is checking to see if the artifacts that can't be resolved are all * part of this reactor. This is done to prevent a chicken or egg scenario with * fresh projects that have a plugin that is an aggregator and requires dependencies. See * MNG-2277 for more info. * @param projects the sibling projects in the reactor * @param missing the artifacts that can't be found * @return true if ALL missing artifacts are found in the reactor. */ private boolean checkMissingArtifactsInReactor(Collection projects, Collection missing) { Collection foundInReactor = new HashSet(); Iterator iter = missing.iterator(); while (iter.hasNext()) { Artifact mArtifact = (Artifact) iter.next(); Iterator pIter = projects.iterator(); while (pIter.hasNext()) { MavenProject p = (MavenProject) pIter.next(); if (p.getArtifactId().equals( mArtifact.getArtifactId()) && p.getGroupId().equals( mArtifact.getGroupId()) && p.getVersion().equals( mArtifact.getVersion())) { //TODO: the packaging could be different, but the exception doesn't contain that info //most likely it would be produced by the project we just found in the reactor since all //the other info matches. Assume it's ok. getLogger().warn( "The dependency: "+ p.getId()+" can't be resolved but has been found in the reactor.\nThis dependency has been excluded from the plugin execution. You should rerun this mojo after executing mvn install.\n" ); //found it, move on. foundInReactor.add( p ); break; } } } //if all of them have been found, we can continue. return foundInReactor.size() == missing.size(); } // ---------------------------------------------------------------------- // Artifact downloading // ---------------------------------------------------------------------- private void downloadDependencies( MavenProject project, MavenSession context, ArtifactResolver artifactResolver ) throws ArtifactResolutionException, ArtifactNotFoundException { ArtifactRepository localRepository = context.getLocalRepository(); List remoteArtifactRepositories = project.getRemoteArtifactRepositories(); for ( Iterator it = project.getArtifacts().iterator(); it.hasNext(); ) { Artifact artifact = (Artifact) it.next(); artifactResolver.resolve( artifact, remoteArtifactRepositories, localRepository ); } } public Object getPluginComponent( Plugin plugin, String role, String roleHint ) throws PluginManagerException, ComponentLookupException { PluginDescriptor pluginDescriptor = pluginCollector.getPluginDescriptor( plugin ); PlexusContainer pluginContainer = getPluginContainer( pluginDescriptor ); return pluginContainer.lookup( role, roleHint ); } @SuppressWarnings( "unchecked" ) public Map getPluginComponents( Plugin plugin, String role ) throws ComponentLookupException, PluginManagerException { PluginDescriptor pluginDescriptor = pluginCollector.getPluginDescriptor( plugin ); PlexusContainer pluginContainer = getPluginContainer( pluginDescriptor ); Set pluginHints = findChildComponentHints( role, container, pluginContainer ); Map components = new HashMap( pluginHints.size() ); for ( String hint : pluginHints ) { getLogger().debug( "Looking up plugin component: " + role + " with hint: " + hint ); components.put( hint, pluginContainer.lookup( role, hint ) ); } return components; } /** * {@inheritDoc} */ public PluginDescriptor loadPluginFully( Plugin plugin, MavenProject project, MavenSession session ) throws ArtifactResolutionException, PluginVersionResolutionException, ArtifactNotFoundException, InvalidVersionSpecificationException, InvalidPluginException, PluginManagerException, PluginNotFoundException, PluginVersionNotFoundException { PluginDescriptor pd = verifyPlugin( plugin, project, session.getSettings(), session.getLocalRepository() ); PlexusContainer pluginContainer = getPluginContainer( pd ); ensurePluginContainerIsComplete( pd, pluginContainer, project, session ); return pd; } /** * {@inheritDoc} */ public PluginDescriptor loadPluginDescriptor( Plugin plugin, MavenProject project, MavenSession session ) throws ArtifactResolutionException, PluginVersionResolutionException, ArtifactNotFoundException, InvalidVersionSpecificationException, InvalidPluginException, PluginManagerException, PluginNotFoundException, PluginVersionNotFoundException { return verifyPlugin( plugin, project, session.getSettings(), session.getLocalRepository() ); } } maven2-core-2.2.1/maven-core/src/main/java/org/apache/maven/plugin/MavenPluginValidator.java0000644000175000017500000000533311175345173031645 0ustar twernertwernerpackage org.apache.maven.plugin; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import org.apache.maven.artifact.Artifact; import org.apache.maven.plugin.descriptor.PluginDescriptor; import org.codehaus.plexus.component.discovery.ComponentDiscoveryEvent; import org.codehaus.plexus.component.discovery.ComponentDiscoveryListener; import org.codehaus.plexus.component.repository.ComponentSetDescriptor; import java.util.ArrayList; import java.util.List; public class MavenPluginValidator implements ComponentDiscoveryListener { private final Artifact pluginArtifact; private List/**/ errors = new ArrayList/**/(); public MavenPluginValidator( Artifact pluginArtifact ) { this.pluginArtifact = pluginArtifact; } public void componentDiscovered( ComponentDiscoveryEvent event ) { ComponentSetDescriptor componentSetDescriptor = event.getComponentSetDescriptor(); if ( componentSetDescriptor instanceof PluginDescriptor ) { PluginDescriptor pluginDescriptor = (PluginDescriptor) componentSetDescriptor; if ( !pluginArtifact.getGroupId().equals( pluginDescriptor.getGroupId() ) ) { errors.add( "Plugin's descriptor contains the wrong group ID: " + pluginDescriptor.getGroupId() ); } if ( !pluginArtifact.getArtifactId().equals( pluginDescriptor.getArtifactId() ) ) { errors.add( "Plugin's descriptor contains the wrong artifact ID: " + pluginDescriptor.getArtifactId() ); } if ( !pluginArtifact.getBaseVersion().equals( pluginDescriptor.getVersion() ) ) { errors.add( "Plugin's descriptor contains the wrong version: " + pluginDescriptor.getVersion() ); } } } public boolean hasErrors() { return !errors.isEmpty(); } public List/**/ getErrors() { return errors; } } maven2-core-2.2.1/maven-core/src/main/java/org/apache/maven/plugin/version/0000755000175000017500000000000011250552240026355 5ustar twernertwerner././@LongLink0000000000000000000000000000016100000000000011563 Lustar rootrootmaven2-core-2.2.1/maven-core/src/main/java/org/apache/maven/plugin/version/PluginVersionResolutionException.javamaven2-core-2.2.1/maven-core/src/main/java/org/apache/maven/plugin/version/PluginVersionResolutionEx0000644000175000017500000000361410772004567033505 0ustar twernertwernerpackage org.apache.maven.plugin.version; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ public class PluginVersionResolutionException extends Exception { private final String groupId; private final String artifactId; private final String baseMessage; public PluginVersionResolutionException( String groupId, String artifactId, String baseMessage, Throwable cause ) { super( "Error resolving version for \'" + groupId + ":" + artifactId + "\': " + baseMessage, cause ); this.groupId = groupId; this.artifactId = artifactId; this.baseMessage = baseMessage; } public PluginVersionResolutionException( String groupId, String artifactId, String baseMessage ) { super( "Error resolving version for \'" + groupId + ":" + artifactId + "\': " + baseMessage ); this.groupId = groupId; this.artifactId = artifactId; this.baseMessage = baseMessage; } public String getGroupId() { return groupId; } public String getArtifactId() { return artifactId; } public String getBaseMessage() { return baseMessage; } } ././@LongLink0000000000000000000000000000015400000000000011565 Lustar rootrootmaven2-core-2.2.1/maven-core/src/main/java/org/apache/maven/plugin/version/DefaultPluginVersionManager.javamaven2-core-2.2.1/maven-core/src/main/java/org/apache/maven/plugin/version/DefaultPluginVersionManag0000644000175000017500000007714610772004567033410 0ustar twernertwernerpackage org.apache.maven.plugin.version; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.ArtifactUtils; import org.apache.maven.artifact.factory.ArtifactFactory; import org.apache.maven.artifact.metadata.ArtifactMetadataRetrievalException; import org.apache.maven.artifact.metadata.ArtifactMetadataSource; import org.apache.maven.artifact.metadata.ResolutionGroup; import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.artifact.versioning.ArtifactVersion; import org.apache.maven.artifact.versioning.DefaultArtifactVersion; import org.apache.maven.artifact.versioning.InvalidVersionSpecificationException; import org.apache.maven.artifact.versioning.VersionRange; import org.apache.maven.execution.RuntimeInformation; import org.apache.maven.model.Plugin; import org.apache.maven.model.ReportPlugin; import org.apache.maven.plugin.InvalidPluginException; import org.apache.maven.plugin.registry.MavenPluginRegistryBuilder; import org.apache.maven.plugin.registry.PluginRegistry; import org.apache.maven.plugin.registry.PluginRegistryUtils; import org.apache.maven.plugin.registry.TrackableBase; import org.apache.maven.plugin.registry.io.xpp3.PluginRegistryXpp3Writer; import org.apache.maven.project.MavenProject; import org.apache.maven.project.MavenProjectBuilder; import org.apache.maven.project.ProjectBuildingException; import org.apache.maven.settings.RuntimeInfo; import org.apache.maven.settings.Settings; import org.codehaus.plexus.components.interactivity.InputHandler; import org.codehaus.plexus.logging.AbstractLogEnabled; import org.codehaus.plexus.util.IOUtil; import org.codehaus.plexus.util.StringUtils; import org.codehaus.plexus.util.WriterFactory; import org.codehaus.plexus.util.xml.pull.XmlPullParserException; import java.io.File; import java.io.IOException; import java.io.Writer; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Date; import java.util.HashMap; import java.util.Iterator; import java.util.List; import java.util.Map; public class DefaultPluginVersionManager extends AbstractLogEnabled implements PluginVersionManager { private MavenPluginRegistryBuilder mavenPluginRegistryBuilder; private ArtifactFactory artifactFactory; private InputHandler inputHandler; private ArtifactMetadataSource artifactMetadataSource; // TODO: [jc] Revisit to remove this piece of state. PLUGIN REGISTRY MAY BE UPDATED ON DISK OUT-OF-PROCESS! private PluginRegistry pluginRegistry; private MavenProjectBuilder mavenProjectBuilder; private RuntimeInformation runtimeInformation; // TODO: Revisit to remove this piece of state. PLUGIN REGISTRY MAY BE UPDATED ON DISK OUT-OF-PROCESS! private Map resolvedMetaVersions = new HashMap(); public String resolvePluginVersion( String groupId, String artifactId, MavenProject project, Settings settings, ArtifactRepository localRepository ) throws PluginVersionResolutionException, InvalidPluginException, PluginVersionNotFoundException { return resolvePluginVersion( groupId, artifactId, project, settings, localRepository, false ); } public String resolveReportPluginVersion( String groupId, String artifactId, MavenProject project, Settings settings, ArtifactRepository localRepository ) throws PluginVersionResolutionException, InvalidPluginException, PluginVersionNotFoundException { return resolvePluginVersion( groupId, artifactId, project, settings, localRepository, true ); } private String resolvePluginVersion( String groupId, String artifactId, MavenProject project, Settings settings, ArtifactRepository localRepository, boolean resolveAsReportPlugin ) throws PluginVersionResolutionException, InvalidPluginException, PluginVersionNotFoundException { // first pass...if the plugin is specified in the pom, try to retrieve the version from there. String version = getVersionFromPluginConfig( groupId, artifactId, project, resolveAsReportPlugin ); // NOTE: We CANNOT check the current project version here, so delay it until later. // It will prevent plugins from building themselves, if they are part of the lifecycle mapping. // if there was no explicit version, try for one in the reactor if ( version == null ) { if ( project.getProjectReferences() != null ) { String refId = ArtifactUtils.versionlessKey( groupId, artifactId ); MavenProject ref = (MavenProject) project.getProjectReferences().get( refId ); if ( ref != null ) { version = ref.getVersion(); } } } // we're NEVER going to persist POM-derived plugin versions. String updatedVersion = null; // we're not going to prompt the user to accept a plugin update until we find one. boolean promptToPersist = false; RuntimeInfo settingsRTInfo = settings.getRuntimeInfo(); // determine the behavior WRT prompting the user and installing plugin updates. Boolean pluginUpdateOverride = settingsRTInfo.getPluginUpdateOverride(); // second pass...if we're using the plugin registry, and the plugin is listed in the plugin-registry.xml, use // the version from . if ( StringUtils.isEmpty( version ) && settings.isUsePluginRegistry() ) { // resolve existing useVersion. version = resolveExistingFromPluginRegistry( groupId, artifactId ); if ( StringUtils.isNotEmpty( version ) ) { // 2. check for updates. Determine whether this is the right time to attempt to update the version. // Only check for plugin updates if: // // a. the CLI switch to force plugin updates is set, OR BOTH OF THE FOLLOWING: // b. the CLI switch to suppress plugin updates is NOT set, AND // c. the update interval for the plugin has triggered an update check. if ( Boolean.TRUE.equals( pluginUpdateOverride ) || ( !Boolean.FALSE.equals( pluginUpdateOverride ) && shouldCheckForUpdates( groupId, artifactId ) ) ) { updatedVersion = resolveMetaVersion( groupId, artifactId, project, localRepository, Artifact.LATEST_VERSION ); if ( StringUtils.isNotEmpty( updatedVersion ) && !updatedVersion.equals( version ) ) { // see if this version we've resolved is on our previously rejected list. boolean isRejected = checkForRejectedStatus( groupId, artifactId, updatedVersion ); // we should only prompt to use this version if the user has not previously rejected it. promptToPersist = !isRejected; // if we've rejected this version previously, forget about updating. if ( isRejected ) { updatedVersion = null; } else { getLogger().info( "Plugin \'" + constructPluginKey( groupId, artifactId ) + "\' has updates." ); } } } } } boolean forcePersist = false; // third pass...we're always checking for latest install/deploy, so retrieve the version for LATEST metadata and // also set that resolved version as the in settings.xml. if ( StringUtils.isEmpty( version ) ) { // 1. resolve the version to be used version = resolveMetaVersion( groupId, artifactId, project, localRepository, Artifact.LATEST_VERSION ); if ( version != null ) { // 2. Set the updatedVersion so the user will be prompted whether to make this version permanent. updatedVersion = version; // 3. Persist this version without prompting. forcePersist = true; promptToPersist = false; } } // final pass...retrieve the version for RELEASE and also set that resolved version as the // in settings.xml. if ( StringUtils.isEmpty( version ) ) { // 1. resolve the version to be used version = resolveMetaVersion( groupId, artifactId, project, localRepository, Artifact.RELEASE_VERSION ); if ( version != null ) { // 2. Set the updatedVersion so the user will be prompted whether to make this version permanent. updatedVersion = version; // 3. Persist this version without prompting. forcePersist = true; promptToPersist = false; } } // if we're still empty here, and the current project matches the plugin in question, use the current project's // version, I guess... if ( StringUtils.isEmpty( version ) && project.getGroupId().equals( groupId ) && project.getArtifactId().equals( artifactId ) ) { version = project.getVersion(); } // if we still haven't found a version, then fail early before we get into the update goop. if ( StringUtils.isEmpty( version ) ) { throw new PluginVersionNotFoundException( groupId, artifactId ); } // if the plugin registry is inactive, then the rest of this goop is useless... if ( settings.isUsePluginRegistry() ) { // determine whether this build is running in interactive mode // If it's not, then we'll defer to the autoUpdate setting from the registry // for a decision on updating the plugin in the registry...rather than prompting // the user. boolean inInteractiveMode = settings.isInteractiveMode(); // determines what should be done if we're in non-interactive mode. // if true, then just update the registry with the new versions. String s = getPluginRegistry( groupId, artifactId ).getAutoUpdate(); boolean autoUpdate = true; if ( s != null ) { autoUpdate = Boolean.valueOf( s ).booleanValue(); } // We should persist by default if: // // 0. RELEASE or LATEST was used to resolve the plugin version (it's not in the registry) // // -OR- // // 1. we detected a change in the plugin version from what was in the registry, or // a. the plugin is not registered // 2. the pluginUpdateOverride flag has NOT been set to Boolean.FALSE (suppression mode) // 3. we're in interactive mode, or // a. the registry is declared to be in autoUpdate mode // // NOTE: This is only the default value; it may be changed as the result of prompting the user. boolean persistUpdate = forcePersist || ( promptToPersist && !Boolean.FALSE.equals( pluginUpdateOverride ) && ( inInteractiveMode || autoUpdate ) ); // retrieve the apply-to-all flag, if it's been set previously. Boolean applyToAll = settings.getRuntimeInfo().getApplyToAllPluginUpdates(); // Incorporate interactive-mode CLI overrides, and previous decisions on apply-to-all, if appropriate. // // don't prompt if RELEASE or LATEST was used to resolve the plugin version // don't prompt if not in interactive mode. // don't prompt if the CLI pluginUpdateOverride is set (either suppression or force mode will stop prompting) // don't prompt if the user has selected ALL/NONE previously in this session // // NOTE: We're incorporating here, to make the usages of this check more consistent and // resistant to change. promptToPersist = promptToPersist && pluginUpdateOverride == null && applyToAll == null && inInteractiveMode; if ( promptToPersist ) { persistUpdate = promptToPersistPluginUpdate( version, updatedVersion, groupId, artifactId, settings ); } // if it is determined that we should use this version, persist it as useVersion. // cases where this version will be persisted: // 1. the user is prompted and answers yes or all // 2. the user has previously answered all in this session // 3. the build is running in non-interactive mode, and the registry setting is for auto-update if ( !Boolean.FALSE.equals( applyToAll ) && persistUpdate ) { updatePluginVersionInRegistry( groupId, artifactId, updatedVersion ); // we're using the updated version of the plugin in this session as well. version = updatedVersion; } // otherwise, if we prompted the user to update, we should treat this as a rejectedVersion, and // persist it iff the plugin pre-exists and is in the user-level registry. else if ( promptToPersist ) { addNewVersionToRejectedListInExisting( groupId, artifactId, updatedVersion ); } } return version; } private boolean shouldCheckForUpdates( String groupId, String artifactId ) throws PluginVersionResolutionException { PluginRegistry pluginRegistry = getPluginRegistry( groupId, artifactId ); org.apache.maven.plugin.registry.Plugin plugin = getPlugin( groupId, artifactId, pluginRegistry ); if ( plugin == null ) { return true; } else { String lastChecked = plugin.getLastChecked(); if ( StringUtils.isEmpty( lastChecked ) ) { return true; } else { SimpleDateFormat format = new SimpleDateFormat( org.apache.maven.plugin.registry.Plugin.LAST_CHECKED_DATE_FORMAT ); try { Date lastCheckedDate = format.parse( lastChecked ); return IntervalUtils.isExpired( pluginRegistry.getUpdateInterval(), lastCheckedDate ); } catch ( ParseException e ) { getLogger().warn( "Last-checked date for plugin {" + constructPluginKey( groupId, artifactId ) + "} is invalid. Checking for updates." ); return true; } } } } private boolean checkForRejectedStatus( String groupId, String artifactId, String version ) throws PluginVersionResolutionException { PluginRegistry pluginRegistry = getPluginRegistry( groupId, artifactId ); org.apache.maven.plugin.registry.Plugin plugin = getPlugin( groupId, artifactId, pluginRegistry ); return plugin.getRejectedVersions().contains( version ); } private boolean promptToPersistPluginUpdate( String version, String updatedVersion, String groupId, String artifactId, Settings settings ) throws PluginVersionResolutionException { try { StringBuffer message = new StringBuffer(); // this means that the plugin is not registered. if ( version != null && version.equals( updatedVersion ) ) { message.append( "Unregistered plugin detected.\n\n" ); } else { message.append( "New plugin version detected.\n\n" ); } message.append( "Group ID: " ).append( groupId ).append( "\n" ); message.append( "Artifact ID: " ).append( artifactId ).append( "\n" ); message.append( "\n" ); // this means that we've detected a new, non-rejected plugin version. if ( version != null && !version.equals( updatedVersion ) ) { message.append( "Registered Version: " ).append( version ).append( "\n" ); } message.append( "Detected plugin version: " ).append( updatedVersion ).append( "\n" ); message.append( "\n" ); message.append( "Would you like to use this new version from now on? ( [Y]es, [n]o, [a]ll, n[o]ne ) " ); // TODO: check the GUI-friendliness of this approach to collecting input. // If we can't port this prompt into a GUI, IDE-integration will not work well. getLogger().info( message.toString() ); String persistAnswer = inputHandler.readLine(); boolean shouldPersist = true; if ( !StringUtils.isEmpty( persistAnswer ) ) { persistAnswer = persistAnswer.toLowerCase(); if ( persistAnswer.startsWith( "y" ) ) { shouldPersist = true; } else if ( persistAnswer.startsWith( "a" ) ) { shouldPersist = true; settings.getRuntimeInfo().setApplyToAllPluginUpdates( Boolean.TRUE ); } else if ( persistAnswer.indexOf( "o" ) > -1 ) { settings.getRuntimeInfo().setApplyToAllPluginUpdates( Boolean.FALSE ); } else if ( persistAnswer.startsWith( "n" ) ) { shouldPersist = false; } else { // default to yes. shouldPersist = true; } } if ( shouldPersist ) { getLogger().info( "Updating plugin version to " + updatedVersion ); } else { getLogger().info( "NOT updating plugin version to " + updatedVersion ); } return shouldPersist; } catch ( IOException e ) { throw new PluginVersionResolutionException( groupId, artifactId, "Can't read user input.", e ); } } private void addNewVersionToRejectedListInExisting( String groupId, String artifactId, String rejectedVersion ) throws PluginVersionResolutionException { PluginRegistry pluginRegistry = getPluginRegistry( groupId, artifactId ); org.apache.maven.plugin.registry.Plugin plugin = getPlugin( groupId, artifactId, pluginRegistry ); String pluginKey = constructPluginKey( groupId, artifactId ); if ( plugin != null && !TrackableBase.GLOBAL_LEVEL.equals( plugin.getSourceLevel() ) ) { plugin.addRejectedVersion( rejectedVersion ); writeUserRegistry( groupId, artifactId, pluginRegistry ); getLogger().warn( "Plugin version: " + rejectedVersion + " added to your rejectedVersions list.\n" + "You will not be prompted for this version again.\n\nPlugin: " + pluginKey ); } else { getLogger().warn( "Cannot add rejectedVersion entry for: " + rejectedVersion + ".\n\nPlugin: " + pluginKey ); } } private String resolveExistingFromPluginRegistry( String groupId, String artifactId ) throws PluginVersionResolutionException { PluginRegistry pluginRegistry = getPluginRegistry( groupId, artifactId ); org.apache.maven.plugin.registry.Plugin plugin = getPlugin( groupId, artifactId, pluginRegistry ); String version = null; if ( plugin != null ) { version = plugin.getUseVersion(); } return version; } private org.apache.maven.plugin.registry.Plugin getPlugin( String groupId, String artifactId, PluginRegistry pluginRegistry ) { Map pluginsByKey; if ( pluginRegistry != null ) { pluginsByKey = pluginRegistry.getPluginsByKey(); } else { pluginsByKey = new HashMap(); } String pluginKey = constructPluginKey( groupId, artifactId ); return (org.apache.maven.plugin.registry.Plugin) pluginsByKey.get( pluginKey ); } private String constructPluginKey( String groupId, String artifactId ) { return groupId + ":" + artifactId; } private String getVersionFromPluginConfig( String groupId, String artifactId, MavenProject project, boolean resolveAsReportPlugin ) { String version = null; if ( resolveAsReportPlugin ) { if ( project.getReportPlugins() != null ) { for ( Iterator it = project.getReportPlugins().iterator(); it.hasNext() && version == null; ) { ReportPlugin plugin = (ReportPlugin) it.next(); if ( groupId.equals( plugin.getGroupId() ) && artifactId.equals( plugin.getArtifactId() ) ) { version = plugin.getVersion(); } } } } else { if ( project.getBuildPlugins() != null ) { for ( Iterator it = project.getBuildPlugins().iterator(); it.hasNext() && version == null; ) { Plugin plugin = (Plugin) it.next(); if ( groupId.equals( plugin.getGroupId() ) && artifactId.equals( plugin.getArtifactId() ) ) { version = plugin.getVersion(); } } } } return version; } private void updatePluginVersionInRegistry( String groupId, String artifactId, String version ) throws PluginVersionResolutionException { PluginRegistry pluginRegistry = getPluginRegistry( groupId, artifactId ); org.apache.maven.plugin.registry.Plugin plugin = getPlugin( groupId, artifactId, pluginRegistry ); // if we can find the plugin, but we've gotten here, the useVersion must be missing; fill it in. if ( plugin != null ) { if ( PluginRegistry.GLOBAL_LEVEL.equals( plugin.getSourceLevel() ) ) { // do nothing. We don't rewrite the globals, under any circumstances. getLogger().warn( "Cannot update registered version for plugin {" + groupId + ":" + artifactId + "}; it is specified in the global registry." ); } else { plugin.setUseVersion( version ); SimpleDateFormat format = new SimpleDateFormat( org.apache.maven.plugin.registry.Plugin.LAST_CHECKED_DATE_FORMAT ); plugin.setLastChecked( format.format( new Date() ) ); } } else { plugin = new org.apache.maven.plugin.registry.Plugin(); plugin.setGroupId( groupId ); plugin.setArtifactId( artifactId ); plugin.setUseVersion( version ); pluginRegistry.addPlugin( plugin ); pluginRegistry.flushPluginsByKey(); } writeUserRegistry( groupId, artifactId, pluginRegistry ); } private void writeUserRegistry( String groupId, String artifactId, PluginRegistry pluginRegistry ) { File pluginRegistryFile = pluginRegistry.getRuntimeInfo().getFile(); PluginRegistry extractedUserRegistry = PluginRegistryUtils.extractUserPluginRegistry( pluginRegistry ); // only rewrite the user-level registry if one existed before, or if we've created user-level data here. if ( extractedUserRegistry != null ) { Writer fWriter = null; try { pluginRegistryFile.getParentFile().mkdirs(); fWriter = WriterFactory.newXmlWriter( pluginRegistryFile ); PluginRegistryXpp3Writer writer = new PluginRegistryXpp3Writer(); writer.write( fWriter, extractedUserRegistry ); } catch ( IOException e ) { getLogger().warn( "Cannot rewrite user-level plugin-registry.xml with new plugin version of plugin: \'" + groupId + ":" + artifactId + "\'.", e ); } finally { IOUtil.close( fWriter ); } } } private PluginRegistry getPluginRegistry( String groupId, String artifactId ) throws PluginVersionResolutionException { if ( pluginRegistry == null ) { try { pluginRegistry = mavenPluginRegistryBuilder.buildPluginRegistry(); } catch ( IOException e ) { throw new PluginVersionResolutionException( groupId, artifactId, "Error reading plugin registry: " + e.getMessage(), e ); } catch ( XmlPullParserException e ) { throw new PluginVersionResolutionException( groupId, artifactId, "Error parsing plugin registry: " + e.getMessage(), e ); } if ( pluginRegistry == null ) { pluginRegistry = mavenPluginRegistryBuilder.createUserPluginRegistry(); } } return pluginRegistry; } private String resolveMetaVersion( String groupId, String artifactId, MavenProject project, ArtifactRepository localRepository, String metaVersionId ) throws PluginVersionResolutionException, InvalidPluginException { Artifact artifact = artifactFactory.createProjectArtifact( groupId, artifactId, metaVersionId ); String key = artifact.getDependencyConflictId(); if ( resolvedMetaVersions.containsKey( key ) ) { return (String) resolvedMetaVersions.get( key ); } String version = null; // This takes the spec version and resolves a real version try { ResolutionGroup resolutionGroup = artifactMetadataSource.retrieve( artifact, localRepository, project.getPluginArtifactRepositories() ); // switching this out with the actual resolved artifact instance, since the MMSource re-creates the pom // artifact. artifact = resolutionGroup.getPomArtifact(); } catch ( ArtifactMetadataRetrievalException e ) { throw new PluginVersionResolutionException( groupId, artifactId, e.getMessage(), e ); } String artifactVersion = artifact.getVersion(); // make sure this artifact was actually resolved to a file in the repo... if ( artifact.getFile() != null ) { boolean pluginValid = false; while ( !pluginValid && artifactVersion != null ) { pluginValid = true; MavenProject pluginProject; try { artifact = artifactFactory.createProjectArtifact( groupId, artifactId, artifactVersion ); pluginProject = mavenProjectBuilder.buildFromRepository( artifact, project.getPluginArtifactRepositories(), localRepository, false ); } catch ( ProjectBuildingException e ) { throw new InvalidPluginException( "Unable to build project information for plugin '" + ArtifactUtils.versionlessKey( groupId, artifactId ) + "': " + e.getMessage(), e ); } // if we don't have the required Maven version, then ignore an update if ( pluginProject.getPrerequisites() != null && pluginProject.getPrerequisites().getMaven() != null ) { DefaultArtifactVersion requiredVersion = new DefaultArtifactVersion( pluginProject.getPrerequisites().getMaven() ); if ( runtimeInformation.getApplicationVersion().compareTo( requiredVersion ) < 0 ) { getLogger().info( "Ignoring available plugin update: " + artifactVersion + " as it requires Maven version " + requiredVersion ); VersionRange vr; try { vr = VersionRange.createFromVersionSpec( "(," + artifactVersion + ")" ); } catch ( InvalidVersionSpecificationException e ) { throw new PluginVersionResolutionException( groupId, artifactId, "Error getting available plugin versions: " + e.getMessage(), e ); } getLogger().debug( "Trying " + vr ); try { List versions = artifactMetadataSource.retrieveAvailableVersions( artifact, localRepository, project.getPluginArtifactRepositories() ); ArtifactVersion v = vr.matchVersion( versions ); artifactVersion = v != null ? v.toString() : null; } catch ( ArtifactMetadataRetrievalException e ) { throw new PluginVersionResolutionException( groupId, artifactId, "Error getting available plugin versions: " + e.getMessage(), e ); } if ( artifactVersion != null ) { getLogger().debug( "Found " + artifactVersion ); pluginValid = false; } } } } } if ( !metaVersionId.equals( artifactVersion ) ) { version = artifactVersion; resolvedMetaVersions.put( key, version ); } return version; } } ././@LongLink0000000000000000000000000000015700000000000011570 Lustar rootrootmaven2-core-2.2.1/maven-core/src/main/java/org/apache/maven/plugin/version/PluginVersionNotFoundException.javamaven2-core-2.2.1/maven-core/src/main/java/org/apache/maven/plugin/version/PluginVersionNotFoundExce0000644000175000017500000000261210551365651033402 0ustar twernertwernerpackage org.apache.maven.plugin.version; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ public class PluginVersionNotFoundException extends Exception { private final String groupId; private final String artifactId; public PluginVersionNotFoundException( String groupId, String artifactId ) { super( "The plugin \'" + groupId + ":" + artifactId + "\' does not exist or no valid version could be found" ); this.groupId = groupId; this.artifactId = artifactId; } public String getGroupId() { return groupId; } public String getArtifactId() { return artifactId; } } maven2-core-2.2.1/maven-core/src/main/java/org/apache/maven/plugin/version/IntervalUtils.java0000644000175000017500000000772710772004567032056 0ustar twernertwernerpackage org.apache.maven.plugin.version; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import java.util.Calendar; import java.util.Date; import java.util.HashMap; import java.util.Map; import java.util.regex.Matcher; import java.util.regex.Pattern; public final class IntervalUtils { private static final String PERIOD_PART_PATTERN = "[0-9]+[WwDdHhMm]?"; private static final Map PART_TYPE_CONTRIBUTIONS; static { Map contributions = new HashMap(); contributions.put( "w", new Long( 7 * 24 * 60 * 60 * 1000 ) ); contributions.put( "d", new Long( 24 * 60 * 60 * 1000 ) ); contributions.put( "h", new Long( 60 * 60 * 1000 ) ); contributions.put( "m", new Long( 60 * 1000 ) ); PART_TYPE_CONTRIBUTIONS = contributions; } private IntervalUtils() { // don't allow construction } public static boolean isExpired( String intervalSpec, Date lastChecked ) { if( "never".equalsIgnoreCase( intervalSpec ) ) { return false; } else if( "always".equalsIgnoreCase( intervalSpec ) ) { return true; } else if( intervalSpec != null && intervalSpec.toLowerCase().startsWith("interval:") && intervalSpec.length() > "interval:".length()) { String intervalPart = intervalSpec.substring( "interval:".length() ); // subtract the specified period from now() and see if it's still after the lastChecked date. long period = IntervalUtils.parseInterval(intervalPart); Calendar cal = Calendar.getInstance(); cal.setTimeInMillis( System.currentTimeMillis() - period ); Date test = cal.getTime(); return lastChecked == null || test.after( lastChecked ); } else { throw new IllegalArgumentException( "Invalid interval specification: \'" + intervalSpec + "\'" ); } } public static long parseInterval( String interval ) { Matcher partMatcher = Pattern.compile(PERIOD_PART_PATTERN).matcher(interval); long period = 0; while( partMatcher.find() ) { String part = partMatcher.group(); period += getPartPeriod( part ); } return period; } private static long getPartPeriod( String part ) { char type = part.charAt( part.length() - 1 ); String coefficientPart; if( Character.isLetter(type)) { coefficientPart = part.substring( 0, part.length() - 1); } else { // if the interval doesn't specify a resolution, assume minutes. coefficientPart = part; type = 'm'; } int coefficient = Integer.parseInt( coefficientPart ); Long period = (Long) PART_TYPE_CONTRIBUTIONS.get( "" + Character.toLowerCase( type ) ); long result = 0; if( period != null ) { result = coefficient * period.longValue(); } return result; } } ././@LongLink0000000000000000000000000000014500000000000011565 Lustar rootrootmaven2-core-2.2.1/maven-core/src/main/java/org/apache/maven/plugin/version/PluginVersionManager.javamaven2-core-2.2.1/maven-core/src/main/java/org/apache/maven/plugin/version/PluginVersionManager.java0000644000175000017500000000331410772004567033334 0ustar twernertwernerpackage org.apache.maven.plugin.version; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.plugin.InvalidPluginException; import org.apache.maven.project.MavenProject; import org.apache.maven.settings.Settings; public interface PluginVersionManager { String ROLE = PluginVersionManager.class.getName(); String resolvePluginVersion( String groupId, String artifactId, MavenProject project, Settings settings, ArtifactRepository localRepository ) throws PluginVersionResolutionException, InvalidPluginException, PluginVersionNotFoundException; String resolveReportPluginVersion( String groupId, String artifactId, MavenProject project, Settings settings, ArtifactRepository localRepository ) throws PluginVersionResolutionException, InvalidPluginException, PluginVersionNotFoundException; } maven2-core-2.2.1/maven-core/src/main/java/org/apache/maven/plugin/PluginMappingManager.java0000644000175000017500000000253610772004567031622 0ustar twernertwernerpackage org.apache.maven.plugin; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.model.Plugin; import java.util.List; /** * Manage plugin prefix to artifact ID mapping associations. * * @author Brett Porter * @version $Id: PluginMappingManager.java 640549 2008-03-24 20:05:11Z bentmann $ */ public interface PluginMappingManager { Plugin getByPrefix( String pluginPrefix, List groupIds, List pluginRepositories, ArtifactRepository localRepository ); } maven2-core-2.2.1/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginMappingManager.java0000644000175000017500000001216310772004567033124 0ustar twernertwernerpackage org.apache.maven.plugin; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.artifact.repository.metadata.GroupRepositoryMetadata; import org.apache.maven.artifact.repository.metadata.Metadata; import org.apache.maven.artifact.repository.metadata.Plugin; import org.apache.maven.artifact.repository.metadata.RepositoryMetadata; import org.apache.maven.artifact.repository.metadata.RepositoryMetadataManager; import org.apache.maven.artifact.repository.metadata.RepositoryMetadataResolutionException; import org.codehaus.plexus.logging.AbstractLogEnabled; import java.util.ArrayList; import java.util.Collections; import java.util.HashMap; import java.util.Iterator; import java.util.List; import java.util.Map; /** * Manage plugin prefix to artifact ID mapping associations. * * @author Brett Porter * @version $Id: DefaultPluginMappingManager.java 495147 2007-01-11 07:47:53Z * jvanzyl $ */ public class DefaultPluginMappingManager extends AbstractLogEnabled implements PluginMappingManager { protected RepositoryMetadataManager repositoryMetadataManager; private Map pluginDefinitionsByPrefix = new HashMap(); public org.apache.maven.model.Plugin getByPrefix( String pluginPrefix, List groupIds, List pluginRepositories, ArtifactRepository localRepository ) { // if not found, try from the remote repository if ( !pluginDefinitionsByPrefix.containsKey( pluginPrefix ) ) { getLogger().info( "Searching repository for plugin with prefix: \'" + pluginPrefix + "\'." ); loadPluginMappings( groupIds, pluginRepositories, localRepository ); } return (org.apache.maven.model.Plugin) pluginDefinitionsByPrefix.get( pluginPrefix ); } private void loadPluginMappings( List groupIds, List pluginRepositories, ArtifactRepository localRepository ) { List pluginGroupIds = new ArrayList( groupIds ); // TODO: use constant if ( !pluginGroupIds.contains( "org.apache.maven.plugins" ) ) { pluginGroupIds.add( "org.apache.maven.plugins" ); } if ( !pluginGroupIds.contains( "org.codehaus.mojo" ) ) { pluginGroupIds.add( "org.codehaus.mojo" ); } for ( Iterator it = pluginGroupIds.iterator(); it.hasNext(); ) { String groupId = (String) it.next(); getLogger().debug( "Loading plugin prefixes from group: " + groupId ); try { loadPluginMappings( groupId, pluginRepositories, localRepository ); } catch ( RepositoryMetadataResolutionException e ) { getLogger().warn( "Cannot resolve plugin-mapping metadata for groupId: " + groupId + " - IGNORING." ); getLogger().debug( "Error resolving plugin-mapping metadata for groupId: " + groupId + ".", e ); } } } private void loadPluginMappings( String groupId, List pluginRepositories, ArtifactRepository localRepository ) throws RepositoryMetadataResolutionException { RepositoryMetadata metadata = new GroupRepositoryMetadata( groupId ); repositoryMetadataManager.resolve( metadata, pluginRepositories, localRepository ); Metadata repoMetadata = metadata.getMetadata(); if ( repoMetadata != null ) { for ( Iterator pluginIterator = repoMetadata.getPlugins().iterator(); pluginIterator.hasNext(); ) { Plugin mapping = (Plugin) pluginIterator.next(); String prefix = mapping.getPrefix(); //if the prefix has already been found, don't add it again. //this is to preserve the correct ordering of prefix searching (MNG-2926) if ( !pluginDefinitionsByPrefix.containsKey( prefix ) ) { String artifactId = mapping.getArtifactId(); org.apache.maven.model.Plugin plugin = new org.apache.maven.model.Plugin(); plugin.setGroupId( metadata.getGroupId() ); plugin.setArtifactId( artifactId ); pluginDefinitionsByPrefix.put( prefix, plugin ); } } } } } maven2-core-2.2.1/maven-core/src/main/java/org/apache/maven/plugin/MavenPluginCollector.java0000644000175000017500000000760311145545252031645 0ustar twernertwernerpackage org.apache.maven.plugin; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import org.apache.maven.model.Plugin; import org.apache.maven.plugin.descriptor.PluginDescriptor; import org.codehaus.plexus.component.discovery.ComponentDiscoveryEvent; import org.codehaus.plexus.component.discovery.ComponentDiscoveryListener; import org.codehaus.plexus.component.repository.ComponentSetDescriptor; import org.codehaus.plexus.logging.AbstractLogEnabled; import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; import java.util.Map; import java.util.Set; public class MavenPluginCollector extends AbstractLogEnabled implements ComponentDiscoveryListener { private Set pluginsInProcess = new HashSet(); private Map pluginDescriptors = new HashMap(); private Map pluginIdsByPrefix = new HashMap(); // ---------------------------------------------------------------------- // Mojo discovery // ---------------------------------------------------------------------- public void componentDiscovered( ComponentDiscoveryEvent event ) { ComponentSetDescriptor componentSetDescriptor = event.getComponentSetDescriptor(); if ( componentSetDescriptor instanceof PluginDescriptor ) { PluginDescriptor pluginDescriptor = (PluginDescriptor) componentSetDescriptor; String key = PluginUtils.constructVersionedKey( pluginDescriptor ); if ( !pluginsInProcess.contains( key ) ) { pluginsInProcess.add( key ); pluginDescriptors.put( key, pluginDescriptor ); // TODO: throw an (not runtime) exception if there is a prefix overlap - means doing so elsewhere // we also need to deal with multiple versions somehow - currently, first wins if ( !pluginIdsByPrefix.containsKey( pluginDescriptor.getGoalPrefix() ) ) { pluginIdsByPrefix.put( pluginDescriptor.getGoalPrefix(), pluginDescriptor ); } } } } public PluginDescriptor getPluginDescriptor( Plugin plugin ) { String key = PluginUtils.constructVersionedKey( plugin ); return (PluginDescriptor) pluginDescriptors.get( key ); } public boolean isPluginInstalled( Plugin plugin ) { String key = PluginUtils.constructVersionedKey( plugin ); return pluginDescriptors.containsKey( key ); } public PluginDescriptor getPluginDescriptorForPrefix( String prefix ) { return (PluginDescriptor) pluginIdsByPrefix.get( prefix ); } public void flushPluginDescriptor( Plugin plugin ) { String key = PluginUtils.constructVersionedKey( plugin ); pluginsInProcess.remove( key ); pluginDescriptors.remove( key ); for ( Iterator it = pluginIdsByPrefix.entrySet().iterator(); it.hasNext(); ) { Map.Entry entry = (Map.Entry) it.next(); if ( key.equals( PluginUtils.constructVersionedKey( (PluginDescriptor) entry.getValue() ) ) ) { it.remove(); } } } } maven2-core-2.2.1/maven-core/src/main/java/org/apache/maven/plugin/PluginManager.java0000644000175000017500000001120011234666772030300 0ustar twernertwernerpackage org.apache.maven.plugin; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.artifact.resolver.ArtifactNotFoundException; import org.apache.maven.artifact.resolver.ArtifactResolutionException; import org.apache.maven.artifact.versioning.InvalidVersionSpecificationException; import org.apache.maven.execution.MavenSession; import org.apache.maven.model.Plugin; import org.apache.maven.model.ReportPlugin; import org.apache.maven.plugin.descriptor.PluginDescriptor; import org.apache.maven.plugin.version.PluginVersionNotFoundException; import org.apache.maven.plugin.version.PluginVersionResolutionException; import org.apache.maven.project.MavenProject; import org.apache.maven.project.artifact.InvalidDependencyVersionException; import org.apache.maven.reporting.MavenReport; import org.apache.maven.settings.Settings; import org.codehaus.plexus.component.repository.exception.ComponentLookupException; import java.util.Map; /** * @author Jason van Zyl * @version $Id: PluginManager.java 799758 2009-07-31 22:19:38Z jdcasey $ */ public interface PluginManager { String ROLE = PluginManager.class.getName(); void executeMojo( MavenProject project, MojoExecution execution, MavenSession session ) throws MojoExecutionException, ArtifactResolutionException, MojoFailureException, ArtifactNotFoundException, InvalidDependencyVersionException, PluginManagerException, PluginConfigurationException; MavenReport getReport( MavenProject project, MojoExecution mojoExecution, MavenSession session ) throws ArtifactNotFoundException, PluginConfigurationException, PluginManagerException, ArtifactResolutionException; PluginDescriptor getPluginDescriptorForPrefix( String prefix ); Plugin getPluginDefinitionForPrefix( String prefix, MavenSession session, MavenProject project ); /** * @deprecated Use {@link PluginManager#loadPluginDescriptor(Plugin, MavenProject, MavenSession)} instead. */ PluginDescriptor verifyPlugin( Plugin plugin, MavenProject project, Settings settings, ArtifactRepository localRepository ) throws ArtifactResolutionException, PluginVersionResolutionException, ArtifactNotFoundException, InvalidVersionSpecificationException, InvalidPluginException, PluginManagerException, PluginNotFoundException, PluginVersionNotFoundException; PluginDescriptor verifyReportPlugin( ReportPlugin reportPlugin, MavenProject project, MavenSession session ) throws PluginVersionResolutionException, ArtifactResolutionException, ArtifactNotFoundException, InvalidVersionSpecificationException, InvalidPluginException, PluginManagerException, PluginNotFoundException, PluginVersionNotFoundException; Object getPluginComponent( Plugin plugin, String role, String roleHint ) throws PluginManagerException, ComponentLookupException; Map getPluginComponents( Plugin plugin, String role ) throws ComponentLookupException, PluginManagerException; /** * @since 2.2.1 */ PluginDescriptor loadPluginDescriptor( Plugin plugin, MavenProject project, MavenSession session ) throws ArtifactResolutionException, PluginVersionResolutionException, ArtifactNotFoundException, InvalidVersionSpecificationException, InvalidPluginException, PluginManagerException, PluginNotFoundException, PluginVersionNotFoundException; /** * @since 2.2.1 */ PluginDescriptor loadPluginFully( Plugin plugin, MavenProject project, MavenSession session ) throws ArtifactResolutionException, PluginVersionResolutionException, ArtifactNotFoundException, InvalidVersionSpecificationException, InvalidPluginException, PluginManagerException, PluginNotFoundException, PluginVersionNotFoundException; }././@LongLink0000000000000000000000000000015300000000000011564 Lustar rootrootmaven2-core-2.2.1/maven-core/src/main/java/org/apache/maven/plugin/PluginParameterExpressionEvaluator.javamaven2-core-2.2.1/maven-core/src/main/java/org/apache/maven/plugin/PluginParameterExpressionEvaluato0000644000175000017500000003007311221205616033476 0ustar twernertwernerpackage org.apache.maven.plugin; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import org.apache.maven.execution.MavenSession; import org.apache.maven.plugin.descriptor.MojoDescriptor; import org.apache.maven.plugin.descriptor.PluginDescriptor; import org.apache.maven.project.MavenProject; import org.apache.maven.project.path.PathTranslator; import org.codehaus.plexus.component.configurator.expression.ExpressionEvaluationException; import org.codehaus.plexus.component.configurator.expression.ExpressionEvaluator; import org.codehaus.plexus.logging.Logger; import org.codehaus.plexus.util.introspection.ReflectionValueExtractor; import java.io.File; import java.util.HashMap; import java.util.Map; import java.util.Properties; /** * @author Jason van Zyl * @version $Id: PluginParameterExpressionEvaluator.java 788791 2009-06-26 17:55:26Z jdcasey $ * @todo belong in MavenSession, so it only gets created once? */ public class PluginParameterExpressionEvaluator implements ExpressionEvaluator { private static final Map BANNED_EXPRESSIONS; private static final Map DEPRECATED_EXPRESSIONS; static { Map deprecated = new HashMap(); deprecated.put( "project.build.resources", "project.resources" ); deprecated.put( "project.build.testResources", "project.testResources" ); DEPRECATED_EXPRESSIONS = deprecated; Map banned = new HashMap(); BANNED_EXPRESSIONS = banned; } private final PathTranslator pathTranslator; private final MavenSession context; private final Logger logger; private final MojoExecution mojoExecution; private final MavenProject project; private final String basedir; private final Properties properties; public PluginParameterExpressionEvaluator( MavenSession context, MojoExecution mojoExecution, PathTranslator pathTranslator, Logger logger, MavenProject project, Properties properties ) { this.context = context; this.mojoExecution = mojoExecution; this.pathTranslator = pathTranslator; this.logger = logger; this.project = project; this.properties = properties; String basedir = null; if ( project != null ) { File baseDir = project.getBasedir(); // this should always be the case for non-super POM instances... if ( baseDir != null ) { basedir = baseDir.getAbsolutePath(); } } if ( basedir == null ) { basedir = System.getProperty( "user.dir" ); } this.basedir = basedir; } public Object evaluate( String expr ) throws ExpressionEvaluationException { Object value = null; if ( expr == null ) { return null; } String expression = stripTokens( expr ); if ( expression.equals( expr ) ) { int index = expr.indexOf( "${" ); if ( index >= 0 ) { int lastIndex = expr.indexOf( "}", index ); if ( lastIndex >= 0 ) { String retVal = expr.substring( 0, index ); if ( index > 0 && expr.charAt( index - 1 ) == '$' ) { retVal += expr.substring( index + 1, lastIndex + 1 ); } else { retVal += evaluate( expr.substring( index, lastIndex + 1 ) ); } retVal += evaluate( expr.substring( lastIndex + 1 ) ); return retVal; } } // Was not an expression if ( expression.indexOf( "$$" ) > -1 ) { return expression.replaceAll( "\\$\\$", "\\$" ); } else { return expression; } } MojoDescriptor mojoDescriptor = mojoExecution.getMojoDescriptor(); if ( BANNED_EXPRESSIONS.containsKey( expression ) ) { throw new ExpressionEvaluationException( "The parameter expression: \'" + expression + "\' used in mojo: \'" + mojoDescriptor.getGoal() + "\' is banned. Use \'" + BANNED_EXPRESSIONS.get( expression ) + "\' instead." ); } else if ( DEPRECATED_EXPRESSIONS.containsKey( expression ) ) { logger.warn( "The parameter expression: \'" + expression + "\' used in mojo: \'" + mojoDescriptor.getGoal() + "\' has been deprecated. Use \'" + DEPRECATED_EXPRESSIONS.get( expression ) + "\' instead." ); } if ( "localRepository".equals( expression ) ) { value = context.getLocalRepository(); } else if ( "session".equals( expression ) ) { value = context; } else if ( "reactorProjects".equals( expression ) ) { value = context.getSortedProjects(); } else if ( "reports".equals( expression ) ) { value = mojoExecution.getReports(); } else if ("mojoExecution".equals(expression)) { value = mojoExecution; } else if ( "project".equals( expression ) ) { value = project; } else if ( "executedProject".equals( expression ) ) { value = project.getExecutionProject(); } else if ( expression.startsWith( "project" ) ) { try { int pathSeparator = expression.indexOf( "/" ); if ( pathSeparator > 0 ) { String pathExpression = expression.substring( 0, pathSeparator ); value = ReflectionValueExtractor.evaluate( pathExpression, project ); value = value + expression.substring( pathSeparator ); } else { value = ReflectionValueExtractor.evaluate( expression.substring( 1 ), project ); } } catch ( Exception e ) { // TODO: don't catch exception throw new ExpressionEvaluationException( "Error evaluating plugin parameter expression: " + expression, e ); } } else if ( expression.startsWith( "plugin" ) ) { try { int pathSeparator = expression.indexOf( "/" ); PluginDescriptor pluginDescriptor = mojoDescriptor.getPluginDescriptor(); if ( pathSeparator > 0 ) { String pathExpression = expression.substring( 1, pathSeparator ); value = ReflectionValueExtractor.evaluate( pathExpression, pluginDescriptor ); value = value + expression.substring( pathSeparator ); } else { value = ReflectionValueExtractor.evaluate( expression.substring( 1 ), pluginDescriptor ); } } catch ( Exception e ) { // TODO: don't catch exception throw new ExpressionEvaluationException( "Error evaluating plugin parameter expression: " + expression, e ); } } else if ( "settings".equals( expression ) ) { value = context.getSettings(); } else if ( expression.startsWith( "settings" ) ) { try { int pathSeparator = expression.indexOf( "/" ); if ( pathSeparator > 0 ) { String pathExpression = expression.substring( 1, pathSeparator ); value = ReflectionValueExtractor.evaluate( pathExpression, context.getSettings() ); value = value + expression.substring( pathSeparator ); } else { value = ReflectionValueExtractor.evaluate( expression.substring( 1 ), context.getSettings() ); } } catch ( Exception e ) { // TODO: don't catch exception throw new ExpressionEvaluationException( "Error evaluating plugin parameter expression: " + expression, e ); } } else if ( "basedir".equals( expression ) ) { value = basedir; } else if ( expression.startsWith( "basedir" ) ) { int pathSeparator = expression.indexOf( "/" ); if ( pathSeparator > 0 ) { value = basedir + expression.substring( pathSeparator ); } else { logger.error( "Got expression '" + expression + "' that was not recognised" ); } } if ( value == null ) { // The CLI should win for defining properties if ( value == null && properties != null ) { // We will attempt to get nab a system property as a way to specify a // parameter to a plugins. My particular case here is allowing the surefire // plugin to run a single test so I want to specify that class on the cli // as a parameter. value = properties.getProperty( expression ); } if ( value == null && project != null && project.getProperties() != null ) { value = project.getProperties().getProperty( expression ); } } if ( value instanceof String ) { // TODO: without #, this could just be an evaluate call... String val = (String) value; int exprStartDelimiter = val.indexOf( "${" ); if ( exprStartDelimiter >= 0 ) { if ( exprStartDelimiter > 0 ) { value = val.substring( 0, exprStartDelimiter ) + evaluate( val.substring( exprStartDelimiter ) ); } else { value = evaluate( val.substring( exprStartDelimiter ) ); } } } return value; } private String stripTokens( String expr ) { if ( expr.startsWith( "${" ) && expr.indexOf( "}" ) == expr.length() - 1 ) { expr = expr.substring( 2, expr.length() - 1 ); } return expr; } public File alignToBaseDirectory( File file ) { File basedir; if ( project != null && project.getFile() != null ) { basedir = project.getFile().getParentFile(); } else { basedir = new File( "." ).getAbsoluteFile().getParentFile(); } return new File( pathTranslator.alignToBaseDirectory( file.getPath(), basedir ) ); } } maven2-core-2.2.1/maven-core/checkstyle-license.txt0000644000175000017500000000141710154505607022151 0ustar twernertwerner /* ==================================================================== * Copyright 2001-2004 The Apache Software Foundation. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ==================================================================== */ maven2-core-2.2.1/maven-core/pom.xml0000644000175000017500000002656111236625310017152 0ustar twernertwerner 4.0.0 org.apache.maven maven 2.2.1 maven-core Maven Core org.apache.maven maven-settings org.apache.maven.wagon wagon-file runtime org.apache.maven maven-plugin-parameter-documenter org.apache.maven.wagon wagon-http-lightweight org.apache.maven.wagon wagon-http commons-logging commons-logging org.apache.maven.wagon wagon-webdav-jackrabbit runtime commons-logging commons-logging org.slf4j slf4j-jdk14 runtime org.slf4j jcl-over-slf4j runtime org.apache.maven.reporting maven-reporting-api org.apache.maven maven-profile org.apache.maven maven-model org.apache.maven maven-artifact org.apache.maven.wagon wagon-provider-api org.codehaus.plexus plexus-container-default org.apache.maven maven-repository-metadata org.apache.maven maven-error-diagnostics org.apache.maven maven-project commons-cli commons-cli commons-lang commons-lang commons-logging commons-logging org.apache.maven maven-plugin-api org.apache.maven.wagon wagon-ssh-external runtime org.apache.maven maven-plugin-descriptor org.codehaus.plexus plexus-interactivity-api 1.0-alpha-4 plexus-utils plexus plexus-container-default org.codehaus.plexus org.apache.maven maven-artifact-manager org.apache.maven maven-monitor org.apache.maven.wagon wagon-ssh org.codehaus.plexus plexus-utils classworlds classworlds org.sonatype.plexus plexus-sec-dispatcher src/main/resources true org.apache.maven.plugins maven-compiler-plugin 2.0.2 default 1.5 1.5 **/cli/*.java cli compile testCompile 1.4 1.4 **/cli/*.java org.codehaus.mojo l10n-maven-plugin 1.0-alpha-1 el de es fr ja nl no pl zh_CN include-site org.apache.maven.plugins maven-scm-plugin scm:svn:http://svn.apache.org/repos/asf/maven/site/trunk ${project.build.directory}/maven-site initialize checkout org.apache.maven.plugins maven-invoker-plugin ${project.build.directory}/maven-site ${project.build.directory}/maven-site/pom.xml clean site initialize initialize run canonical-buildnumber .svn org.codehaus.mojo buildnumber-maven-plugin 1.0-beta-1 generate-resources create false false non-canonical-buildnumber .svn org.codehaus.mojo buildnumber-maven-plugin 1.0-beta-1 generate-resources create false false NON-CANONICAL_{0,date,yyyy-MM-dd_HH-mm}_{1} timestamp ${user.name} maven2-core-2.2.1/maven-monitor/0000755000175000017500000000000011250552240016357 5ustar twernertwernermaven2-core-2.2.1/maven-monitor/src/0000755000175000017500000000000011250552240017146 5ustar twernertwernermaven2-core-2.2.1/maven-monitor/src/site/0000755000175000017500000000000011250552240020112 5ustar twernertwernermaven2-core-2.2.1/maven-monitor/src/site/site.xml0000644000175000017500000000013211002611514021567 0ustar twernertwerner maven2-core-2.2.1/maven-monitor/src/main/0000755000175000017500000000000011250552240020072 5ustar twernertwernermaven2-core-2.2.1/maven-monitor/src/main/java/0000755000175000017500000000000011250552240021013 5ustar twernertwernermaven2-core-2.2.1/maven-monitor/src/main/java/org/0000755000175000017500000000000011250552240021602 5ustar twernertwernermaven2-core-2.2.1/maven-monitor/src/main/java/org/apache/0000755000175000017500000000000011250552240023023 5ustar twernertwernermaven2-core-2.2.1/maven-monitor/src/main/java/org/apache/maven/0000755000175000017500000000000011250552240024131 5ustar twernertwernermaven2-core-2.2.1/maven-monitor/src/main/java/org/apache/maven/monitor/0000755000175000017500000000000011250552240025620 5ustar twernertwernermaven2-core-2.2.1/maven-monitor/src/main/java/org/apache/maven/monitor/event/0000755000175000017500000000000011250552240026741 5ustar twernertwernermaven2-core-2.2.1/maven-monitor/src/main/java/org/apache/maven/monitor/event/EventDispatcher.java0000644000175000017500000000217310551365651032712 0ustar twernertwernerpackage org.apache.maven.monitor.event; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ /** * @author jdcasey */ public interface EventDispatcher { void addEventMonitor( EventMonitor monitor ); void dispatchStart( String event, String target ); void dispatchEnd( String event, String target ); void dispatchError( String event, String target, Throwable cause ); }maven2-core-2.2.1/maven-monitor/src/main/java/org/apache/maven/monitor/event/MavenEvents.java0000644000175000017500000000264110551365651032055 0ustar twernertwernerpackage org.apache.maven.monitor.event; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ /** * @author jdcasey */ public final class MavenEvents { public static final String PHASE_EXECUTION = "phase-execute"; public static final String MOJO_EXECUTION = "mojo-execute"; public static final String PROJECT_EXECUTION = "project-execute"; public static final String REACTOR_EXECUTION = "reactor-execute"; public static final String[] ALL_EVENTS = { PHASE_EXECUTION, MOJO_EXECUTION, PROJECT_EXECUTION, REACTOR_EXECUTION }; public static final String[] NO_EVENTS = {}; private MavenEvents() { } }././@LongLink0000000000000000000000000000016000000000000011562 Lustar rootrootmaven2-core-2.2.1/maven-monitor/src/main/java/org/apache/maven/monitor/event/AbstractSelectiveEventMonitor.javamaven2-core-2.2.1/maven-monitor/src/main/java/org/apache/maven/monitor/event/AbstractSelectiveEventM0000644000175000017500000000462010551365651033427 0ustar twernertwernerpackage org.apache.maven.monitor.event; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import java.util.Arrays; import java.util.List; /** * @author jdcasey */ public abstract class AbstractSelectiveEventMonitor implements EventMonitor { private List boundStartEvents; private List boundErrorEvents; private List boundEndEvents; protected AbstractSelectiveEventMonitor(String[] startEvents, String[] endEvents, String[] errorEvents) { this.boundStartEvents = Arrays.asList( startEvents ); this.boundEndEvents = Arrays.asList( endEvents ); this.boundErrorEvents = Arrays.asList( errorEvents ); } public final void startEvent( String eventName, String target, long timestamp ) { if( boundStartEvents.contains( eventName ) ) { doStartEvent( eventName, target, timestamp ); } } protected void doStartEvent( String eventName, String target, long timestamp ) { } public final void endEvent( String eventName, String target, long timestamp ) { if( boundEndEvents.contains( eventName ) ) { doEndEvent( eventName, target, timestamp ); } } protected void doEndEvent( String eventName, String target, long timestamp ) { } public final void errorEvent( String eventName, String target, long timestamp, Throwable cause ) { if( boundErrorEvents.contains( eventName ) ) { doErrorEvent( eventName, target, timestamp, cause ); } } protected void doErrorEvent( String eventName, String target, long timestamp, Throwable cause ) { } } maven2-core-2.2.1/maven-monitor/src/main/java/org/apache/maven/monitor/event/EventMonitor.java0000644000175000017500000000220110551365651032243 0ustar twernertwernerpackage org.apache.maven.monitor.event; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ /** * @author jdcasey */ public interface EventMonitor { void startEvent( String eventName, String target, long timestamp ); void endEvent( String eventName, String target, long timestamp ); void errorEvent( String eventName, String target, long timestamp, Throwable cause ); }././@LongLink0000000000000000000000000000015100000000000011562 Lustar rootrootmaven2-core-2.2.1/maven-monitor/src/main/java/org/apache/maven/monitor/event/DefaultEventDispatcher.javamaven2-core-2.2.1/maven-monitor/src/main/java/org/apache/maven/monitor/event/DefaultEventDispatcher.0000644000175000017500000000407610551365651033361 0ustar twernertwernerpackage org.apache.maven.monitor.event; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import java.util.ArrayList; import java.util.Iterator; import java.util.List; /** * @author jdcasey */ public class DefaultEventDispatcher implements EventDispatcher { private List eventMonitors = new ArrayList(); public void addEventMonitor( EventMonitor monitor ) { eventMonitors.add( monitor ); } public void dispatchStart( String event, String target ) { for ( Iterator it = eventMonitors.iterator(); it.hasNext(); ) { EventMonitor monitor = (EventMonitor) it.next(); monitor.startEvent( event, target, System.currentTimeMillis() ); } } public void dispatchEnd( String event, String target ) { for ( Iterator it = eventMonitors.iterator(); it.hasNext(); ) { EventMonitor monitor = (EventMonitor) it.next(); monitor.endEvent( event, target, System.currentTimeMillis() ); } } public void dispatchError( String event, String target, Throwable cause ) { for ( Iterator it = eventMonitors.iterator(); it.hasNext(); ) { EventMonitor monitor = (EventMonitor) it.next(); monitor.errorEvent( event, target, System.currentTimeMillis(), cause ); } } }maven2-core-2.2.1/maven-monitor/pom.xml0000644000175000017500000000235111236625310017700 0ustar twernertwerner 4.0.0 org.apache.maven maven 2.2.1 maven-monitor Maven Monitor maven2-core-2.2.1/maven-artifact-test/0000755000175000017500000000000011250552246017450 5ustar twernertwernermaven2-core-2.2.1/maven-artifact-test/src/0000755000175000017500000000000011250552246020237 5ustar twernertwernermaven2-core-2.2.1/maven-artifact-test/src/site/0000755000175000017500000000000011250552246021203 5ustar twernertwernermaven2-core-2.2.1/maven-artifact-test/src/site/site.xml0000644000175000017500000000013211002611514022652 0ustar twernertwerner maven2-core-2.2.1/maven-artifact-test/src/main/0000755000175000017500000000000011250552246021163 5ustar twernertwernermaven2-core-2.2.1/maven-artifact-test/src/main/java/0000755000175000017500000000000011250552246022104 5ustar twernertwernermaven2-core-2.2.1/maven-artifact-test/src/main/java/org/0000755000175000017500000000000011250552246022673 5ustar twernertwernermaven2-core-2.2.1/maven-artifact-test/src/main/java/org/apache/0000755000175000017500000000000011250552246024114 5ustar twernertwernermaven2-core-2.2.1/maven-artifact-test/src/main/java/org/apache/maven/0000755000175000017500000000000011250552246025222 5ustar twernertwernermaven2-core-2.2.1/maven-artifact-test/src/main/java/org/apache/maven/artifact/0000755000175000017500000000000011250552246027017 5ustar twernertwernermaven2-core-2.2.1/maven-artifact-test/src/main/java/org/apache/maven/artifact/test/0000755000175000017500000000000011250552246027776 5ustar twernertwerner././@LongLink0000000000000000000000000000015100000000000011562 Lustar rootrootmaven2-core-2.2.1/maven-artifact-test/src/main/java/org/apache/maven/artifact/test/ArtifactTestCase.javamaven2-core-2.2.1/maven-artifact-test/src/main/java/org/apache/maven/artifact/test/ArtifactTestCase.0000644000175000017500000000532611013631045033166 0ustar twernertwernerpackage org.apache.maven.artifact.test; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout; import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.artifact.repository.DefaultArtifactRepository; import org.apache.maven.settings.Settings; import org.apache.maven.settings.io.xpp3.SettingsXpp3Reader; import org.codehaus.plexus.PlexusTestCase; import org.codehaus.plexus.util.ReaderFactory; import java.io.File; /** * Test case that builds standard artifact stuff like repositories. * * @author Brett Porter * @version $Id: ArtifactTestCase.java 657432 2008-05-17 19:29:41Z hboutemy $ */ public abstract class ArtifactTestCase extends PlexusTestCase { private ArtifactRepository localRepository; protected File getLocalArtifactPath( Artifact artifact ) { return new File( localRepository.getBasedir(), localRepository.pathOf( artifact ) ); } protected void setUp() throws Exception { super.setUp(); String localRepo = System.getProperty( "maven.repo.local" ); if ( localRepo == null ) { File settingsFile = new File( System.getProperty( "user.home" ), ".m2/settings.xml" ); if ( settingsFile.exists() ) { Settings settings = new SettingsXpp3Reader().read( ReaderFactory.newXmlReader( settingsFile ) ); localRepo = settings.getLocalRepository(); } } if ( localRepo == null ) { localRepo = System.getProperty( "user.home" ) + "/.m2/repository"; } ArtifactRepositoryLayout repositoryLayout = (ArtifactRepositoryLayout) container.lookup( ArtifactRepositoryLayout.ROLE, "default" ); localRepository = new DefaultArtifactRepository( "local", "file://" + localRepo, repositoryLayout ); } } maven2-core-2.2.1/maven-artifact-test/pom.xml0000644000175000017500000000411011236625310020756 0ustar twernertwerner 4.0.0 org.apache.maven maven 2.2.1 maven-artifact-test Maven Artifact Test Helper Library junit junit 3.8.1 compile org.apache.maven maven-settings org.apache.maven maven-artifact-manager org.apache.maven maven-artifact org.codehaus.plexus plexus-container-default org.codehaus.plexus plexus-utils maven2-core-2.2.1/maven-settings/0000755000175000017500000000000011250552243016533 5ustar twernertwernermaven2-core-2.2.1/maven-settings/src/0000755000175000017500000000000011250552243017322 5ustar twernertwernermaven2-core-2.2.1/maven-settings/src/site/0000755000175000017500000000000011250552243020266 5ustar twernertwernermaven2-core-2.2.1/maven-settings/src/site/site.xml0000644000175000017500000000013211002611514021740 0ustar twernertwerner maven2-core-2.2.1/maven-settings/src/site/apt/0000755000175000017500000000000011250552243021052 5ustar twernertwernermaven2-core-2.2.1/maven-settings/src/site/apt/index.apt0000644000175000017500000000062310772004567022701 0ustar twernertwerner ----- Maven Settings ----- Vincent Siveton ----- 04 November 2006 ----- Maven Settings Model This is strictly the model for Maven settings. The following are generated from this model: * {{{apidocs/index.html}Java sources}} with Reader and Writers for the Xpp3 XML parser * A {{{settings.html}Descriptor Reference}} * An {{{ http://maven.apache.org/xsd/settings-1.0.0.xsd}XSD}} maven2-core-2.2.1/maven-settings/src/test/0000755000175000017500000000000011250552243020301 5ustar twernertwernermaven2-core-2.2.1/maven-settings/src/test/resources/0000755000175000017500000000000011250552243022313 5ustar twernertwernermaven2-core-2.2.1/maven-settings/src/test/resources/org/0000755000175000017500000000000011250552243023102 5ustar twernertwernermaven2-core-2.2.1/maven-settings/src/test/resources/org/apache/0000755000175000017500000000000011250552243024323 5ustar twernertwernermaven2-core-2.2.1/maven-settings/src/test/resources/org/apache/maven/0000755000175000017500000000000011250552243025431 5ustar twernertwernermaven2-core-2.2.1/maven-settings/src/test/resources/org/apache/maven/settings/0000755000175000017500000000000011250552243027271 5ustar twernertwerner././@LongLink0000000000000000000000000000015400000000000011565 Lustar rootrootmaven2-core-2.2.1/maven-settings/src/test/resources/org/apache/maven/settings/settings-one-active-proxy.xmlmaven2-core-2.2.1/maven-settings/src/test/resources/org/apache/maven/settings/settings-one-active-pr0000644000175000017500000000050611151254102033515 0ustar twernertwerner true http proxyuser proxypass proxy.host.net 80 local.net,some.host.com ././@LongLink0000000000000000000000000000015600000000000011567 Lustar rootrootmaven2-core-2.2.1/maven-settings/src/test/resources/org/apache/maven/settings/settings-one-inactive-proxy.xmlmaven2-core-2.2.1/maven-settings/src/test/resources/org/apache/maven/settings/settings-one-inactive-0000644000175000017500000000050711151254102033503 0ustar twernertwerner false http proxyuser proxypass proxy.host.net 80 local.net,some.host.com ././@LongLink0000000000000000000000000000014600000000000011566 Lustar rootrootmaven2-core-2.2.1/maven-settings/src/test/resources/org/apache/maven/settings/settings-no-proxies.xmlmaven2-core-2.2.1/maven-settings/src/test/resources/org/apache/maven/settings/settings-no-proxies.xm0000644000175000017500000000006211151254102033567 0ustar twernertwerner maven2-core-2.2.1/maven-settings/src/test/java/0000755000175000017500000000000011250552243021222 5ustar twernertwernermaven2-core-2.2.1/maven-settings/src/test/java/org/0000755000175000017500000000000011250552243022011 5ustar twernertwernermaven2-core-2.2.1/maven-settings/src/test/java/org/apache/0000755000175000017500000000000011250552243023232 5ustar twernertwernermaven2-core-2.2.1/maven-settings/src/test/java/org/apache/maven/0000755000175000017500000000000011250552243024340 5ustar twernertwernermaven2-core-2.2.1/maven-settings/src/test/java/org/apache/maven/settings/0000755000175000017500000000000011250552243026200 5ustar twernertwernermaven2-core-2.2.1/maven-settings/src/test/java/org/apache/maven/settings/SettingsTest.java0000644000175000017500000000215711151254102031501 0ustar twernertwernerpackage org.apache.maven.settings; import java.io.File; import junit.framework.TestCase; public class SettingsTest extends TestCase { private Settings settingsNoProxies; private Settings settingsOneInactiveProxy; private Settings settingsOneActiveProxy; protected void setUp() throws Exception { super.setUp(); // Read different settings files for proxy testing. DefaultMavenSettingsBuilder settingsBuilder = new DefaultMavenSettingsBuilder(); settingsNoProxies = settingsBuilder.buildSettings(new File("src/test/resources/org/apache/maven/settings/settings-no-proxies.xml"), false); settingsOneInactiveProxy = settingsBuilder.buildSettings(new File("src/test/resources/org/apache/maven/settings/settings-one-inactive-proxy.xml"), false); settingsOneActiveProxy = settingsBuilder.buildSettings(new File("src/test/resources/org/apache/maven/settings/settings-one-active-proxy.xml"), false); } public void testProxySettings() { assertNull(settingsNoProxies.getActiveProxy()); assertNull(settingsOneInactiveProxy.getActiveProxy()); assertNotNull(settingsOneActiveProxy.getActiveProxy()); } } maven2-core-2.2.1/maven-settings/src/test/java/org/apache/maven/settings/SettingsUtilsTest.java0000644000175000017500000000351610767713554032551 0ustar twernertwernerpackage org.apache.maven.settings; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import java.util.List; import junit.framework.TestCase; public class SettingsUtilsTest extends TestCase { public void testShouldAppendRecessivePluginGroupIds() { Settings dominant = new Settings(); dominant.addPluginGroup( "org.apache.maven.plugins" ); dominant.addPluginGroup( "org.codehaus.modello" ); dominant.setRuntimeInfo(new RuntimeInfo(dominant)); Settings recessive = new Settings(); recessive.addPluginGroup( "org.codehaus.plexus" ); recessive.setRuntimeInfo(new RuntimeInfo(recessive)); SettingsUtils.merge( dominant, recessive, Settings.GLOBAL_LEVEL ); List pluginGroups = dominant.getPluginGroups(); assertNotNull( pluginGroups ); assertEquals( 3, pluginGroups.size() ); assertEquals( "org.apache.maven.plugins", pluginGroups.get( 0 ) ); assertEquals( "org.codehaus.modello", pluginGroups.get( 1 ) ); assertEquals( "org.codehaus.plexus", pluginGroups.get( 2 ) ); } } maven2-core-2.2.1/maven-settings/src/main/0000755000175000017500000000000011250552243020246 5ustar twernertwernermaven2-core-2.2.1/maven-settings/src/main/mdo/0000755000175000017500000000000011250552243021025 5ustar twernertwernermaven2-core-2.2.1/maven-settings/src/main/mdo/settings.mdo0000644000175000017500000007664111230603666023410 0ustar twernertwerner settings Settings This is a reference for the user-specific configuration for Maven.

Includes things that should not be distributed with the pom.xml file, such as developer identity, along with local settings, like proxy information.

The default location for the settings file is ~/.m2/settings.xml

An XSD is available at:

]]>
package org.apache.maven.settings TrackableBase 1.0.0 common base class that contains code to track the source for this instance (USER|GLOBAL) 1.0.0 IdentifiableBase TrackableBase 1.0.0 Mirror, Profile, Proxy and Server. ]]> id 1.0.0 String default true Settings 1.0.0 TrackableBase Root element of the user configuration file. localRepository 1.0.0 true String interactiveMode 1.0.0 boolean true usePluginRegistry 1.0.0 boolean false offline 1.0.0 false boolean false proxies 1.0.0 Proxy * servers 1.0.0 Server * mirrors 1.0.0 Configuration of download mirrors for repositories. Mirror * profiles 1.0.0 Profile * activeProfiles 1.0.0 String * pluginGroups 1.0.0 List of groupIds to search for a plugin when that plugin groupId is not explicitly provided. String * 1.0.0 activeProxy field to null */ public void flushActiveProxy() { this.activeProxy = null; } /** * @return the first active proxy */ public synchronized Proxy getActiveProxy() { if(activeProxy == null) { java.util.List proxies = getProxies(); if ( proxies != null && !proxies.isEmpty() ) { for ( java.util.Iterator it = proxies.iterator(); it.hasNext(); ) { Proxy proxy = (Proxy) it.next(); if ( proxy.isActive() ) { activeProxy = proxy; break; } } } } return activeProxy; } public Server getServer( String serverId ) { Server match = null; java.util.List servers = getServers(); if ( servers != null && serverId != null ) { for ( java.util.Iterator it = servers.iterator(); it.hasNext(); ) { Server server = (Server) it.next(); if ( serverId.equals( server.getId() ) ) { match = server; break; } } } return match; } @Deprecated public Mirror getMirrorOf( String repositoryId ) { Mirror match = null; java.util.List mirrors = getMirrors(); if ( mirrors != null && repositoryId != null ) { for ( java.util.Iterator it = mirrors.iterator(); it.hasNext(); ) { Mirror mirror = (Mirror) it.next(); if ( repositoryId.equals( mirror.getMirrorOf() ) ) { match = mirror; break; } } } return match; } private java.util.Map profileMap; /** * Reset the profileMap field to null */ public void flushProfileMap() { this.profileMap = null; } /** * @return a Map of profiles field with Profile#getId() as key * @see org.apache.maven.settings.Profile#getId() */ public java.util.Map getProfilesAsMap() { if ( profileMap == null ) { profileMap = new java.util.LinkedHashMap(); if ( getProfiles() != null ) { for ( java.util.Iterator it = getProfiles().iterator(); it.hasNext(); ) { Profile profile = (Profile) it.next(); profileMap.put( profile.getId(), profile ); } } } return profileMap; } private RuntimeInfo runtimeInfo; public void setRuntimeInfo( RuntimeInfo runtimeInfo ) { this.runtimeInfo = runtimeInfo; } public RuntimeInfo getRuntimeInfo() { return runtimeInfo; } ]]> Proxy 1.0.0 IdentifiableBase <proxy> element contains informations required to a proxy settings. ]]> active 1.0.0 false true boolean protocol 1.0.0 String http username 1.0.0 String password 1.0.0 String port 1.0.0 int 8080 host 1.0.0 String true nonProxyHosts 1.0.0 String Server 1.0.0 IdentifiableBase <server> element contains informations required to a server settings. ]]> username 1.0.0 String password 1.0.0 String privateKey 1.0.0 String passphrase 1.0.0 String filePermissions 1.0.0 String directoryPermissions 1.0.0 String configuration DOM Mirror 1.0.0 IdentifiableBase A download mirror for a given repository. mirrorOf true 1.0.0 String The server ID of the repository being mirrored, eg "central". This MUST NOT match the mirror id. name false 1.0.0 String The optional name that describes the mirror. url true 1.0.0 String The URL of the mirror repository. Profile 1.0.0 IdentifiableBase activation 1.0.0 Activation properties Extended configuration specific to this profile goes here. Contents take the form of <property.name>property.value</property.name> Properties String * repositories 1.0.0 Repository * pluginRepositories 1.0.0 Repository * Activation 1.0.0 activeByDefault 1.0.0 boolean Flag specifying whether this profile is active as a default. jdk 1.0.0 String os 1.0.0 ActivationOS property 1.0.0 ActivationProperty file 1.0.0 ActivationFile RepositoryBase 1.0.0 id 1.0.0 String name 1.0.0 String url 1.0.0 String layout 1.0.0 The type of layout this repository uses for locating and storing artifacts - can be "legacy" or "default". String default 1.0.0 Repository RepositoryBase 1.0.0 Repository contains the information needed for establishing connections with remote repoistory releases 1.0.0 How to handle downloading of releases from this repository RepositoryPolicy snapshots 1.0.0 How to handle downloading of snapshots from this repository RepositoryPolicy 1.0.0 RepositoryPolicy 1.0.0 Download policy enabled 1.0.0 Whether to use this repository for downloading this type of artifact. boolean true updatePolicy 1.0.0 The frequency for downloading updates - can be "always", "daily" (default), "interval:XXX" (in minutes) or "never" (only if it doesn't exist locally). String checksumPolicy 1.0.0 What to do when verification of an artifact checksum fails - warn, fail, etc. Valid values are "fail" or "warn". String ActivationProperty 1.0.0 name 1.0.0 String true The name of the property to be used to activate a profile. value 1.0.0 String The value of the property to be used to activate a profile. ActivationOS 1.0.0 name 1.0.0 String The name of the OS to be used to activate a profile. family 1.0.0 String The general family of the OS to be used to activate a profile (e.g. 'windows') arch 1.0.0 String The architecture of the OS to be used to activate a profile. version 1.0.0 String The version of the OS to be used to activate a profile. ActivationFile 1.0.0 missing 1.0.0 String The name of the file that should be missing to activate a profile. exists 1.0.0 String The name of the file that should exist to activate a profile.
maven2-core-2.2.1/maven-settings/src/main/resources/0000755000175000017500000000000011250552243022260 5ustar twernertwernermaven2-core-2.2.1/maven-settings/src/main/resources/META-INF/0000755000175000017500000000000011250552243023420 5ustar twernertwernermaven2-core-2.2.1/maven-settings/src/main/resources/META-INF/plexus/0000755000175000017500000000000011250552243024740 5ustar twernertwernermaven2-core-2.2.1/maven-settings/src/main/resources/META-INF/plexus/components.xml0000644000175000017500000000231610772004567027662 0ustar twernertwerner org.apache.maven.settings.MavenSettingsBuilder org.apache.maven.settings.DefaultMavenSettingsBuilder ${maven.home}/conf/settings.xml ${user.home}/.m2/settings.xml maven2-core-2.2.1/maven-settings/src/main/java/0000755000175000017500000000000011250552243021167 5ustar twernertwernermaven2-core-2.2.1/maven-settings/src/main/java/org/0000755000175000017500000000000011250552243021756 5ustar twernertwernermaven2-core-2.2.1/maven-settings/src/main/java/org/apache/0000755000175000017500000000000011250552243023177 5ustar twernertwernermaven2-core-2.2.1/maven-settings/src/main/java/org/apache/maven/0000755000175000017500000000000011250552243024305 5ustar twernertwernermaven2-core-2.2.1/maven-settings/src/main/java/org/apache/maven/settings/0000755000175000017500000000000011250552243026145 5ustar twernertwernermaven2-core-2.2.1/maven-settings/src/main/java/org/apache/maven/settings/MavenSettingsBuilder.java0000644000175000017500000000630310767713554033130 0ustar twernertwernerpackage org.apache.maven.settings; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import org.codehaus.plexus.util.xml.pull.XmlPullParserException; import java.io.File; import java.io.IOException; /** * Builder for the user or global settings. By default, the settings files are located: *
    *
  • user settings: ${user.home}/settings.xml
  • *
  • global settings: ${maven.home}/conf/settings.xml
  • *
* * You could also use system properties to specify the path for user and global settings: *
    *
  • user settings is defined by org.apache.maven.user-settings
  • *
  • global settings is defined by org.apache.maven.global-settings
  • *
* * @author jdcasey * @version $Id: MavenSettingsBuilder.java 638306 2008-03-18 10:20:28Z bentmann $ */ public interface MavenSettingsBuilder { String ROLE = MavenSettingsBuilder.class.getName(); String ALT_USER_SETTINGS_XML_LOCATION = "org.apache.maven.user-settings"; String ALT_GLOBAL_SETTINGS_XML_LOCATION = "org.apache.maven.global-settings"; String ALT_LOCAL_REPOSITORY_LOCATION = "maven.repo.local"; /** * @return a Settings object from the user settings file. * @throws IOException if any * @throws XmlPullParserException if any */ Settings buildSettings() throws IOException, XmlPullParserException; /** * @param useCachedSettings if true, doesn't reload the user settings * @return a Settings object from the user settings file. * @throws IOException if any * @throws XmlPullParserException if any */ Settings buildSettings( boolean useCachedSettings ) throws IOException, XmlPullParserException; /** * @param userSettingsFile a given user settings file * @return a Settings object from the user settings file. * @throws IOException if any * @throws XmlPullParserException if any */ Settings buildSettings( File userSettingsFile ) throws IOException, XmlPullParserException; /** * @param userSettingsFile a given user settings file * @param useCachedSettings if true, doesn't reload the user settings * @return a Settings object from the user settings file. * @throws IOException if any * @throws XmlPullParserException if any */ Settings buildSettings( File userSettingsFile, boolean useCachedSettings ) throws IOException, XmlPullParserException; } maven2-core-2.2.1/maven-settings/src/main/java/org/apache/maven/settings/RuntimeInfo.java0000644000175000017500000001033110767713554031265 0ustar twernertwernerpackage org.apache.maven.settings; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import java.io.File; import java.util.HashMap; import java.util.Map; /** * To handle runtime informations like local repository or profiles. * * @version $Id: RuntimeInfo.java 638306 2008-03-18 10:20:28Z bentmann $ */ public class RuntimeInfo { private File file; // using Boolean for 3VL (null for not-set, otherwise override with value) private Boolean pluginUpdateForced; // using Boolean for 3VL (null, true-to-all, false-to-all) private Boolean applyToAllPluginUpdates; // private boolean pluginRegistryActive = true; // using Boolean for 3VL (null for not-set, otherwise override with value) // private Boolean checkLatest; private Map activeProfileToSourceLevel = new HashMap(); private String localRepositorySourceLevel = TrackableBase.USER_LEVEL; private Map pluginGroupIdSourceLevels = new HashMap(); private final Settings settings; /** * @param settings */ public RuntimeInfo( Settings settings ) { this.settings = settings; } /** * @param file */ public void setFile( File file ) { this.file = file; } /** * @return */ public File getFile() { return file; } /** * @param pluginUpdateForced */ public void setPluginUpdateOverride( Boolean pluginUpdateForced ) { this.pluginUpdateForced = pluginUpdateForced; } /** * @return */ public Boolean getPluginUpdateOverride() { return pluginUpdateForced; } /** * @return */ public Boolean getApplyToAllPluginUpdates() { return applyToAllPluginUpdates; } /** * @param applyToAll */ public void setApplyToAllPluginUpdates( Boolean applyToAll ) { this.applyToAllPluginUpdates = applyToAll; } /** * @param activeProfile * @param sourceLevel */ public void setActiveProfileSourceLevel( String activeProfile, String sourceLevel ) { activeProfileToSourceLevel.put( activeProfile, sourceLevel ); } /** * @param activeProfile * @return */ public String getSourceLevelForActiveProfile( String activeProfile ) { String sourceLevel = (String) activeProfileToSourceLevel.get( activeProfile ); if ( sourceLevel != null ) { return sourceLevel; } else { return settings.getSourceLevel(); } } /** * @param pluginGroupId * @param sourceLevel */ public void setPluginGroupIdSourceLevel( String pluginGroupId, String sourceLevel ) { pluginGroupIdSourceLevels.put( pluginGroupId, sourceLevel ); } /** * @param pluginGroupId * @return */ public String getSourceLevelForPluginGroupId( String pluginGroupId ) { String sourceLevel = (String) pluginGroupIdSourceLevels.get( pluginGroupId ); if ( sourceLevel != null ) { return sourceLevel; } else { return settings.getSourceLevel(); } } /** * @param localRepoSourceLevel */ public void setLocalRepositorySourceLevel( String localRepoSourceLevel ) { this.localRepositorySourceLevel = localRepoSourceLevel; } /** * @return */ public String getLocalRepositorySourceLevel() { return localRepositorySourceLevel; } } ././@LongLink0000000000000000000000000000015200000000000011563 Lustar rootrootmaven2-core-2.2.1/maven-settings/src/main/java/org/apache/maven/settings/DefaultMavenSettingsBuilder.javamaven2-core-2.2.1/maven-settings/src/main/java/org/apache/maven/settings/DefaultMavenSettingsBuilder0000644000175000017500000002477111151165306033506 0ustar twernertwernerpackage org.apache.maven.settings; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import org.apache.maven.settings.io.xpp3.SettingsXpp3Reader; import org.codehaus.plexus.interpolation.EnvarBasedValueSource; import org.codehaus.plexus.interpolation.RegexBasedInterpolator; import org.codehaus.plexus.logging.AbstractLogEnabled; import org.codehaus.plexus.personality.plexus.lifecycle.phase.Initializable; import org.codehaus.plexus.util.IOUtil; import org.codehaus.plexus.util.ReaderFactory; import org.codehaus.plexus.util.StringUtils; import org.codehaus.plexus.util.xml.pull.XmlPullParserException; import java.io.File; import java.io.IOException; import java.io.Reader; import java.io.StringReader; import java.io.StringWriter; import java.util.Iterator; import java.util.List; /** * @author jdcasey * @version $Id: DefaultMavenSettingsBuilder.java 747683 2009-02-25 06:52:54Z brett $ */ public class DefaultMavenSettingsBuilder extends AbstractLogEnabled implements MavenSettingsBuilder, Initializable { public static final String userHome = System.getProperty( "user.home" ); /** * @configuration */ private String userSettingsPath; /** * @configuration */ private String globalSettingsPath; private File userSettingsFile; private File globalSettingsFile; private Settings loadedSettings; // ---------------------------------------------------------------------- // Component Lifecycle // ---------------------------------------------------------------------- public void initialize() { userSettingsFile = getFile( userSettingsPath, "user.home", MavenSettingsBuilder.ALT_USER_SETTINGS_XML_LOCATION ); globalSettingsFile = getFile( globalSettingsPath, "maven.home", MavenSettingsBuilder.ALT_GLOBAL_SETTINGS_XML_LOCATION ); getLogger().debug( "Building Maven global-level settings from: '" + globalSettingsFile.getAbsolutePath() + "'" ); getLogger().debug( "Building Maven user-level settings from: '" + userSettingsFile.getAbsolutePath() + "'" ); } // ---------------------------------------------------------------------- // MavenProfilesBuilder Implementation // ---------------------------------------------------------------------- private Settings readSettings( File settingsFile ) throws IOException, XmlPullParserException { Settings settings = null; if ( settingsFile != null && settingsFile.exists() && settingsFile.isFile() ) { Reader reader = null; try { reader = ReaderFactory.newXmlReader( settingsFile ); StringWriter sWriter = new StringWriter(); IOUtil.copy( reader, sWriter ); String rawInput = sWriter.toString(); try { RegexBasedInterpolator interpolator = new RegexBasedInterpolator(); interpolator.addValueSource( new EnvarBasedValueSource() ); rawInput = interpolator.interpolate( rawInput, "settings" ); } catch ( Exception e ) { getLogger().warn( "Failed to initialize environment variable resolver. Skipping environment substitution in settings." ); getLogger().debug( "Failed to initialize envar resolver. Skipping resolution.", e ); } StringReader sReader = new StringReader( rawInput ); SettingsXpp3Reader modelReader = new SettingsXpp3Reader(); settings = modelReader.read( sReader, true ); RuntimeInfo rtInfo = new RuntimeInfo( settings ); rtInfo.setFile( settingsFile ); settings.setRuntimeInfo( rtInfo ); } finally { IOUtil.close( reader ); } } return settings; } public Settings buildSettings() throws IOException, XmlPullParserException { return buildSettings( userSettingsFile ); } public Settings buildSettings( boolean useCachedSettings ) throws IOException, XmlPullParserException { return buildSettings( userSettingsFile, useCachedSettings ); } public Settings buildSettings( File userSettingsFile ) throws IOException, XmlPullParserException { return buildSettings( userSettingsFile, true ); } public Settings buildSettings( File userSettingsFile, boolean useCachedSettings ) throws IOException, XmlPullParserException { if ( !useCachedSettings || loadedSettings == null ) { Settings globalSettings = readSettings( globalSettingsFile ); Settings userSettings = readSettings( userSettingsFile ); if ( globalSettings == null ) { globalSettings = new Settings(); } if ( userSettings == null ) { userSettings = new Settings(); userSettings.setRuntimeInfo( new RuntimeInfo( userSettings ) ); } SettingsUtils.merge( userSettings, globalSettings, TrackableBase.GLOBAL_LEVEL ); activateDefaultProfiles( userSettings ); setLocalRepository( userSettings ); loadedSettings = userSettings; } return loadedSettings; } private void activateDefaultProfiles( Settings settings ) { List activeProfiles = settings.getActiveProfiles(); for ( Iterator profiles = settings.getProfiles().iterator(); profiles.hasNext(); ) { Profile profile = (Profile) profiles.next(); if ( profile.getActivation() != null && profile.getActivation().isActiveByDefault() && !activeProfiles.contains( profile.getId() ) ) { settings.addActiveProfile( profile.getId() ); } } } private void setLocalRepository( Settings userSettings ) { // try using the local repository specified on the command line... String localRepository = System.getProperty( MavenSettingsBuilder.ALT_LOCAL_REPOSITORY_LOCATION ); // otherwise, use the one in settings.xml if ( localRepository == null || localRepository.length() < 1 ) { localRepository = userSettings.getLocalRepository(); } // if all of the above are missing, default to ~/.m2/repository. if ( localRepository == null || localRepository.length() < 1 ) { File mavenUserConfigurationDirectory = new File( userHome, ".m2" ); if ( !mavenUserConfigurationDirectory.exists() ) { if ( !mavenUserConfigurationDirectory.mkdirs() ) { //throw a configuration exception } } localRepository = new File( mavenUserConfigurationDirectory, "repository" ).getAbsolutePath(); } // for the special case of a drive-relative Windows path, make sure it's absolute to save plugins from trouble File file = new File( localRepository ); if ( !file.isAbsolute() && file.getPath().startsWith( File.separator ) ) { localRepository = file.getAbsolutePath(); } userSettings.setLocalRepository( localRepository ); } private File getFile( String pathPattern, String basedirSysProp, String altLocationSysProp ) { // ------------------------------------------------------------------------------------- // Alright, here's the justification for all the regexp wizardry below... // // Continuum and other server-like apps may need to locate the user-level and // global-level settings somewhere other than ${user.home} and ${maven.home}, // respectively. Using a simple replacement of these patterns will allow them // to specify the absolute path to these files in a customized components.xml // file. Ideally, we'd do full pattern-evaluation against the sysprops, but this // is a first step. There are several replacements below, in order to normalize // the path character before we operate on the string as a regex input, and // in order to avoid surprises with the File construction... // ------------------------------------------------------------------------------------- String path = System.getProperty( altLocationSysProp ); if ( StringUtils.isEmpty( path ) ) { // TODO: This replacing shouldn't be necessary as user.home should be in the // context of the container and thus the value would be interpolated by Plexus String basedir = System.getProperty( basedirSysProp ); if ( basedir == null ) { basedir = System.getProperty( "user.dir" ); } basedir = basedir.replaceAll( "\\\\", "/" ); basedir = basedir.replaceAll( "\\$", "\\\\\\$" ); path = pathPattern.replaceAll( "\\$\\{" + basedirSysProp + "\\}", basedir ); path = path.replaceAll( "\\\\", "/" ); // --------------------------------------------------------------------------------- // I'm not sure if this last regexp was really intended to disallow the usage of // network paths as user.home directory. Unfortunately it did. I removed it and // have not detected any problems yet. // --------------------------------------------------------------------------------- // path = path.replaceAll( "//", "/" ); return new File( path ).getAbsoluteFile(); } else { return new File( path ).getAbsoluteFile(); } } } maven2-core-2.2.1/maven-settings/src/main/java/org/apache/maven/settings/SettingsUtils.java0000644000175000017500000002435311045562224031642 0ustar twernertwernerpackage org.apache.maven.settings; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import org.apache.maven.model.ActivationFile; import org.codehaus.plexus.util.StringUtils; import java.util.ArrayList; import java.util.HashMap; import java.util.Iterator; import java.util.List; import java.util.Map; /** * Several convenience methods to handle settings * * @author Vincent Siveton * @version $Id: SettingsUtils.java 682323 2008-08-04 11:14:28Z vsiveton $ */ public final class SettingsUtils { private SettingsUtils() { // don't allow construction. } /** * @param dominant * @param recessive * @param recessiveSourceLevel */ public static void merge( Settings dominant, Settings recessive, String recessiveSourceLevel ) { if ( dominant == null || recessive == null ) { return; } recessive.setSourceLevel( recessiveSourceLevel ); List dominantActiveProfiles = dominant.getActiveProfiles(); List recessiveActiveProfiles = recessive.getActiveProfiles(); if ( recessiveActiveProfiles != null ) { if ( dominantActiveProfiles == null ) { dominantActiveProfiles = new ArrayList(); dominant.setActiveProfiles( dominantActiveProfiles ); } for ( Iterator it = recessiveActiveProfiles.iterator(); it.hasNext(); ) { String profileId = (String) it.next(); if ( !dominantActiveProfiles.contains( profileId ) ) { dominantActiveProfiles.add( profileId ); dominant.getRuntimeInfo().setActiveProfileSourceLevel( profileId, recessiveSourceLevel ); } } } List dominantPluginGroupIds = dominant.getPluginGroups(); List recessivePluginGroupIds = recessive.getPluginGroups(); if ( recessivePluginGroupIds != null ) { if ( dominantPluginGroupIds == null ) { dominantPluginGroupIds = new ArrayList(); dominant.setPluginGroups( dominantPluginGroupIds ); } for ( Iterator it = recessivePluginGroupIds.iterator(); it.hasNext(); ) { String pluginGroupId = (String) it.next(); if ( !dominantPluginGroupIds.contains( pluginGroupId ) ) { dominantPluginGroupIds.add( pluginGroupId ); dominant.getRuntimeInfo().setPluginGroupIdSourceLevel( pluginGroupId, recessiveSourceLevel ); } } } if ( StringUtils.isEmpty( dominant.getLocalRepository() ) ) { dominant.setLocalRepository( recessive.getLocalRepository() ); dominant.getRuntimeInfo().setLocalRepositorySourceLevel( recessiveSourceLevel ); } shallowMergeById( dominant.getMirrors(), recessive.getMirrors(), recessiveSourceLevel ); shallowMergeById( dominant.getServers(), recessive.getServers(), recessiveSourceLevel ); shallowMergeById( dominant.getProxies(), recessive.getProxies(), recessiveSourceLevel ); shallowMergeById( dominant.getProfiles(), recessive.getProfiles(), recessiveSourceLevel ); } /** * @param dominant * @param recessive * @param recessiveSourceLevel */ private static void shallowMergeById( List dominant, List recessive, String recessiveSourceLevel ) { Map dominantById = mapById( dominant ); for ( Iterator it = recessive.iterator(); it.hasNext(); ) { IdentifiableBase identifiable = (IdentifiableBase) it.next(); if ( !dominantById.containsKey( identifiable.getId() ) ) { identifiable.setSourceLevel( recessiveSourceLevel ); dominant.add( identifiable ); } } } /** * @param identifiables * @return a map */ private static Map mapById( List identifiables ) { Map byId = new HashMap(); for ( Iterator it = identifiables.iterator(); it.hasNext(); ) { IdentifiableBase identifiable = (IdentifiableBase) it.next(); byId.put( identifiable.getId(), identifiable ); } return byId; } /** * @param settingsProfile * @return a profile */ public static org.apache.maven.model.Profile convertFromSettingsProfile( Profile settingsProfile ) { org.apache.maven.model.Profile profile = new org.apache.maven.model.Profile(); profile.setId( settingsProfile.getId() ); profile.setSource( "settings.xml" ); Activation settingsActivation = settingsProfile.getActivation(); if ( settingsActivation != null ) { org.apache.maven.model.Activation activation = new org.apache.maven.model.Activation(); activation.setActiveByDefault( settingsActivation.isActiveByDefault() ); activation.setJdk( settingsActivation.getJdk() ); ActivationProperty settingsProp = settingsActivation.getProperty(); if ( settingsProp != null ) { org.apache.maven.model.ActivationProperty prop = new org.apache.maven.model.ActivationProperty(); prop.setName( settingsProp.getName() ); prop.setValue( settingsProp.getValue() ); activation.setProperty( prop ); } ActivationOS settingsOs = settingsActivation.getOs(); if ( settingsOs != null ) { org.apache.maven.model.ActivationOS os = new org.apache.maven.model.ActivationOS(); os.setArch( settingsOs.getArch() ); os.setFamily( settingsOs.getFamily() ); os.setName( settingsOs.getName() ); os.setVersion( settingsOs.getVersion() ); activation.setOs( os ); } org.apache.maven.settings.ActivationFile settingsFile = settingsActivation.getFile(); if ( settingsFile != null ) { ActivationFile file = new ActivationFile(); file.setExists( settingsFile.getExists() ); file.setMissing( settingsFile.getMissing() ); activation.setFile( file ); } profile.setActivation( activation ); } profile.setProperties( settingsProfile.getProperties() ); List repos = settingsProfile.getRepositories(); if ( repos != null ) { for ( Iterator it = repos.iterator(); it.hasNext(); ) { profile.addRepository( convertFromSettingsRepository( (Repository) it.next() ) ); } } List pluginRepos = settingsProfile.getPluginRepositories(); if ( pluginRepos != null ) { for ( Iterator it = pluginRepos.iterator(); it.hasNext(); ) { profile.addPluginRepository( convertFromSettingsRepository( (Repository) it.next() ) ); } } return profile; } /** * @param settingsRepo * @return a repository */ private static org.apache.maven.model.Repository convertFromSettingsRepository( Repository settingsRepo ) { org.apache.maven.model.Repository repo = new org.apache.maven.model.Repository(); repo.setId( settingsRepo.getId() ); repo.setLayout( settingsRepo.getLayout() ); repo.setName( settingsRepo.getName() ); repo.setUrl( settingsRepo.getUrl() ); if ( settingsRepo.getSnapshots() != null ) { repo.setSnapshots( convertRepositoryPolicy( settingsRepo.getSnapshots() ) ); } if ( settingsRepo.getReleases() != null ) { repo.setReleases( convertRepositoryPolicy( settingsRepo.getReleases() ) ); } return repo; } /** * @param settingsPolicy * @return a RepositoryPolicy */ private static org.apache.maven.model.RepositoryPolicy convertRepositoryPolicy( RepositoryPolicy settingsPolicy ) { org.apache.maven.model.RepositoryPolicy policy = new org.apache.maven.model.RepositoryPolicy(); policy.setEnabled( settingsPolicy.isEnabled() ); policy.setUpdatePolicy( settingsPolicy.getUpdatePolicy() ); policy.setChecksumPolicy( settingsPolicy.getChecksumPolicy() ); return policy; } /** * @param settings could be null * @return a new instance of settings or null if settings was null. */ public static Settings copySettings( Settings settings ) { if ( settings == null ) { return null; } Settings clone = new Settings(); clone.setActiveProfiles( settings.getActiveProfiles() ); clone.setInteractiveMode( settings.isInteractiveMode() ); clone.setLocalRepository( settings.getLocalRepository() ); clone.setMirrors( settings.getMirrors() ); clone.setModelEncoding( settings.getModelEncoding() ); clone.setOffline( settings.isOffline() ); clone.setPluginGroups( settings.getPluginGroups() ); clone.setProfiles( settings.getProfiles() ); clone.setProxies( settings.getProxies() ); clone.setRuntimeInfo( settings.getRuntimeInfo() ); clone.setServers( settings.getServers() ); clone.setSourceLevel( settings.getSourceLevel() ); clone.setUsePluginRegistry( settings.isUsePluginRegistry() ); return clone; } } maven2-core-2.2.1/maven-settings/pom.xml0000644000175000017500000000420311236625310020047 0ustar twernertwerner 4.0.0 org.apache.maven maven 2.2.1 maven-settings Maven Local Settings Model org.apache.maven maven-model org.codehaus.plexus plexus-interpolation org.codehaus.plexus plexus-utils org.codehaus.plexus plexus-container-default org.codehaus.modello modello-maven-plugin 1.0.0 src/main/mdo/settings.mdo maven2-core-2.2.1/maven-repository-metadata/0000755000175000017500000000000011250552241020666 5ustar twernertwernermaven2-core-2.2.1/maven-repository-metadata/src/0000755000175000017500000000000011250552241021455 5ustar twernertwernermaven2-core-2.2.1/maven-repository-metadata/src/site/0000755000175000017500000000000011250552241022421 5ustar twernertwernermaven2-core-2.2.1/maven-repository-metadata/src/site/site.xml0000644000175000017500000000013211002611514024075 0ustar twernertwerner maven2-core-2.2.1/maven-repository-metadata/src/site/apt/0000755000175000017500000000000011250552241023205 5ustar twernertwernermaven2-core-2.2.1/maven-repository-metadata/src/site/apt/index.apt0000644000175000017500000000071611175144556025042 0ustar twernertwerner ----- Maven Repository Metadata Model ----- Hervé Boutemy ----- 2009-04-26 ----- Maven Repository Metadata Model This is strictly the model for Maven Repository Metadata, so really just plain objects. The following are generated from this model: * {{{apidocs/index.html}Java sources}} with Reader and Writers for the Xpp3 XML parser, to read and write <<>> files * A {{{repository-metadata.html}Descriptor Reference}} maven2-core-2.2.1/maven-repository-metadata/src/main/0000755000175000017500000000000011250552241022401 5ustar twernertwernermaven2-core-2.2.1/maven-repository-metadata/src/main/mdo/0000755000175000017500000000000011250552241023160 5ustar twernertwernermaven2-core-2.2.1/maven-repository-metadata/src/main/mdo/plugins.mdo0000644000175000017500000000606311146611627025357 0ustar twernertwerner plugin-map PluginMapping Mappings for searching for a plugin within a particular groupId. package org.apache.maven.plugin.mapping PluginMap 1.0.0 Root model class, containing various mappings for plugins in this group. groupId 1.0.0 String true The groupId for plugins mapped in this file. plugins 1.0.0 true The set of plugin mappings MappedPlugin * MappedPlugin 1.0.0 Mapping information for a single plugin within this group NOTE: plugin version is _NOT_ included here, since it is resolved using a separate algorithm. prefix String true 1.0.0 The plugin invocation prefix (i.e. eclipse for eclipse:eclipse) artifactId String true 1.0.0 The plugin artifactId maven2-core-2.2.1/maven-repository-metadata/src/main/mdo/metadata.mdo0000644000175000017500000002540211175150337025452 0ustar twernertwerner repository-metadata Metadata Per-directory repository metadata. package org.apache.maven.artifact.repository.metadata Metadata 1.0.0 groupId 1.0.0 String The groupId that this directory represents, if any. artifactId 1.0.0 String The artifactId that this directory represents, if any. version 1.0.0 String The version that this directory represents, if any. versioning 1.0.0 Versioning Versioning information for the artifact. plugins 1.0.0 The set of plugin mappings for the group. Plugin * 1.0.0 = 0 ) { changed = true; v.setLastUpdated( versioning.getLastUpdated() ); if ( versioning.getRelease() != null ) { changed = true; v.setRelease( versioning.getRelease() ); } if ( versioning.getLatest() != null ) { changed = true; v.setLatest( versioning.getLatest() ); } Snapshot s = v.getSnapshot(); Snapshot snapshot = versioning.getSnapshot(); if ( snapshot != null ) { if ( s == null ) { s = new Snapshot(); v.setSnapshot( s ); changed = true; } // overwrite if ( s.getTimestamp() == null ? snapshot.getTimestamp() != null : !s.getTimestamp().equals( snapshot.getTimestamp() ) ) { s.setTimestamp( snapshot.getTimestamp() ); changed = true; } if ( s.getBuildNumber() != snapshot.getBuildNumber() ) { s.setBuildNumber( snapshot.getBuildNumber() ); changed = true; } if ( s.isLocalCopy() != snapshot.isLocalCopy() ) { s.setLocalCopy( snapshot.isLocalCopy() ); changed = true; } } } } return changed; } ]]> Versioning 1.0.0 Versioning information for an artifact. latest 1.0.0 String What the latest version in the directory is, including snapshots. release 1.0.0 String What the latest version in the directory is, of the releases. snapshot 1.0.0 Snapshot The current snapshot data in use for this version. versions 1.0.0 Versions available for the artifact. String * lastUpdated 1.0.0 String When the metadata was last updated. 1.0.0 public void updateTimestamp() { setLastUpdatedTimestamp( new java.util.Date() ); } public void setLastUpdatedTimestamp( java.util.Date date ) { java.util.TimeZone timezone = java.util.TimeZone.getTimeZone( "UTC" ); java.text.DateFormat fmt = new java.text.SimpleDateFormat( "yyyyMMddHHmmss" ); fmt.setTimeZone( timezone ); setLastUpdated( fmt.format( date ) ); } Snapshot 1.0.0 Snapshot data for the current version. timestamp 1.0.0 The time it was deployed. String buildNumber 1.0.0 The incremental build number. int localCopy 1.0.0 Whether to use a local copy instead (with filename that includes the base version). boolean false Plugin 1.0.0 Mapping information for a single plugin within this group. NOTE: plugin version is _NOT_ included here, since it is resolved using a separate algorithm. name String true 1.0.0 Display name for the plugin. prefix String true 1.0.0 The plugin invocation prefix (i.e. eclipse for eclipse:eclipse). artifactId String true 1.0.0 The plugin artifactId. maven2-core-2.2.1/maven-repository-metadata/pom.xml0000644000175000017500000000351711236625310022213 0ustar twernertwerner 4.0.0 org.apache.maven maven 2.2.1 maven-repository-metadata Maven Repository Metadata Model Per-directory repository metadata. org.codehaus.plexus plexus-utils org.codehaus.modello modello-maven-plugin 1.0.0 src/main/mdo/metadata.mdo maven2-core-2.2.1/maven-plugin-registry/0000755000175000017500000000000011250552243020037 5ustar twernertwernermaven2-core-2.2.1/maven-plugin-registry/plugin-registry.mdo0000644000175000017500000001633211146611627023717 0ustar twernertwerner plugin-registry PluginRegistry package org.apache.maven.plugin.registry TrackableBase 1.0.0 common base class that contains code to track the source for this instance (USER|GLOBAL) 1.0.0 PluginRegistry 1.0.0 TrackableBase Root element of the plugin registry file. updateInterval 1.0.0 String never autoUpdate 1.0.0 String Specifies whether the user should be prompted to update plugins. checkLatest 1.0.0 String Whether to resolve plugin versions using LATEST metadata. plugins 1.0.0 Specified plugin update policy information. Plugin * 1.0.0 Plugin 1.0.0 TrackableBase Policy for updating a single plugin. groupId 1.0.0 true String artifactId 1.0.0 true String lastChecked 1.0.0 String [format: yyyy-MM-dd.HH:mm:ss Z] Specifies the date/time at which this plugin was last checked. useVersion 1.0.0 String The current version of this plugin, to be used until the appropriate update actions happen. rejectedVersions 1.0.0 The list of versions for this plugin that the user declined to "install" String * 1.0.0 maven2-core-2.2.1/maven-plugin-registry/src/0000755000175000017500000000000011250552243020626 5ustar twernertwernermaven2-core-2.2.1/maven-plugin-registry/src/site/0000755000175000017500000000000011250552243021572 5ustar twernertwernermaven2-core-2.2.1/maven-plugin-registry/src/site/site.xml0000644000175000017500000000013211002611514023244 0ustar twernertwerner maven2-core-2.2.1/maven-plugin-registry/src/main/0000755000175000017500000000000011250552243021552 5ustar twernertwernermaven2-core-2.2.1/maven-plugin-registry/src/main/resources/0000755000175000017500000000000011250552243023564 5ustar twernertwernermaven2-core-2.2.1/maven-plugin-registry/src/main/resources/META-INF/0000755000175000017500000000000011250552243024724 5ustar twernertwernermaven2-core-2.2.1/maven-plugin-registry/src/main/resources/META-INF/plexus/0000755000175000017500000000000011250552243026244 5ustar twernertwernermaven2-core-2.2.1/maven-plugin-registry/src/main/resources/META-INF/plexus/components.xml0000644000175000017500000000236110772004567031166 0ustar twernertwerner org.apache.maven.plugin.registry.MavenPluginRegistryBuilder org.apache.maven.plugin.registry.DefaultPluginRegistryBuilder ${maven.home}/conf/plugin-registry.xml ${user.home}/.m2/plugin-registry.xml maven2-core-2.2.1/maven-plugin-registry/src/main/java/0000755000175000017500000000000011250552243022473 5ustar twernertwernermaven2-core-2.2.1/maven-plugin-registry/src/main/java/org/0000755000175000017500000000000011250552243023262 5ustar twernertwernermaven2-core-2.2.1/maven-plugin-registry/src/main/java/org/apache/0000755000175000017500000000000011250552243024503 5ustar twernertwernermaven2-core-2.2.1/maven-plugin-registry/src/main/java/org/apache/maven/0000755000175000017500000000000011250552243025611 5ustar twernertwernermaven2-core-2.2.1/maven-plugin-registry/src/main/java/org/apache/maven/plugin/0000755000175000017500000000000011250552243027107 5ustar twernertwernermaven2-core-2.2.1/maven-plugin-registry/src/main/java/org/apache/maven/plugin/registry/0000755000175000017500000000000011250552243030757 5ustar twernertwerner././@LongLink0000000000000000000000000000016000000000000011562 Lustar rootrootmaven2-core-2.2.1/maven-plugin-registry/src/main/java/org/apache/maven/plugin/registry/PluginRegistryUtils.javamaven2-core-2.2.1/maven-plugin-registry/src/main/java/org/apache/maven/plugin/registry/PluginRegistr0000644000175000017500000001217210772004567033514 0ustar twernertwernerpackage org.apache.maven.plugin.registry; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import java.util.ArrayList; import java.util.Collections; import java.util.Iterator; import java.util.List; import java.util.Map; public final class PluginRegistryUtils { private PluginRegistryUtils() { // don't allow construction. } public static void merge( PluginRegistry dominant, PluginRegistry recessive, String recessiveSourceLevel ) { // nothing to merge... if ( dominant == null || recessive == null ) { return; } RuntimeInfo dominantRtInfo = dominant.getRuntimeInfo(); String dominantUpdateInterval = dominant.getUpdateInterval(); if ( dominantUpdateInterval == null ) { String recessiveUpdateInterval = recessive.getUpdateInterval(); if ( recessiveUpdateInterval != null ) { dominant.setUpdateInterval( recessiveUpdateInterval ); dominantRtInfo.setUpdateIntervalSourceLevel( recessiveSourceLevel ); } } String dominantAutoUpdate = dominant.getAutoUpdate(); if ( dominantAutoUpdate == null ) { String recessiveAutoUpdate = recessive.getAutoUpdate(); if ( recessiveAutoUpdate != null ) { dominant.setAutoUpdate( recessiveAutoUpdate ); dominantRtInfo.setAutoUpdateSourceLevel( recessiveSourceLevel ); } } List recessivePlugins = null; if ( recessive != null ) { recessivePlugins = recessive.getPlugins(); } else { recessivePlugins = Collections.EMPTY_LIST; } shallowMergePlugins( dominant, recessivePlugins, recessiveSourceLevel ); } public static void recursivelySetSourceLevel( PluginRegistry pluginRegistry, String sourceLevel ) { if ( pluginRegistry == null ) { return; } pluginRegistry.setSourceLevel( sourceLevel ); for ( Iterator it = pluginRegistry.getPlugins().iterator(); it.hasNext(); ) { Plugin plugin = (Plugin) it.next(); plugin.setSourceLevel( sourceLevel ); } } private static void shallowMergePlugins( PluginRegistry dominant, List recessive, String recessiveSourceLevel ) { Map dominantByKey = dominant.getPluginsByKey(); List dominantPlugins = dominant.getPlugins(); for ( Iterator it = recessive.iterator(); it.hasNext(); ) { Plugin recessivePlugin = (Plugin) it.next(); if ( !dominantByKey.containsKey( recessivePlugin.getKey() ) ) { recessivePlugin.setSourceLevel( recessiveSourceLevel ); dominantPlugins.add( recessivePlugin ); } } dominant.flushPluginsByKey(); } public static PluginRegistry extractUserPluginRegistry( PluginRegistry pluginRegistry ) { PluginRegistry userRegistry = null; // check if this registry is entirely made up of global settings if ( pluginRegistry != null && !PluginRegistry.GLOBAL_LEVEL.equals( pluginRegistry.getSourceLevel() ) ) { userRegistry = new PluginRegistry(); RuntimeInfo rtInfo = new RuntimeInfo( userRegistry ); userRegistry.setRuntimeInfo( rtInfo ); RuntimeInfo oldRtInfo = pluginRegistry.getRuntimeInfo(); if ( TrackableBase.USER_LEVEL.equals( oldRtInfo.getAutoUpdateSourceLevel() ) ) { userRegistry.setAutoUpdate( pluginRegistry.getAutoUpdate() ); } if ( TrackableBase.USER_LEVEL.equals( oldRtInfo.getUpdateIntervalSourceLevel() ) ) { userRegistry.setUpdateInterval( pluginRegistry.getUpdateInterval() ); } List plugins = new ArrayList(); for ( Iterator it = pluginRegistry.getPlugins().iterator(); it.hasNext(); ) { Plugin plugin = (Plugin) it.next(); if ( TrackableBase.USER_LEVEL.equals( plugin.getSourceLevel() ) ) { plugins.add( plugin ); } } userRegistry.setPlugins( plugins ); rtInfo.setFile( pluginRegistry.getRuntimeInfo().getFile() ); } return userRegistry; } } ././@LongLink0000000000000000000000000000017100000000000011564 Lustar rootrootmaven2-core-2.2.1/maven-plugin-registry/src/main/java/org/apache/maven/plugin/registry/DefaultPluginRegistryBuilder.javamaven2-core-2.2.1/maven-plugin-registry/src/main/java/org/apache/maven/plugin/registry/DefaultPlugin0000644000175000017500000001454210772004567033464 0ustar twernertwernerpackage org.apache.maven.plugin.registry; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import org.apache.maven.plugin.registry.io.xpp3.PluginRegistryXpp3Reader; import org.codehaus.plexus.logging.AbstractLogEnabled; import org.codehaus.plexus.personality.plexus.lifecycle.phase.Initializable; import org.codehaus.plexus.util.IOUtil; import org.codehaus.plexus.util.ReaderFactory; import org.codehaus.plexus.util.StringUtils; import org.codehaus.plexus.util.xml.pull.XmlPullParserException; import java.io.File; import java.io.IOException; import java.io.Reader; public class DefaultPluginRegistryBuilder extends AbstractLogEnabled implements MavenPluginRegistryBuilder, Initializable { public static final String userHome = System.getProperty( "user.home" ); /** * @configuration */ private String userRegistryPath; /** * @configuration */ private String globalRegistryPath; private File userRegistryFile; private File globalRegistryFile; // ---------------------------------------------------------------------- // Component Lifecycle // ---------------------------------------------------------------------- public void initialize() { userRegistryFile = getFile( userRegistryPath, "user.home", MavenPluginRegistryBuilder.ALT_USER_PLUGIN_REG_LOCATION ); getLogger().debug( "Building Maven user-level plugin registry from: '" + userRegistryFile.getAbsolutePath() + "'" ); if ( System.getProperty( "maven.home" ) != null || System.getProperty( MavenPluginRegistryBuilder.ALT_GLOBAL_PLUGIN_REG_LOCATION ) != null ) { globalRegistryFile = getFile( globalRegistryPath, "maven.home", MavenPluginRegistryBuilder.ALT_GLOBAL_PLUGIN_REG_LOCATION ); getLogger().debug( "Building Maven global-level plugin registry from: '" + globalRegistryFile.getAbsolutePath() + "'" ); } } public PluginRegistry buildPluginRegistry() throws IOException, XmlPullParserException { PluginRegistry global = readPluginRegistry( globalRegistryFile ); PluginRegistry user = readPluginRegistry( userRegistryFile ); if ( user == null && global != null ) { // we'll use the globals, but first we have to recursively mark them as global... PluginRegistryUtils.recursivelySetSourceLevel( global, PluginRegistry.GLOBAL_LEVEL ); user = global; } else { // merge non-colliding plugins into the user registry. PluginRegistryUtils.merge( user, global, TrackableBase.GLOBAL_LEVEL ); } return user; } private PluginRegistry readPluginRegistry( File registryFile ) throws IOException, XmlPullParserException { PluginRegistry registry = null; if ( registryFile != null && registryFile.exists() && registryFile.isFile() ) { Reader reader = null; try { reader = ReaderFactory.newXmlReader( registryFile ); PluginRegistryXpp3Reader modelReader = new PluginRegistryXpp3Reader(); registry = modelReader.read( reader ); RuntimeInfo rtInfo = new RuntimeInfo( registry ); registry.setRuntimeInfo( rtInfo ); rtInfo.setFile( registryFile ); } finally { IOUtil.close( reader ); } } return registry; } private File getFile( String pathPattern, String basedirSysProp, String altLocationSysProp ) { // ------------------------------------------------------------------------------------- // Alright, here's the justification for all the regexp wizardry below... // // Continuum and other server-like apps may need to locate the user-level and // global-level settings somewhere other than ${user.home} and ${maven.home}, // respectively. Using a simple replacement of these patterns will allow them // to specify the absolute path to these files in a customized components.xml // file. Ideally, we'd do full pattern-evaluation against the sysprops, but this // is a first step. There are several replacements below, in order to normalize // the path character before we operate on the string as a regex input, and // in order to avoid surprises with the File construction... // ------------------------------------------------------------------------------------- String path = System.getProperty( altLocationSysProp ); if ( StringUtils.isEmpty( path ) ) { // TODO: This replacing shouldn't be necessary as user.home should be in the // context of the container and thus the value would be interpolated by Plexus String basedir = System.getProperty( basedirSysProp ); basedir = basedir.replaceAll( "\\\\", "/" ); basedir = basedir.replaceAll("\\$", "\\\\\\$"); path = pathPattern.replaceAll( "\\$\\{" + basedirSysProp + "\\}", basedir ); path = path.replaceAll( "\\\\", "/" ); path = path.replaceAll( "//", "/" ); return new File( path ).getAbsoluteFile(); } else { return new File( path ).getAbsoluteFile(); } } public PluginRegistry createUserPluginRegistry() { PluginRegistry registry = new PluginRegistry(); RuntimeInfo rtInfo = new RuntimeInfo( registry ); registry.setRuntimeInfo( rtInfo ); rtInfo.setFile( userRegistryFile ); return registry; } } ././@LongLink0000000000000000000000000000016700000000000011571 Lustar rootrootmaven2-core-2.2.1/maven-plugin-registry/src/main/java/org/apache/maven/plugin/registry/MavenPluginRegistryBuilder.javamaven2-core-2.2.1/maven-plugin-registry/src/main/java/org/apache/maven/plugin/registry/MavenPluginRe0000644000175000017500000000254610772004567033436 0ustar twernertwernerpackage org.apache.maven.plugin.registry; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import org.codehaus.plexus.util.xml.pull.XmlPullParserException; import java.io.IOException; public interface MavenPluginRegistryBuilder { String ROLE = MavenPluginRegistryBuilder.class.getName(); String ALT_USER_PLUGIN_REG_LOCATION = "org.apache.maven.user-plugin-registry"; String ALT_GLOBAL_PLUGIN_REG_LOCATION = "org.apache.maven.global-plugin-registry"; PluginRegistry buildPluginRegistry() throws IOException, XmlPullParserException; PluginRegistry createUserPluginRegistry(); } ././@LongLink0000000000000000000000000000015000000000000011561 Lustar rootrootmaven2-core-2.2.1/maven-plugin-registry/src/main/java/org/apache/maven/plugin/registry/RuntimeInfo.javamaven2-core-2.2.1/maven-plugin-registry/src/main/java/org/apache/maven/plugin/registry/RuntimeInfo.j0000644000175000017500000000406610772004567033410 0ustar twernertwernerpackage org.apache.maven.plugin.registry; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import java.io.File; public class RuntimeInfo { private File file; private String autoUpdateSourceLevel; private String updateIntervalSourceLevel; private final PluginRegistry registry; public RuntimeInfo( PluginRegistry registry ) { this.registry = registry; } public String getAutoUpdateSourceLevel() { if ( autoUpdateSourceLevel == null ) { return registry.getSourceLevel(); } else { return autoUpdateSourceLevel; } } public void setAutoUpdateSourceLevel( String autoUpdateSourceLevel ) { this.autoUpdateSourceLevel = autoUpdateSourceLevel; } public File getFile() { return file; } public void setFile( File file ) { this.file = file; } public String getUpdateIntervalSourceLevel() { if ( updateIntervalSourceLevel == null ) { return registry.getSourceLevel(); } else { return updateIntervalSourceLevel; } } public void setUpdateIntervalSourceLevel( String updateIntervalSourceLevel ) { this.updateIntervalSourceLevel = updateIntervalSourceLevel; } } maven2-core-2.2.1/maven-plugin-registry/pom.xml0000644000175000017500000000361111236625310021355 0ustar twernertwerner 4.0.0 org.apache.maven maven 2.2.1 maven-plugin-registry Maven Plugin Registry Model org.codehaus.plexus plexus-utils org.codehaus.plexus plexus-container-default org.codehaus.modello modello-maven-plugin 1.0.0 plugin-registry.mdo maven2-core-2.2.1/maven-error-diagnostics/0000755000175000017500000000000011250552242020330 5ustar twernertwernermaven2-core-2.2.1/maven-error-diagnostics/src/0000755000175000017500000000000011250552242021117 5ustar twernertwernermaven2-core-2.2.1/maven-error-diagnostics/src/site/0000755000175000017500000000000011250552242022063 5ustar twernertwernermaven2-core-2.2.1/maven-error-diagnostics/src/site/site.xml0000644000175000017500000000013211002611514023536 0ustar twernertwerner maven2-core-2.2.1/maven-error-diagnostics/src/main/0000755000175000017500000000000011250552242022043 5ustar twernertwernermaven2-core-2.2.1/maven-error-diagnostics/src/main/resources/0000755000175000017500000000000011250552242024055 5ustar twernertwernermaven2-core-2.2.1/maven-error-diagnostics/src/main/resources/META-INF/0000755000175000017500000000000011250552242025215 5ustar twernertwernermaven2-core-2.2.1/maven-error-diagnostics/src/main/resources/META-INF/plexus/0000755000175000017500000000000011250552242026535 5ustar twernertwernermaven2-core-2.2.1/maven-error-diagnostics/src/main/resources/META-INF/plexus/components.xml0000644000175000017500000000206110772004567031455 0ustar twernertwerner org.apache.maven.usability.diagnostics.ErrorDiagnostics org.apache.maven.usability.diagnostics.ErrorDiagnostics maven2-core-2.2.1/maven-error-diagnostics/src/main/java/0000755000175000017500000000000011250552242022764 5ustar twernertwernermaven2-core-2.2.1/maven-error-diagnostics/src/main/java/org/0000755000175000017500000000000011250552242023553 5ustar twernertwernermaven2-core-2.2.1/maven-error-diagnostics/src/main/java/org/apache/0000755000175000017500000000000011250552242024774 5ustar twernertwernermaven2-core-2.2.1/maven-error-diagnostics/src/main/java/org/apache/maven/0000755000175000017500000000000011250552242026102 5ustar twernertwernermaven2-core-2.2.1/maven-error-diagnostics/src/main/java/org/apache/maven/usability/0000755000175000017500000000000011250552242030107 5ustar twernertwernermaven2-core-2.2.1/maven-error-diagnostics/src/main/java/org/apache/maven/usability/diagnostics/0000755000175000017500000000000011250552242032416 5ustar twernertwerner././@LongLink0000000000000000000000000000016300000000000011565 Lustar rootrootmaven2-core-2.2.1/maven-error-diagnostics/src/main/java/org/apache/maven/usability/diagnostics/DiagnosisUtils.javamaven2-core-2.2.1/maven-error-diagnostics/src/main/java/org/apache/maven/usability/diagnostics/Diagn0000644000175000017500000000542510772004567033403 0ustar twernertwernerpackage org.apache.maven.usability.diagnostics; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ public final class DiagnosisUtils { private DiagnosisUtils() { } public static boolean containsInCausality( Throwable error, Class test ) { Throwable cause = error; while ( cause != null ) { if ( test.isInstance( cause ) ) { return true; } cause = cause.getCause(); } return false; } public static Throwable getRootCause( Throwable error ) { Throwable cause = error; while ( true ) { Throwable nextCause = cause.getCause(); if ( nextCause == null ) { break; } else { cause = nextCause; } } return cause; } public static Throwable getFromCausality( Throwable error, Class targetClass ) { Throwable cause = error; while ( cause != null ) { if ( targetClass.isInstance( cause ) ) { return cause; } cause = cause.getCause(); } return null; } public static void appendRootCauseIfPresentAndUnique( Throwable error, StringBuffer message, boolean includeTypeInfo ) { if ( error == null ) { return; } Throwable root = getRootCause( error ); if ( root != null && !root.equals( error ) ) { String rootMsg = root.getMessage(); if ( rootMsg != null && ( error.getMessage() == null || error.getMessage().indexOf( rootMsg ) < 0 ) ) { message.append( "\n" ).append( rootMsg ); if ( includeTypeInfo ) { message.append( "\nRoot error type: " ).append( root.getClass().getName() ); } } } } } ././@LongLink0000000000000000000000000000016500000000000011567 Lustar rootrootmaven2-core-2.2.1/maven-error-diagnostics/src/main/java/org/apache/maven/usability/diagnostics/ErrorDiagnostics.javamaven2-core-2.2.1/maven-error-diagnostics/src/main/java/org/apache/maven/usability/diagnostics/Error0000644000175000017500000001005410772004567033444 0ustar twernertwernerpackage org.apache.maven.usability.diagnostics; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import org.codehaus.plexus.PlexusConstants; import org.codehaus.plexus.PlexusContainer; import org.codehaus.plexus.component.repository.exception.ComponentLifecycleException; import org.codehaus.plexus.component.repository.exception.ComponentLookupException; import org.codehaus.plexus.context.Context; import org.codehaus.plexus.context.ContextException; import org.codehaus.plexus.logging.AbstractLogEnabled; import org.codehaus.plexus.personality.plexus.lifecycle.phase.Contextualizable; import java.util.Iterator; import java.util.List; public class ErrorDiagnostics extends AbstractLogEnabled implements Contextualizable { public static final String ROLE = ErrorDiagnostics.class.getName(); private PlexusContainer container; private List errorDiagnosers; public void setErrorDiagnosers( List errorDiagnosers ) { this.errorDiagnosers = errorDiagnosers; } public String diagnose( Throwable error ) { List diags = errorDiagnosers; boolean releaseDiags = false; boolean errorProcessed = false; String message = null; try { if ( diags == null ) { releaseDiags = true; try { diags = container.lookupList( ErrorDiagnoser.ROLE ); } catch ( ComponentLookupException e ) { getLogger().error( "Failed to lookup the list of error diagnosers.", e ); } } if ( diags != null ) { for ( Iterator it = diags.iterator(); it.hasNext(); ) { ErrorDiagnoser diagnoser = (ErrorDiagnoser) it.next(); if ( diagnoser.canDiagnose( error ) ) { errorProcessed = true; message = diagnoser.diagnose( error ); break; } } } } finally { if ( releaseDiags && diags != null ) { try { container.releaseAll( diags ); } catch ( ComponentLifecycleException e ) { getLogger().debug( "Failed to release error diagnoser list.", e ); } } if ( !errorProcessed ) { message = new PuntErrorDiagnoser().diagnose( error ); } } return message; } public void contextualize( Context context ) throws ContextException { this.container = (PlexusContainer) context.get( PlexusConstants.PLEXUS_KEY ); } private static class PuntErrorDiagnoser implements ErrorDiagnoser { public boolean canDiagnose( Throwable error ) { return true; } public String diagnose( Throwable error ) { StringBuffer message = new StringBuffer(); message.append( error.getMessage() ); DiagnosisUtils.appendRootCauseIfPresentAndUnique( error, message, false ); return message.toString(); } } } ././@LongLink0000000000000000000000000000016300000000000011565 Lustar rootrootmaven2-core-2.2.1/maven-error-diagnostics/src/main/java/org/apache/maven/usability/diagnostics/ErrorDiagnoser.javamaven2-core-2.2.1/maven-error-diagnostics/src/main/java/org/apache/maven/usability/diagnostics/Error0000644000175000017500000000205010772004567033441 0ustar twernertwernerpackage org.apache.maven.usability.diagnostics; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ public interface ErrorDiagnoser { public static final String ROLE = ErrorDiagnoser.class.getName(); public boolean canDiagnose( Throwable error ); public String diagnose( Throwable error ); } maven2-core-2.2.1/maven-error-diagnostics/pom.xml0000644000175000017500000000325411236625310021652 0ustar twernertwerner 4.0.0 org.apache.maven maven 2.2.1 maven-error-diagnostics Maven Error Diagnostics Provides a manager component which will process a given Throwable instance through a set of diagnostic sub-components, and return a String message with user-friendly information about the error and possibly how to fix it. org.codehaus.plexus plexus-container-default maven2-core-2.2.1/maven-plugin-descriptor/0000755000175000017500000000000011250552246020350 5ustar twernertwernermaven2-core-2.2.1/maven-plugin-descriptor/src/0000755000175000017500000000000011250552246021137 5ustar twernertwernermaven2-core-2.2.1/maven-plugin-descriptor/src/site/0000755000175000017500000000000011250552246022103 5ustar twernertwernermaven2-core-2.2.1/maven-plugin-descriptor/src/site/site.xml0000644000175000017500000000013211002611514023552 0ustar twernertwerner maven2-core-2.2.1/maven-plugin-descriptor/src/test/0000755000175000017500000000000011250552246022116 5ustar twernertwernermaven2-core-2.2.1/maven-plugin-descriptor/src/test/resources/0000755000175000017500000000000011250552246024130 5ustar twernertwernermaven2-core-2.2.1/maven-plugin-descriptor/src/test/resources/lifecycle.xml0000644000175000017500000000226210772004567026621 0ustar twernertwerner clover generate-sources true clover:compiler maven2-core-2.2.1/maven-plugin-descriptor/src/test/java/0000755000175000017500000000000011250552246023037 5ustar twernertwernermaven2-core-2.2.1/maven-plugin-descriptor/src/test/java/org/0000755000175000017500000000000011250552246023626 5ustar twernertwernermaven2-core-2.2.1/maven-plugin-descriptor/src/test/java/org/apache/0000755000175000017500000000000011250552246025047 5ustar twernertwernermaven2-core-2.2.1/maven-plugin-descriptor/src/test/java/org/apache/maven/0000755000175000017500000000000011250552246026155 5ustar twernertwernermaven2-core-2.2.1/maven-plugin-descriptor/src/test/java/org/apache/maven/plugin/0000755000175000017500000000000011250552246027453 5ustar twernertwernermaven2-core-2.2.1/maven-plugin-descriptor/src/test/java/org/apache/maven/plugin/lifecycle/0000755000175000017500000000000011250552246031412 5ustar twernertwerner././@LongLink0000000000000000000000000000016700000000000011571 Lustar rootrootmaven2-core-2.2.1/maven-plugin-descriptor/src/test/java/org/apache/maven/plugin/lifecycle/LifecycleXpp3ReaderTest.javamaven2-core-2.2.1/maven-plugin-descriptor/src/test/java/org/apache/maven/plugin/lifecycle/LifecycleX0000644000175000017500000000503610772004567033376 0ustar twernertwernerpackage org.apache.maven.plugin.lifecycle; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import org.apache.maven.plugin.lifecycle.io.xpp3.LifecycleMappingsXpp3Reader; import org.codehaus.plexus.util.xml.Xpp3Dom; import org.codehaus.plexus.util.xml.pull.XmlPullParserException; import java.io.IOException; import java.io.InputStreamReader; import junit.framework.TestCase; /** * Test the lifecycle reader. * * @author Brett Porter * @version $Id: LifecycleXpp3ReaderTest.java 640549 2008-03-24 20:05:11Z bentmann $ */ public class LifecycleXpp3ReaderTest extends TestCase { public void testLifecycleReader() throws IOException, XmlPullParserException { LifecycleMappingsXpp3Reader reader = new LifecycleMappingsXpp3Reader(); LifecycleConfiguration config = reader.read( new InputStreamReader( getClass().getResourceAsStream( "/lifecycle.xml" ) ) ); assertEquals( "check number of lifecycles", 1, config.getLifecycles().size() ); Lifecycle l = (Lifecycle) config.getLifecycles().iterator().next(); assertEquals( "check id", "clover", l.getId() ); assertEquals( "check number of phases", 1, l.getPhases().size() ); Phase p = (Phase) l.getPhases().iterator().next(); assertEquals( "check id", "generate-sources", p.getId() ); assertEquals( "check number of executions", 1, p.getExecutions().size() ); Execution e = (Execution) p.getExecutions().iterator().next(); assertEquals( "check configuration", "true", ((Xpp3Dom) e.getConfiguration()).getChild( "debug" ).getValue() ); assertEquals( "check number of goals", 1, e.getGoals().size() ); String g = (String) e.getGoals().iterator().next(); assertEquals( "check goal", "clover:compiler", g ); } } maven2-core-2.2.1/maven-plugin-descriptor/src/main/0000755000175000017500000000000011250552246022063 5ustar twernertwernermaven2-core-2.2.1/maven-plugin-descriptor/src/main/mdo/0000755000175000017500000000000011250552246022642 5ustar twernertwernermaven2-core-2.2.1/maven-plugin-descriptor/src/main/mdo/lifecycle.mdo0000644000175000017500000001046311146611627025311 0ustar twernertwerner lifecycle-mappings LifecycleMappings package org.apache.maven.plugin.lifecycle LifecycleConfiguration 1.0.0 Root element of the lifecycle.xml file. lifecycles 1.0.0 Lifecycle * Lifecycle 1.0.0 id true 1.0.0 String The ID of this lifecycle, for identification in the mojo descriptor. phases 1.0.0 The phase mappings for this lifecycle. Phase * Phase 1.0.0 A phase mapping definition. id true 1.0.0 String The ID of this phase, eg <code>generate-sources</code>. executions 1.0.0 The goals to execute within the phase. Execution * configuration 1.0.0 DOM Configuration to pass to all goals run in this phase. Execution 1.0.0 A set of goals to execute. configuration 1.0.0 DOM Configuration to pass to the goals. goals 1.0.0 The goals to execute. String * maven2-core-2.2.1/maven-plugin-descriptor/src/main/java/0000755000175000017500000000000011250552246023004 5ustar twernertwernermaven2-core-2.2.1/maven-plugin-descriptor/src/main/java/org/0000755000175000017500000000000011250552246023573 5ustar twernertwernermaven2-core-2.2.1/maven-plugin-descriptor/src/main/java/org/apache/0000755000175000017500000000000011250552246025014 5ustar twernertwernermaven2-core-2.2.1/maven-plugin-descriptor/src/main/java/org/apache/maven/0000755000175000017500000000000011250552246026122 5ustar twernertwernermaven2-core-2.2.1/maven-plugin-descriptor/src/main/java/org/apache/maven/plugin/0000755000175000017500000000000011250552246027420 5ustar twernertwernermaven2-core-2.2.1/maven-plugin-descriptor/src/main/java/org/apache/maven/plugin/descriptor/0000755000175000017500000000000011250552246031576 5ustar twernertwerner././@LongLink0000000000000000000000000000016100000000000011563 Lustar rootrootmaven2-core-2.2.1/maven-plugin-descriptor/src/main/java/org/apache/maven/plugin/descriptor/PluginDescriptor.javamaven2-core-2.2.1/maven-plugin-descriptor/src/main/java/org/apache/maven/plugin/descriptor/PluginDes0000644000175000017500000002310011144676102033407 0ustar twernertwernerpackage org.apache.maven.plugin.descriptor; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.ArtifactUtils; import org.apache.maven.plugin.lifecycle.Lifecycle; import org.apache.maven.plugin.lifecycle.LifecycleConfiguration; import org.apache.maven.plugin.lifecycle.io.xpp3.LifecycleMappingsXpp3Reader; import org.codehaus.classworlds.ClassRealm; import org.codehaus.plexus.component.repository.ComponentSetDescriptor; import org.codehaus.plexus.util.IOUtil; import org.codehaus.plexus.util.xml.pull.XmlPullParserException; import java.io.FileNotFoundException; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.util.Collections; import java.util.HashMap; import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.Set; /** * @author Jason van Zyl * @version $Id: PluginDescriptor.java 743587 2009-02-12 01:32:50Z jdcasey $ */ public class PluginDescriptor extends ComponentSetDescriptor { private String groupId; private String artifactId; private String version; private String goalPrefix; private String source; private boolean inheritedByDefault = true; private Artifact pluginArtifact; private List artifacts; private Map lifecycleMappings; private ClassRealm classRealm; // calculated on-demand. private Map artifactMap; private Set introducedDependencyArtifacts; private String name; private String description; // ---------------------------------------------------------------------- // // ---------------------------------------------------------------------- public List getMojos() { return getComponents(); } public void addMojo( MojoDescriptor mojoDescriptor ) throws DuplicateMojoDescriptorException { MojoDescriptor existing = null; // this relies heavily on the equals() and hashCode() for ComponentDescriptor, // which uses role:roleHint for identity...and roleHint == goalPrefix:goal. // role does not vary for Mojos. List mojos = getComponents(); if ( mojos != null && mojos.contains( mojoDescriptor ) ) { int indexOf = mojos.indexOf( mojoDescriptor ); existing = (MojoDescriptor) mojos.get( indexOf ); } if ( existing != null ) { throw new DuplicateMojoDescriptorException( getGoalPrefix(), mojoDescriptor.getGoal(), existing .getImplementation(), mojoDescriptor.getImplementation() ); } else { addComponentDescriptor( mojoDescriptor ); } } public String getGroupId() { return groupId; } public void setGroupId( String groupId ) { this.groupId = groupId; } public String getArtifactId() { return artifactId; } public void setArtifactId( String artifactId ) { this.artifactId = artifactId; } // ---------------------------------------------------------------------- // Dependencies // ---------------------------------------------------------------------- public static String constructPluginKey( String groupId, String artifactId, String version ) { return groupId + ":" + artifactId + ":" + version; } private String lookupKey; public String getPluginLookupKey() { if ( lookupKey == null ) { lookupKey = ( groupId + ":" + artifactId ).intern(); } return lookupKey; } private String id; public String getId() { if ( id == null ) { id = constructPluginKey( groupId, artifactId, version ).intern(); } return id; } public static String getDefaultPluginArtifactId( String id ) { return "maven-" + id + "-plugin"; } public static String getDefaultPluginGroupId() { return "org.apache.maven.plugins"; } /** * Parse maven-...-plugin. * * @todo move to plugin-tools-api as a default only */ public static String getGoalPrefixFromArtifactId( String artifactId ) { if ( "maven-plugin-plugin".equals( artifactId ) ) { return "plugin"; } else { return artifactId.replaceAll( "-?maven-?", "" ).replaceAll( "-?plugin-?", "" ); } } public String getGoalPrefix() { return goalPrefix; } public void setGoalPrefix( String goalPrefix ) { this.goalPrefix = goalPrefix; } public void setVersion( String version ) { this.version = version; } public String getVersion() { return version; } public void setSource( String source ) { this.source = source; } public String getSource() { return source; } public boolean isInheritedByDefault() { return inheritedByDefault; } public void setInheritedByDefault( boolean inheritedByDefault ) { this.inheritedByDefault = inheritedByDefault; } public List getArtifacts() { return artifacts; } public void setArtifacts( List artifacts ) { this.artifacts = artifacts; // clear the calculated artifactMap artifactMap = null; } public Map getArtifactMap() { if ( artifactMap == null ) { artifactMap = ArtifactUtils.artifactMapByVersionlessId( getArtifacts() ); } return artifactMap; } public boolean equals( Object object ) { if ( this == object ) { return true; } return getId().equals( ( (PluginDescriptor) object ).getId() ); } public int hashCode() { return 10 + getId().hashCode(); } public MojoDescriptor getMojo( String goal ) { if ( getMojos() == null ) { return null; // no mojo in this POM } // TODO: could we use a map? Maybe if the parent did that for components too, as this is too vulnerable to // changes above not being propogated to the map MojoDescriptor mojoDescriptor = null; for ( Iterator i = getMojos().iterator(); i.hasNext() && mojoDescriptor == null; ) { MojoDescriptor desc = (MojoDescriptor) i.next(); if ( goal.equals( desc.getGoal() ) ) { mojoDescriptor = desc; } } return mojoDescriptor; } public Lifecycle getLifecycleMapping( String lifecycle ) throws IOException, XmlPullParserException { if ( lifecycleMappings == null ) { LifecycleMappingsXpp3Reader reader = new LifecycleMappingsXpp3Reader(); InputStreamReader r = null; LifecycleConfiguration config; try { InputStream resourceAsStream = classRealm.getResourceAsStream( "/META-INF/maven/lifecycle.xml" ); if ( resourceAsStream == null ) { throw new FileNotFoundException( "Unable to find /META-INF/maven/lifecycle.xml in the plugin" ); } r = new InputStreamReader( resourceAsStream ); config = reader.read( r, true ); } finally { IOUtil.close( r ); } Map map = new HashMap(); for ( Iterator i = config.getLifecycles().iterator(); i.hasNext(); ) { Lifecycle l = (Lifecycle) i.next(); map.put( l.getId(), l ); } lifecycleMappings = map; } return (Lifecycle) lifecycleMappings.get( lifecycle ); } public void setClassRealm( ClassRealm classRealm ) { this.classRealm = classRealm; } public ClassRealm getClassRealm() { return classRealm; } public void setIntroducedDependencyArtifacts( Set introducedDependencyArtifacts ) { this.introducedDependencyArtifacts = introducedDependencyArtifacts; } public Set getIntroducedDependencyArtifacts() { return introducedDependencyArtifacts != null ? introducedDependencyArtifacts : Collections.EMPTY_SET; } public void setName( String name ) { this.name = name; } public String getName() { return name; } public void setDescription( String description ) { this.description = description; } public String getDescription() { return description; } public Artifact getPluginArtifact() { return pluginArtifact; } public void setPluginArtifact( Artifact pluginArtifact ) { this.pluginArtifact = pluginArtifact; } } ././@LongLink0000000000000000000000000000015200000000000011563 Lustar rootrootmaven2-core-2.2.1/maven-plugin-descriptor/src/main/java/org/apache/maven/plugin/descriptor/Parameter.javamaven2-core-2.2.1/maven-plugin-descriptor/src/main/java/org/apache/maven/plugin/descriptor/Parameter0000644000175000017500000000754710551365651033463 0ustar twernertwernerpackage org.apache.maven.plugin.descriptor; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ /** * @author Jason van Zyl * @version $Id: Parameter.java 495147 2007-01-11 07:47:53Z jvanzyl $ */ public class Parameter { private String alias; private String name; private String type; private boolean required; private boolean editable = true; private String description; private String expression; private String deprecated; private String defaultValue; private String implementation; private Requirement requirement; private String since; // ---------------------------------------------------------------------- // // ---------------------------------------------------------------------- public String getName() { return name; } public void setName( String name ) { this.name = name; } public String getType() { return type; } public void setType( String type ) { this.type = type; } public boolean isRequired() { return required; } public void setRequired( boolean required ) { this.required = required; } public String getDescription() { return description; } public void setDescription( String description ) { this.description = description; } public String getExpression() { return expression; } public void setExpression( String expression ) { this.expression = expression; } public String getDeprecated() { return deprecated; } public void setDeprecated( String deprecated ) { this.deprecated = deprecated; } public int hashCode() { return name.hashCode(); } public boolean equals( Object other ) { return ( other instanceof Parameter ) && getName().equals( ( (Parameter) other ).getName() ); } public String getAlias() { return alias; } public void setAlias( String alias ) { this.alias = alias; } public boolean isEditable() { return editable; } public void setEditable( boolean editable ) { this.editable = editable; } public void setDefaultValue( String defaultValue ) { this.defaultValue = defaultValue; } public String getDefaultValue() { return defaultValue; } public String toString() { return "Mojo parameter [name: \'" + getName() + "\'; alias: \'" + getAlias() + "\']"; } public Requirement getRequirement() { return requirement; } public void setRequirement( Requirement requirement ) { this.requirement = requirement; } public String getImplementation() { return implementation; } public void setImplementation( String implementation ) { this.implementation = implementation; } public String getSince() { return since; } public void setSince( String since ) { this.since = since; } } ././@LongLink0000000000000000000000000000020100000000000011556 Lustar rootrootmaven2-core-2.2.1/maven-plugin-descriptor/src/main/java/org/apache/maven/plugin/descriptor/InvalidPluginDescriptorException.javamaven2-core-2.2.1/maven-plugin-descriptor/src/main/java/org/apache/maven/plugin/descriptor/InvalidPl0000644000175000017500000000233310772004567033412 0ustar twernertwernerpackage org.apache.maven.plugin.descriptor; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import org.codehaus.plexus.configuration.PlexusConfigurationException; public class InvalidPluginDescriptorException extends PlexusConfigurationException { public InvalidPluginDescriptorException( String message, Throwable cause ) { super( message, cause ); } public InvalidPluginDescriptorException( String message ) { super( message ); } } ././@LongLink0000000000000000000000000000015700000000000011570 Lustar rootrootmaven2-core-2.2.1/maven-plugin-descriptor/src/main/java/org/apache/maven/plugin/descriptor/MojoDescriptor.javamaven2-core-2.2.1/maven-plugin-descriptor/src/main/java/org/apache/maven/plugin/descriptor/MojoDescr0000644000175000017500000004031611144676102033412 0ustar twernertwernerpackage org.apache.maven.plugin.descriptor; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import org.apache.maven.plugin.Mojo; import org.codehaus.plexus.component.repository.ComponentDescriptor; import org.codehaus.plexus.configuration.PlexusConfiguration; import org.codehaus.plexus.configuration.xml.XmlPlexusConfiguration; import java.util.HashMap; import java.util.Iterator; import java.util.LinkedList; import java.util.List; import java.util.Map; /** * The bean containing the Mojo descriptor. *
* For more information about the usage tag, have a look to: * http://maven.apache.org/developers/mojo-api-specification.html * * @todo is there a need for the delegation of MavenMojoDescriptor to this? * Why not just extend ComponentDescriptor here? * @version $Id: MojoDescriptor.java 743587 2009-02-12 01:32:50Z jdcasey $ */ public class MojoDescriptor extends ComponentDescriptor implements Cloneable { /** The Plexus component type */ public static String MAVEN_PLUGIN = "maven-plugin"; /** "once-per-session" execution strategy */ public static final String SINGLE_PASS_EXEC_STRATEGY = "once-per-session"; /** "always" execution strategy */ public static final String MULTI_PASS_EXEC_STRATEGY = "always"; private static final String DEFAULT_INSTANTIATION_STRATEGY = "per-lookup"; private static final String DEFAULT_LANGUAGE = "java"; private List parameters; private Map parameterMap; /** By default, the execution strategy is "once-per-session" */ private String executionStrategy = SINGLE_PASS_EXEC_STRATEGY; /** The goal name of the Mojo */ private String goal; /** Reference the binded phase name of the Mojo */ private String phase; /** Specify the version when the Mojo was added to the API. Similar to Javadoc since. */ private String since; /** Reference the invocation phase of the Mojo */ private String executePhase; /** Reference the invocation goal of the Mojo */ private String executeGoal; /** Reference the invocation lifecycle of the Mojo */ private String executeLifecycle; /** Specify the version when the Mojo was deprecated to the API. Similar to Javadoc deprecated. */ private String deprecated; /** By default, no need to aggregate the Maven project and its child modules */ private boolean aggregator = false; // ---------------------------------------------------------------------- // // ---------------------------------------------------------------------- /** Specify the required dependencies in a specified scope */ private String dependencyResolutionRequired = null; /** By default, the Mojo needs a Maven project to be executed */ private boolean projectRequired = true; /** By default, the Mojo is online */ private boolean onlineRequired = false; /** Plugin configuration */ private PlexusConfiguration mojoConfiguration; /** Plugin descriptor */ private PluginDescriptor pluginDescriptor; /** By default, the Mojo is herited */ private boolean inheritedByDefault = true; /** By default, the Mojo could not be invoke directly */ private boolean directInvocationOnly = false; /** By default, the Mojo don't need reports to run */ private boolean requiresReports = false; /** * Default constructor. */ public MojoDescriptor() { setInstantiationStrategy( DEFAULT_INSTANTIATION_STRATEGY ); setComponentFactory( DEFAULT_LANGUAGE ); } // ---------------------------------------------------------------------- // // ---------------------------------------------------------------------- /** * @return the language of this Mojo, i.e. java */ public String getLanguage() { return getComponentFactory(); } /** * @param language the new language */ public void setLanguage( String language ) { setComponentFactory( language ); } /** * @return true if the Mojo is deprecated, false otherwise. */ public String getDeprecated() { return deprecated; } /** * @param deprecated true to deprecate the Mojo, false otherwise. */ public void setDeprecated( String deprecated ) { this.deprecated = deprecated; } /** * @return the list of parameters */ public List getParameters() { return parameters; } /** * @param parameters the new list of parameters * @throws DuplicateParameterException if any */ public void setParameters( List parameters ) throws DuplicateParameterException { for ( Iterator it = parameters.iterator(); it.hasNext(); ) { Parameter parameter = (Parameter) it.next(); addParameter( parameter ); } } /** * @param parameter add a new parameter * @throws DuplicateParameterException if any */ public void addParameter( Parameter parameter ) throws DuplicateParameterException { if ( parameters != null && parameters.contains( parameter ) ) { throw new DuplicateParameterException( parameter.getName() + " has been declared multiple times in mojo with goal: " + getGoal() + " (implementation: " + getImplementation() + ")" ); } if ( parameters == null ) { parameters = new LinkedList(); } parameters.add( parameter ); parameterMap = null; } /** * @return the list parameters as a Map */ public Map getParameterMap() { if ( parameterMap == null ) { parameterMap = new HashMap(); if ( parameters != null ) { for ( Iterator iterator = parameters.iterator(); iterator.hasNext(); ) { Parameter pd = (Parameter) iterator.next(); parameterMap.put( pd.getName(), pd ); } } } return parameterMap; } // ---------------------------------------------------------------------- // Dependency requirement // ---------------------------------------------------------------------- /** * @param requiresDependencyResolution the new required dependencies in a specified scope */ public void setDependencyResolutionRequired( String requiresDependencyResolution ) { this.dependencyResolutionRequired = requiresDependencyResolution; } /** * @return the required dependencies in a specified scope * @TODO the name is not intelligible */ public String isDependencyResolutionRequired() { return dependencyResolutionRequired; } // ---------------------------------------------------------------------- // Project requirement // ---------------------------------------------------------------------- /** * @param requiresProject true if the Mojo needs a Maven project to be executed, false otherwise. */ public void setProjectRequired( boolean requiresProject ) { this.projectRequired = requiresProject; } /** * @return true if the Mojo needs a Maven project to be executed, false otherwise. */ public boolean isProjectRequired() { return projectRequired; } // ---------------------------------------------------------------------- // Online vs. Offline requirement // ---------------------------------------------------------------------- /** * @param requiresOnline true if the Mojo is online, false otherwise. */ public void setOnlineRequired( boolean requiresOnline ) { this.onlineRequired = requiresOnline; } /** * @return true if the Mojo is online, false otherwise. */ // blech! this isn't even intelligible as a method name. provided for // consistency... public boolean isOnlineRequired() { return onlineRequired; } /** * @return true if the Mojo is online, false otherwise. */ // more english-friendly method...keep the code clean! :) public boolean requiresOnline() { return onlineRequired; } /** * @return the binded phase name of the Mojo */ public String getPhase() { return phase; } /** * @param phase the new binded phase name of the Mojo */ public void setPhase( String phase ) { this.phase = phase; } /** * @return the version when the Mojo was added to the API */ public String getSince() { return since; } /** * @param since the new version when the Mojo was added to the API */ public void setSince( String since ) { this.since = since; } /** * @return The goal name of the Mojo */ public String getGoal() { return goal; } /** * @param goal The new goal name of the Mojo */ public void setGoal( String goal ) { this.goal = goal; } /** * @return the invocation phase of the Mojo */ public String getExecutePhase() { return executePhase; } /** * @param executePhase the new invocation phase of the Mojo */ public void setExecutePhase( String executePhase ) { this.executePhase = executePhase; } /** * @return true if the Mojo uses always for the executionStrategy */ public boolean alwaysExecute() { return MULTI_PASS_EXEC_STRATEGY.equals( executionStrategy ); } /** * @return the execution strategy */ public String getExecutionStrategy() { return executionStrategy; } /** * @param executionStrategy the new execution strategy */ public void setExecutionStrategy( String executionStrategy ) { this.executionStrategy = executionStrategy; } /** * @return the mojo configuration */ public PlexusConfiguration getMojoConfiguration() { if ( mojoConfiguration == null ) { mojoConfiguration = new XmlPlexusConfiguration( "configuration" ); } return mojoConfiguration; } /** * @param mojoConfiguration a new mojo configuration */ public void setMojoConfiguration( PlexusConfiguration mojoConfiguration ) { this.mojoConfiguration = mojoConfiguration; } /** {@inheritDoc} */ public String getRole() { return Mojo.ROLE; } /** {@inheritDoc} */ public String getRoleHint() { return getId(); } /** * @return the id of the mojo, based on the goal name */ public String getId() { return getPluginDescriptor().getId() + ":" + getGoal(); } /** * @return the full goal name * @see PluginDescriptor#getGoalPrefix() * @see #getGoal() */ public String getFullGoalName() { return getPluginDescriptor().getGoalPrefix() + ":" + getGoal(); } /** {@inheritDoc} */ public String getComponentType() { return MAVEN_PLUGIN; } /** * @return the plugin descriptor */ public PluginDescriptor getPluginDescriptor() { return pluginDescriptor; } /** * @param pluginDescriptor the new plugin descriptor */ public void setPluginDescriptor( PluginDescriptor pluginDescriptor ) { this.pluginDescriptor = pluginDescriptor; } /** * @return true if the Mojo is herited, false otherwise. */ public boolean isInheritedByDefault() { return inheritedByDefault; } /** * @param inheritedByDefault true if the Mojo is herited, false otherwise. */ public void setInheritedByDefault( boolean inheritedByDefault ) { this.inheritedByDefault = inheritedByDefault; } /** {@inheritDoc} */ public boolean equals( Object object ) { if ( this == object ) { return true; } if ( object instanceof MojoDescriptor ) { MojoDescriptor other = (MojoDescriptor) object; if ( !compareObjects( getPluginDescriptor(), other.getPluginDescriptor() ) ) { return false; } if ( !compareObjects( getGoal(), other.getGoal() ) ) { return false; } return true; } return false; } private boolean compareObjects( Object first, Object second ) { if ( ( first == null && second != null ) || ( first != null && second == null ) ) { return false; } if ( !first.equals( second ) ) { return false; } return true; } /** {@inheritDoc} */ public int hashCode() { int result = 1; String goal = getGoal(); if ( goal != null ) { result += goal.hashCode(); } PluginDescriptor pd = getPluginDescriptor(); if ( pd != null ) { result -= pd.hashCode(); } return result; } /** * @return the invocation lifecycle of the Mojo */ public String getExecuteLifecycle() { return executeLifecycle; } /** * @param executeLifecycle the new invocation lifecycle of the Mojo */ public void setExecuteLifecycle( String executeLifecycle ) { this.executeLifecycle = executeLifecycle; } /** * @param aggregator true if the Mojo uses the Maven project and its child modules, false otherwise. */ public void setAggregator( boolean aggregator ) { this.aggregator = aggregator; } /** * @return true if the Mojo uses the Maven project and its child modules, false otherwise. */ public boolean isAggregator() { return aggregator; } /** * @return true if the Mojo could not be invoke directly, false otherwise. */ public boolean isDirectInvocationOnly() { return directInvocationOnly; } /** * @param directInvocationOnly true if the Mojo could not be invoke directly, false otherwise. */ public void setDirectInvocationOnly( boolean directInvocationOnly ) { this.directInvocationOnly = directInvocationOnly; } /** * @return true if the Mojo needs reports to run, false otherwise. */ public boolean isRequiresReports() { return requiresReports; } /** * @param requiresReports true if the Mojo needs reports to run, false otherwise. */ public void setRequiresReports( boolean requiresReports ) { this.requiresReports = requiresReports; } /** * @param executeGoal the new invocation goal of the Mojo */ public void setExecuteGoal( String executeGoal ) { this.executeGoal = executeGoal; } /** * @return the invocation goal of the Mojo */ public String getExecuteGoal() { return executeGoal; } } ././@LongLink0000000000000000000000000000017400000000000011567 Lustar rootrootmaven2-core-2.2.1/maven-plugin-descriptor/src/main/java/org/apache/maven/plugin/descriptor/DuplicateParameterException.javamaven2-core-2.2.1/maven-plugin-descriptor/src/main/java/org/apache/maven/plugin/descriptor/Duplicate0000644000175000017500000000202010772004567033433 0ustar twernertwernerpackage org.apache.maven.plugin.descriptor; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ public class DuplicateParameterException extends InvalidPluginDescriptorException { public DuplicateParameterException( String message ) { super( message ); } } ././@LongLink0000000000000000000000000000015400000000000011565 Lustar rootrootmaven2-core-2.2.1/maven-plugin-descriptor/src/main/java/org/apache/maven/plugin/descriptor/Requirement.javamaven2-core-2.2.1/maven-plugin-descriptor/src/main/java/org/apache/maven/plugin/descriptor/Requireme0000644000175000017500000000273410772004567033473 0ustar twernertwernerpackage org.apache.maven.plugin.descriptor; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ /** * Describes a component requirement. * * @author Brett Porter * @version $Id: Requirement.java 640549 2008-03-24 20:05:11Z bentmann $ */ public class Requirement { private final String role; private final String roleHint; public Requirement( String role ) { this.role = role; this.roleHint = null; } public Requirement( String role, String roleHint ) { this.role = role; this.roleHint = roleHint; } public String getRole() { return role; } public String getRoleHint() { return roleHint; } } ././@LongLink0000000000000000000000000000020100000000000011556 Lustar rootrootmaven2-core-2.2.1/maven-plugin-descriptor/src/main/java/org/apache/maven/plugin/descriptor/DuplicateMojoDescriptorException.javamaven2-core-2.2.1/maven-plugin-descriptor/src/main/java/org/apache/maven/plugin/descriptor/Duplicate0000644000175000017500000000245010772004567033442 0ustar twernertwernerpackage org.apache.maven.plugin.descriptor; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ public class DuplicateMojoDescriptorException extends InvalidPluginDescriptorException { public DuplicateMojoDescriptorException( String goalPrefix, String goal, String existingImplementation, String newImplementation ) { super( "Goal: " + goal + " already exists in the plugin descriptor for prefix: " + goalPrefix + "\nExisting implementation is: " + existingImplementation + "\nConflicting implementation is: " + newImplementation ); } } ././@LongLink0000000000000000000000000000017000000000000011563 Lustar rootrootmaven2-core-2.2.1/maven-plugin-descriptor/src/main/java/org/apache/maven/plugin/descriptor/PluginDescriptorBuilder.javamaven2-core-2.2.1/maven-plugin-descriptor/src/main/java/org/apache/maven/plugin/descriptor/PluginDes0000644000175000017500000002704610772003040033413 0ustar twernertwernerpackage org.apache.maven.plugin.descriptor; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import org.codehaus.plexus.component.repository.ComponentDependency; import org.codehaus.plexus.component.repository.ComponentRequirement; import org.codehaus.plexus.configuration.PlexusConfiguration; import org.codehaus.plexus.configuration.PlexusConfigurationException; import org.codehaus.plexus.configuration.xml.XmlPlexusConfiguration; import org.codehaus.plexus.util.xml.Xpp3DomBuilder; import org.codehaus.plexus.util.xml.pull.XmlPullParserException; import java.io.IOException; import java.io.Reader; import java.util.ArrayList; import java.util.List; /** * @author Jason van Zyl * @version $Id: PluginDescriptorBuilder.java 640545 2008-03-24 19:50:56Z bentmann $ */ public class PluginDescriptorBuilder { public PluginDescriptor build( Reader reader ) throws PlexusConfigurationException { return build( reader, null ); } public PluginDescriptor build( Reader reader, String source ) throws PlexusConfigurationException { PlexusConfiguration c = buildConfiguration( reader ); PluginDescriptor pluginDescriptor = new PluginDescriptor(); pluginDescriptor.setSource( source ); pluginDescriptor.setGroupId( c.getChild( "groupId" ).getValue() ); pluginDescriptor.setArtifactId( c.getChild( "artifactId" ).getValue() ); pluginDescriptor.setVersion( c.getChild( "version" ).getValue() ); pluginDescriptor.setGoalPrefix( c.getChild( "goalPrefix" ).getValue() ); pluginDescriptor.setName( c.getChild( "name" ).getValue() ); pluginDescriptor.setDescription( c.getChild( "description" ).getValue() ); String isolatedRealm = c.getChild( "isolatedRealm" ).getValue(); if ( isolatedRealm != null ) { pluginDescriptor.setIsolatedRealm( Boolean.valueOf( isolatedRealm ).booleanValue() ); } String inheritedByDefault = c.getChild( "inheritedByDefault" ).getValue(); if ( inheritedByDefault != null ) { pluginDescriptor.setInheritedByDefault( Boolean.valueOf( inheritedByDefault ).booleanValue() ); } // ---------------------------------------------------------------------- // Components // ---------------------------------------------------------------------- PlexusConfiguration[] mojoConfigurations = c.getChild( "mojos" ).getChildren( "mojo" ); for ( int i = 0; i < mojoConfigurations.length; i++ ) { PlexusConfiguration component = mojoConfigurations[i]; MojoDescriptor mojoDescriptor = buildComponentDescriptor( component, pluginDescriptor ); pluginDescriptor.addMojo( mojoDescriptor ); } // ---------------------------------------------------------------------- // Dependencies // ---------------------------------------------------------------------- PlexusConfiguration[] dependencyConfigurations = c.getChild( "dependencies" ).getChildren( "dependency" ); List dependencies = new ArrayList(); for ( int i = 0; i < dependencyConfigurations.length; i++ ) { PlexusConfiguration d = dependencyConfigurations[i]; ComponentDependency cd = new ComponentDependency(); cd.setArtifactId( d.getChild( "artifactId" ).getValue() ); cd.setGroupId( d.getChild( "groupId" ).getValue() ); cd.setType( d.getChild( "type" ).getValue() ); cd.setVersion( d.getChild( "version" ).getValue() ); dependencies.add( cd ); } pluginDescriptor.setDependencies( dependencies ); return pluginDescriptor; } public MojoDescriptor buildComponentDescriptor( PlexusConfiguration c, PluginDescriptor pluginDescriptor ) throws PlexusConfigurationException { MojoDescriptor mojo = new MojoDescriptor(); mojo.setPluginDescriptor( pluginDescriptor ); mojo.setGoal( c.getChild( "goal" ).getValue() ); mojo.setImplementation( c.getChild( "implementation" ).getValue() ); PlexusConfiguration langConfig = c.getChild( "language" ); if ( langConfig != null ) { mojo.setLanguage( langConfig.getValue() ); } PlexusConfiguration configuratorConfig = c.getChild( "configurator" ); if ( configuratorConfig != null ) { mojo.setComponentConfigurator( configuratorConfig.getValue() ); } PlexusConfiguration composerConfig = c.getChild( "composer" ); if ( composerConfig != null ) { mojo.setComponentComposer( composerConfig.getValue() ); } String since = c.getChild( "since" ).getValue(); if ( since != null ) { mojo.setSince( since ); } String phase = c.getChild( "phase" ).getValue(); if ( phase != null ) { mojo.setPhase( phase ); } String executePhase = c.getChild( "executePhase" ).getValue(); if ( executePhase != null ) { mojo.setExecutePhase( executePhase ); } String executeMojo = c.getChild( "executeGoal" ).getValue(); if ( executeMojo != null ) { mojo.setExecuteGoal( executeMojo ); } String executeLifecycle = c.getChild( "executeLifecycle" ).getValue(); if ( executeLifecycle != null ) { mojo.setExecuteLifecycle( executeLifecycle ); } mojo.setInstantiationStrategy( c.getChild( "instantiationStrategy" ).getValue() ); mojo.setDescription( c.getChild( "description" ).getValue() ); String dependencyResolution = c.getChild( "requiresDependencyResolution" ).getValue(); if ( dependencyResolution != null ) { mojo.setDependencyResolutionRequired( dependencyResolution ); } String directInvocationOnly = c.getChild( "requiresDirectInvocation" ).getValue(); if ( directInvocationOnly != null ) { mojo.setDirectInvocationOnly( Boolean.valueOf( directInvocationOnly ).booleanValue() ); } String requiresProject = c.getChild( "requiresProject" ).getValue(); if ( requiresProject != null ) { mojo.setProjectRequired( Boolean.valueOf( requiresProject ).booleanValue() ); } String requiresReports = c.getChild( "requiresReports" ).getValue(); if ( requiresReports != null ) { mojo.setRequiresReports( Boolean.valueOf( requiresReports ).booleanValue() ); } String aggregator = c.getChild( "aggregator" ).getValue(); if ( aggregator != null ) { mojo.setAggregator( Boolean.valueOf( aggregator ).booleanValue() ); } String requiresOnline = c.getChild( "requiresOnline" ).getValue(); if ( requiresOnline != null ) { mojo.setOnlineRequired( Boolean.valueOf( requiresOnline ).booleanValue() ); } String inheritedByDefault = c.getChild( "inheritedByDefault" ).getValue(); if ( inheritedByDefault != null ) { mojo.setInheritedByDefault( Boolean.valueOf( inheritedByDefault ).booleanValue() ); } // ---------------------------------------------------------------------- // Parameters // ---------------------------------------------------------------------- PlexusConfiguration[] parameterConfigurations = c.getChild( "parameters" ).getChildren( "parameter" ); List parameters = new ArrayList(); for ( int i = 0; i < parameterConfigurations.length; i++ ) { PlexusConfiguration d = parameterConfigurations[i]; Parameter parameter = new Parameter(); parameter.setName( d.getChild( "name" ).getValue() ); parameter.setAlias( d.getChild( "alias" ).getValue() ); parameter.setType( d.getChild( "type" ).getValue() ); String required = d.getChild( "required" ).getValue(); parameter.setRequired( Boolean.valueOf( required ).booleanValue() ); PlexusConfiguration editableConfig = d.getChild( "editable" ); // we need the null check for pre-build legacy plugins... if ( editableConfig != null ) { String editable = d.getChild( "editable" ).getValue(); parameter.setEditable( editable == null || Boolean.valueOf( editable ).booleanValue() ); } parameter.setDescription( d.getChild( "description" ).getValue() ); parameter.setDeprecated( d.getChild( "deprecated" ).getValue() ); parameter.setImplementation( d.getChild( "implementation" ).getValue() ); parameters.add( parameter ); } mojo.setParameters( parameters ); // TODO: this should not need to be handed off... // ---------------------------------------------------------------------- // Configuration // ---------------------------------------------------------------------- mojo.setMojoConfiguration( c.getChild( "configuration" ) ); // TODO: Go back to this when we get the container ready to configure mojos... // mojo.setConfiguration( c.getChild( "configuration" ) ); // ---------------------------------------------------------------------- // Requirements // ---------------------------------------------------------------------- PlexusConfiguration[] requirements = c.getChild( "requirements" ).getChildren( "requirement" ); for ( int i = 0; i < requirements.length; i++ ) { PlexusConfiguration requirement = requirements[i]; ComponentRequirement cr = new ComponentRequirement(); cr.setRole( requirement.getChild( "role" ).getValue() ); cr.setRoleHint( requirement.getChild( "role-hint" ).getValue() ); cr.setFieldName( requirement.getChild( "field-name" ).getValue() ); mojo.addRequirement( cr ); } return mojo; } // ---------------------------------------------------------------------- // // ---------------------------------------------------------------------- public PlexusConfiguration buildConfiguration( Reader configuration ) throws PlexusConfigurationException { try { return new XmlPlexusConfiguration( Xpp3DomBuilder.build( configuration ) ); } catch ( IOException e ) { throw new PlexusConfigurationException( "Error creating configuration", e ); } catch ( XmlPullParserException e ) { throw new PlexusConfigurationException( "Error creating configuration", e ); } } } ././@LongLink0000000000000000000000000000017200000000000011565 Lustar rootrootmaven2-core-2.2.1/maven-plugin-descriptor/src/main/java/org/apache/maven/plugin/descriptor/InvalidParameterException.javamaven2-core-2.2.1/maven-plugin-descriptor/src/main/java/org/apache/maven/plugin/descriptor/InvalidPa0000644000175000017500000000257710551365651033410 0ustar twernertwernerpackage org.apache.maven.plugin.descriptor; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ /** * @author Jason van Zyl * @version $Id: InvalidParameterException.java,v 1.1 2005/02/20 16:25:21 * jdcasey Exp $ */ public class InvalidParameterException extends InvalidPluginDescriptorException { public InvalidParameterException( String element, int i ) { super( "The " + element + " element in parameter # " + i + " is invalid. It cannot be null." ); } public InvalidParameterException( String message, Throwable cause ) { super( message, cause ); } }maven2-core-2.2.1/maven-plugin-descriptor/pom.xml0000644000175000017500000000402011236625310021656 0ustar twernertwerner 4.0.0 org.apache.maven maven 2.2.1 maven-plugin-descriptor Maven Plugin Descriptor Model org.apache.maven maven-plugin-api org.apache.maven maven-artifact org.codehaus.plexus plexus-container-default org.codehaus.modello modello-maven-plugin src/main/mdo/lifecycle.mdo 1.0.0 maven2-core-2.2.1/maven-reporting/0000755000175000017500000000000011250552246016707 5ustar twernertwernermaven2-core-2.2.1/maven-reporting/maven-reporting-api/0000755000175000017500000000000011250552246022573 5ustar twernertwernermaven2-core-2.2.1/maven-reporting/maven-reporting-api/src/0000755000175000017500000000000011250552246023362 5ustar twernertwernermaven2-core-2.2.1/maven-reporting/maven-reporting-api/src/site/0000755000175000017500000000000011250552246024326 5ustar twernertwernermaven2-core-2.2.1/maven-reporting/maven-reporting-api/src/site/site.xml0000644000175000017500000000013211002611514025775 0ustar twernertwerner maven2-core-2.2.1/maven-reporting/maven-reporting-api/src/main/0000755000175000017500000000000011250552246024306 5ustar twernertwernermaven2-core-2.2.1/maven-reporting/maven-reporting-api/src/main/resources/0000755000175000017500000000000011250552246026320 5ustar twernertwernermaven2-core-2.2.1/maven-reporting/maven-reporting-api/src/main/resources/default-report.xml0000644000175000017500000000157110772004567032011 0ustar twernertwerner ${reports} maven2-core-2.2.1/maven-reporting/maven-reporting-api/src/main/java/0000755000175000017500000000000011250552246025227 5ustar twernertwernermaven2-core-2.2.1/maven-reporting/maven-reporting-api/src/main/java/org/0000755000175000017500000000000011250552246026016 5ustar twernertwernermaven2-core-2.2.1/maven-reporting/maven-reporting-api/src/main/java/org/apache/0000755000175000017500000000000011250552246027237 5ustar twernertwernermaven2-core-2.2.1/maven-reporting/maven-reporting-api/src/main/java/org/apache/maven/0000755000175000017500000000000011250552246030345 5ustar twernertwernermaven2-core-2.2.1/maven-reporting/maven-reporting-api/src/main/java/org/apache/maven/reporting/0000755000175000017500000000000011250552246032356 5ustar twernertwerner././@LongLink0000000000000000000000000000016000000000000011562 Lustar rootrootmaven2-core-2.2.1/maven-reporting/maven-reporting-api/src/main/java/org/apache/maven/reporting/MavenReport.javamaven2-core-2.2.1/maven-reporting/maven-reporting-api/src/main/java/org/apache/maven/reporting/Maven0000644000175000017500000000703310772004567033360 0ustar twernertwernerpackage org.apache.maven.reporting; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import org.codehaus.doxia.sink.Sink; import java.io.File; import java.util.Locale; /** * The basis for a Maven report. * * @author Brett Porter * @author Emmanuel Venisse * @author Vincent Siveton * @version $Id: MavenReport.java 640549 2008-03-24 20:05:11Z bentmann $ * @since 2.0 */ public interface MavenReport { /** Plexus lookup name */ String ROLE = MavenReport.class.getName(); /** Category for project information reports */ String CATEGORY_PROJECT_INFORMATION = "Project Info"; /** Category for project reports */ String CATEGORY_PROJECT_REPORTS = "Project Reports"; /** * Generate the report depending the wanted locale. *
* Mainly used for external reports like javadoc. * * @param sink the sink to use for the generation. * @param locale the wanted locale to generate the report, could be null. * @throws MavenReportException if any */ void generate( Sink sink, Locale locale ) throws MavenReportException; /** * @return the output name of this report. */ String getOutputName(); /** * Get the category name for this report. * * @return the category name of this report. Should be CATEGORY_PROJECT_INFORMATION * or CATEGORY_PROJECT_REPORTS * {@link #CATEGORY_PROJECT_INFORMATION} * {@link #CATEGORY_PROJECT_REPORTS} */ String getCategoryName(); /** * @param locale the wanted locale to return the report's name, could be null. * @return the name of this report. */ String getName( Locale locale ); /** * @param locale the wanted locale to return the report's description, could be null. * @return the description of this report. */ String getDescription( Locale locale ); /** * Set a new output directory. Useful for staging. * * @param outputDirectory the new output directory */ void setReportOutputDirectory( File outputDirectory ); /** * @return the current report output directory. */ File getReportOutputDirectory(); /** * An external report is a report which calls a third party program which generates some reports too. * A good example is javadoc tool. * * @return true if this report is external, false otherwise. * Default should false. */ boolean isExternalReport(); /** * Verify some conditions before generate the report. * * @return true if this report could be generated, false otherwise. * Default should true. */ boolean canGenerateReport(); } ././@LongLink0000000000000000000000000000017000000000000011563 Lustar rootrootmaven2-core-2.2.1/maven-reporting/maven-reporting-api/src/main/java/org/apache/maven/reporting/MavenReportRenderer.javamaven2-core-2.2.1/maven-reporting/maven-reporting-api/src/main/java/org/apache/maven/reporting/Maven0000644000175000017500000000272110772004567033357 0ustar twernertwernerpackage org.apache.maven.reporting; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ /** * Basis for rendering report. * * @author Jason van Zyl * @author Emmanuel Venisse * @version $Id: MavenReportRenderer.java 640549 2008-03-24 20:05:11Z bentmann $ * @since 2.0 * @TODO Later it may be appropriate to create something like a VelocityMavenReportRenderer * that could take a velocity template and pipe that through Doxia rather than coding * them up like this. */ public interface MavenReportRenderer { /** * @return the wanted report's title. */ String getTitle(); /** * Renderer a report. */ void render(); }././@LongLink0000000000000000000000000000017100000000000011564 Lustar rootrootmaven2-core-2.2.1/maven-reporting/maven-reporting-api/src/main/java/org/apache/maven/reporting/MavenReportException.javamaven2-core-2.2.1/maven-reporting/maven-reporting-api/src/main/java/org/apache/maven/reporting/Maven0000644000175000017500000000316710772004567033364 0ustar twernertwernerpackage org.apache.maven.reporting; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ /** * An exception occurring during the execution of a Maven report. * * @author Brett Porter * @author Emmanuel Venisse * @version $Id: MavenReportException.java 640549 2008-03-24 20:05:11Z bentmann $ * @since 2.0 */ public class MavenReportException extends Exception { /** The serialVersionUID **/ public static final long serialVersionUID = -6200353563231163785L; /** * Default constructor. * * @param msg the exception message. */ public MavenReportException( String msg ) { super( msg ); } /** * Other constructor. * * @param msg the exception message. * @param e the exception. */ public MavenReportException( String msg, Exception e ) { super( msg, e ); } } maven2-core-2.2.1/maven-reporting/maven-reporting-api/pom.xml0000644000175000017500000000347411236625310024115 0ustar twernertwerner 4.0.0 org.apache.maven.reporting maven-reporting 2.2.1 maven-reporting-api Maven Reporting API vsiveton Vincent Siveton vincent.siveton@gmail.com Java Developer -5 org.apache.maven.doxia doxia-sink-api org.apache.maven.doxia doxia-logging-api maven2-core-2.2.1/maven-reporting/src/0000755000175000017500000000000011250552246017476 5ustar twernertwernermaven2-core-2.2.1/maven-reporting/src/site/0000755000175000017500000000000011250552246020442 5ustar twernertwernermaven2-core-2.2.1/maven-reporting/src/site/site.xml0000644000175000017500000000016411002611514022116 0ustar twernertwerner maven2-core-2.2.1/maven-reporting/pom.xml0000644000175000017500000000264311236625310020226 0ustar twernertwerner 4.0.0 org.apache.maven maven 2.2.1 org.apache.maven.reporting maven-reporting pom Maven Reporting 2005 maven-reporting-api maven2-core-2.2.1/maven-compat/0000755000175000017500000000000011250552240016153 5ustar twernertwernermaven2-core-2.2.1/maven-compat/src/0000755000175000017500000000000011250552240016742 5ustar twernertwernermaven2-core-2.2.1/maven-compat/src/main/0000755000175000017500000000000011250552240017666 5ustar twernertwernermaven2-core-2.2.1/maven-compat/src/main/java/0000755000175000017500000000000011250552240020607 5ustar twernertwernermaven2-core-2.2.1/maven-compat/src/main/java/org/0000755000175000017500000000000011250552240021376 5ustar twernertwernermaven2-core-2.2.1/maven-compat/src/main/java/org/apache/0000755000175000017500000000000011250552240022617 5ustar twernertwernermaven2-core-2.2.1/maven-compat/src/main/java/org/apache/maven/0000755000175000017500000000000011250552240023725 5ustar twernertwernermaven2-core-2.2.1/maven-compat/src/main/java/org/apache/maven/cli/0000755000175000017500000000000011250552240024474 5ustar twernertwernermaven2-core-2.2.1/maven-compat/src/main/java/org/apache/maven/cli/compat/0000755000175000017500000000000011250552240025757 5ustar twernertwernermaven2-core-2.2.1/maven-compat/src/main/java/org/apache/maven/cli/compat/CompatibleMain.java0000644000175000017500000000424111232100305031476 0ustar twernertwernerpackage org.apache.maven.cli.compat; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import org.apache.maven.cli.MavenCli; import org.codehaus.classworlds.ClassWorld; /** * Main class used to shield the user from the rest of Maven in the event the user is using JDK < 1.5. * * @since 2.2.0 */ public class CompatibleMain { public static void main( String[] args ) { ClassWorld classWorld = new ClassWorld( "plexus.core", Thread.currentThread().getContextClassLoader() ); int result = main( args, classWorld ); System.exit( result ); } /** * @noinspection ConfusingMainMethod */ public static int main( String[] args, ClassWorld classWorld ) { // ---------------------------------------------------------------------- // Setup the command line parser // ---------------------------------------------------------------------- String javaVersion = System.getProperty( "java.specification.version", "1.5" ); if ( "1.4".equals( javaVersion ) || "1.3".equals( javaVersion ) || "1.2".equals( javaVersion ) || "1.1".equals( javaVersion ) ) { System.out.println( "Java specification version: " + javaVersion ); System.err.println( "This release of Maven requires Java version 1.5 or greater." ); return 1; } return MavenCli.main( args, classWorld ); } } maven2-core-2.2.1/maven-compat/pom.xml0000644000175000017500000000714211236625310017477 0ustar twernertwerner 4.0.0 org.apache.maven maven 2.2.1 maven-compat Maven Compatibility Layer org.apache.maven maven-core org.codehaus.plexus plexus-container-default commons-cli commons-cli commons-lang commons-lang commons-logging commons-logging org.codehaus.plexus plexus-utils classworlds classworlds org.apache.maven.plugins maven-compiler-plugin 2.0.2 1.3 1.3 org.codehaus.mojo clirr-maven-plugin ${project.groupId} maven-core 2.1.0 ** maven2-core-2.2.1/maven-artifact-manager/0000755000175000017500000000000011250552244020101 5ustar twernertwernermaven2-core-2.2.1/maven-artifact-manager/src/0000755000175000017500000000000011250552244020670 5ustar twernertwernermaven2-core-2.2.1/maven-artifact-manager/src/site/0000755000175000017500000000000011250552244021634 5ustar twernertwernermaven2-core-2.2.1/maven-artifact-manager/src/site/site.xml0000644000175000017500000000013211002611514023305 0ustar twernertwerner maven2-core-2.2.1/maven-artifact-manager/src/test/0000755000175000017500000000000011250552243021646 5ustar twernertwernermaven2-core-2.2.1/maven-artifact-manager/src/test/resources/0000755000175000017500000000000011250552243023660 5ustar twernertwernermaven2-core-2.2.1/maven-artifact-manager/src/test/resources/org/0000755000175000017500000000000011250552243024447 5ustar twernertwernermaven2-core-2.2.1/maven-artifact-manager/src/test/resources/org/apache/0000755000175000017500000000000011250552243025670 5ustar twernertwernermaven2-core-2.2.1/maven-artifact-manager/src/test/resources/org/apache/maven/0000755000175000017500000000000011250552243026776 5ustar twernertwernermaven2-core-2.2.1/maven-artifact-manager/src/test/resources/org/apache/maven/artifact/0000755000175000017500000000000011250552243030573 5ustar twernertwernermaven2-core-2.2.1/maven-artifact-manager/src/test/resources/org/apache/maven/artifact/manager/0000755000175000017500000000000011250552243032205 5ustar twernertwerner././@LongLink0000000000000000000000000000017200000000000011565 Lustar rootrootmaven2-core-2.2.1/maven-artifact-manager/src/test/resources/org/apache/maven/artifact/manager/DefaultWagonManagerTest.xmlmaven2-core-2.2.1/maven-artifact-manager/src/test/resources/org/apache/maven/artifact/manager/Defaul0000644000175000017500000000432511233654070033336 0ustar twernertwerner org.apache.maven.wagon.Wagon a org.apache.maven.artifact.manager.WagonA org.apache.maven.wagon.Wagon a-foo org.apache.maven.artifact.manager.WagonAWithImplementationHint org.apache.maven.wagon.Wagon b1 org.apache.maven.artifact.manager.WagonB org.apache.maven.wagon.Wagon b2 org.apache.maven.artifact.manager.WagonB org.apache.maven.wagon.Wagon c org.apache.maven.artifact.manager.WagonC org.apache.maven.wagon.Wagon string org.apache.maven.artifact.manager.StringWagon org.apache.maven.artifact.repository.authentication.AuthenticationInfoProvider org.apache.maven.artifact.repository.authentication.DummyAuthenticationInfoProvider maven2-core-2.2.1/maven-artifact-manager/src/test/resources/org/apache/maven/artifact/deployer/0000755000175000017500000000000011250552243032416 5ustar twernertwerner././@LongLink0000000000000000000000000000017000000000000011563 Lustar rootrootmaven2-core-2.2.1/maven-artifact-manager/src/test/resources/org/apache/maven/artifact/deployer/ArtifactDeployerTest.xmlmaven2-core-2.2.1/maven-artifact-manager/src/test/resources/org/apache/maven/artifact/deployer/Artif0000644000175000017500000000205610551365651033421 0ustar twernertwerner org.apache.maven.artifact.repository.authentication.AuthenticationInfoProvider org.apache.maven.artifact.repository.authentication.DummyAuthenticationInfoProvider maven2-core-2.2.1/maven-artifact-manager/src/test/resources/org/apache/maven/artifact/resolver/0000755000175000017500000000000011250552243032434 5ustar twernertwerner././@LongLink0000000000000000000000000000017000000000000011563 Lustar rootrootmaven2-core-2.2.1/maven-artifact-manager/src/test/resources/org/apache/maven/artifact/resolver/ArtifactResolverTest.xmlmaven2-core-2.2.1/maven-artifact-manager/src/test/resources/org/apache/maven/artifact/resolver/Artif0000644000175000017500000000205610551365651033437 0ustar twernertwerner org.apache.maven.artifact.repository.authentication.AuthenticationInfoProvider org.apache.maven.artifact.repository.authentication.DummyAuthenticationInfoProvider maven2-core-2.2.1/maven-artifact-manager/src/test/resources/org/apache/maven/artifact/installer/0000755000175000017500000000000011250552243032570 5ustar twernertwerner././@LongLink0000000000000000000000000000017200000000000011565 Lustar rootrootmaven2-core-2.2.1/maven-artifact-manager/src/test/resources/org/apache/maven/artifact/installer/ArtifactInstallerTest.xmlmaven2-core-2.2.1/maven-artifact-manager/src/test/resources/org/apache/maven/artifact/installer/Arti0000644000175000017500000000205610551365651033425 0ustar twernertwerner org.apache.maven.artifact.repository.authentication.AuthenticationInfoProvider org.apache.maven.artifact.repository.authentication.DummyAuthenticationInfoProvider maven2-core-2.2.1/maven-artifact-manager/src/test/resources/artifact-install/0000755000175000017500000000000011250552243027121 5ustar twernertwernermaven2-core-2.2.1/maven-artifact-manager/src/test/resources/pom.xml0000644000175000017500000001021710551365651025206 0ustar twernertwerner 4.0.0 org.apache.maven maven-core jar Maven 2.0-SNAPSHOT 2001 org.apache.maven maven-model 2.0-SNAPSHOT jar compile org.apache.maven maven-plugin 2.0-SNAPSHOT jar compile commons-cli commons-cli 1.0-beta-2 jar compile plexus plexus-i18n 1.0-beta-2-SNAPSHOT jar compile ognl ognl 2.5.1 jar compile marmalade marmalade-core 0.1 jar compile marmalade marmalade-el-ognl 0.1 jar compile plexus plexus-compiler-api 1.0 jar compile plexus plexus-compiler-javac 1.0 jar compile surefire surefire-booter 1.1 jar compile maven wagon-api 0.9-SNAPSHOT jar compile org.apache.maven wagon-http-lightweight 0.9-SNAPSHOT jar compile maven wagon-ssh 0.9-SNAPSHOT jar compile jsch jsch 0.1.14 jar compile qdox qdox 1.2 jar compile maven2-core-2.2.1/maven-artifact-manager/src/test/java/0000755000175000017500000000000011250552243022567 5ustar twernertwernermaven2-core-2.2.1/maven-artifact-manager/src/test/java/org/0000755000175000017500000000000011250552243023356 5ustar twernertwernermaven2-core-2.2.1/maven-artifact-manager/src/test/java/org/apache/0000755000175000017500000000000011250552243024577 5ustar twernertwernermaven2-core-2.2.1/maven-artifact-manager/src/test/java/org/apache/maven/0000755000175000017500000000000011250552243025705 5ustar twernertwernermaven2-core-2.2.1/maven-artifact-manager/src/test/java/org/apache/maven/artifact/0000755000175000017500000000000011250552243027502 5ustar twernertwernermaven2-core-2.2.1/maven-artifact-manager/src/test/java/org/apache/maven/artifact/manager/0000755000175000017500000000000011250552243031114 5ustar twernertwerner././@LongLink0000000000000000000000000000015000000000000011561 Lustar rootrootmaven2-core-2.2.1/maven-artifact-manager/src/test/java/org/apache/maven/artifact/manager/WagonMock.javamaven2-core-2.2.1/maven-artifact-manager/src/test/java/org/apache/maven/artifact/manager/WagonMock.j0000644000175000017500000000300010772004567033156 0ustar twernertwernerpackage org.apache.maven.artifact.manager; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import org.apache.maven.wagon.providers.file.FileWagon; /** * Mock of a Wagon for testing * * @author Carlos Sanchez * @version $Id: WagonMock.java 640549 2008-03-24 20:05:11Z bentmann $ */ public class WagonMock extends FileWagon { /** * A field that can be configured in the Wagon * * @component.configuration default="configurableField" */ private String configurableField = null; public void setConfigurableField( String configurableField ) { this.configurableField = configurableField; } public String getConfigurableField() { return configurableField; } } ././@LongLink0000000000000000000000000000014500000000000011565 Lustar rootrootmaven2-core-2.2.1/maven-artifact-manager/src/test/java/org/apache/maven/artifact/manager/WagonB.javamaven2-core-2.2.1/maven-artifact-manager/src/test/java/org/apache/maven/artifact/manager/WagonB.java0000644000175000017500000000237310551365651033151 0ustar twernertwernerpackage org.apache.maven.artifact.manager; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ /** * Wagon for testing, for protocols b1 and b2 * * @author Carlos Sanchez * @author Jason van Zyl * @version $Id: WagonB.java 495147 2007-01-11 07:47:53Z jvanzyl $ */ public class WagonB extends WagonMock { public String[] getSupportedProtocols() { return new String[]{ "b1", "b2" }; } } ././@LongLink0000000000000000000000000000014500000000000011565 Lustar rootrootmaven2-core-2.2.1/maven-artifact-manager/src/test/java/org/apache/maven/artifact/manager/WagonA.javamaven2-core-2.2.1/maven-artifact-manager/src/test/java/org/apache/maven/artifact/manager/WagonA.java0000644000175000017500000000233610551365651033147 0ustar twernertwernerpackage org.apache.maven.artifact.manager; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ /** * Wagon for testing, for protocol a * * @author Carlos Sanchez * @author Jason van Zyl * @version $Id: WagonA.java 495147 2007-01-11 07:47:53Z jvanzyl $ */ public class WagonA extends WagonMock { public String[] getSupportedProtocols() { return new String[]{ "a" }; } } ././@LongLink0000000000000000000000000000017300000000000011566 Lustar rootrootmaven2-core-2.2.1/maven-artifact-manager/src/test/java/org/apache/maven/artifact/manager/WagonAWithImplementationHint.javamaven2-core-2.2.1/maven-artifact-manager/src/test/java/org/apache/maven/artifact/manager/WagonAWithI0000644000175000017500000000241011233654070033157 0ustar twernertwernerpackage org.apache.maven.artifact.manager; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ /** * Wagon for testing, for protocol a * * @author Carlos Sanchez * @author Jason van Zyl * @version $Id: WagonAWithImplementationHint.java 798691 2009-07-28 19:57:44Z brett $ */ public class WagonAWithImplementationHint extends WagonMock { public String[] getSupportedProtocols() { return new String[]{ "a" }; } } ././@LongLink0000000000000000000000000000016600000000000011570 Lustar rootrootmaven2-core-2.2.1/maven-artifact-manager/src/test/java/org/apache/maven/artifact/manager/DefaultWagonManagerTest.javamaven2-core-2.2.1/maven-artifact-manager/src/test/java/org/apache/maven/artifact/manager/DefaultWago0000644000175000017500000005164111233654070033252 0ustar twernertwernerpackage org.apache.maven.artifact.manager; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.factory.ArtifactFactory; import org.apache.maven.artifact.metadata.ArtifactMetadata; import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.artifact.repository.ArtifactRepositoryPolicy; import org.apache.maven.artifact.repository.DefaultArtifactRepository; import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout; import org.apache.maven.artifact.repository.layout.DefaultRepositoryLayout; import org.apache.maven.wagon.ResourceDoesNotExistException; import org.apache.maven.wagon.TransferFailedException; import org.apache.maven.wagon.UnsupportedProtocolException; import org.apache.maven.wagon.Wagon; import org.apache.maven.wagon.providers.http.HttpWagon; import org.apache.maven.wagon.repository.Repository; import org.codehaus.plexus.PlexusTestCase; import org.codehaus.plexus.util.FileUtils; import org.codehaus.plexus.util.xml.Xpp3Dom; import java.io.File; import java.io.IOException; import edu.umd.cs.mtc.MultithreadedTestCase; import edu.umd.cs.mtc.TestFramework; /** * @author Michal Maczka * @version $Id: DefaultWagonManagerTest.java 798691 2009-07-28 19:57:44Z brett $ */ public class DefaultWagonManagerTest extends PlexusTestCase { private static final int NUM_EXECUTIONS = 1000; private static final String TEST_USER_AGENT = "Test-Agent/1.0"; private WagonManager wagonManager; private ArtifactFactory artifactFactory; protected void setUp() throws Exception { super.setUp(); wagonManager = (WagonManager) lookup( WagonManager.ROLE ); artifactFactory = (ArtifactFactory) lookup( ArtifactFactory.ROLE ); } private Artifact createTestPomArtifact( String directory ) throws IOException { File testData = getTestFile( directory ); FileUtils.deleteDirectory( testData ); testData.mkdirs(); Artifact artifact = artifactFactory.createProjectArtifact( "test", "test", "1.0" ); artifact.setFile( new File( testData, "test-1.0.pom" ) ); assertFalse( artifact.getFile().exists() ); return artifact; } private Artifact createTestArtifact( String directory, String type ) throws IOException { File testData = getTestFile( directory ); FileUtils.deleteDirectory( testData ); testData.mkdirs(); Artifact artifact = artifactFactory.createBuildArtifact( "test", "test", "1.0", type ); artifact.setFile( new File( testData, "test-1.0." + artifact.getArtifactHandler().getExtension() ) ); assertFalse( artifact.getFile().exists() ); return artifact; } public void testAddMirrorWithNullRepositoryId() { wagonManager.addMirror( null, "test", "http://www.nowhere.com/" ); } public void testGetArtifactSha1MissingMd5Present() throws IOException, UnsupportedProtocolException, TransferFailedException, ResourceDoesNotExistException { Artifact artifact = createTestPomArtifact( "target/test-data/get-remote-artifact" ); ArtifactRepository repo = createStringRepo(); StringWagon wagon = (StringWagon) wagonManager.getWagon( "string" ); wagon.addExpectedContent( repo.getLayout().pathOf( artifact ), "expected" ); wagon.addExpectedContent( repo.getLayout().pathOf( artifact ) + ".md5", "bad_checksum" ); wagonManager.getArtifact( artifact, repo ); assertTrue( artifact.getFile().exists() ); } private ArtifactRepository createStringRepo() { ArtifactRepository repo = new DefaultArtifactRepository( "id", "string://url", new ArtifactRepositoryLayoutStub() ); return repo; } /** * checks the handling of urls */ public void testExternalURL() { DefaultWagonManager mgr = new DefaultWagonManager(); assertTrue( mgr.isExternalRepo( getRepo( "foo", "http://somehost" ) ) ); assertTrue( mgr.isExternalRepo( getRepo( "foo", "http://somehost:9090/somepath" ) ) ); assertTrue( mgr.isExternalRepo( getRepo( "foo", "ftp://somehost" ) ) ); assertTrue( mgr.isExternalRepo( getRepo( "foo", "http://192.168.101.1" ) ) ); assertTrue( mgr.isExternalRepo( getRepo( "foo", "http://" ) ) ); // these are local assertFalse( mgr.isExternalRepo( getRepo( "foo", "http://localhost:8080" ) ) ); assertFalse( mgr.isExternalRepo( getRepo( "foo", "http://127.0.0.1:9090" ) ) ); assertFalse( mgr.isExternalRepo( getRepo( "foo", "file://localhost/somepath" ) ) ); assertFalse( mgr.isExternalRepo( getRepo( "foo", "file://localhost/D:/somepath" ) ) ); assertFalse( mgr.isExternalRepo( getRepo( "foo", "http://localhost" ) ) ); assertFalse( mgr.isExternalRepo( getRepo( "foo", "http://127.0.0.1" ) ) ); assertFalse( mgr.isExternalRepo( getRepo( "foo", "file:///somepath" ) ) ); assertFalse( mgr.isExternalRepo( getRepo( "foo", "file://D:/somepath" ) ) ); // not a proper url so returns false; assertFalse( mgr.isExternalRepo( getRepo( "foo", "192.168.101.1" ) ) ); assertFalse( mgr.isExternalRepo( getRepo( "foo", "" ) ) ); } /** * Check that lookups with exact matches work and that no matches don't corrupt the repo. */ public void testMirrorLookup() { wagonManager.addMirror( "a", "a", "http://a" ); wagonManager.addMirror( "b", "b", "http://b" ); ArtifactRepository repo = null; repo = wagonManager.getMirrorRepository( getRepo( "a", "http://a.a" ) ); assertEquals( "http://a", repo.getUrl() ); repo = wagonManager.getMirrorRepository( getRepo( "b", "http://a.a" ) ); assertEquals( "http://b", repo.getUrl() ); repo = wagonManager.getMirrorRepository( getRepo( "c", "http://c.c" ) ); assertEquals( "http://c.c", repo.getUrl() ); } /** * Check that wildcards don't override exact id matches. */ public void testMirrorWildcardLookup() { wagonManager.addMirror( "a", "a", "http://a" ); wagonManager.addMirror( "b", "b", "http://b" ); wagonManager.addMirror( "c", "*", "http://wildcard" ); ArtifactRepository repo = null; repo = wagonManager.getMirrorRepository( getRepo( "a", "http://a.a" ) ); assertEquals( "http://a", repo.getUrl() ); repo = wagonManager.getMirrorRepository( getRepo( "b", "http://a.a" ) ); assertEquals( "http://b", repo.getUrl() ); repo = wagonManager.getMirrorRepository( getRepo( "c", "http://c.c" ) ); assertEquals( "http://wildcard", repo.getUrl() ); } /** * Check that patterns are processed correctly Valid patterns: * = everything external:* = everything not on the * localhost and not file based. repo,repo1 = repo or repo1 *,!repo1 = everything except repo1 */ public void testPatterns() { DefaultWagonManager mgr = new DefaultWagonManager(); assertTrue( mgr.matchPattern( getRepo( "a" ), "*" ) ); assertTrue( mgr.matchPattern( getRepo( "a" ), "*," ) ); assertTrue( mgr.matchPattern( getRepo( "a" ), ",*," ) ); assertTrue( mgr.matchPattern( getRepo( "a" ), "*," ) ); assertTrue( mgr.matchPattern( getRepo( "a" ), "a" ) ); assertTrue( mgr.matchPattern( getRepo( "a" ), "a," ) ); assertTrue( mgr.matchPattern( getRepo( "a" ), ",a," ) ); assertTrue( mgr.matchPattern( getRepo( "a" ), "a," ) ); assertFalse( mgr.matchPattern( getRepo( "b" ), "a" ) ); assertFalse( mgr.matchPattern( getRepo( "b" ), "a," ) ); assertFalse( mgr.matchPattern( getRepo( "b" ), ",a" ) ); assertFalse( mgr.matchPattern( getRepo( "b" ), ",a," ) ); assertTrue( mgr.matchPattern( getRepo( "a" ), "a,b" ) ); assertTrue( mgr.matchPattern( getRepo( "b" ), "a,b" ) ); assertFalse( mgr.matchPattern( getRepo( "c" ), "a,b" ) ); assertTrue( mgr.matchPattern( getRepo( "a" ), "*" ) ); assertTrue( mgr.matchPattern( getRepo( "a" ), "*,b" ) ); assertTrue( mgr.matchPattern( getRepo( "a" ), "*,!b" ) ); assertFalse( mgr.matchPattern( getRepo( "a" ), "*,!a" ) ); assertFalse( mgr.matchPattern( getRepo( "a" ), "!a,*" ) ); assertTrue( mgr.matchPattern( getRepo( "c" ), "*,!a" ) ); assertTrue( mgr.matchPattern( getRepo( "c" ), "!a,*" ) ); assertFalse( mgr.matchPattern( getRepo( "c" ), "!a,!c" ) ); assertFalse( mgr.matchPattern( getRepo( "d" ), "!a,!c*" ) ); } /** * make sure the external if is fully exercised. We can assume file and ips are also handled because they have a * separate test above. */ public void testPatternsWithExternal() { DefaultWagonManager mgr = new DefaultWagonManager(); assertTrue( mgr.matchPattern( getRepo( "a", "http://localhost" ), "*" ) ); assertFalse( mgr.matchPattern( getRepo( "a", "http://localhost" ), "external:*" ) ); assertTrue( mgr.matchPattern( getRepo( "a", "http://localhost" ), "external:*,a" ) ); assertFalse( mgr.matchPattern( getRepo( "a", "http://localhost" ), "external:*,!a" ) ); assertTrue( mgr.matchPattern( getRepo( "a", "http://localhost" ), "a,external:*" ) ); assertFalse( mgr.matchPattern( getRepo( "a", "http://localhost" ), "!a,external:*" ) ); assertFalse( mgr.matchPattern( getRepo( "c", "http://localhost" ), "!a,external:*" ) ); assertTrue( mgr.matchPattern( getRepo( "c", "http://somehost" ), "!a,external:*" ) ); } /** * Check that first match wins */ public void testMirrorStopOnFirstMatch() { // exact matches win first wagonManager.addMirror( "a2", "a,b", "http://a2" ); wagonManager.addMirror( "a", "a", "http://a" ); // make sure repeated entries are skipped wagonManager.addMirror( "a", "a", "http://a3" ); wagonManager.addMirror( "b", "b", "http://b" ); wagonManager.addMirror( "c", "d,e", "http://de" ); wagonManager.addMirror( "c", "*", "http://wildcard" ); wagonManager.addMirror( "c", "e,f", "http://ef" ); ArtifactRepository repo = null; repo = wagonManager.getMirrorRepository( getRepo( "a", "http://a.a" ) ); assertEquals( "http://a", repo.getUrl() ); repo = wagonManager.getMirrorRepository( getRepo( "b", "http://a.a" ) ); assertEquals( "http://b", repo.getUrl() ); repo = wagonManager.getMirrorRepository( getRepo( "c", "http://c.c" ) ); assertEquals( "http://wildcard", repo.getUrl() ); repo = wagonManager.getMirrorRepository( getRepo( "d", "http://d" ) ); assertEquals( "http://de", repo.getUrl() ); repo = wagonManager.getMirrorRepository( getRepo( "e", "http://e" ) ); assertEquals( "http://de", repo.getUrl() ); repo = wagonManager.getMirrorRepository( getRepo( "f", "http://f" ) ); assertEquals( "http://wildcard", repo.getUrl() ); } /** * Build an ArtifactRepository object. * * @param id * @param url * @return */ private ArtifactRepository getRepo( String id, String url ) { return new DefaultArtifactRepository( id, url, new DefaultRepositoryLayout() ); } /** * Build an ArtifactRepository object. * * @param id * @return */ private ArtifactRepository getRepo( String id ) { return getRepo( id, "http://something" ); } public void testDefaultWagonManager() throws Exception { assertWagon( "a" ); assertWagon( "b1" ); assertWagon( "b2" ); assertWagon( "c" ); assertWagon( "string" ); try { assertWagon( "d" ); fail( "Expected :" + UnsupportedProtocolException.class.getName() ); } catch ( UnsupportedProtocolException e ) { // ok assertTrue( true ); } } public void testGetWagonRepository() throws Exception { assertWagonRepository( "a" ); assertWagonRepository( "b1" ); assertWagonRepository( "b2" ); assertWagonRepository( "c" ); try { assertWagonRepository( "d" ); fail( "Expected :" + UnsupportedProtocolException.class.getName() ); } catch ( UnsupportedProtocolException e ) { // ok assertTrue( true ); } } public void testGetWagonRepositoryNullProtocol() throws Exception { try { Repository repository = new Repository(); repository.setProtocol( null ); Wagon wagon = wagonManager.getWagon( repository ); fail( "Expected :" + UnsupportedProtocolException.class.getName() ); } catch ( UnsupportedProtocolException e ) { // ok assertTrue( true ); } } public void testGetWagonMultithreaded() throws Throwable { DefaultWagonManager manager = (DefaultWagonManager) wagonManager; manager.setHttpUserAgent( TEST_USER_AGENT ); assertNotNull( manager.getHttpUserAgent() ); TestFramework.runOnce( new MultithreadedTestCase() { private Repository repository; public void initialize() { repository = new Repository(); repository.setProtocol( "http" ); repository.setId( "server" ); } public void thread1() throws Exception { for ( int i = 0; i < NUM_EXECUTIONS; i++ ) { runThread(); } } public void thread2() throws Exception { for ( int i = 0; i < NUM_EXECUTIONS; i++ ) { runThread(); } } private void runThread() throws Exception { HttpWagon wagon = (HttpWagon) wagonManager.getWagon( repository ); assertEquals( TEST_USER_AGENT, wagon.getHttpHeaders().getProperty( "User-Agent" ) ); container.release( wagon ); } } ); } /** * Checks the verification of checksums. */ public void testChecksumVerification() throws Exception { ArtifactRepositoryPolicy policy = new ArtifactRepositoryPolicy( true, ArtifactRepositoryPolicy.UPDATE_POLICY_ALWAYS, ArtifactRepositoryPolicy.CHECKSUM_POLICY_FAIL ); ArtifactRepository repo = new DefaultArtifactRepository( "id", "string://url", new ArtifactRepositoryLayoutStub(), policy, policy ); Artifact artifact = createTestArtifact( "target/test-data/sample-art", "jar" ); StringWagon wagon = (StringWagon) wagonManager.getWagon( "string" ); artifact.getFile().delete(); wagon.clearExpectedContent(); wagon.addExpectedContent( "path", "lower-case-checksum" ); wagon.addExpectedContent( "path.sha1", "2a25dc564a3b34f68237fc849066cbc7bb7a36a1" ); try { wagonManager.getArtifact( artifact, repo ); } catch ( ChecksumFailedException e ) { fail( "Checksum verification did not pass: " + e.getMessage() ); } artifact.getFile().delete(); wagon.clearExpectedContent(); wagon.addExpectedContent( "path", "upper-case-checksum" ); wagon.addExpectedContent( "path.sha1", "B7BB97D7D0B9244398D9B47296907F73313663E6" ); try { wagonManager.getArtifact( artifact, repo ); } catch ( ChecksumFailedException e ) { fail( "Checksum verification did not pass: " + e.getMessage() ); } artifact.getFile().delete(); wagon.clearExpectedContent(); wagon.addExpectedContent( "path", "expected-failure" ); wagon.addExpectedContent( "path.sha1", "b7bb97d7d0b9244398d9b47296907f73313663e6" ); try { wagonManager.getArtifact( artifact, repo ); fail( "Checksum verification did not fail" ); } catch ( ChecksumFailedException e ) { // expected } artifact.getFile().delete(); wagon.clearExpectedContent(); wagon.addExpectedContent( "path", "lower-case-checksum" ); wagon.addExpectedContent( "path.md5", "50b2cf50a103a965efac62b983035cac" ); try { wagonManager.getArtifact( artifact, repo ); } catch ( ChecksumFailedException e ) { fail( "Checksum verification did not pass: " + e.getMessage() ); } artifact.getFile().delete(); wagon.clearExpectedContent(); wagon.addExpectedContent( "path", "upper-case-checksum" ); wagon.addExpectedContent( "path.md5", "842F568FCCFEB7E534DC72133D42FFDC" ); try { wagonManager.getArtifact( artifact, repo ); } catch ( ChecksumFailedException e ) { fail( "Checksum verification did not pass: " + e.getMessage() ); } artifact.getFile().delete(); wagon.clearExpectedContent(); wagon.addExpectedContent( "path", "expected-failure" ); wagon.addExpectedContent( "path.md5", "b7bb97d7d0b9244398d9b47296907f73313663e6" ); try { wagonManager.getArtifact( artifact, repo ); fail( "Checksum verification did not fail" ); } catch ( ChecksumFailedException e ) { // expected } } private void assertWagon( String protocol ) throws Exception { Wagon wagon = wagonManager.getWagon( protocol ); assertNotNull( "Check wagon, protocol=" + protocol, wagon ); } private void assertWagonRepository( String protocol ) throws Exception { Repository repository = new Repository(); String s = "value=" + protocol; repository.setId( "id=" + protocol ); repository.setProtocol( protocol ); Xpp3Dom conf = new Xpp3Dom( "configuration" ); Xpp3Dom configurableField = new Xpp3Dom( "configurableField" ); configurableField.setValue( s ); conf.addChild( configurableField ); wagonManager.addConfiguration( repository.getId(), conf ); WagonMock wagon = (WagonMock) wagonManager.getWagon( repository ); assertNotNull( "Check wagon, protocol=" + protocol, wagon ); assertEquals( "Check configuration for wagon, protocol=" + protocol, s, wagon.getConfigurableField() ); } public void testWagonWithImplHint() throws Exception { Repository repository = new Repository(); repository.setId( "id" ); repository.setProtocol( "a" ); Xpp3Dom conf = new Xpp3Dom( "configuration" ); Xpp3Dom configurableField = new Xpp3Dom( "wagonProvider" ); configurableField.setValue( "foo" ); conf.addChild( configurableField ); wagonManager.addConfiguration( repository.getId(), conf ); WagonMock wagon = (WagonMock) wagonManager.getWagon( repository ); assertNotNull( "Check wagon", wagon ); assertEquals( "Check configuration for wagon", WagonAWithImplementationHint.class, wagon.getClass() ); // try again to check configuration alterations don't modify behaviour wagon = (WagonMock) wagonManager.getWagon( repository ); assertNotNull( "Check wagon", wagon ); assertEquals( "Check configuration for wagon", WagonAWithImplementationHint.class, wagon.getClass() ); } private final class ArtifactRepositoryLayoutStub implements ArtifactRepositoryLayout { public String pathOfRemoteRepositoryMetadata( ArtifactMetadata metadata ) { return "path"; } public String pathOfLocalRepositoryMetadata( ArtifactMetadata metadata, ArtifactRepository repository ) { return "path"; } public String pathOf( Artifact artifact ) { return "path"; } } } ././@LongLink0000000000000000000000000000015200000000000011563 Lustar rootrootmaven2-core-2.2.1/maven-artifact-manager/src/test/java/org/apache/maven/artifact/manager/StringWagon.javamaven2-core-2.2.1/maven-artifact-manager/src/test/java/org/apache/maven/artifact/manager/StringWagon0000644000175000017500000000602711035045260033303 0ustar twernertwernerpackage org.apache.maven.artifact.manager; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import java.io.File; import java.io.InputStream; import java.util.HashMap; import java.util.Map; import org.apache.maven.wagon.ConnectionException; import org.apache.maven.wagon.InputData; import org.apache.maven.wagon.OutputData; import org.apache.maven.wagon.ResourceDoesNotExistException; import org.apache.maven.wagon.StreamWagon; import org.apache.maven.wagon.TransferFailedException; import org.apache.maven.wagon.authentication.AuthenticationException; import org.apache.maven.wagon.authorization.AuthorizationException; import org.apache.maven.wagon.resource.Resource; import org.codehaus.plexus.util.IOUtil; import org.codehaus.plexus.util.StringInputStream; import org.codehaus.plexus.util.StringOutputStream; public class StringWagon extends StreamWagon { private Map expectedContent = new HashMap(); public void addExpectedContent( String resourceName, String expectedContent ) { this.expectedContent.put( resourceName, expectedContent ); } public String[] getSupportedProtocols() { return new String[] { "string" }; } public void closeConnection() throws ConnectionException { } public void fillInputData( InputData inputData ) throws TransferFailedException, ResourceDoesNotExistException, AuthorizationException { Resource resource = inputData.getResource(); String content = (String) expectedContent.get( resource.getName() ); if ( content != null ) { resource.setContentLength( content.length() ); resource.setLastModified( System.currentTimeMillis() ); inputData.setInputStream( new StringInputStream( content ) ); } else { throw new ResourceDoesNotExistException( "No content provided for " + resource.getName() ); } } public void fillOutputData( OutputData outputData ) throws TransferFailedException { outputData.setOutputStream( new StringOutputStream() ); } protected void openConnectionInternal() throws ConnectionException, AuthenticationException { } public void clearExpectedContent() { expectedContent.clear(); } } ././@LongLink0000000000000000000000000000014500000000000011565 Lustar rootrootmaven2-core-2.2.1/maven-artifact-manager/src/test/java/org/apache/maven/artifact/manager/WagonC.javamaven2-core-2.2.1/maven-artifact-manager/src/test/java/org/apache/maven/artifact/manager/WagonC.java0000644000175000017500000000233610551365651033151 0ustar twernertwernerpackage org.apache.maven.artifact.manager; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ /** * Wagon for testing, for protocol c * * @author Carlos Sanchez * @author Jason van Zyl * @version $Id: WagonC.java 495147 2007-01-11 07:47:53Z jvanzyl $ */ public class WagonC extends WagonMock { public String[] getSupportedProtocols() { return new String[]{ "c" }; } } ././@LongLink0000000000000000000000000000017000000000000011563 Lustar rootrootmaven2-core-2.2.1/maven-artifact-manager/src/test/java/org/apache/maven/artifact/AbstractArtifactComponentTestCase.javamaven2-core-2.2.1/maven-artifact-manager/src/test/java/org/apache/maven/artifact/AbstractArtifactCom0000644000175000017500000002203311221061521033275 0ustar twernertwernerpackage org.apache.maven.artifact; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import org.apache.maven.artifact.factory.ArtifactFactory; import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.artifact.repository.ArtifactRepositoryPolicy; import org.apache.maven.artifact.repository.DefaultArtifactRepository; import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout; import org.codehaus.plexus.PlexusTestCase; import java.io.File; import java.io.FileWriter; import java.io.IOException; import java.io.Writer; import java.util.ArrayList; import java.util.List; /** * @author Jason van Zyl * @version $Id: AbstractArtifactComponentTestCase.java,v 1.5 2004/10/23 13:33:59 * jvanzyl Exp $ */ public abstract class AbstractArtifactComponentTestCase extends PlexusTestCase { protected abstract String component(); /** * Return an existing file, not a directory - causes creation to fail. * * @throws Exception */ protected ArtifactRepository badLocalRepository() throws Exception { String path = "target/test-classes/repositories/" + component() + "/bad-local-repository"; File f = new File( getBasedir(), path ); f.createNewFile(); ArtifactRepositoryLayout repoLayout = (ArtifactRepositoryLayout) lookup( ArtifactRepositoryLayout.ROLE, "legacy" ); return new DefaultArtifactRepository( "test", "file://" + f.getPath(), repoLayout ); } protected String getRepositoryLayout() { return "legacy"; } protected ArtifactRepository localRepository() throws Exception { String path = "target/test-classes/repositories/" + component() + "/local-repository"; File f = new File( getBasedir(), path ); ArtifactRepositoryLayout repoLayout = (ArtifactRepositoryLayout) lookup( ArtifactRepositoryLayout.ROLE, "legacy" ); return new DefaultArtifactRepository( "local", "file://" + f.getPath(), repoLayout ); } protected ArtifactRepository remoteRepository() throws Exception { String path = "target/test-classes/repositories/" + component() + "/remote-repository"; File f = new File( getBasedir(), path ); ArtifactRepositoryLayout repoLayout = (ArtifactRepositoryLayout) lookup( ArtifactRepositoryLayout.ROLE, "legacy" ); return new DefaultArtifactRepository( "test", "file://" + f.getPath(), repoLayout, new ArtifactRepositoryPolicy(), new ArtifactRepositoryPolicy() ); } protected ArtifactRepository badRemoteRepository() throws Exception { ArtifactRepositoryLayout repoLayout = (ArtifactRepositoryLayout) lookup( ArtifactRepositoryLayout.ROLE, "legacy" ); return new DefaultArtifactRepository( "test", "http://foo.bar/repository", repoLayout ); } protected void assertRemoteArtifactPresent( Artifact artifact ) throws Exception { ArtifactRepository remoteRepo = remoteRepository(); String path = remoteRepo.pathOf( artifact ); File file = new File( remoteRepo.getBasedir(), path ); if ( !file.exists() ) { fail( "Remote artifact " + file + " should be present." ); } } protected void assertLocalArtifactPresent( Artifact artifact ) throws Exception { ArtifactRepository localRepo = localRepository(); String path = localRepo.pathOf( artifact ); File file = new File( localRepo.getBasedir(), path ); if ( !file.exists() ) { fail( "Local artifact " + file + " should be present." ); } } protected void assertRemoteArtifactNotPresent( Artifact artifact ) throws Exception { ArtifactRepository remoteRepo = remoteRepository(); String path = remoteRepo.pathOf( artifact ); File file = new File( remoteRepo.getBasedir(), path ); if ( file.exists() ) { fail( "Remote artifact " + file + " should not be present." ); } } protected void assertLocalArtifactNotPresent( Artifact artifact ) throws Exception { ArtifactRepository localRepo = localRepository(); String path = localRepo.pathOf( artifact ); File file = new File( localRepo.getBasedir(), path ); if ( file.exists() ) { fail( "Local artifact " + file + " should not be present." ); } } // ---------------------------------------------------------------------- // // ---------------------------------------------------------------------- protected List remoteRepositories() throws Exception { List remoteRepositories = new ArrayList(); remoteRepositories.add( remoteRepository() ); return remoteRepositories; } // ---------------------------------------------------------------------- // Test artifact generation for unit tests // ---------------------------------------------------------------------- protected Artifact createLocalArtifact( String artifactId, String version, String content ) throws Exception { Artifact artifact = createArtifact( artifactId, version ); createArtifact( artifact, localRepository(), content ); return artifact; } protected Artifact createRemoteArtifact( String artifactId, String version ) throws Exception { Artifact artifact = createArtifact( artifactId, version ); createArtifact( artifact, remoteRepository(), null ); return artifact; } protected void createLocalArtifact( Artifact artifact ) throws Exception { createArtifact( artifact, localRepository(), null ); } protected void createRemoteArtifact( Artifact artifact ) throws Exception { createArtifact( artifact, remoteRepository(), null ); } protected void createArtifact( Artifact artifact, ArtifactRepository repository, String content ) throws Exception { String path = repository.pathOf( artifact ); File artifactFile = new File( repository.getBasedir(), path ); if ( !artifactFile.getParentFile().exists() ) { artifactFile.getParentFile().mkdirs(); } Writer writer = new FileWriter( artifactFile ); if( content == null ) { writer.write( artifact.getId() ); } else { writer.write( content ); } writer.close(); artifactFile = new File( repository.getBasedir(), path ); artifact.setFile( artifactFile ); } protected Artifact createArtifact( String artifactId, String version ) throws Exception { return createArtifact( artifactId, version, "jar" ); } protected Artifact createArtifact( String artifactId, String version, String type ) throws Exception { return createArtifact( "org.apache.maven", artifactId, version, type ); } protected Artifact createArtifact( String groupId, String artifactId, String version, String type ) throws Exception { ArtifactFactory artifactFactory = (ArtifactFactory) lookup( ArtifactFactory.ROLE ); return artifactFactory.createBuildArtifact( groupId, artifactId, version, type ); } protected void deleteLocalArtifact( Artifact artifact ) throws Exception { deleteArtifact( artifact, localRepository() ); } protected void deleteArtifact( Artifact artifact, ArtifactRepository repository ) throws Exception { String path = repository.pathOf( artifact ); File artifactFile = new File( repository.getBasedir(), path ); if ( artifactFile.exists() ) { if ( !artifactFile.delete() ) { throw new IOException( "Failure while attempting to delete artifact " + artifactFile ); } } } } maven2-core-2.2.1/maven-artifact-manager/src/test/java/org/apache/maven/artifact/deployer/0000755000175000017500000000000011250552243031325 5ustar twernertwerner././@LongLink0000000000000000000000000000016400000000000011566 Lustar rootrootmaven2-core-2.2.1/maven-artifact-manager/src/test/java/org/apache/maven/artifact/deployer/ArtifactDeployerTest.javamaven2-core-2.2.1/maven-artifact-manager/src/test/java/org/apache/maven/artifact/deployer/ArtifactDe0000644000175000017500000000367710551365651033303 0ustar twernertwernerpackage org.apache.maven.artifact.deployer; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import org.apache.maven.artifact.AbstractArtifactComponentTestCase; import org.apache.maven.artifact.Artifact; import java.io.File; /** * @author Jason van Zyl * @version $Id: ArtifactDeployerTest.java 495147 2007-01-11 07:47:53Z jvanzyl $ */ public class ArtifactDeployerTest extends AbstractArtifactComponentTestCase { private ArtifactDeployer artifactDeployer; protected void setUp() throws Exception { super.setUp(); artifactDeployer = (ArtifactDeployer) lookup( ArtifactDeployer.ROLE ); } protected String component() { return "deployer"; } public void testArtifactInstallation() throws Exception { String artifactBasedir = new File( getBasedir(), "src/test/resources/artifact-install" ).getAbsolutePath(); Artifact artifact = createArtifact( "artifact", "1.0" ); File file = new File( artifactBasedir, "artifact-1.0.jar" ); artifactDeployer.deploy( file, artifact, remoteRepository(), localRepository() ); assertRemoteArtifactPresent( artifact ); } }maven2-core-2.2.1/maven-artifact-manager/src/test/java/org/apache/maven/artifact/resolver/0000755000175000017500000000000011250552243031343 5ustar twernertwerner././@LongLink0000000000000000000000000000016400000000000011566 Lustar rootrootmaven2-core-2.2.1/maven-artifact-manager/src/test/java/org/apache/maven/artifact/resolver/ArtifactResolverTest.javamaven2-core-2.2.1/maven-artifact-manager/src/test/java/org/apache/maven/artifact/resolver/ArtifactRe0000644000175000017500000004332011221205616033311 0ustar twernertwernerpackage org.apache.maven.artifact.resolver; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.HashSet; import java.util.LinkedHashSet; import java.util.List; import java.util.Set; import org.apache.maven.artifact.AbstractArtifactComponentTestCase; import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.manager.WagonManager; import org.apache.maven.artifact.metadata.ArtifactMetadataRetrievalException; import org.apache.maven.artifact.metadata.ArtifactMetadataSource; import org.apache.maven.artifact.metadata.ResolutionGroup; import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.wagon.TransferFailedException; import org.easymock.MockControl; // It would be cool if there was a hook that i could use to setup a test environment. // I want to setup a local/remote repositories for testing but i don't want to have // to change them when i change the layout of the repositories. So i want to generate // the structure i want to test by using the artifact handler manager which dictates // the layout used for a particular artifact type. /** * @author Jason van Zyl * @version $Id: ArtifactResolverTest.java 788791 2009-06-26 17:55:26Z jdcasey $ */ public class ArtifactResolverTest extends AbstractArtifactComponentTestCase { private static class ArtifactMetadataSourceImplementation implements ArtifactMetadataSource { public ResolutionGroup retrieve( Artifact artifact, ArtifactRepository localRepository, List remoteRepositories ) throws ArtifactMetadataRetrievalException { return new ResolutionGroup( artifact, Collections.EMPTY_SET, remoteRepositories ); } public List retrieveAvailableVersions( Artifact artifact, ArtifactRepository localRepository, List remoteRepositories ) { throw new UnsupportedOperationException( "Cannot get available versions in this test case" ); } public Artifact retrieveRelocatedArtifact( Artifact artifact, ArtifactRepository localRepository, List remoteRepositories ) throws ArtifactMetadataRetrievalException { return artifact; } } private ArtifactResolver artifactResolver; private Artifact projectArtifact; protected void setUp() throws Exception { super.setUp(); artifactResolver = (ArtifactResolver) lookup( ArtifactResolver.ROLE ); projectArtifact = createLocalArtifact( "project", "3.0", null ); } protected String component() { return "resolver"; } public void testResolutionOfASingleArtifactWhereTheArtifactIsPresentInTheLocalRepository() throws Exception { Artifact a = createLocalArtifact( "a", "1.0", null ); artifactResolver.resolve( a, remoteRepositories(), localRepository() ); assertLocalArtifactPresent( a ); } public void testResolutionOfASingleArtifactWhereTheArtifactIsNotPresentLocallyAndMustBeRetrievedFromTheRemoteRepository() throws Exception { Artifact b = createRemoteArtifact( "b", "1.0" ); deleteLocalArtifact( b ); artifactResolver.resolve( b, remoteRepositories(), localRepository() ); assertLocalArtifactPresent( b ); } protected Artifact createArtifact( String groupId, String artifactId, String version, String type ) throws Exception { // for the anonymous classes return super.createArtifact( groupId, artifactId, version, type ); } public void testTransitiveResolutionWhereAllArtifactsArePresentInTheLocalRepository() throws Exception { Artifact g = createLocalArtifact( "g", "1.0", null ); Artifact h = createLocalArtifact( "h", "1.0", null ); ArtifactMetadataSource mds = new ArtifactMetadataSourceImplementation() { public ResolutionGroup retrieve( Artifact artifact, ArtifactRepository localRepository, List remoteRepositories ) throws ArtifactMetadataRetrievalException { Set dependencies = new LinkedHashSet(); if ( "g".equals( artifact.getArtifactId() ) ) { Artifact a = null; try { a = createArtifact( "org.apache.maven", "h", "1.0", "jar" ); dependencies.add( a ); } catch ( Exception e ) { throw new ArtifactMetadataRetrievalException( "Error retrieving metadata", e, a ); } } return new ResolutionGroup( artifact, dependencies, remoteRepositories ); } }; ArtifactResolutionResult result = artifactResolver.resolveTransitively( Collections.singleton( g ), projectArtifact, remoteRepositories(), localRepository(), mds ); assertEquals( 2, result.getArtifacts().size() ); assertTrue( result.getArtifacts().contains( g ) ); assertTrue( result.getArtifacts().contains( h ) ); assertLocalArtifactPresent( g ); assertLocalArtifactPresent( h ); } public void testTransitiveResolutionWhereAllArtifactsAreNotPresentInTheLocalRepositoryAndMustBeRetrievedFromTheRemoteRepository() throws Exception { Artifact i = createRemoteArtifact( "i", "1.0" ); deleteLocalArtifact( i ); Artifact j = createRemoteArtifact( "j", "1.0" ); deleteLocalArtifact( j ); ArtifactMetadataSource mds = new ArtifactMetadataSourceImplementation() { public ResolutionGroup retrieve( Artifact artifact, ArtifactRepository localRepository, List remoteRepositories ) throws ArtifactMetadataRetrievalException { Set dependencies = new LinkedHashSet(); if ( "i".equals( artifact.getArtifactId() ) ) { Artifact a = null; try { a = createArtifact( "org.apache.maven", "j", "1.0", "jar" ); dependencies.add( a ); } catch ( Exception e ) { throw new ArtifactMetadataRetrievalException( "Error retrieving metadata", e, a ); } } return new ResolutionGroup( artifact, dependencies, remoteRepositories ); } }; ArtifactResolutionResult result = artifactResolver.resolveTransitively( Collections.singleton( i ), projectArtifact, remoteRepositories(), localRepository(), mds ); assertEquals( 2, result.getArtifacts().size() ); assertTrue( result.getArtifacts().contains( i ) ); assertTrue( result.getArtifacts().contains( j ) ); assertLocalArtifactPresent( i ); assertLocalArtifactPresent( j ); } public void testResolutionFailureWhenArtifactNotPresentInRemoteRepository() throws Exception { Artifact k = createArtifact( "k", "1.0" ); try { artifactResolver.resolve( k, remoteRepositories(), localRepository() ); fail( "Resolution succeeded when it should have failed" ); } catch ( ArtifactNotFoundException expected ) { List repos = expected.getRemoteRepositories(); assertEquals( 1, repos.size() ); assertEquals( "test", ( (ArtifactRepository) repos.get( 0 ) ).getId() ); } } public void testResolutionFailureWhenArtifactNotPresentInRemoteRepositoryWithMirrors() throws Exception { ArtifactRepository repository = remoteRepository(); WagonManager wagonManager = (WagonManager) lookup( WagonManager.ROLE ); wagonManager.addMirror( "mirror", "test", repository.getUrl() ); Artifact k = createArtifact( "k", "1.0" ); try { artifactResolver.resolve( k, Collections.singletonList( repository ), localRepository() ); fail( "Resolution succeeded when it should have failed" ); } catch ( ArtifactNotFoundException expected ) { List repos = expected.getRemoteRepositories(); assertEquals( 1, repos.size() ); assertEquals( "mirror", ( (ArtifactRepository) repos.get( 0 ) ).getId() ); } } public void testResolutionOfAnArtifactWhereOneRemoteRepositoryIsBadButOneIsGood() throws Exception { Artifact l = createRemoteArtifact( "l", "1.0" ); deleteLocalArtifact( l ); List repositories = new ArrayList(); repositories.add( remoteRepository() ); repositories.add( badRemoteRepository() ); artifactResolver.resolve( l, repositories, localRepository() ); 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 } */ public void testResolutionFailureWhenMultipleArtifactsNotPresentInRemoteRepository() throws Exception { Artifact i = createArtifact( "i", "1.0" ); Artifact n = createArtifact( "n", "1.0" ); Artifact o = createArtifact( "o", "1.0" ); try { ArtifactMetadataSource mds = new ArtifactMetadataSourceImplementation(); artifactResolver.resolveTransitively( new HashSet( Arrays.asList( new Artifact[] { i, n, o } ) ), projectArtifact, remoteRepositories(), localRepository(), mds ); fail( "Resolution succeeded when it should have failed" ); } catch ( MultipleArtifactsNotFoundException expected ) { List repos = expected.getRemoteRepositories(); assertEquals( 1, repos.size() ); assertEquals( "test", ( (ArtifactRepository) repos.get( 0 ) ).getId() ); List missingArtifacts = expected.getMissingArtifacts(); assertEquals( 2, missingArtifacts.size() ); assertTrue( missingArtifacts.contains( n ) ); assertTrue( missingArtifacts.contains( o ) ); assertFalse( missingArtifacts.contains( i ) ); } } /** * Test deadlocking (which occurs even with a single artifact in error). */ public void testResolveWithException() throws Exception { ArtifactRepository repository = remoteRepository(); List remoteRepositories = Collections.singletonList( repository ); Artifact a1 = createArtifact( "testGroup", "artifactId", "1.0", "jar" ); ArtifactMetadataSource mds = new ArtifactMetadataSourceImplementation(); DefaultArtifactResolver artifactResolver = (DefaultArtifactResolver) this.artifactResolver; MockControl control = MockControl.createControl( WagonManager.class ); WagonManager wagonManager = (WagonManager) control.getMock(); artifactResolver.setWagonManager( wagonManager ); wagonManager.isOnline(); control.setReturnValue( true ); wagonManager.getArtifact( a1, remoteRepositories ); control.setThrowable( new TransferFailedException( "message" ) ); wagonManager.getMirrorRepository( repository ); control.setReturnValue( repository ); control.replay(); try { artifactResolver.resolveTransitively( new LinkedHashSet( Arrays.asList( new Artifact[] { a1 } ) ), projectArtifact, remoteRepositories, localRepository(), mds ); fail( "Resolution succeeded when it should have failed" ); } catch ( ArtifactResolutionException expected ) { List repos = expected.getRemoteRepositories(); assertEquals( 1, repos.size() ); assertEquals( "test", ( (ArtifactRepository) repos.get( 0 ) ).getId() ); assertEquals( "testGroup", expected.getGroupId() ); } control.verify(); } /** * Test deadlocking in case a transfer error occurs within a group of multiple artifacts (MNG-4179). */ public void testResolveMultipleWithException() throws Exception { ArtifactRepository repository = remoteRepository(); List remoteRepositories = Collections.singletonList( repository ); Artifact a1 = createArtifact( "testGroup", "artifactId", "1.0", "jar" ); Artifact a2 = createArtifact( "testGroup", "anotherId", "1.0", "jar" ); ArtifactMetadataSource mds = new ArtifactMetadataSourceImplementation(); DefaultArtifactResolver artifactResolver = (DefaultArtifactResolver) this.artifactResolver; MockControl control = MockControl.createControl( WagonManager.class ); WagonManager wagonManager = (WagonManager) control.getMock(); artifactResolver.setWagonManager( wagonManager ); wagonManager.isOnline(); control.setReturnValue( true ); wagonManager.getArtifact( a1, remoteRepositories ); control.setThrowable( new TransferFailedException( "message" ) ); wagonManager.getMirrorRepository( repository ); control.setReturnValue( repository ); wagonManager.isOnline(); control.setReturnValue( true ); wagonManager.getArtifact( a2, remoteRepositories ); control.setThrowable( new TransferFailedException( "message" ) ); wagonManager.getMirrorRepository( repository ); control.setReturnValue( repository ); control.replay(); try { artifactResolver.resolveTransitively( new LinkedHashSet( Arrays.asList( new Artifact[] { a1, a2 } ) ), projectArtifact, remoteRepositories, localRepository(), mds ); fail( "Resolution succeeded when it should have failed" ); } catch ( ArtifactResolutionException expected ) { List repos = expected.getRemoteRepositories(); assertEquals( 1, repos.size() ); assertEquals( "test", ( (ArtifactRepository) repos.get( 0 ) ).getId() ); assertEquals( "testGroup", expected.getGroupId() ); } control.verify(); } public void testResolveOlderSpecificSnapshotVersionWhenNewerVersionAlreadyExistsAndBothAreInLocalRepository() throws Exception { Artifact g1 = createLocalArtifact( "g", "1.0-20090608.090416-1", "Write something to make file length longer" ); long expectedFileLength = g1.getFile().length(); Artifact g3 = createLocalArtifact( "g", "1.0-SNAPSHOT", null ); long incorrectFileLength = g3.getFile().length(); ArtifactMetadataSource mds = new ArtifactMetadataSourceImplementation() { public ResolutionGroup retrieve( Artifact artifact, ArtifactRepository localRepository, List remoteRepositories ) throws ArtifactMetadataRetrievalException { Set dependencies = new LinkedHashSet(); return new ResolutionGroup( artifact, dependencies, remoteRepositories ); } }; ArtifactResolutionResult result = artifactResolver.resolveTransitively( Collections.singleton( g1 ), projectArtifact, remoteRepositories(), localRepository(), mds ); assertEquals( 1, result.getArtifacts().size() ); assertTrue( result.getArtifacts().contains( g1 ) ); assertFalse( result.getArtifacts().contains( g3 ) ); Artifact artifact = ( (Artifact) result.getArtifacts().iterator().next() ); assertEquals( expectedFileLength, artifact.getFile().length() ); assertFalse( "Incorrect artifact file resolved", incorrectFileLength == artifact.getFile().length() ); assertLocalArtifactPresent( g1 ); assertLocalArtifactPresent( g3 ); } } maven2-core-2.2.1/maven-artifact-manager/src/test/java/org/apache/maven/artifact/installer/0000755000175000017500000000000011250552243031477 5ustar twernertwerner././@LongLink0000000000000000000000000000016600000000000011570 Lustar rootrootmaven2-core-2.2.1/maven-artifact-manager/src/test/java/org/apache/maven/artifact/installer/ArtifactInstallerTest.javamaven2-core-2.2.1/maven-artifact-manager/src/test/java/org/apache/maven/artifact/installer/ArtifactI0000644000175000017500000000367110551365651033307 0ustar twernertwernerpackage org.apache.maven.artifact.installer; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import org.apache.maven.artifact.AbstractArtifactComponentTestCase; import org.apache.maven.artifact.Artifact; import java.io.File; /** * @author Jason van Zyl * @version $Id: ArtifactInstallerTest.java 495147 2007-01-11 07:47:53Z jvanzyl $ */ public class ArtifactInstallerTest extends AbstractArtifactComponentTestCase { private ArtifactInstaller artifactInstaller; protected void setUp() throws Exception { super.setUp(); artifactInstaller = (ArtifactInstaller) lookup( ArtifactInstaller.ROLE ); } protected String component() { return "installer"; } public void testArtifactInstallation() throws Exception { String artifactBasedir = new File( getBasedir(), "src/test/resources/artifact-install" ).getAbsolutePath(); Artifact artifact = createArtifact( "artifact", "1.0" ); File source = new File( artifactBasedir, "artifact-1.0.jar" ); artifactInstaller.install( source, artifact, localRepository() ); assertLocalArtifactPresent( artifact ); } }maven2-core-2.2.1/maven-artifact-manager/src/test/java/org/apache/maven/artifact/repository/0000755000175000017500000000000011250552243031721 5ustar twernertwerner././@LongLink0000000000000000000000000000014600000000000011566 Lustar rootrootmaven2-core-2.2.1/maven-artifact-manager/src/test/java/org/apache/maven/artifact/repository/metadata/maven2-core-2.2.1/maven-artifact-manager/src/test/java/org/apache/maven/artifact/repository/metadata0000755000175000017500000000000011250552243033422 5ustar twernertwerner././@LongLink0000000000000000000000000000021100000000000011557 Lustar rootrootmaven2-core-2.2.1/maven-artifact-manager/src/test/java/org/apache/maven/artifact/repository/metadata/AbstractRepositoryMetadataTest.javamaven2-core-2.2.1/maven-artifact-manager/src/test/java/org/apache/maven/artifact/repository/metadata0000644000175000017500000001255410772004567033444 0ustar twernertwernerpackage org.apache.maven.artifact.repository.metadata; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.artifact.testutils.MockManager; import org.apache.maven.artifact.testutils.TestFileManager; import org.codehaus.plexus.util.xml.pull.XmlPullParserException; import org.easymock.MockControl; import java.io.File; import java.io.IOException; import junit.framework.TestCase; public class AbstractRepositoryMetadataTest extends TestCase { private MockManager mm = new MockManager(); private TestFileManager fileManager = new TestFileManager( "AbstractRepositoryMetadataTest.test.", "" ); public void tearDown() throws IOException { fileManager.cleanUp(); } public void testUpdateRepositoryMetadata_NoVersionTagIfMainVersionIsLATEST() throws IOException, XmlPullParserException { MockAndControlForArtifactRepository local = new MockAndControlForArtifactRepository(); MockAndControlForArtifactRepository remote = new MockAndControlForArtifactRepository(); File basedir = fileManager.createTempDir(); String path = "metadata.xml"; Metadata m = new Metadata(); m.setVersion( Artifact.LATEST_VERSION ); TestRepoMetadata trm = new TestRepoMetadata( m ); local.expectGetBasedir( basedir ); local.expectPathOfLocalRepositoryMetadata( trm, remote.repository, path ); mm.replayAll(); trm.updateRepositoryMetadata( local.repository, remote.repository ); fileManager.assertFileExistence( basedir, path, true ); assertTrue( fileManager.getFileContents( new File( basedir, path ) ).indexOf( "" + Artifact.LATEST_VERSION + "" ) < 0 ); mm.verifyAll(); } public void testUpdateRepositoryMetadata_NoVersionTagIfVersionIsRELEASE() throws IOException, XmlPullParserException { MockAndControlForArtifactRepository local = new MockAndControlForArtifactRepository(); MockAndControlForArtifactRepository remote = new MockAndControlForArtifactRepository(); File basedir = fileManager.createTempDir(); String path = "metadata.xml"; Metadata m = new Metadata(); m.setVersion( Artifact.RELEASE_VERSION ); TestRepoMetadata trm = new TestRepoMetadata( m ); local.expectGetBasedir( basedir ); local.expectPathOfLocalRepositoryMetadata( trm, remote.repository, path ); mm.replayAll(); trm.updateRepositoryMetadata( local.repository, remote.repository ); fileManager.assertFileExistence( basedir, path, true ); assertTrue( fileManager.getFileContents( new File( basedir, path ) ).indexOf( "" + Artifact.RELEASE_VERSION + "" ) < 0 ); mm.verifyAll(); } private final class MockAndControlForArtifactRepository { MockControl control; ArtifactRepository repository; public MockAndControlForArtifactRepository() { control = MockControl.createControl( ArtifactRepository.class ); mm.add( control ); repository = ( ArtifactRepository ) control.getMock(); } public void expectPathOfLocalRepositoryMetadata( TestRepoMetadata trm, ArtifactRepository remote, String path ) { repository.pathOfLocalRepositoryMetadata( trm, remote ); control.setReturnValue( path, MockControl.ONE_OR_MORE ); } public void expectGetBasedir( File basedir ) { repository.getBasedir(); control.setReturnValue( basedir.getAbsolutePath(), MockControl.ONE_OR_MORE ); } } private static final class TestRepoMetadata extends AbstractRepositoryMetadata { protected TestRepoMetadata( Metadata metadata ) { super( metadata ); } public boolean isSnapshot() { return false; } public void setRepository( ArtifactRepository remoteRepository ) { } public String getArtifactId() { return null; } public String getBaseVersion() { return null; } public String getGroupId() { return null; } public Object getKey() { return null; } public boolean storedInArtifactVersionDirectory() { return false; } public boolean storedInGroupDirectory() { return false; } } } maven2-core-2.2.1/maven-artifact-manager/src/test/java/org/apache/maven/artifact/testutils/0000755000175000017500000000000011250552243031542 5ustar twernertwerner././@LongLink0000000000000000000000000000015400000000000011565 Lustar rootrootmaven2-core-2.2.1/maven-artifact-manager/src/test/java/org/apache/maven/artifact/testutils/MockManager.javamaven2-core-2.2.1/maven-artifact-manager/src/test/java/org/apache/maven/artifact/testutils/MockManag0000644000175000017500000000313010772004567033330 0ustar twernertwernerpackage org.apache.maven.artifact.testutils; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import org.easymock.MockControl; import java.util.ArrayList; import java.util.Iterator; import java.util.List; public class MockManager { private List mockControls = new ArrayList(); public void add( MockControl control ) { mockControls.add( control ); } public void replayAll() { for ( Iterator it = mockControls.iterator(); it.hasNext(); ) { MockControl control = ( MockControl ) it.next(); control.replay(); } } public void verifyAll() { for ( Iterator it = mockControls.iterator(); it.hasNext(); ) { MockControl control = ( MockControl ) it.next(); control.verify(); } } } ././@LongLink0000000000000000000000000000016000000000000011562 Lustar rootrootmaven2-core-2.2.1/maven-artifact-manager/src/test/java/org/apache/maven/artifact/testutils/TestFileManager.javamaven2-core-2.2.1/maven-artifact-manager/src/test/java/org/apache/maven/artifact/testutils/TestFileM0000644000175000017500000001340310772004567033333 0ustar twernertwernerpackage org.apache.maven.artifact.testutils; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import org.codehaus.plexus.util.FileUtils; import org.codehaus.plexus.util.IOUtil; import java.io.File; import java.io.FileReader; import java.io.FileWriter; import java.io.IOException; import java.io.StringReader; import java.io.StringWriter; import java.util.ArrayList; import java.util.Iterator; import java.util.List; import junit.framework.Assert; public class TestFileManager { public static final String TEMP_DIR_PATH = System.getProperty( "java.io.tmpdir" ); private List filesToDelete = new ArrayList(); private final String baseFilename; private final String fileSuffix; private StackTraceElement callerInfo; private Thread cleanupWarning; private boolean warnAboutCleanup = false; public TestFileManager( String baseFilename, String fileSuffix ) { this.baseFilename = baseFilename; this.fileSuffix = fileSuffix; initializeCleanupMonitoring(); } private void initializeCleanupMonitoring() { callerInfo = new NullPointerException().getStackTrace()[2]; Runnable warning = new Runnable() { public void run() { maybeWarnAboutCleanUp(); } }; cleanupWarning = new Thread( warning ); Runtime.getRuntime().addShutdownHook( cleanupWarning ); } private void maybeWarnAboutCleanUp() { if ( warnAboutCleanup ) { System.out.println( "[WARNING] TestFileManager from: " + callerInfo.getClassName() + " not cleaned up!" ); } } public void markForDeletion( File toDelete ) { filesToDelete.add( toDelete ); warnAboutCleanup = true; } public synchronized File createTempDir() { try { Thread.sleep( 20 ); } catch ( InterruptedException e ) { } File dir = new File( TEMP_DIR_PATH, baseFilename + System.currentTimeMillis() ); dir.mkdirs(); markForDeletion( dir ); return dir; } public synchronized File createTempFile() throws IOException { File tempFile = File.createTempFile( baseFilename, fileSuffix ); tempFile.deleteOnExit(); markForDeletion( tempFile ); return tempFile; } public void cleanUp() throws IOException { for ( Iterator it = filesToDelete.iterator(); it.hasNext(); ) { File file = ( File ) it.next(); if ( file.exists() ) { if ( file.isDirectory() ) { FileUtils.deleteDirectory( file ); } else { file.delete(); } } it.remove(); } warnAboutCleanup = false; } public void assertFileExistence( File dir, String filename, boolean shouldExist ) { File file = new File( dir, filename ); if ( shouldExist ) { Assert.assertTrue( file.exists() ); } else { Assert.assertFalse( file.exists() ); } } public void assertFileContents( File dir, String filename, String contentsTest ) throws IOException { assertFileExistence( dir, filename, true ); File file = new File( dir, filename ); FileReader reader = null; StringWriter writer = new StringWriter(); try { reader = new FileReader( file ); IOUtil.copy( reader, writer ); } finally { IOUtil.close( reader ); } Assert.assertEquals( contentsTest, writer.toString() ); } public File createFile( File dir, String filename, String contents ) throws IOException { File file = new File( dir, filename ); file.getParentFile().mkdirs(); FileWriter writer = null; try { writer = new FileWriter( file ); IOUtil.copy( new StringReader( contents ), writer ); } finally { IOUtil.close( writer ); } markForDeletion( file ); return file; } public String getFileContents( File file ) throws IOException { String result = null; FileReader reader = null; try { reader = new FileReader( file ); StringWriter writer = new StringWriter(); IOUtil.copy( reader, writer ); result = writer.toString(); } finally { IOUtil.close( reader ); } return result; } protected void finalize() throws Throwable { maybeWarnAboutCleanUp(); super.finalize(); } public File createFile( String filename, String content ) throws IOException { File dir = createTempDir(); return createFile( dir, filename, content ); } } maven2-core-2.2.1/maven-artifact-manager/src/main/0000755000175000017500000000000011250552244021614 5ustar twernertwernermaven2-core-2.2.1/maven-artifact-manager/src/main/resources/0000755000175000017500000000000011250552244023626 5ustar twernertwernermaven2-core-2.2.1/maven-artifact-manager/src/main/resources/META-INF/0000755000175000017500000000000011250552244024766 5ustar twernertwernermaven2-core-2.2.1/maven-artifact-manager/src/main/resources/META-INF/plexus/0000755000175000017500000000000011250552244026306 5ustar twernertwernermaven2-core-2.2.1/maven-artifact-manager/src/main/resources/META-INF/plexus/components.xml0000644000175000017500000001513211233662172031222 0ustar twernertwerner org.apache.maven.artifact.manager.WagonManager org.apache.maven.artifact.manager.DefaultWagonManager org.apache.maven.artifact.repository.ArtifactRepositoryFactory org.apache.maven.artifact.manager.WagonProviderMapping org.apache.maven.artifact.manager.WagonProviderMapping org.apache.maven.artifact.manager.DefaultWagonProviderMapping org.apache.maven.artifact.repository.metadata.RepositoryMetadataManager org.apache.maven.artifact.repository.metadata.DefaultRepositoryMetadataManager org.apache.maven.artifact.manager.WagonManager org.apache.maven.artifact.transform.ArtifactTransformation snapshot org.apache.maven.artifact.transform.SnapshotTransformation org.apache.maven.artifact.manager.WagonManager org.apache.maven.artifact.repository.metadata.RepositoryMetadataManager org.apache.maven.artifact.transform.ArtifactTransformation release org.apache.maven.artifact.transform.ReleaseArtifactTransformation org.apache.maven.artifact.manager.WagonManager org.apache.maven.artifact.repository.metadata.RepositoryMetadataManager org.apache.maven.artifact.transform.ArtifactTransformation latest org.apache.maven.artifact.transform.LatestArtifactTransformation org.apache.maven.artifact.manager.WagonManager org.apache.maven.artifact.repository.metadata.RepositoryMetadataManager org.apache.maven.artifact.transform.ArtifactTransformationManager org.apache.maven.artifact.transform.DefaultArtifactTransformationManager org.apache.maven.artifact.transform.ArtifactTransformation artifactTransformations org.apache.maven.artifact.resolver.ArtifactResolver org.apache.maven.artifact.resolver.DefaultArtifactResolver org.apache.maven.artifact.manager.WagonManager org.apache.maven.artifact.transform.ArtifactTransformationManager org.apache.maven.artifact.factory.ArtifactFactory org.apache.maven.artifact.resolver.ArtifactCollector org.apache.maven.artifact.installer.ArtifactInstaller org.apache.maven.artifact.installer.DefaultArtifactInstaller org.apache.maven.artifact.transform.ArtifactTransformationManager org.apache.maven.artifact.repository.metadata.RepositoryMetadataManager org.apache.maven.artifact.deployer.ArtifactDeployer org.apache.maven.artifact.deployer.DefaultArtifactDeployer org.apache.maven.artifact.manager.WagonManager org.apache.maven.artifact.transform.ArtifactTransformationManager org.apache.maven.artifact.repository.metadata.RepositoryMetadataManager org.apache.maven.artifact.repository.ArtifactRepositoryFactory org.apache.maven.artifact.repository.DefaultArtifactRepositoryFactory org.codehaus.plexus.component.configurator.ComponentConfigurator org.apache.maven.artifact.manager.WagonComponentConfigurator wagon maven2-core-2.2.1/maven-artifact-manager/src/main/java/0000755000175000017500000000000011250552243022534 5ustar twernertwernermaven2-core-2.2.1/maven-artifact-manager/src/main/java/org/0000755000175000017500000000000011250552243023323 5ustar twernertwernermaven2-core-2.2.1/maven-artifact-manager/src/main/java/org/apache/0000755000175000017500000000000011250552243024544 5ustar twernertwernermaven2-core-2.2.1/maven-artifact-manager/src/main/java/org/apache/maven/0000755000175000017500000000000011250552243025652 5ustar twernertwernermaven2-core-2.2.1/maven-artifact-manager/src/main/java/org/apache/maven/artifact/0000755000175000017500000000000011250552244027450 5ustar twernertwernermaven2-core-2.2.1/maven-artifact-manager/src/main/java/org/apache/maven/artifact/manager/0000755000175000017500000000000011250552244031062 5ustar twernertwerner././@LongLink0000000000000000000000000000016300000000000011565 Lustar rootrootmaven2-core-2.2.1/maven-artifact-manager/src/main/java/org/apache/maven/artifact/manager/WagonProviderMapping.javamaven2-core-2.2.1/maven-artifact-manager/src/main/java/org/apache/maven/artifact/manager/WagonProvid0000644000175000017500000000207711233662172033255 0ustar twernertwernerpackage org.apache.maven.artifact.manager; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ public interface WagonProviderMapping { String ROLE = WagonProviderMapping.class.getName(); public void setWagonProvider( String protocol, String provider ); public String getWagonProvider( String protocol ); } ././@LongLink0000000000000000000000000000017100000000000011564 Lustar rootrootmaven2-core-2.2.1/maven-artifact-manager/src/main/java/org/apache/maven/artifact/manager/WagonComponentConfigurator.javamaven2-core-2.2.1/maven-artifact-manager/src/main/java/org/apache/maven/artifact/manager/WagonCompon0000644000175000017500000000430711151147037033240 0ustar twernertwernerpackage org.apache.maven.artifact.manager; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import org.codehaus.classworlds.ClassRealm; import org.codehaus.plexus.component.configurator.AbstractComponentConfigurator; import org.codehaus.plexus.component.configurator.ComponentConfigurationException; import org.codehaus.plexus.component.configurator.ConfigurationListener; import org.codehaus.plexus.component.configurator.converters.composite.ObjectWithFieldsConverter; import org.codehaus.plexus.component.configurator.expression.ExpressionEvaluator; import org.codehaus.plexus.configuration.PlexusConfiguration; /** * Custom configurator that removes the unnecessary addition of a new converter that caused a thread synchronization * issue. Once fixed in Plexus, this custom component can be removed. */ public class WagonComponentConfigurator extends AbstractComponentConfigurator { public void configureComponent( Object component, PlexusConfiguration configuration, ExpressionEvaluator expressionEvaluator, ClassRealm containerRealm, ConfigurationListener listener ) throws ComponentConfigurationException { ObjectWithFieldsConverter converter = new ObjectWithFieldsConverter(); converter.processConfiguration( converterLookup, component, containerRealm.getClassLoader(), configuration, expressionEvaluator, listener ); } } ././@LongLink0000000000000000000000000000017200000000000011565 Lustar rootrootmaven2-core-2.2.1/maven-artifact-manager/src/main/java/org/apache/maven/artifact/manager/WagonConfigurationException.javamaven2-core-2.2.1/maven-artifact-manager/src/main/java/org/apache/maven/artifact/manager/WagonConfig0000644000175000017500000000350610772004567033222 0ustar twernertwernerpackage org.apache.maven.artifact.manager; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import org.apache.maven.wagon.TransferFailedException; public class WagonConfigurationException extends TransferFailedException { static final long serialVersionUID = 1; private final String originalMessage; private final String repositoryId; public WagonConfigurationException( String repositoryId, String message, Throwable cause ) { super( "While configuring wagon for \'" + repositoryId + "\': " + message, cause ); this.repositoryId = repositoryId; this.originalMessage = message; } public WagonConfigurationException( String repositoryId, String message ) { super( "While configuring wagon for \'" + repositoryId + "\': " + message ); this.repositoryId = repositoryId; this.originalMessage = message; } public final String getRepositoryId() { return repositoryId; } public final String getOriginalMessage() { return originalMessage; } } ././@LongLink0000000000000000000000000000015300000000000011564 Lustar rootrootmaven2-core-2.2.1/maven-artifact-manager/src/main/java/org/apache/maven/artifact/manager/WagonManager.javamaven2-core-2.2.1/maven-artifact-manager/src/main/java/org/apache/maven/artifact/manager/WagonManage0000644000175000017500000001257011233662172033201 0ustar twernertwernerpackage org.apache.maven.artifact.manager; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.metadata.ArtifactMetadata; import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.wagon.ResourceDoesNotExistException; import org.apache.maven.wagon.TransferFailedException; import org.apache.maven.wagon.UnsupportedProtocolException; import org.apache.maven.wagon.Wagon; import org.apache.maven.wagon.authentication.AuthenticationInfo; import org.apache.maven.wagon.events.TransferListener; import org.apache.maven.wagon.proxy.ProxyInfo; import org.apache.maven.wagon.repository.Repository; import org.apache.maven.wagon.repository.RepositoryPermissions; import org.codehaus.plexus.PlexusContainer; import org.codehaus.plexus.util.xml.Xpp3Dom; import java.io.File; import java.util.Collection; import java.util.List; /** * Manages Wagon related operations in Maven. * * @author Michal Maczka * @version $Id: WagonManager.java 798706 2009-07-28 20:50:02Z brett $ */ public interface WagonManager { String ROLE = WagonManager.class.getName(); /** * Get a Wagon provider that understands the protocol passed as argument. * It doesn't configure the Wagon. * * @param protocol the protocol the {@link Wagon} will handle * @return the {@link Wagon} instance able to handle the protocol provided * @throws UnsupportedProtocolException if there is no provider able to handle the protocol * @deprecated prone to errors. use {@link #getWagon(Repository)} instead. */ Wagon getWagon( String protocol ) throws UnsupportedProtocolException; /** * Get a Wagon provider for the provided repository. * It will configure the Wagon for that repository. * * @param repository the repository * @return the {@link Wagon} instance that can be used to connect to the repository * @throws UnsupportedProtocolException if there is no provider able to handle the protocol * @throws WagonConfigurationException if the wagon can't be configured for the repository */ Wagon getWagon( Repository repository ) throws UnsupportedProtocolException, WagonConfigurationException; void getArtifact( Artifact artifact, List remoteRepositories ) throws TransferFailedException, ResourceDoesNotExistException; void getArtifact( Artifact artifact, ArtifactRepository repository ) throws TransferFailedException, ResourceDoesNotExistException; void putArtifact( File source, Artifact artifact, ArtifactRepository deploymentRepository ) throws TransferFailedException; void putArtifactMetadata( File source, ArtifactMetadata artifactMetadata, ArtifactRepository repository ) throws TransferFailedException; void getArtifactMetadata( ArtifactMetadata metadata, ArtifactRepository remoteRepository, File destination, String checksumPolicy ) throws TransferFailedException, ResourceDoesNotExistException; void getArtifactMetadataFromDeploymentRepository( ArtifactMetadata metadata, ArtifactRepository remoteRepository, File file, String checksumPolicyWarn ) throws TransferFailedException, ResourceDoesNotExistException; void setOnline( boolean online ); boolean isOnline(); void addProxy( String protocol, String host, int port, String username, String password, String nonProxyHosts ); void addAuthenticationInfo( String repositoryId, String username, String password, String privateKey, String passphrase ); void addMirror( String id, String mirrorOf, String url ); void setDownloadMonitor( TransferListener downloadMonitor ); void addPermissionInfo( String repositoryId, String filePermissions, String directoryPermissions ); ProxyInfo getProxy( String protocol ); AuthenticationInfo getAuthenticationInfo( String id ); /** * Set the configuration for a repository * * @param repositoryId id of the repository to set the configuration to * @param configuration dom tree of the xml with the configuration for the {@link Wagon} */ void addConfiguration( String repositoryId, Xpp3Dom configuration ); void setInteractive( boolean interactive ); void registerWagons( Collection wagons, PlexusContainer extensionContainer ); void setDefaultRepositoryPermissions( RepositoryPermissions permissions ); ArtifactRepository getMirrorRepository( ArtifactRepository repository ); } ././@LongLink0000000000000000000000000000017200000000000011565 Lustar rootrootmaven2-core-2.2.1/maven-artifact-manager/src/main/java/org/apache/maven/artifact/manager/DefaultWagonProviderMapping.javamaven2-core-2.2.1/maven-artifact-manager/src/main/java/org/apache/maven/artifact/manager/DefaultWago0000644000175000017500000000265511232077172033221 0ustar twernertwernerpackage org.apache.maven.artifact.manager; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import java.util.HashMap; import java.util.Map; public class DefaultWagonProviderMapping implements WagonProviderMapping { private Map wagonProviders = new HashMap(); public String getWagonProvider( String protocol ) { return wagonProviders.get( protocol ); } public void setWagonProvider( String protocol, String provider ) { wagonProviders.put( protocol, provider ); } public void setWagonProviders( Map wagonProviders ) { this.wagonProviders = wagonProviders; } } ././@LongLink0000000000000000000000000000016200000000000011564 Lustar rootrootmaven2-core-2.2.1/maven-artifact-manager/src/main/java/org/apache/maven/artifact/manager/DefaultWagonManager.javamaven2-core-2.2.1/maven-artifact-manager/src/main/java/org/apache/maven/artifact/manager/DefaultWago0000644000175000017500000014112511235661553033222 0ustar twernertwernerpackage org.apache.maven.artifact.manager; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.metadata.ArtifactMetadata; import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.artifact.repository.ArtifactRepositoryFactory; import org.apache.maven.artifact.repository.ArtifactRepositoryPolicy; import org.apache.maven.artifact.repository.DefaultArtifactRepository; import org.apache.maven.wagon.ConnectionException; import org.apache.maven.wagon.ResourceDoesNotExistException; import org.apache.maven.wagon.TransferFailedException; import org.apache.maven.wagon.UnsupportedProtocolException; import org.apache.maven.wagon.Wagon; import org.apache.maven.wagon.authentication.AuthenticationException; import org.apache.maven.wagon.authentication.AuthenticationInfo; import org.apache.maven.wagon.authorization.AuthorizationException; import org.apache.maven.wagon.events.TransferListener; import org.apache.maven.wagon.observers.ChecksumObserver; import org.apache.maven.wagon.proxy.ProxyInfo; import org.apache.maven.wagon.proxy.ProxyInfoProvider; import org.apache.maven.wagon.repository.Repository; import org.apache.maven.wagon.repository.RepositoryPermissions; import org.codehaus.plexus.PlexusConstants; import org.codehaus.plexus.PlexusContainer; import org.codehaus.plexus.component.configurator.ComponentConfigurationException; import org.codehaus.plexus.component.configurator.ComponentConfigurator; import org.codehaus.plexus.component.repository.exception.ComponentLifecycleException; import org.codehaus.plexus.component.repository.exception.ComponentLookupException; import org.codehaus.plexus.configuration.PlexusConfiguration; import org.codehaus.plexus.configuration.PlexusConfigurationException; import org.codehaus.plexus.configuration.xml.XmlPlexusConfiguration; import org.codehaus.plexus.context.Context; import org.codehaus.plexus.context.ContextException; import org.codehaus.plexus.logging.AbstractLogEnabled; import org.codehaus.plexus.personality.plexus.lifecycle.phase.Contextualizable; import org.codehaus.plexus.personality.plexus.lifecycle.phase.Initializable; import org.codehaus.plexus.personality.plexus.lifecycle.phase.InitializationException; import org.codehaus.plexus.util.FileUtils; import org.codehaus.plexus.util.IOUtil; import org.codehaus.plexus.util.xml.Xpp3Dom; import java.io.File; import java.io.IOException; import java.io.InputStream; import java.net.MalformedURLException; import java.net.URL; import java.security.NoSuchAlgorithmException; import java.util.Collection; import java.util.HashMap; import java.util.Iterator; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; import java.util.Properties; import java.util.Set; public class DefaultWagonManager extends AbstractLogEnabled implements WagonManager, Contextualizable, Initializable { private static final String WILDCARD = "*"; private static final String EXTERNAL_WILDCARD = "external:*"; private static final String MAVEN_ARTIFACT_PROPERTIES = "META-INF/maven/org.apache.maven/maven-artifact/pom.properties"; private static final String WAGON_PROVIDER_CONFIGURATION = "wagonProvider"; private static int anonymousMirrorIdSeed = 0; private PlexusContainer container; // TODO: proxies, authentication and mirrors are via settings, and should come in via an alternate method - perhaps // attached to ArtifactRepository before the method is called (so AR would be composed of WR, not inherit it) private Map proxies = new HashMap(); private Map authenticationInfoMap = new HashMap(); private Map serverPermissionsMap = new HashMap(); //used LinkedMap to preserve the order. private Map mirrors = new LinkedHashMap(); /** Map( String, XmlPlexusConfiguration ) with the repository id and the wagon configuration */ private Map serverConfigurationMap = new HashMap(); private Map serverWagonProviderMap = new HashMap(); private TransferListener downloadMonitor; private boolean online = true; private ArtifactRepositoryFactory repositoryFactory; private boolean interactive = true; private Map availableWagons = new HashMap(); private RepositoryPermissions defaultRepositoryPermissions; private String httpUserAgent; private WagonProviderMapping providerMapping = new DefaultWagonProviderMapping(); // TODO: this leaks the component in the public api - it is never released back to the container public Wagon getWagon( Repository repository ) throws UnsupportedProtocolException, WagonConfigurationException { String protocol = repository.getProtocol(); if ( protocol == null ) { throw new UnsupportedProtocolException( "The repository " + repository + " does not specify a protocol" ); } Wagon wagon = getWagon( protocol, repository.getId() ); configureWagon( wagon, repository.getId(), protocol ); return wagon; } public Wagon getWagon( String protocol ) throws UnsupportedProtocolException { return getWagon( protocol, null ); } private Wagon getWagon( String protocol, String repositoryId ) throws UnsupportedProtocolException { String hint = getWagonHint( protocol, repositoryId ); PlexusContainer container = getWagonContainer( hint ); Wagon wagon; try { wagon = (Wagon) container.lookup( Wagon.ROLE, hint ); } catch ( ComponentLookupException e1 ) { throw new UnsupportedProtocolException( "Cannot find wagon which supports the requested protocol: " + protocol, e1 ); } wagon.setInteractive( interactive ); return wagon; } private String getWagonHint( String protocol, String repositoryId ) { // TODO: Implement a better way to get the hint, via settings.xml or something. String impl = null; if ( repositoryId != null && serverWagonProviderMap.containsKey( repositoryId ) ) { impl = serverWagonProviderMap.get( repositoryId ); getLogger().debug( "Using Wagon implementation " + impl + " from settings for server " + repositoryId ); } else { impl = providerMapping.getWagonProvider( protocol ); if ( impl != null ) { getLogger().debug( "Using Wagon implementation " + impl + " from default mapping for protocol " + protocol ); } } String hint; if ( impl != null ) { hint = protocol + "-" + impl; PlexusContainer container = getWagonContainer( hint ); if ( container == null || !container.hasComponent( Wagon.ROLE, hint ) ) { getLogger().debug( "Cannot find wagon for protocol-provider hint: '" + hint + "', configured for repository: '" + repositoryId + "'. Using protocol hint: '" + protocol + "' instead." ); hint = protocol; } } else { hint = protocol; } return hint; } private PlexusContainer getWagonContainer( String hint ) { PlexusContainer container = this.container; if ( availableWagons.containsKey( hint ) ) { container = availableWagons.get( hint ); } return container; } public void putArtifact( File source, Artifact artifact, ArtifactRepository deploymentRepository ) throws TransferFailedException { putRemoteFile( deploymentRepository, source, deploymentRepository.pathOf( artifact ), downloadMonitor ); } public void putArtifactMetadata( File source, ArtifactMetadata artifactMetadata, ArtifactRepository repository ) throws TransferFailedException { getLogger().info( "Uploading " + artifactMetadata ); putRemoteFile( repository, source, repository.pathOfRemoteRepositoryMetadata( artifactMetadata ), null ); } private void putRemoteFile( ArtifactRepository repository, File source, String remotePath, TransferListener downloadMonitor ) throws TransferFailedException { failIfNotOnline(); String protocol = repository.getProtocol(); Wagon wagon; try { wagon = getWagon( protocol, repository.getId() ); configureWagon( wagon, repository ); } catch ( UnsupportedProtocolException e ) { throw new TransferFailedException( "Unsupported Protocol: '" + protocol + "': " + e.getMessage(), e ); } if ( downloadMonitor != null ) { wagon.addTransferListener( downloadMonitor ); } Map checksums = new HashMap( 2 ); Map sums = new HashMap( 2 ); // TODO: configure these on the repository try { ChecksumObserver checksumObserver = new ChecksumObserver( "MD5" ); wagon.addTransferListener( checksumObserver ); checksums.put( "md5", checksumObserver ); checksumObserver = new ChecksumObserver( "SHA-1" ); wagon.addTransferListener( checksumObserver ); checksums.put( "sha1", checksumObserver ); } catch ( NoSuchAlgorithmException e ) { throw new TransferFailedException( "Unable to add checksum methods: " + e.getMessage(), e ); } try { Repository artifactRepository = new Repository( repository.getId(), repository.getUrl() ); if ( serverPermissionsMap.containsKey( repository.getId() ) ) { RepositoryPermissions perms = (RepositoryPermissions) serverPermissionsMap.get( repository.getId() ); getLogger().debug( "adding permissions to wagon connection: " + perms.getFileMode() + " " + perms.getDirectoryMode() ); artifactRepository.setPermissions( perms ); } else { if ( defaultRepositoryPermissions != null ) { artifactRepository.setPermissions( defaultRepositoryPermissions ); } else { getLogger().debug( "not adding permissions to wagon connection" ); } } wagon.connect( artifactRepository, getAuthenticationInfo( repository.getId() ), new ProxyInfoProvider() { public ProxyInfo getProxyInfo( String protocol ) { return getProxy( protocol ); } }); wagon.put( source, remotePath ); wagon.removeTransferListener( downloadMonitor ); // Pre-store the checksums as any future puts will overwrite them for ( Iterator i = checksums.keySet().iterator(); i.hasNext(); ) { String extension = (String) i.next(); ChecksumObserver observer = (ChecksumObserver) checksums.get( extension ); sums.put( extension, observer.getActualChecksum() ); } // We do this in here so we can checksum the artifact metadata too, otherwise it could be metadata itself for ( Iterator i = checksums.keySet().iterator(); i.hasNext(); ) { String extension = (String) i.next(); // TODO: shouldn't need a file intermediatary - improve wagon to take a stream File temp = File.createTempFile( "maven-artifact", null ); temp.deleteOnExit(); FileUtils.fileWrite( temp.getAbsolutePath(), "UTF-8", (String) sums.get( extension ) ); wagon.put( temp, remotePath + "." + extension ); } } catch ( ConnectionException e ) { throw new TransferFailedException( "Connection failed: " + e.getMessage(), e ); } catch ( AuthenticationException e ) { throw new TransferFailedException( "Authentication failed: " + e.getMessage(), e ); } catch ( AuthorizationException e ) { throw new TransferFailedException( "Authorization failed: " + e.getMessage(), e ); } catch ( ResourceDoesNotExistException e ) { throw new TransferFailedException( "Resource to deploy not found: " + e.getMessage(), e ); } catch ( IOException e ) { throw new TransferFailedException( "Error creating temporary file for deployment: " + e.getMessage(), e ); } finally { disconnectWagon( wagon ); releaseWagon( protocol, wagon, repository.getId() ); } } public void getArtifact( Artifact artifact, List remoteRepositories ) throws TransferFailedException, ResourceDoesNotExistException { // TODO [BP]: The exception handling here needs some work boolean successful = false; for ( Iterator iter = remoteRepositories.iterator(); iter.hasNext() && !successful; ) { ArtifactRepository repository = (ArtifactRepository) iter.next(); try { getArtifact( artifact, repository ); successful = artifact.isResolved(); } catch ( ResourceDoesNotExistException e ) { // This one we will eat when looking through remote repositories // because we want to cycle through them all before squawking. getLogger().info( "Unable to find resource '" + artifact.getId() + "' in repository " + repository.getId() + " (" + repository.getUrl() + ")" ); } catch ( TransferFailedException e ) { getLogger().warn( "Unable to get resource '" + artifact.getId() + "' from repository " + repository.getId() + " (" + repository.getUrl() + "): " + e.getMessage() ); } } // if it already exists locally we were just trying to force it - ignore the update if ( !successful && !artifact.getFile().exists() ) { throw new ResourceDoesNotExistException( "Unable to download the artifact from any repository" ); } } public void getArtifact( Artifact artifact, ArtifactRepository repository ) throws TransferFailedException, ResourceDoesNotExistException { String remotePath = repository.pathOf( artifact ); ArtifactRepositoryPolicy policy = artifact.isSnapshot() ? repository.getSnapshots() : repository.getReleases(); if ( !policy.isEnabled() ) { getLogger().debug( "Skipping disabled repository " + repository.getId() ); } else if ( repository.isBlacklisted() ) { getLogger().debug( "Skipping blacklisted repository " + repository.getId() ); } else { getLogger().debug( "Trying repository " + repository.getId() ); getRemoteFile( getMirrorRepository( repository ), artifact.getFile(), remotePath, downloadMonitor, policy.getChecksumPolicy(), false ); getLogger().debug( " Artifact resolved" ); artifact.setResolved( true ); } } public void getArtifactMetadata( ArtifactMetadata metadata, ArtifactRepository repository, File destination, String checksumPolicy ) throws TransferFailedException, ResourceDoesNotExistException { String remotePath = repository.pathOfRemoteRepositoryMetadata( metadata ); getRemoteFile( getMirrorRepository( repository ), destination, remotePath, null, checksumPolicy, true ); } public void getArtifactMetadataFromDeploymentRepository( ArtifactMetadata metadata, ArtifactRepository repository, File destination, String checksumPolicy ) throws TransferFailedException, ResourceDoesNotExistException { String remotePath = repository.pathOfRemoteRepositoryMetadata( metadata ); getRemoteFile( repository, destination, remotePath, null, checksumPolicy, true ); } private void getRemoteFile( ArtifactRepository repository, File destination, String remotePath, TransferListener downloadMonitor, String checksumPolicy, boolean force ) throws TransferFailedException, ResourceDoesNotExistException { // TODO: better excetpions - transfer failed is not enough? failIfNotOnline(); String protocol = repository.getProtocol(); Wagon wagon; try { wagon = getWagon( protocol, repository.getId() ); configureWagon( wagon, repository ); } catch ( UnsupportedProtocolException e ) { throw new TransferFailedException( "Unsupported Protocol: '" + protocol + "': " + e.getMessage(), e ); } if ( downloadMonitor != null ) { wagon.addTransferListener( downloadMonitor ); } File temp = new File( destination + ".tmp" ); temp.deleteOnExit(); boolean downloaded = false; try { getLogger().debug( "Connecting to repository: \'" + repository.getId() + "\' with url: \'" + repository.getUrl() + "\'." ); wagon.connect( new Repository( repository.getId(), repository.getUrl() ), getAuthenticationInfo( repository.getId() ), new ProxyInfoProvider() { public ProxyInfo getProxyInfo( String protocol ) { return getProxy( protocol ); } }); boolean firstRun = true; boolean retry = true; // this will run at most twice. The first time, the firstRun flag is turned off, and if the retry flag // is set on the first run, it will be turned off and not re-set on the second try. This is because the // only way the retry flag can be set is if ( firstRun == true ). while ( firstRun || retry ) { // reset the retry flag. retry = false; // TODO: configure on repository ChecksumObserver md5ChecksumObserver = null; ChecksumObserver sha1ChecksumObserver = null; try { md5ChecksumObserver = new ChecksumObserver( "MD5" ); wagon.addTransferListener( md5ChecksumObserver ); sha1ChecksumObserver = new ChecksumObserver( "SHA-1" ); wagon.addTransferListener( sha1ChecksumObserver ); // This should take care of creating destination directory now on if ( destination.exists() && !force ) { try { downloaded = wagon.getIfNewer( remotePath, temp, destination.lastModified() ); if ( !downloaded ) { // prevent additional checks of this artifact until it expires again destination.setLastModified( System.currentTimeMillis() ); } } catch ( UnsupportedOperationException e ) { // older wagons throw this. Just get() instead wagon.get( remotePath, temp ); downloaded = true; } } else { wagon.get( remotePath, temp ); downloaded = true; } } catch ( NoSuchAlgorithmException e ) { throw new TransferFailedException( "Unable to add checksum methods: " + e.getMessage(), e ); } finally { if ( md5ChecksumObserver != null ) { wagon.removeTransferListener( md5ChecksumObserver ); } if ( sha1ChecksumObserver != null ) { wagon.removeTransferListener( sha1ChecksumObserver ); } } if ( downloaded ) { // keep the checksum files from showing up on the download monitor... if ( downloadMonitor != null ) { wagon.removeTransferListener( downloadMonitor ); } // try to verify the SHA-1 checksum for this file. try { verifyChecksum( sha1ChecksumObserver, destination, temp, remotePath, ".sha1", wagon ); } catch ( ChecksumFailedException e ) { // if we catch a ChecksumFailedException, it means the transfer/read succeeded, but the checksum // doesn't match. This could be a problem with the server (ibiblio HTTP-200 error page), so we'll // try this up to two times. On the second try, we'll handle it as a bona-fide error, based on the // repository's checksum checking policy. if ( firstRun ) { getLogger().warn( "*** CHECKSUM FAILED - " + e.getMessage() + " - RETRYING" ); retry = true; } else { handleChecksumFailure( checksumPolicy, e.getMessage(), e.getCause() ); } } catch ( ResourceDoesNotExistException sha1TryException ) { getLogger().debug( "SHA1 not found, trying MD5", sha1TryException ); // if this IS NOT a ChecksumFailedException, it was a problem with transfer/read of the checksum // file...we'll try again with the MD5 checksum. try { verifyChecksum( md5ChecksumObserver, destination, temp, remotePath, ".md5", wagon ); } catch ( ChecksumFailedException e ) { // if we also fail to verify based on the MD5 checksum, and the checksum transfer/read // succeeded, then we need to determine whether to retry or handle it as a failure. if ( firstRun ) { retry = true; } else { handleChecksumFailure( checksumPolicy, e.getMessage(), e.getCause() ); } } catch ( ResourceDoesNotExistException md5TryException ) { // this was a failed transfer, and we don't want to retry. handleChecksumFailure( checksumPolicy, "Error retrieving checksum file for " + remotePath, md5TryException ); } } // reinstate the download monitor... if ( downloadMonitor != null ) { wagon.addTransferListener( downloadMonitor ); } } // unset the firstRun flag, so we don't get caught in an infinite loop... firstRun = false; } } catch ( ConnectionException e ) { throw new TransferFailedException( "Connection failed: " + e.getMessage(), e ); } catch ( AuthenticationException e ) { throw new TransferFailedException( "Authentication failed: " + e.getMessage(), e ); } catch ( AuthorizationException e ) { throw new TransferFailedException( "Authorization failed: " + e.getMessage(), e ); } finally { disconnectWagon( wagon ); releaseWagon( protocol, wagon, repository.getId() ); } if ( downloaded ) { if ( !temp.exists() ) { throw new ResourceDoesNotExistException( "Downloaded file does not exist: " + temp ); } // The temporary file is named destination + ".tmp" and is done this way to ensure // that the temporary file is in the same file system as the destination because the // File.renameTo operation doesn't really work across file systems. // So we will attempt to do a File.renameTo for efficiency and atomicity, if this fails // then we will use a brute force copy and delete the temporary file. if ( !temp.renameTo( destination ) ) { try { FileUtils.copyFile( temp, destination ); temp.delete(); } catch ( IOException e ) { throw new TransferFailedException( "Error copying temporary file to the final destination: " + e.getMessage(), e ); } } } } public ArtifactRepository getMirrorRepository( ArtifactRepository repository ) { ArtifactRepository mirror = getMirror( repository ); if ( mirror != null ) { String id = mirror.getId(); if ( id == null ) { // TODO: this should be illegal in settings.xml id = repository.getId(); } getLogger().debug( "Using mirror: " + mirror.getUrl() + " (id: " + id + ")" ); repository = repositoryFactory.createArtifactRepository( id, mirror.getUrl(), repository.getLayout(), repository.getSnapshots(), repository.getReleases() ); } return repository; } private void failIfNotOnline() throws TransferFailedException { if ( !isOnline() ) { throw new TransferFailedException( "System is offline." ); } } private void handleChecksumFailure( String checksumPolicy, String message, Throwable cause ) throws ChecksumFailedException { if ( ArtifactRepositoryPolicy.CHECKSUM_POLICY_FAIL.equals( checksumPolicy ) ) { throw new ChecksumFailedException( message, cause ); } else if ( !ArtifactRepositoryPolicy.CHECKSUM_POLICY_IGNORE.equals( checksumPolicy ) ) { // warn if it is set to anything other than ignore getLogger().warn( "*** CHECKSUM FAILED - " + message + " - IGNORING" ); } // otherwise it is ignore } private void verifyChecksum( ChecksumObserver checksumObserver, File destination, File tempDestination, String remotePath, String checksumFileExtension, Wagon wagon ) throws ResourceDoesNotExistException, TransferFailedException, AuthorizationException { try { // grab it first, because it's about to change... String actualChecksum = checksumObserver.getActualChecksum(); File tempChecksumFile = new File( tempDestination + checksumFileExtension + ".tmp" ); tempChecksumFile.deleteOnExit(); wagon.get( remotePath + checksumFileExtension, tempChecksumFile ); String expectedChecksum = FileUtils.fileRead( tempChecksumFile, "UTF-8" ); // remove whitespaces at the end expectedChecksum = expectedChecksum.trim(); // check for 'ALGO (name) = CHECKSUM' like used by openssl if ( expectedChecksum.regionMatches( true, 0, "MD", 0, 2 ) || expectedChecksum.regionMatches( true, 0, "SHA", 0, 3 ) ) { int lastSpacePos = expectedChecksum.lastIndexOf( ' ' ); expectedChecksum = expectedChecksum.substring( lastSpacePos + 1 ); } else { // remove everything after the first space (if available) int spacePos = expectedChecksum.indexOf( ' ' ); if ( spacePos != -1 ) { expectedChecksum = expectedChecksum.substring( 0, spacePos ); } } if ( expectedChecksum.equalsIgnoreCase( actualChecksum ) ) { File checksumFile = new File( destination + checksumFileExtension ); if ( checksumFile.exists() ) { checksumFile.delete(); } FileUtils.copyFile( tempChecksumFile, checksumFile ); } else { throw new ChecksumFailedException( "Checksum failed on download: local = '" + actualChecksum + "'; remote = '" + expectedChecksum + "'" ); } } catch ( IOException e ) { throw new ChecksumFailedException( "Invalid checksum file", e ); } } private void disconnectWagon( Wagon wagon ) { try { wagon.disconnect(); } catch ( ConnectionException e ) { getLogger().error( "Problem disconnecting from wagon - ignoring: " + e.getMessage() ); } } private void releaseWagon( String protocol, Wagon wagon, String repositoryId ) { String hint = getWagonHint( protocol, repositoryId ); PlexusContainer container = getWagonContainer( hint ); try { container.release( wagon ); } catch ( ComponentLifecycleException e ) { getLogger().error( "Problem releasing wagon - ignoring: " + e.getMessage() ); } } public ProxyInfo getProxy( String protocol ) { ProxyInfo info = (ProxyInfo) proxies.get( protocol ); if ( info != null ) { getLogger().debug( "Using Proxy: " + info.getHost() ); } return info; } public AuthenticationInfo getAuthenticationInfo( String id ) { return (AuthenticationInfo) authenticationInfoMap.get( id ); } /** * This method finds a matching mirror for the selected repository. If there is an exact match, this will be used. * If there is no exact match, then the list of mirrors is examined to see if a pattern applies. * * @param originalRepository See if there is a mirror for this repository. * @return the selected mirror or null if none are found. */ public ArtifactRepository getMirror( ArtifactRepository originalRepository ) { ArtifactRepository selectedMirror = (ArtifactRepository) mirrors.get( originalRepository.getId() ); if ( null == selectedMirror ) { // Process the patterns in order. First one that matches wins. Set keySet = mirrors.keySet(); if ( keySet != null ) { Iterator iter = keySet.iterator(); while ( iter.hasNext() ) { String pattern = (String) iter.next(); if ( matchPattern( originalRepository, pattern ) ) { selectedMirror = (ArtifactRepository) mirrors.get( pattern ); break; } } } } return selectedMirror; } /** * This method checks if the pattern matches the originalRepository. * Valid patterns: * * = everything * external:* = everything not on the localhost and not file based. * repo,repo1 = repo or repo1 * *,!repo1 = everything except repo1 * * @param originalRepository to compare for a match. * @param pattern used for match. Currently only '*' is supported. * @return true if the repository is a match to this pattern. */ public boolean matchPattern( ArtifactRepository originalRepository, String pattern ) { boolean result = false; String originalId = originalRepository.getId(); // simple checks first to short circuit processing below. if ( WILDCARD.equals( pattern ) || pattern.equals( originalId ) ) { result = true; } else { // process the list String[] repos = pattern.split( "," ); for ( int i = 0; i < repos.length; i++ ) { String repo = repos[i]; // see if this is a negative match if ( repo.length() > 1 && repo.startsWith( "!" ) ) { if ( originalId.equals( repo.substring( 1 ) ) ) { // explicitly exclude. Set result and stop processing. result = false; break; } } // check for exact match else if ( originalId.equals( repo ) ) { result = true; break; } // check for external:* else if ( EXTERNAL_WILDCARD.equals( repo ) && isExternalRepo( originalRepository ) ) { result = true; // don't stop processing in case a future segment explicitly excludes this repo } else if ( WILDCARD.equals( repo ) ) { result = true; // don't stop processing in case a future segment explicitly excludes this repo } } } return result; } /** * Checks the URL to see if this repository refers to an external repository * * @param originalRepository * @return true if external. */ public boolean isExternalRepo( ArtifactRepository originalRepository ) { try { URL url = new URL( originalRepository.getUrl() ); return !( url.getHost().equals( "localhost" ) || url.getHost().equals( "127.0.0.1" ) || url.getProtocol().equals( "file" ) ); } catch ( MalformedURLException e ) { // bad url just skip it here. It should have been validated already, but the wagon lookup will deal with it return false; } } /** * Set the proxy used for a particular protocol. * * @param protocol the protocol (required) * @param host the proxy host name (required) * @param port the proxy port (required) * @param username the username for the proxy, or null if there is none * @param password the password for the proxy, or null if there is none * @param nonProxyHosts the set of hosts not to use the proxy for. Follows Java system property format: * *.foo.com|localhost. * @todo [BP] would be nice to configure this via plexus in some way */ public void addProxy( String protocol, String host, int port, String username, String password, String nonProxyHosts ) { ProxyInfo proxyInfo = new ProxyInfo(); proxyInfo.setHost( host ); proxyInfo.setType( protocol ); proxyInfo.setPort( port ); proxyInfo.setNonProxyHosts( nonProxyHosts ); proxyInfo.setUserName( username ); proxyInfo.setPassword( password ); proxies.put( protocol, proxyInfo ); } public void contextualize( Context context ) throws ContextException { container = (PlexusContainer) context.get( PlexusConstants.PLEXUS_KEY ); } /** @todo I'd rather not be setting this explicitly. */ public void setDownloadMonitor( TransferListener downloadMonitor ) { this.downloadMonitor = downloadMonitor; } public void addAuthenticationInfo( String repositoryId, String username, String password, String privateKey, String passphrase ) { AuthenticationInfo authInfo = new AuthenticationInfo(); authInfo.setUserName( username ); authInfo.setPassword( password ); authInfo.setPrivateKey( privateKey ); authInfo.setPassphrase( passphrase ); authenticationInfoMap.put( repositoryId, authInfo ); } public void addPermissionInfo( String repositoryId, String filePermissions, String directoryPermissions ) { RepositoryPermissions permissions = new RepositoryPermissions(); boolean addPermissions = false; if ( filePermissions != null ) { permissions.setFileMode( filePermissions ); addPermissions = true; } if ( directoryPermissions != null ) { permissions.setDirectoryMode( directoryPermissions ); addPermissions = true; } if ( addPermissions ) { serverPermissionsMap.put( repositoryId, permissions ); } } public void addMirror( String id, String mirrorOf, String url ) { if ( id == null ) { id = "mirror-" + anonymousMirrorIdSeed++; getLogger().warn( "You are using a mirror that doesn't declare an element. Using \'" + id + "\' instead:\nId: " + id + "\nmirrorOf: " + mirrorOf + "\nurl: " + url + "\n" ); } ArtifactRepository mirror = new DefaultArtifactRepository( id, url, null ); //to preserve first wins, don't add repeated mirrors. if (!mirrors.containsKey( mirrorOf )) { mirrors.put( mirrorOf, mirror ); } } public void setOnline( boolean online ) { this.online = online; } public boolean isOnline() { return online; } public void setInteractive( boolean interactive ) { this.interactive = interactive; } @SuppressWarnings( "unchecked" ) public void registerWagons( Collection wagons, PlexusContainer extensionContainer ) { for ( Iterator i = wagons.iterator(); i.hasNext(); ) { availableWagons.put( i.next(), extensionContainer ); } } /** * Applies the server configuration to the wagon * * @param wagon the wagon to configure * @param repository the repository that has the configuration * @throws WagonConfigurationException wraps any error given during configuration of the wagon instance */ private void configureWagon( Wagon wagon, ArtifactRepository repository ) throws WagonConfigurationException { configureWagon( wagon, repository.getId(), repository.getProtocol() ); } private void configureWagon( Wagon wagon, String repositoryId, String protocol ) throws WagonConfigurationException { PlexusConfiguration config = (PlexusConfiguration) serverConfigurationMap.get( repositoryId ); if ( protocol.startsWith( "http" ) || protocol.startsWith( "dav" ) ) { config = updateUserAgentForHttp( wagon, config ); } if ( config != null ) { ComponentConfigurator componentConfigurator = null; try { componentConfigurator = (ComponentConfigurator) container.lookup( ComponentConfigurator.ROLE, "wagon" ); componentConfigurator.configureComponent( wagon, config, container.getContainerRealm() ); } catch ( final ComponentLookupException e ) { throw new WagonConfigurationException( repositoryId, "Unable to lookup wagon configurator. Wagon configuration cannot be applied.", e ); } catch ( ComponentConfigurationException e ) { throw new WagonConfigurationException( repositoryId, "Unable to apply wagon configuration.", e ); } finally { if ( componentConfigurator != null ) { try { container.release( componentConfigurator ); } catch ( ComponentLifecycleException e ) { getLogger().error( "Problem releasing configurator - ignoring: " + e.getMessage() ); } } } } } // TODO: Remove this, once the maven-shade-plugin 1.2 release is out, allowing configuration of httpHeaders in the components.xml private PlexusConfiguration updateUserAgentForHttp( Wagon wagon, PlexusConfiguration config ) { if ( config == null ) { config = new XmlPlexusConfiguration( "configuration" ); } if ( httpUserAgent != null ) { try { wagon.getClass().getMethod( "setHttpHeaders", new Class[]{ Properties.class } ); PlexusConfiguration headerConfig = config.getChild( "httpHeaders", true ); PlexusConfiguration[] children = headerConfig.getChildren( "property" ); boolean found = false; getLogger().debug( "Checking for pre-existing User-Agent configuration." ); for ( int i = 0; i < children.length; i++ ) { PlexusConfiguration c = children[i].getChild( "name", false ); if ( c != null && "User-Agent".equals( c.getValue( null ) ) ) { found = true; break; } } if ( !found ) { getLogger().debug( "Adding User-Agent configuration." ); XmlPlexusConfiguration propertyConfig = new XmlPlexusConfiguration( "property" ); headerConfig.addChild( propertyConfig ); XmlPlexusConfiguration nameConfig = new XmlPlexusConfiguration( "name" ); nameConfig.setValue( "User-Agent" ); propertyConfig.addChild( nameConfig ); XmlPlexusConfiguration versionConfig = new XmlPlexusConfiguration( "value" ); versionConfig.setValue( httpUserAgent ); propertyConfig.addChild( versionConfig ); } else { getLogger().debug( "User-Agent configuration found." ); } } catch ( SecurityException e ) { getLogger().debug( "setHttpHeaders method not accessible on wagon: " + wagon + "; skipping User-Agent configuration." ); // forget it. this method is public, if it exists. } catch ( NoSuchMethodException e ) { getLogger().debug( "setHttpHeaders method not found on wagon: " + wagon + "; skipping User-Agent configuration." ); // forget it. } } return config; } public void addConfiguration( String repositoryId, Xpp3Dom configuration ) { if ( repositoryId == null || configuration == null ) { throw new IllegalArgumentException( "arguments can't be null" ); } final XmlPlexusConfiguration xmlConf = new XmlPlexusConfiguration( configuration ); for ( int i = 0; i < configuration.getChildCount(); i++ ) { Xpp3Dom domChild = configuration.getChild( i ); if ( WAGON_PROVIDER_CONFIGURATION.equals( domChild.getName() ) ) { serverWagonProviderMap.put( repositoryId, domChild.getValue() ); configuration.removeChild( i ); break; } i++; } serverConfigurationMap.put( repositoryId, xmlConf ); } public void setDefaultRepositoryPermissions( RepositoryPermissions defaultRepositoryPermissions ) { this.defaultRepositoryPermissions = defaultRepositoryPermissions; } // TODO: Remove this, once the maven-shade-plugin 1.2 release is out, allowing configuration of httpHeaders in the components.xml public void initialize() throws InitializationException { if ( httpUserAgent == null ) { InputStream resourceAsStream = null; try { Properties properties = new Properties(); resourceAsStream = getClass().getClassLoader().getResourceAsStream( MAVEN_ARTIFACT_PROPERTIES ); if ( resourceAsStream != null ) { try { properties.load( resourceAsStream ); httpUserAgent = "maven-artifact/" + properties.getProperty( "version" ) + " (Java " + System.getProperty( "java.version" ) + "; " + System.getProperty( "os.name" ) + " " + System.getProperty( "os.version" ) + ")"; } catch ( IOException e ) { getLogger().warn( "Failed to load Maven artifact properties from:\n" + MAVEN_ARTIFACT_PROPERTIES + "\n\nUser-Agent HTTP header may be incorrect for artifact resolution." ); } } } finally { IOUtil.close( resourceAsStream ); } } } /** * {@inheritDoc} */ public void setHttpUserAgent( String userAgent ) { this.httpUserAgent = userAgent; } /** * {@inheritDoc} */ public String getHttpUserAgent() { return httpUserAgent; } } ././@LongLink0000000000000000000000000000016600000000000011570 Lustar rootrootmaven2-core-2.2.1/maven-artifact-manager/src/main/java/org/apache/maven/artifact/manager/ChecksumFailedException.javamaven2-core-2.2.1/maven-artifact-manager/src/main/java/org/apache/maven/artifact/manager/ChecksumFai0000644000175000017500000000254410772004567033204 0ustar twernertwernerpackage org.apache.maven.artifact.manager; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import org.apache.maven.wagon.TransferFailedException; /** * Occurs when a download checksum fails. * * @author Brett Porter * @version $Id: ChecksumFailedException.java 640549 2008-03-24 20:05:11Z bentmann $ */ public class ChecksumFailedException extends TransferFailedException { public ChecksumFailedException( String s ) { super( s ); } public ChecksumFailedException( String message, Throwable cause ) { super( message, cause ); } } maven2-core-2.2.1/maven-artifact-manager/src/main/java/org/apache/maven/artifact/deployer/0000755000175000017500000000000011250552244031273 5ustar twernertwerner././@LongLink0000000000000000000000000000016700000000000011571 Lustar rootrootmaven2-core-2.2.1/maven-artifact-manager/src/main/java/org/apache/maven/artifact/deployer/DefaultArtifactDeployer.javamaven2-core-2.2.1/maven-artifact-manager/src/main/java/org/apache/maven/artifact/deployer/DefaultArt0000644000175000017500000001364111151024413033246 0ustar twernertwernerpackage org.apache.maven.artifact.deployer; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.manager.WagonManager; import org.apache.maven.artifact.metadata.ArtifactMetadata; import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.artifact.repository.metadata.RepositoryMetadataDeploymentException; import org.apache.maven.artifact.repository.metadata.RepositoryMetadataManager; import org.apache.maven.artifact.transform.ArtifactTransformationManager; import org.apache.maven.wagon.TransferFailedException; import org.codehaus.plexus.logging.AbstractLogEnabled; import org.codehaus.plexus.util.FileUtils; import java.io.File; import java.io.IOException; import java.util.Iterator; public class DefaultArtifactDeployer extends AbstractLogEnabled implements ArtifactDeployer { private WagonManager wagonManager; private ArtifactTransformationManager transformationManager; private RepositoryMetadataManager repositoryMetadataManager; /** * @deprecated we want to use the artifact method only, and ensure artifact.file is set correctly. */ public void deploy( String basedir, String finalName, Artifact artifact, ArtifactRepository deploymentRepository, ArtifactRepository localRepository ) throws ArtifactDeploymentException { String extension = artifact.getArtifactHandler().getExtension(); File source = new File( basedir, finalName + "." + extension ); deploy( source, artifact, deploymentRepository, localRepository ); } public void deploy( File source, Artifact artifact, ArtifactRepository deploymentRepository, ArtifactRepository localRepository ) throws ArtifactDeploymentException { if ( !wagonManager.isOnline() ) { // deployment shouldn't silently fail when offline throw new ArtifactDeploymentException( "System is offline. Cannot deploy artifact: " + artifact + "." ); } // If we're installing the POM, we need to transform it first. The source file supplied for // installation here may be the POM, but that POM may not be set as the file of the supplied // artifact. Since the transformation only has access to the artifact and not the supplied // source file, we have to use the Artifact.setFile(..) and Artifact.getFile(..) methods // to shunt the POM file into the transformation process. // Here, we also set a flag indicating that the POM has been shunted through the Artifact, // and to expect the transformed version to be available in the Artifact afterwards... boolean useArtifactFile = false; File oldArtifactFile = artifact.getFile(); if ( "pom".equals( artifact.getType() ) ) { artifact.setFile( source ); useArtifactFile = true; } try { transformationManager.transformForDeployment( artifact, deploymentRepository, localRepository ); // If we used the Artifact shunt to transform a POM source file, we need to install // the transformed version, not the supplied version. Therefore, we need to replace // the supplied source POM with the one from Artifact.getFile(..). if ( useArtifactFile ) { source = artifact.getFile(); artifact.setFile( oldArtifactFile ); } // FIXME: Why oh why are we re-installing the artifact in the local repository? Isn't this // the responsibility of the ArtifactInstaller?? // Copy the original file to the new one if it was transformed File artifactFile = new File( localRepository.getBasedir(), localRepository.pathOf( artifact ) ); if ( !artifactFile.equals( source ) ) { FileUtils.copyFile( source, artifactFile ); } wagonManager.putArtifact( source, artifact, deploymentRepository ); // must be after the artifact is installed for ( Iterator i = artifact.getMetadataList().iterator(); i.hasNext(); ) { ArtifactMetadata metadata = (ArtifactMetadata) i.next(); repositoryMetadataManager.deploy( metadata, localRepository, deploymentRepository ); } // TODO: would like to flush this, but the plugin metadata is added in advance, not as an install/deploy transformation // This would avoid the need to merge and clear out the state during deployment // artifact.getMetadataList().clear(); } catch ( TransferFailedException e ) { throw new ArtifactDeploymentException( "Error deploying artifact: " + e.getMessage(), e ); } catch ( IOException e ) { throw new ArtifactDeploymentException( "Error deploying artifact: " + e.getMessage(), e ); } catch ( RepositoryMetadataDeploymentException e ) { throw new ArtifactDeploymentException( "Error installing artifact's metadata: " + e.getMessage(), e ); } } } maven2-core-2.2.1/maven-artifact-manager/src/main/java/org/apache/maven/artifact/resolver/0000755000175000017500000000000011250552244031311 5ustar twernertwerner././@LongLink0000000000000000000000000000016700000000000011571 Lustar rootrootmaven2-core-2.2.1/maven-artifact-manager/src/main/java/org/apache/maven/artifact/resolver/DebugResolutionListener.javamaven2-core-2.2.1/maven-artifact-manager/src/main/java/org/apache/maven/artifact/resolver/DebugResol0000644000175000017500000001276010772004567033305 0ustar twernertwernerpackage org.apache.maven.artifact.resolver; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.versioning.VersionRange; import org.codehaus.plexus.logging.Logger; import java.util.Set; import java.util.HashSet; /** * Send resolution events to the debug log. * * @author Brett Porter * @version $Id: DebugResolutionListener.java 640549 2008-03-24 20:05:11Z bentmann $ */ public class DebugResolutionListener implements ResolutionListener, ResolutionListenerForDepMgmt { private Logger logger; private String indent = ""; private static Set ignoredArtifacts = new HashSet(); public DebugResolutionListener( Logger logger ) { this.logger = logger; } public void testArtifact( Artifact node ) { } public void startProcessChildren( Artifact artifact ) { indent += " "; } public void endProcessChildren( Artifact artifact ) { indent = indent.substring( 2 ); } public void includeArtifact( Artifact artifact ) { logger.debug( indent + artifact + " (selected for " + artifact.getScope() + ")" ); } public void omitForNearer( Artifact omitted, Artifact kept ) { String omittedVersion = omitted.getVersion(); String keptVersion = kept.getVersion(); if ( omittedVersion != null ? !omittedVersion.equals( keptVersion ) : keptVersion != null ) { logger.debug( indent + omitted + " (removed - nearer found: " + kept.getVersion() + ")" ); } } public void omitForCycle( Artifact omitted ) { logger.debug( indent + omitted + " (removed - causes a cycle in the graph)" ); } public void updateScopeCurrentPom( Artifact artifact, String ignoredScope ) { logger.debug( indent + artifact + " (not setting scope to: " + ignoredScope + "; local scope " + artifact.getScope() + " wins)" ); // TODO: better way than static? this might hide messages in a reactor if ( !ignoredArtifacts.contains( artifact ) ) { logger.warn( "\n\tArtifact " + artifact + " retains local scope '" + artifact.getScope() + "' overriding broader scope '" + ignoredScope + "'\n" + "\tgiven by a dependency. If this is not intended, modify or remove the local scope.\n" ); ignoredArtifacts.add( artifact ); } } public void updateScope( Artifact artifact, String scope ) { logger.debug( indent + artifact + " (setting scope to: " + scope + ")" ); } public void selectVersionFromRange( Artifact artifact ) { logger.debug( indent + artifact + " (setting version to: " + artifact.getVersion() + " from range: " + artifact.getVersionRange() + ")" ); } public void restrictRange( Artifact artifact, Artifact replacement, VersionRange newRange ) { logger.debug( indent + artifact + " (range restricted from: " + artifact.getVersionRange() + " and: " + replacement.getVersionRange() + " to: " + newRange + " )" ); } /** * The logic used here used to be a copy of the logic used in the DefaultArtifactCollector, and this method was * called right before the actual version/scope changes were done. However, a different set of conditionals (and * more information) is needed to be able to determine when and if the version and/or scope changes. See the two * added methods, manageArtifactVersion and manageArtifactScope. */ public void manageArtifact( Artifact artifact, Artifact replacement ) { String msg = indent + artifact; msg += " ("; if ( replacement.getVersion() != null ) { msg += "applying version: " + replacement.getVersion() + ";"; } if ( replacement.getScope() != null ) { msg += "applying scope: " + replacement.getScope(); } msg += ")"; logger.debug( msg ); } public void manageArtifactVersion( Artifact artifact, Artifact replacement ) { // only show msg if a change is actually taking place if ( !replacement.getVersion().equals( artifact.getVersion() ) ) { String msg = indent + artifact + " (applying version: " + replacement.getVersion() + ")"; logger.debug( msg ); } } public void manageArtifactScope( Artifact artifact, Artifact replacement ) { // only show msg if a change is actually taking place if ( !replacement.getScope().equals( artifact.getScope() ) ) { String msg = indent + artifact + " (applying scope: " + replacement.getScope() + ")"; logger.debug( msg ); } } }././@LongLink0000000000000000000000000000016700000000000011571 Lustar rootrootmaven2-core-2.2.1/maven-artifact-manager/src/main/java/org/apache/maven/artifact/resolver/DefaultArtifactResolver.javamaven2-core-2.2.1/maven-artifact-manager/src/main/java/org/apache/maven/artifact/resolver/DefaultArt0000644000175000017500000005022711221061521033264 0ustar twernertwernerpackage org.apache.maven.artifact.resolver; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import java.io.File; import java.io.IOException; import java.util.ArrayList; import java.util.Collections; import java.util.Date; import java.util.HashMap; import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.Set; import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.factory.ArtifactFactory; import org.apache.maven.artifact.manager.WagonManager; import org.apache.maven.artifact.metadata.ArtifactMetadata; import org.apache.maven.artifact.metadata.ArtifactMetadataSource; import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.artifact.repository.ArtifactRepositoryPolicy; import org.apache.maven.artifact.repository.metadata.Metadata; import org.apache.maven.artifact.repository.metadata.Snapshot; import org.apache.maven.artifact.repository.metadata.SnapshotArtifactRepositoryMetadata; import org.apache.maven.artifact.repository.metadata.Versioning; import org.apache.maven.artifact.resolver.filter.ArtifactFilter; import org.apache.maven.artifact.transform.ArtifactTransformationManager; import org.apache.maven.wagon.ResourceDoesNotExistException; import org.apache.maven.wagon.TransferFailedException; import org.codehaus.plexus.logging.AbstractLogEnabled; import org.codehaus.plexus.util.FileUtils; import edu.emory.mathcs.backport.java.util.concurrent.CountDownLatch; import edu.emory.mathcs.backport.java.util.concurrent.LinkedBlockingQueue; import edu.emory.mathcs.backport.java.util.concurrent.ThreadPoolExecutor; import edu.emory.mathcs.backport.java.util.concurrent.TimeUnit; public class DefaultArtifactResolver extends AbstractLogEnabled implements ArtifactResolver { // ---------------------------------------------------------------------- // Components // ---------------------------------------------------------------------- private static final int DEFAULT_POOL_SIZE = 5; private WagonManager wagonManager; private ArtifactTransformationManager transformationManager; protected ArtifactFactory artifactFactory; private ArtifactCollector artifactCollector; private final ThreadPoolExecutor resolveArtifactPool; public DefaultArtifactResolver() { super(); resolveArtifactPool = new ThreadPoolExecutor( DEFAULT_POOL_SIZE, DEFAULT_POOL_SIZE, 3, TimeUnit.SECONDS, new LinkedBlockingQueue() ); } // ---------------------------------------------------------------------- // Implementation // ---------------------------------------------------------------------- public void resolve( Artifact artifact, List remoteRepositories, ArtifactRepository localRepository ) throws ArtifactResolutionException, ArtifactNotFoundException { resolve( artifact, remoteRepositories, localRepository, false ); } public void resolveAlways( Artifact artifact, List remoteRepositories, ArtifactRepository localRepository ) throws ArtifactResolutionException, ArtifactNotFoundException { resolve( artifact, remoteRepositories, localRepository, true ); } private void resolve( Artifact artifact, List remoteRepositories, ArtifactRepository localRepository, boolean force ) throws ArtifactResolutionException, ArtifactNotFoundException { if ( artifact == null ) { return; } if ( Artifact.SCOPE_SYSTEM.equals( artifact.getScope() ) ) { File systemFile = artifact.getFile(); if ( systemFile == null ) { throw new ArtifactNotFoundException( "System artifact: " + artifact + " has no file attached", artifact ); } if ( !systemFile.isFile() ) { throw new ArtifactNotFoundException( "System artifact: " + artifact + " is not a file: " + systemFile, artifact ); } if ( !systemFile.exists() ) { throw new ArtifactNotFoundException( "System artifact: " + artifact + " not found in path: " + systemFile, artifact ); } artifact.setResolved( true ); } else if ( !artifact.isResolved() ) { // ---------------------------------------------------------------------- // Check for the existence of the artifact in the specified local // ArtifactRepository. If it is present then simply return as the // request for resolution has been satisfied. // ---------------------------------------------------------------------- String localPath = localRepository.pathOf( artifact ); artifact.setFile( new File( localRepository.getBasedir(), localPath ) ); transformationManager.transformForResolve( artifact, remoteRepositories, localRepository ); boolean localCopy = false; for ( Iterator i = artifact.getMetadataList().iterator(); i.hasNext(); ) { ArtifactMetadata m = (ArtifactMetadata) i.next(); if ( m instanceof SnapshotArtifactRepositoryMetadata ) { SnapshotArtifactRepositoryMetadata snapshotMetadata = (SnapshotArtifactRepositoryMetadata) m; Metadata metadata = snapshotMetadata.getMetadata(); if ( metadata != null ) { Versioning versioning = metadata.getVersioning(); if ( versioning != null ) { Snapshot snapshot = versioning.getSnapshot(); if ( snapshot != null ) { localCopy = snapshot.isLocalCopy(); } } } } } File destination = artifact.getFile(); List repositories = remoteRepositories; // TODO: would prefer the snapshot transformation took care of this. Maybe we need a "shouldresolve" flag. if ( artifact.isSnapshot() && artifact.getBaseVersion().equals( artifact.getVersion() ) && destination.exists() && !localCopy && wagonManager.isOnline() ) { Date comparisonDate = new Date( destination.lastModified() ); // cull to list of repositories that would like an update repositories = new ArrayList( remoteRepositories ); for ( Iterator i = repositories.iterator(); i.hasNext(); ) { ArtifactRepository repository = (ArtifactRepository) i.next(); ArtifactRepositoryPolicy policy = repository.getSnapshots(); if ( !policy.isEnabled() || !policy.checkOutOfDate( comparisonDate ) ) { i.remove(); } } if ( !repositories.isEmpty() ) { // someone wants to check for updates force = true; } } if ( !destination.exists() || force ) { if ( !wagonManager.isOnline() ) { throw new ArtifactNotFoundException( "System is offline.", artifact ); } try { // TODO: force should be passed to the wagon manager if ( artifact.getRepository() != null ) { // the transformations discovered the artifact - so use it exclusively wagonManager.getArtifact( artifact, artifact.getRepository() ); } else { wagonManager.getArtifact( artifact, repositories ); } if ( !artifact.isResolved() && !destination.exists() ) { throw new ArtifactResolutionException( "Failed to resolve artifact, possibly due to a repository list that is not appropriately equipped for this artifact's metadata.", artifact, getMirroredRepositories( remoteRepositories ) ); } } catch ( ResourceDoesNotExistException e ) { throw new ArtifactNotFoundException( e.getMessage(), artifact, getMirroredRepositories( remoteRepositories ), e ); } catch ( TransferFailedException e ) { throw new ArtifactResolutionException( e.getMessage(), artifact, getMirroredRepositories( remoteRepositories ), e ); } } else if ( destination.exists() ) { // locally resolved...no need to hit the remote repo. artifact.setResolved( true ); } if ( artifact.isSnapshot() && !artifact.getBaseVersion().equals( artifact.getVersion() ) ) { String version = artifact.getVersion(); artifact.selectVersion( artifact.getBaseVersion() ); File copy = new File( localRepository.getBasedir(), localRepository.pathOf( artifact ) ); if ( !copy.exists() || copy.lastModified() != destination.lastModified() || copy.length() != destination.length() ) { // recopy file if it was reresolved, or doesn't exist. try { FileUtils.copyFile( destination, copy ); copy.setLastModified( destination.lastModified() ); } catch ( IOException e ) { throw new ArtifactResolutionException( "Unable to copy resolved artifact for local use: " + e.getMessage(), artifact, getMirroredRepositories( remoteRepositories ), e ); } } artifact.setFile( copy ); artifact.selectVersion( version ); } } } public ArtifactResolutionResult resolveTransitively( Set artifacts, Artifact originatingArtifact, ArtifactRepository localRepository, List remoteRepositories, ArtifactMetadataSource source, ArtifactFilter filter ) throws ArtifactResolutionException, ArtifactNotFoundException { return resolveTransitively( artifacts, originatingArtifact, Collections.EMPTY_MAP, localRepository, remoteRepositories, source, filter ); } public ArtifactResolutionResult resolveTransitively( Set artifacts, Artifact originatingArtifact, Map managedVersions, ArtifactRepository localRepository, List remoteRepositories, ArtifactMetadataSource source ) throws ArtifactResolutionException, ArtifactNotFoundException { return resolveTransitively( artifacts, originatingArtifact, managedVersions, localRepository, remoteRepositories, source, null ); } public ArtifactResolutionResult resolveTransitively( Set artifacts, Artifact originatingArtifact, Map managedVersions, ArtifactRepository localRepository, List remoteRepositories, ArtifactMetadataSource source, ArtifactFilter filter ) throws ArtifactResolutionException, ArtifactNotFoundException { // TODO: this is simplistic List listeners = new ArrayList(); if ( getLogger().isDebugEnabled() ) { listeners.add( new DebugResolutionListener( getLogger() ) ); } listeners.add( new WarningResolutionListener( getLogger() ) ); return resolveTransitively( artifacts, originatingArtifact, managedVersions, localRepository, remoteRepositories, source, filter, listeners ); } public ArtifactResolutionResult resolveTransitively( Set artifacts, Artifact originatingArtifact, Map managedVersions, ArtifactRepository localRepository, List remoteRepositories, ArtifactMetadataSource source, ArtifactFilter filter, List listeners ) throws ArtifactResolutionException, ArtifactNotFoundException { ArtifactResolutionResult artifactResolutionResult; artifactResolutionResult = artifactCollector.collect( artifacts, originatingArtifact, managedVersions, localRepository, remoteRepositories, source, filter, listeners ); List resolvedArtifacts = Collections.synchronizedList( new ArrayList() ); List missingArtifacts = Collections.synchronizedList( new ArrayList() ); CountDownLatch latch = new CountDownLatch( artifactResolutionResult.getArtifactResolutionNodes().size() ); Map nodesByGroupId = new HashMap(); for ( Iterator i = artifactResolutionResult.getArtifactResolutionNodes().iterator(); i.hasNext(); ) { ResolutionNode node = (ResolutionNode) i.next(); List nodes = (List) nodesByGroupId.get( node.getArtifact().getGroupId() ); if ( nodes == null ) { nodes = new ArrayList(); nodesByGroupId.put( node.getArtifact().getGroupId(), nodes ); } nodes.add( node ); } List resolutionExceptions = Collections.synchronizedList( new ArrayList() ); try { for ( Iterator i = nodesByGroupId.values().iterator(); i.hasNext(); ) { List nodes = (List) i.next(); resolveArtifactPool.execute( new ResolveArtifactTask( resolveArtifactPool, latch, nodes, localRepository, resolvedArtifacts, missingArtifacts, resolutionExceptions ) ); } latch.await(); } catch ( InterruptedException e ) { throw new ArtifactResolutionException( "Resolution interrupted", originatingArtifact, e ); } if ( !resolutionExceptions.isEmpty() ) { throw (ArtifactResolutionException) resolutionExceptions.get( 0 ); } if ( missingArtifacts.size() > 0 ) { throw new MultipleArtifactsNotFoundException( originatingArtifact, resolvedArtifacts, missingArtifacts, getMirroredRepositories( remoteRepositories ) ); } return artifactResolutionResult; } private List getMirroredRepositories( List remoteRepositories ) { Map repos = new HashMap(); for ( Iterator i = remoteRepositories.iterator(); i.hasNext(); ) { ArtifactRepository repository = (ArtifactRepository) i.next(); ArtifactRepository repo = wagonManager.getMirrorRepository( repository ); repos.put( repo.getId(), repo ); } return new ArrayList( repos.values() ); } public ArtifactResolutionResult resolveTransitively( Set artifacts, Artifact originatingArtifact, List remoteRepositories, ArtifactRepository localRepository, ArtifactMetadataSource source ) throws ArtifactResolutionException, ArtifactNotFoundException { return resolveTransitively( artifacts, originatingArtifact, localRepository, remoteRepositories, source, null ); } public ArtifactResolutionResult resolveTransitively( Set artifacts, Artifact originatingArtifact, List remoteRepositories, ArtifactRepository localRepository, ArtifactMetadataSource source, List listeners ) throws ArtifactResolutionException, ArtifactNotFoundException { return resolveTransitively( artifacts, originatingArtifact, Collections.EMPTY_MAP, localRepository, remoteRepositories, source, null, listeners ); } private class ResolveArtifactTask implements Runnable { private List nodes; private ArtifactRepository localRepository; private List resolvedArtifacts; private List missingArtifacts; private CountDownLatch latch; private ThreadPoolExecutor pool; private List resolutionExceptions; public ResolveArtifactTask( ThreadPoolExecutor pool, CountDownLatch latch, List nodes, ArtifactRepository localRepository, List resolvedArtifacts, List missingArtifacts, List resolutionExceptions ) { this.nodes = nodes; this.localRepository = localRepository; this.resolvedArtifacts = resolvedArtifacts; this.missingArtifacts = missingArtifacts; this.latch = latch; this.pool = pool; this.resolutionExceptions = resolutionExceptions; } public void run() { Iterator i = nodes.iterator(); ResolutionNode node = (ResolutionNode) i.next(); i.remove(); try { resolveArtifact( node ); } catch ( ArtifactResolutionException e ) { resolutionExceptions.add( e ); } finally { latch.countDown(); if ( i.hasNext() ) { pool.execute( new ResolveArtifactTask( pool, latch, nodes, localRepository, resolvedArtifacts, missingArtifacts, resolutionExceptions ) ); } } } private void resolveArtifact( ResolutionNode node ) throws ArtifactResolutionException { try { resolve( node.getArtifact(), node.getRemoteRepositories(), localRepository ); resolvedArtifacts.add( node.getArtifact() ); } catch ( ArtifactNotFoundException anfe ) { getLogger().debug( anfe.getMessage(), anfe ); missingArtifacts.add( node.getArtifact() ); } } } public synchronized void configureNumberOfThreads( int threads ) { resolveArtifactPool.setCorePoolSize( threads ); resolveArtifactPool.setMaximumPoolSize( threads ); } void setWagonManager( WagonManager wagonManager ) { this.wagonManager = wagonManager; } } ././@LongLink0000000000000000000000000000017100000000000011564 Lustar rootrootmaven2-core-2.2.1/maven-artifact-manager/src/main/java/org/apache/maven/artifact/resolver/WarningResolutionListener.javamaven2-core-2.2.1/maven-artifact-manager/src/main/java/org/apache/maven/artifact/resolver/WarningRes0000644000175000017500000000437210772004567033331 0ustar twernertwernerpackage org.apache.maven.artifact.resolver; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.versioning.VersionRange; import org.codehaus.plexus.logging.Logger; import java.util.HashSet; import java.util.Set; /** * Send resolution warning events to the warning log. * * @author Brett Porter * @version $Id: WarningResolutionListener.java 640549 2008-03-24 20:05:11Z bentmann $ */ public class WarningResolutionListener implements ResolutionListener { private Logger logger; public WarningResolutionListener( Logger logger ) { this.logger = logger; } public void testArtifact( Artifact node ) { } public void startProcessChildren( Artifact artifact ) { } public void endProcessChildren( Artifact artifact ) { } public void includeArtifact( Artifact artifact ) { } public void omitForNearer( Artifact omitted, Artifact kept ) { } public void omitForCycle( Artifact omitted ) { } public void updateScopeCurrentPom( Artifact artifact, String scope ) { } public void updateScope( Artifact artifact, String scope ) { } public void manageArtifact( Artifact artifact, Artifact replacement ) { } public void selectVersionFromRange( Artifact artifact ) { } public void restrictRange( Artifact artifact, Artifact replacement, VersionRange newRange ) { } } maven2-core-2.2.1/maven-artifact-manager/src/main/java/org/apache/maven/artifact/transform/0000755000175000017500000000000011250552244031463 5ustar twernertwerner././@LongLink0000000000000000000000000000017500000000000011570 Lustar rootrootmaven2-core-2.2.1/maven-artifact-manager/src/main/java/org/apache/maven/artifact/transform/LatestArtifactTransformation.javamaven2-core-2.2.1/maven-artifact-manager/src/main/java/org/apache/maven/artifact/transform/LatestArt0000644000175000017500000000547611173447106033331 0ustar twernertwernerpackage org.apache.maven.artifact.transform; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.artifact.repository.metadata.RepositoryMetadataResolutionException; import org.apache.maven.artifact.repository.metadata.Versioning; import org.apache.maven.artifact.resolver.ArtifactNotFoundException; import org.apache.maven.artifact.resolver.ArtifactResolutionException; import java.util.List; public class LatestArtifactTransformation extends AbstractVersionTransformation { public void transformForResolve( Artifact artifact, List remoteRepositories, ArtifactRepository localRepository ) throws ArtifactResolutionException, ArtifactNotFoundException { if ( Artifact.LATEST_VERSION.equals( artifact.getVersion() ) ) { try { String version = resolveVersion( artifact, localRepository, remoteRepositories ); if ( Artifact.LATEST_VERSION.equals( version ) ) { throw new ArtifactNotFoundException( "Unable to determine the latest version", artifact ); } artifact.setBaseVersion( version ); artifact.updateVersion( version, localRepository ); } catch ( RepositoryMetadataResolutionException e ) { throw new ArtifactResolutionException( e.getMessage(), artifact, e ); } } } public void transformForInstall( Artifact artifact, ArtifactRepository localRepository ) { // metadata is added via addPluginArtifactMetadata } public void transformForDeployment( Artifact artifact, ArtifactRepository remoteRepository, ArtifactRepository localRepository ) { // metadata is added via addPluginArtifactMetadata } protected String constructVersion( Versioning versioning, String baseVersion ) { return versioning.getLatest(); } } ././@LongLink0000000000000000000000000000017600000000000011571 Lustar rootrootmaven2-core-2.2.1/maven-artifact-manager/src/main/java/org/apache/maven/artifact/transform/AbstractVersionTransformation.javamaven2-core-2.2.1/maven-artifact-manager/src/main/java/org/apache/maven/artifact/transform/AbstractV0000644000175000017500000001061111173447106033302 0ustar twernertwernerpackage org.apache.maven.artifact.transform; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.manager.WagonManager; import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.artifact.repository.metadata.ArtifactRepositoryMetadata; import org.apache.maven.artifact.repository.metadata.Metadata; import org.apache.maven.artifact.repository.metadata.RepositoryMetadata; import org.apache.maven.artifact.repository.metadata.RepositoryMetadataManager; import org.apache.maven.artifact.repository.metadata.RepositoryMetadataResolutionException; import org.apache.maven.artifact.repository.metadata.SnapshotArtifactRepositoryMetadata; import org.apache.maven.artifact.repository.metadata.Versioning; import org.codehaus.plexus.logging.AbstractLogEnabled; import java.util.List; /** * Describes a version transformation during artifact resolution. * * @author Brett Porter * @version $Id: AbstractVersionTransformation.java 767322 2009-04-21 22:52:54Z jdcasey $ * @todo try and refactor to remove abstract methods - not particular happy about current design */ public abstract class AbstractVersionTransformation extends AbstractLogEnabled implements ArtifactTransformation { protected RepositoryMetadataManager repositoryMetadataManager; protected WagonManager wagonManager; protected String resolveVersion( Artifact artifact, ArtifactRepository localRepository, List remoteRepositories ) throws RepositoryMetadataResolutionException { RepositoryMetadata metadata; // Don't use snapshot metadata for LATEST (which isSnapshot returns true for) if ( !artifact.isSnapshot() || Artifact.LATEST_VERSION.equals( artifact.getBaseVersion() ) ) { metadata = new ArtifactRepositoryMetadata( artifact ); } else { metadata = new SnapshotArtifactRepositoryMetadata( artifact ); } repositoryMetadataManager.resolve( metadata, remoteRepositories, localRepository ); artifact.addMetadata( metadata ); Metadata repoMetadata = metadata.getMetadata(); String version = null; if ( repoMetadata != null && repoMetadata.getVersioning() != null ) { version = constructVersion( repoMetadata.getVersioning(), artifact.getBaseVersion() ); } if ( version == null ) { // use the local copy, or if it doesn't exist - go to the remote repo for it version = artifact.getBaseVersion(); } // TODO: also do this logging for other metadata? // TODO: figure out way to avoid duplicated message if ( getLogger().isDebugEnabled() ) { if ( !version.equals( artifact.getBaseVersion() ) ) { String message = artifact.getArtifactId() + ": resolved to version " + version; if ( artifact.getRepository() != null ) { message += " from repository " + artifact.getRepository().getId(); } else { message += " from local repository"; } getLogger().debug( message ); } else { // Locally installed file is newer, don't use the resolved version getLogger().debug( artifact.getArtifactId() + ": using locally installed snapshot" ); } } return version; } protected abstract String constructVersion( Versioning versioning, String baseVersion ); } ././@LongLink0000000000000000000000000000020500000000000011562 Lustar rootrootmaven2-core-2.2.1/maven-artifact-manager/src/main/java/org/apache/maven/artifact/transform/DefaultArtifactTransformationManager.javamaven2-core-2.2.1/maven-artifact-manager/src/main/java/org/apache/maven/artifact/transform/DefaultAr0000644000175000017500000000625111173447106033265 0ustar twernertwernerpackage org.apache.maven.artifact.transform; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.deployer.ArtifactDeploymentException; import org.apache.maven.artifact.installer.ArtifactInstallationException; import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.artifact.resolver.ArtifactNotFoundException; import org.apache.maven.artifact.resolver.ArtifactResolutionException; import org.codehaus.plexus.personality.plexus.lifecycle.phase.Initializable; import org.codehaus.plexus.personality.plexus.lifecycle.phase.InitializationException; import java.util.List; public class DefaultArtifactTransformationManager implements ArtifactTransformationManager, Initializable { private List artifactTransformations; public void initialize() throws InitializationException { // TODO this is a hack until plexus can fix the ordering of the arrays ArtifactTransformation transforms[] = artifactTransformations.toArray( new ArtifactTransformation[]{} ); for (int x = 0; x < transforms.length; x++) { if (transforms[x].getClass().getName().indexOf("Snapshot") != -1) { artifactTransformations.remove(transforms[x]); artifactTransformations.add(transforms[x]); } } } public void transformForResolve( Artifact artifact, List remoteRepositories, ArtifactRepository localRepository ) throws ArtifactResolutionException, ArtifactNotFoundException { for ( ArtifactTransformation transform : artifactTransformations ) { transform.transformForResolve( artifact, remoteRepositories, localRepository ); } } public void transformForInstall( Artifact artifact, ArtifactRepository localRepository ) throws ArtifactInstallationException { for ( ArtifactTransformation transform : artifactTransformations ) { transform.transformForInstall( artifact, localRepository ); } } public void transformForDeployment( Artifact artifact, ArtifactRepository remoteRepository, ArtifactRepository localRepository ) throws ArtifactDeploymentException { for ( ArtifactTransformation transform : artifactTransformations ) { transform.transformForDeployment( artifact, remoteRepository, localRepository ); } } } ././@LongLink0000000000000000000000000000017600000000000011571 Lustar rootrootmaven2-core-2.2.1/maven-artifact-manager/src/main/java/org/apache/maven/artifact/transform/ReleaseArtifactTransformation.javamaven2-core-2.2.1/maven-artifact-manager/src/main/java/org/apache/maven/artifact/transform/ReleaseAr0000644000175000017500000000733111173447106033261 0ustar twernertwernerpackage org.apache.maven.artifact.transform; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.metadata.ArtifactMetadata; import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.artifact.repository.metadata.ArtifactRepositoryMetadata; import org.apache.maven.artifact.repository.metadata.RepositoryMetadataResolutionException; import org.apache.maven.artifact.repository.metadata.Versioning; import org.apache.maven.artifact.resolver.ArtifactNotFoundException; import org.apache.maven.artifact.resolver.ArtifactResolutionException; import java.util.List; /** * Change the version RELEASE to the appropriate release version from the remote repository. * * @author Brett Porter * @version $Id: ReleaseArtifactTransformation.java 767322 2009-04-21 22:52:54Z jdcasey $ */ public class ReleaseArtifactTransformation extends AbstractVersionTransformation { public void transformForResolve( Artifact artifact, List remoteRepositories, ArtifactRepository localRepository ) throws ArtifactResolutionException, ArtifactNotFoundException { if ( Artifact.RELEASE_VERSION.equals( artifact.getVersion() ) ) { try { String version = resolveVersion( artifact, localRepository, remoteRepositories ); if ( Artifact.RELEASE_VERSION.equals( version ) ) { throw new ArtifactNotFoundException( "Unable to determine the release version", artifact ); } artifact.setBaseVersion( version ); artifact.updateVersion( version, localRepository ); } catch ( RepositoryMetadataResolutionException e ) { throw new ArtifactResolutionException( e.getMessage(), artifact, e ); } } } public void transformForInstall( Artifact artifact, ArtifactRepository localRepository ) { ArtifactMetadata metadata = createMetadata( artifact ); artifact.addMetadata( metadata ); } public void transformForDeployment( Artifact artifact, ArtifactRepository remoteRepository, ArtifactRepository localRepository ) { ArtifactMetadata metadata = createMetadata( artifact ); artifact.addMetadata( metadata ); } private ArtifactMetadata createMetadata( Artifact artifact ) { Versioning versioning = new Versioning(); versioning.updateTimestamp(); versioning.addVersion( artifact.getVersion() ); if ( artifact.isRelease() ) { versioning.setRelease( artifact.getVersion() ); } return new ArtifactRepositoryMetadata( artifact, versioning ); } protected String constructVersion( Versioning versioning, String baseVersion ) { return versioning.getRelease(); } } ././@LongLink0000000000000000000000000000016700000000000011571 Lustar rootrootmaven2-core-2.2.1/maven-artifact-manager/src/main/java/org/apache/maven/artifact/transform/SnapshotTransformation.javamaven2-core-2.2.1/maven-artifact-manager/src/main/java/org/apache/maven/artifact/transform/SnapshotT0000644000175000017500000001600711173447106033341 0ustar twernertwernerpackage org.apache.maven.artifact.transform; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.deployer.ArtifactDeploymentException; import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.artifact.repository.metadata.Metadata; import org.apache.maven.artifact.repository.metadata.RepositoryMetadata; import org.apache.maven.artifact.repository.metadata.RepositoryMetadataResolutionException; import org.apache.maven.artifact.repository.metadata.Snapshot; import org.apache.maven.artifact.repository.metadata.SnapshotArtifactRepositoryMetadata; import org.apache.maven.artifact.repository.metadata.Versioning; import org.apache.maven.artifact.resolver.ArtifactResolutionException; import org.codehaus.plexus.util.StringUtils; import java.text.DateFormat; import java.text.SimpleDateFormat; import java.util.Date; import java.util.List; import java.util.TimeZone; /** * @author Brett Porter * @author Michal Maczka * @version $Id: SnapshotTransformation.java,v 1.1 2005/03/03 15:37:25 * jvanzyl Exp $ */ public class SnapshotTransformation extends AbstractVersionTransformation { private String deploymentTimestamp; private static final TimeZone UTC_TIME_ZONE = TimeZone.getTimeZone( "UTC" ); private static final String UTC_TIMESTAMP_PATTERN = "yyyyMMdd.HHmmss"; public void transformForResolve( Artifact artifact, List remoteRepositories, ArtifactRepository localRepository ) throws ArtifactResolutionException { // Only select snapshots that are unresolved (eg 1.0-SNAPSHOT, not 1.0-20050607.123456) if ( artifact.isSnapshot() && artifact.getBaseVersion().equals( artifact.getVersion() ) ) { try { String version = resolveVersion( artifact, localRepository, remoteRepositories ); artifact.updateVersion( version, localRepository ); } catch ( RepositoryMetadataResolutionException e ) { throw new ArtifactResolutionException( e.getMessage(), artifact, e ); } } } public void transformForInstall( Artifact artifact, ArtifactRepository localRepository ) { if ( artifact.isSnapshot() ) { Snapshot snapshot = new Snapshot(); snapshot.setLocalCopy( true ); RepositoryMetadata metadata = new SnapshotArtifactRepositoryMetadata( artifact, snapshot ); artifact.addMetadata( metadata ); } } public void transformForDeployment( Artifact artifact, ArtifactRepository remoteRepository, ArtifactRepository localRepository ) throws ArtifactDeploymentException { if ( artifact.isSnapshot() ) { Snapshot snapshot = new Snapshot(); if ( remoteRepository.isUniqueVersion() ) { snapshot.setTimestamp( getDeploymentTimestamp() ); } // we update the build number anyway so that it doesn't get lost. It requires the timestamp to take effect try { int buildNumber = resolveLatestSnapshotBuildNumber( artifact, localRepository, remoteRepository ); snapshot.setBuildNumber( buildNumber + 1 ); } catch ( RepositoryMetadataResolutionException e ) { throw new ArtifactDeploymentException( "Error retrieving previous build number for artifact '" + artifact.getDependencyConflictId() + "': " + e.getMessage(), e ); } RepositoryMetadata metadata = new SnapshotArtifactRepositoryMetadata( artifact, snapshot ); artifact.setResolvedVersion( constructVersion( metadata.getMetadata().getVersioning(), artifact.getBaseVersion() ) ); artifact.addMetadata( metadata ); } } public String getDeploymentTimestamp() { if ( deploymentTimestamp == null ) { deploymentTimestamp = getUtcDateFormatter().format( new Date() ); } return deploymentTimestamp; } protected String constructVersion( Versioning versioning, String baseVersion ) { String version = null; Snapshot snapshot = versioning.getSnapshot(); if ( snapshot != null ) { if ( snapshot.getTimestamp() != null && snapshot.getBuildNumber() > 0 ) { String newVersion = snapshot.getTimestamp() + "-" + snapshot.getBuildNumber(); version = StringUtils.replace( baseVersion, "SNAPSHOT", newVersion ); } else { version = baseVersion; } } return version; } private int resolveLatestSnapshotBuildNumber( Artifact artifact, ArtifactRepository localRepository, ArtifactRepository remoteRepository ) throws RepositoryMetadataResolutionException { RepositoryMetadata metadata = new SnapshotArtifactRepositoryMetadata( artifact ); if ( !wagonManager.isOnline() ) { // build number is a required feature for metadata consistency throw new RepositoryMetadataResolutionException( "System is offline. Cannot resolve metadata:\n" + metadata.extendedToString() + "\n\n" ); } getLogger().info( "Retrieving previous build number from " + remoteRepository.getId() ); repositoryMetadataManager.resolveAlways( metadata, localRepository, remoteRepository ); int buildNumber = 0; Metadata repoMetadata = metadata.getMetadata(); if ( ( repoMetadata != null ) && ( repoMetadata.getVersioning() != null && repoMetadata.getVersioning().getSnapshot() != null ) ) { buildNumber = repoMetadata.getVersioning().getSnapshot().getBuildNumber(); } return buildNumber; } public static DateFormat getUtcDateFormatter() { DateFormat utcDateFormatter = new SimpleDateFormat( UTC_TIMESTAMP_PATTERN ); utcDateFormatter.setTimeZone( UTC_TIME_ZONE ); return utcDateFormatter; } } maven2-core-2.2.1/maven-artifact-manager/src/main/java/org/apache/maven/artifact/installer/0000755000175000017500000000000011250552244031445 5ustar twernertwerner././@LongLink0000000000000000000000000000017100000000000011564 Lustar rootrootmaven2-core-2.2.1/maven-artifact-manager/src/main/java/org/apache/maven/artifact/installer/DefaultArtifactInstaller.javamaven2-core-2.2.1/maven-artifact-manager/src/main/java/org/apache/maven/artifact/installer/DefaultAr0000644000175000017500000001265711151024413033242 0ustar twernertwernerpackage org.apache.maven.artifact.installer; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.metadata.ArtifactMetadata; import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.artifact.repository.metadata.RepositoryMetadataInstallationException; import org.apache.maven.artifact.repository.metadata.RepositoryMetadataManager; import org.apache.maven.artifact.transform.ArtifactTransformationManager; import org.codehaus.plexus.logging.AbstractLogEnabled; import org.codehaus.plexus.util.FileUtils; import java.io.File; import java.io.IOException; import java.util.Iterator; public class DefaultArtifactInstaller extends AbstractLogEnabled implements ArtifactInstaller { private ArtifactTransformationManager transformationManager; private RepositoryMetadataManager repositoryMetadataManager; /** * @deprecated we want to use the artifact method only, and ensure artifact.file is set correctly. */ public void install( String basedir, String finalName, Artifact artifact, ArtifactRepository localRepository ) throws ArtifactInstallationException { String extension = artifact.getArtifactHandler().getExtension(); File source = new File( basedir, finalName + "." + extension ); install( source, artifact, localRepository ); } public void install( File source, Artifact artifact, ArtifactRepository localRepository ) throws ArtifactInstallationException { // If we're installing the POM, we need to transform it first. The source file supplied for // installation here may be the POM, but that POM may not be set as the file of the supplied // artifact. Since the transformation only has access to the artifact and not the supplied // source file, we have to use the Artifact.setFile(..) and Artifact.getFile(..) methods // to shunt the POM file into the transformation process. // Here, we also set a flag indicating that the POM has been shunted through the Artifact, // and to expect the transformed version to be available in the Artifact afterwards... boolean useArtifactFile = false; File oldArtifactFile = artifact.getFile(); if ( "pom".equals( artifact.getType() ) ) { artifact.setFile( source ); useArtifactFile = true; } try { transformationManager.transformForInstall( artifact, localRepository ); // If we used the Artifact shunt to transform a POM source file, we need to install // the transformed version, not the supplied version. Therefore, we need to replace // the supplied source POM with the one from Artifact.getFile(..). if ( useArtifactFile ) { source = artifact.getFile(); artifact.setFile( oldArtifactFile ); } String localPath = localRepository.pathOf( artifact ); // TODO: use a file: wagon and the wagon manager? File destination = new File( localRepository.getBasedir(), localPath ); if ( !destination.getParentFile().exists() ) { destination.getParentFile().mkdirs(); } getLogger().info( "Installing " + source.getPath() + " to " + destination ); FileUtils.copyFile( source, destination ); // Now, we'll set the artifact's file to the one installed in the local repository, // to help avoid duplicate copy operations in the deployment step. if ( useArtifactFile ) { artifact.setFile( destination ); } // must be after the artifact is installed for ( Iterator i = artifact.getMetadataList().iterator(); i.hasNext(); ) { ArtifactMetadata metadata = (ArtifactMetadata) i.next(); repositoryMetadataManager.install( metadata, localRepository ); } // TODO: would like to flush this, but the plugin metadata is added in advance, not as an install/deploy transformation // This would avoid the need to merge and clear out the state during deployment // artifact.getMetadataList().clear(); } catch ( IOException e ) { throw new ArtifactInstallationException( "Error installing artifact: " + e.getMessage(), e ); } catch ( RepositoryMetadataInstallationException e ) { throw new ArtifactInstallationException( "Error installing artifact's metadata: " + e.getMessage(), e ); } } }maven2-core-2.2.1/maven-artifact-manager/src/main/java/org/apache/maven/artifact/repository/0000755000175000017500000000000011250552244031667 5ustar twernertwerner././@LongLink0000000000000000000000000000020200000000000011557 Lustar rootrootmaven2-core-2.2.1/maven-artifact-manager/src/main/java/org/apache/maven/artifact/repository/DefaultArtifactRepositoryFactory.javamaven2-core-2.2.1/maven-artifact-manager/src/main/java/org/apache/maven/artifact/repository/DefaultA0000644000175000017500000000706010551365651033311 0ustar twernertwernerpackage org.apache.maven.artifact.repository; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout; import java.util.HashMap; import java.util.Map; /** * @author jdcasey */ public class DefaultArtifactRepositoryFactory implements ArtifactRepositoryFactory { // TODO: use settings? private String globalUpdatePolicy; private String globalChecksumPolicy; private final Map artifactRepositories = new HashMap(); public ArtifactRepository createDeploymentArtifactRepository( String id, String url, ArtifactRepositoryLayout repositoryLayout, boolean uniqueVersion ) { return new DefaultArtifactRepository( id, url, repositoryLayout, uniqueVersion ); } public ArtifactRepository createArtifactRepository( String id, String url, ArtifactRepositoryLayout repositoryLayout, ArtifactRepositoryPolicy snapshots, ArtifactRepositoryPolicy releases ) { boolean blacklisted = false; if ( artifactRepositories.containsKey( id ) ) { ArtifactRepository repository = (ArtifactRepository) artifactRepositories.get( id ); // TODO: this should be an if there are duplicates? if ( repository.getUrl().equals( url ) ) { blacklisted = repository.isBlacklisted(); } } if ( snapshots == null ) { snapshots = new ArtifactRepositoryPolicy(); } if ( releases == null ) { releases = new ArtifactRepositoryPolicy(); } if ( globalUpdatePolicy != null ) { snapshots.setUpdatePolicy( globalUpdatePolicy ); releases.setUpdatePolicy( globalUpdatePolicy ); } if ( globalChecksumPolicy != null ) { snapshots.setChecksumPolicy( globalChecksumPolicy ); releases.setChecksumPolicy( globalChecksumPolicy ); } DefaultArtifactRepository repository = new DefaultArtifactRepository( id, url, repositoryLayout, snapshots, releases ); repository.setBlacklisted( blacklisted ); artifactRepositories.put( id, repository ); return repository; } public void setGlobalUpdatePolicy( String updatePolicy ) { this.globalUpdatePolicy = updatePolicy; } public void setGlobalChecksumPolicy( String checksumPolicy ) { this.globalChecksumPolicy = checksumPolicy; } } ././@LongLink0000000000000000000000000000017300000000000011566 Lustar rootrootmaven2-core-2.2.1/maven-artifact-manager/src/main/java/org/apache/maven/artifact/repository/DefaultArtifactRepository.javamaven2-core-2.2.1/maven-artifact-manager/src/main/java/org/apache/maven/artifact/repository/DefaultA0000644000175000017500000001134510551365651033312 0ustar twernertwernerpackage org.apache.maven.artifact.repository; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.metadata.ArtifactMetadata; import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout; import org.apache.maven.wagon.repository.Repository; /** * This class is an abstraction of the location from/to resources can be * transfered. * * @author Michal Maczka * @version $Id: DefaultArtifactRepository.java 495147 2007-01-11 07:47:53Z jvanzyl $ */ public class DefaultArtifactRepository extends Repository implements ArtifactRepository { private final ArtifactRepositoryLayout layout; private ArtifactRepositoryPolicy snapshots; private ArtifactRepositoryPolicy releases; private boolean uniqueVersion; private boolean blacklisted; /** * Create a local repository or a test repository. * * @param id the unique identifier of the repository * @param url the URL of the repository * @param layout the layout of the repository */ public DefaultArtifactRepository( String id, String url, ArtifactRepositoryLayout layout ) { this( id, url, layout, null, null ); } /** * Create a remote deployment repository. * * @param id the unique identifier of the repository * @param url the URL of the repository * @param layout the layout of the repository * @param uniqueVersion whether to assign each snapshot a unique version */ public DefaultArtifactRepository( String id, String url, ArtifactRepositoryLayout layout, boolean uniqueVersion ) { super( id, url ); this.layout = layout; this.uniqueVersion = uniqueVersion; } /** * Create a remote download repository. * * @param id the unique identifier of the repository * @param url the URL of the repository * @param layout the layout of the repository * @param snapshots the policies to use for snapshots * @param releases the policies to use for releases */ public DefaultArtifactRepository( String id, String url, ArtifactRepositoryLayout layout, ArtifactRepositoryPolicy snapshots, ArtifactRepositoryPolicy releases ) { super( id, url ); this.layout = layout; if ( snapshots == null ) { snapshots = new ArtifactRepositoryPolicy( true, ArtifactRepositoryPolicy.UPDATE_POLICY_ALWAYS, ArtifactRepositoryPolicy.CHECKSUM_POLICY_IGNORE ); } this.snapshots = snapshots; if ( releases == null ) { releases = new ArtifactRepositoryPolicy( true, ArtifactRepositoryPolicy.UPDATE_POLICY_ALWAYS, ArtifactRepositoryPolicy.CHECKSUM_POLICY_IGNORE ); } this.releases = releases; } public String pathOf( Artifact artifact ) { return layout.pathOf( artifact ); } public String pathOfRemoteRepositoryMetadata( ArtifactMetadata artifactMetadata ) { return layout.pathOfRemoteRepositoryMetadata( artifactMetadata ); } public String pathOfLocalRepositoryMetadata( ArtifactMetadata metadata, ArtifactRepository repository ) { return layout.pathOfLocalRepositoryMetadata( metadata, repository ); } public ArtifactRepositoryLayout getLayout() { return layout; } public ArtifactRepositoryPolicy getSnapshots() { return snapshots; } public ArtifactRepositoryPolicy getReleases() { return releases; } public String getKey() { return getId(); } public boolean isUniqueVersion() { return uniqueVersion; } public boolean isBlacklisted() { return blacklisted; } public void setBlacklisted( boolean blacklisted ) { this.blacklisted = blacklisted; } } ././@LongLink0000000000000000000000000000014600000000000011566 Lustar rootrootmaven2-core-2.2.1/maven-artifact-manager/src/main/java/org/apache/maven/artifact/repository/metadata/maven2-core-2.2.1/maven-artifact-manager/src/main/java/org/apache/maven/artifact/repository/metadata0000755000175000017500000000000011250552244033370 5ustar twernertwerner././@LongLink0000000000000000000000000000020500000000000011562 Lustar rootrootmaven2-core-2.2.1/maven-artifact-manager/src/main/java/org/apache/maven/artifact/repository/metadata/AbstractRepositoryMetadata.javamaven2-core-2.2.1/maven-artifact-manager/src/main/java/org/apache/maven/artifact/repository/metadata0000644000175000017500000001457410772004567033415 0ustar twernertwernerpackage org.apache.maven.artifact.repository.metadata; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.metadata.ArtifactMetadata; import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.artifact.repository.metadata.io.xpp3.MetadataXpp3Reader; import org.apache.maven.artifact.repository.metadata.io.xpp3.MetadataXpp3Writer; import org.codehaus.plexus.util.IOUtil; import org.codehaus.plexus.util.ReaderFactory; import org.codehaus.plexus.util.WriterFactory; import org.codehaus.plexus.util.xml.pull.XmlPullParserException; import java.io.File; import java.io.IOException; import java.io.Reader; import java.io.Writer; /** * Shared methods of the repository metadata handling. * * @author Brett Porter * @version $Id: AbstractRepositoryMetadata.java 640549 2008-03-24 20:05:11Z bentmann $ */ public abstract class AbstractRepositoryMetadata implements RepositoryMetadata { private Metadata metadata; protected AbstractRepositoryMetadata( Metadata metadata ) { this.metadata = metadata; } public String getRemoteFilename() { return "maven-metadata.xml"; } public String getLocalFilename( ArtifactRepository repository ) { return "maven-metadata-" + repository.getKey() + ".xml"; } public void storeInLocalRepository( ArtifactRepository localRepository, ArtifactRepository remoteRepository ) throws RepositoryMetadataStoreException { try { updateRepositoryMetadata( localRepository, remoteRepository ); } catch ( IOException e ) { throw new RepositoryMetadataStoreException( "Error updating group repository metadata", e ); } catch ( XmlPullParserException e ) { throw new RepositoryMetadataStoreException( "Error updating group repository metadata", e ); } } protected void updateRepositoryMetadata( ArtifactRepository localRepository, ArtifactRepository remoteRepository ) throws IOException, XmlPullParserException { MetadataXpp3Reader mappingReader = new MetadataXpp3Reader(); Metadata metadata = null; File metadataFile = new File( localRepository.getBasedir(), localRepository.pathOfLocalRepositoryMetadata( this, remoteRepository ) ); if ( metadataFile.exists() ) { Reader reader = null; try { reader = ReaderFactory.newXmlReader( metadataFile ); metadata = mappingReader.read( reader, false ); } finally { IOUtil.close( reader ); } } boolean changed; // If file could not be found or was not valid, start from scratch if ( metadata == null ) { metadata = this.metadata; changed = true; } else { changed = metadata.merge( this.metadata ); } // beware meta-versions! String version = metadata.getVersion(); if ( version != null && ( Artifact.LATEST_VERSION.equals( version ) || Artifact.RELEASE_VERSION.equals( version ) ) ) { // meta-versions are not valid values...don't write them. metadata.setVersion( null ); } if ( changed || !metadataFile.exists() ) { Writer writer = null; try { metadataFile.getParentFile().mkdirs(); writer = WriterFactory.newXmlWriter( metadataFile ); MetadataXpp3Writer mappingWriter = new MetadataXpp3Writer(); mappingWriter.write( writer, metadata ); } finally { IOUtil.close( writer ); } } else { metadataFile.setLastModified( System.currentTimeMillis() ); } } public String toString() { return "repository metadata for: \'" + getKey() + "\'"; } protected static Metadata createMetadata( Artifact artifact, Versioning versioning ) { Metadata metadata = new Metadata(); metadata.setGroupId( artifact.getGroupId() ); metadata.setArtifactId( artifact.getArtifactId() ); metadata.setVersion( artifact.getVersion() ); metadata.setVersioning( versioning ); return metadata; } protected static Versioning createVersioning( Snapshot snapshot ) { Versioning versioning = new Versioning(); versioning.setSnapshot( snapshot ); versioning.updateTimestamp(); return versioning; } public void setMetadata( Metadata metadata ) { this.metadata = metadata; } public Metadata getMetadata() { return metadata; } public void merge( ArtifactMetadata metadata ) { // TODO: not sure that it should assume this, maybe the calls to addMetadata should pre-merge, then artifact replaces? AbstractRepositoryMetadata repoMetadata = (AbstractRepositoryMetadata) metadata; this.metadata.merge( repoMetadata.getMetadata() ); } public String extendedToString() { StringBuffer buffer = new StringBuffer(); buffer.append( "\nRepository Metadata\n--------------------------" ); buffer.append( "\nGroupId: " ).append( getGroupId() ); buffer.append( "\nArtifactId: " ).append( getArtifactId() ); buffer.append( "\nMetadata Type: " ).append( getClass().getName() ); return buffer.toString(); } } ././@LongLink0000000000000000000000000000020500000000000011562 Lustar rootrootmaven2-core-2.2.1/maven-artifact-manager/src/main/java/org/apache/maven/artifact/repository/metadata/ArtifactRepositoryMetadata.javamaven2-core-2.2.1/maven-artifact-manager/src/main/java/org/apache/maven/artifact/repository/metadata0000644000175000017500000000474410772004567033413 0ustar twernertwernerpackage org.apache.maven.artifact.repository.metadata; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.repository.ArtifactRepository; /** * Metadata for the artifact directory of the repository. * * @author Brett Porter * @version $Id: ArtifactRepositoryMetadata.java 640549 2008-03-24 20:05:11Z bentmann $ */ public class ArtifactRepositoryMetadata extends AbstractRepositoryMetadata { private Artifact artifact; public ArtifactRepositoryMetadata( Artifact artifact ) { this( artifact, null ); } public ArtifactRepositoryMetadata( Artifact artifact, Versioning versioning ) { super( createMetadata( artifact, versioning ) ); this.artifact = artifact; } public boolean storedInGroupDirectory() { return false; } public boolean storedInArtifactVersionDirectory() { return false; } public String getGroupId() { return artifact.getGroupId(); } public String getArtifactId() { return artifact.getArtifactId(); } public String getBaseVersion() { // Don't want the artifact's version in here, as this is stored in the directory above that return null; } public Object getKey() { return "artifact " + artifact.getGroupId() + ":" + artifact.getArtifactId(); } public boolean isSnapshot() { // Don't consider the artifact's version in here, as this is stored in the directory above that return false; } public void setRepository( ArtifactRepository remoteRepository ) { artifact.setRepository( remoteRepository ); } } ././@LongLink0000000000000000000000000000020200000000000011557 Lustar rootrootmaven2-core-2.2.1/maven-artifact-manager/src/main/java/org/apache/maven/artifact/repository/metadata/GroupRepositoryMetadata.javamaven2-core-2.2.1/maven-artifact-manager/src/main/java/org/apache/maven/artifact/repository/metadata0000644000175000017500000000553210772004567033407 0ustar twernertwernerpackage org.apache.maven.artifact.repository.metadata; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import org.apache.maven.artifact.repository.ArtifactRepository; import java.util.Iterator; import java.util.List; /** * Metadata for the group directory of the repository. * * @author Brett Porter * @version $Id: GroupRepositoryMetadata.java 640549 2008-03-24 20:05:11Z bentmann $ */ public class GroupRepositoryMetadata extends AbstractRepositoryMetadata { private final String groupId; public GroupRepositoryMetadata( String groupId ) { super( new Metadata() ); this.groupId = groupId; } public boolean storedInGroupDirectory() { return true; } public boolean storedInArtifactVersionDirectory() { return false; } public String getGroupId() { return groupId; } public String getArtifactId() { return null; } public String getBaseVersion() { return null; } public void addPluginMapping( String goalPrefix, String artifactId ) { addPluginMapping( goalPrefix, artifactId, artifactId ); } public void addPluginMapping( String goalPrefix, String artifactId, String name ) { List plugins = getMetadata().getPlugins(); boolean found = false; for ( Iterator i = plugins.iterator(); i.hasNext() && !found; ) { Plugin plugin = (Plugin) i.next(); if ( plugin.getPrefix().equals( goalPrefix ) ) { found = true; } } if ( !found ) { Plugin plugin = new Plugin(); plugin.setPrefix( goalPrefix ); plugin.setArtifactId( artifactId ); plugin.setName( name ); getMetadata().addPlugin( plugin ); } } public Object getKey() { return groupId; } public boolean isSnapshot() { return false; } public void setRepository( ArtifactRepository remoteRepository ) { // intentionally blank } } ././@LongLink0000000000000000000000000000021500000000000011563 Lustar rootrootmaven2-core-2.2.1/maven-artifact-manager/src/main/java/org/apache/maven/artifact/repository/metadata/SnapshotArtifactRepositoryMetadata.javamaven2-core-2.2.1/maven-artifact-manager/src/main/java/org/apache/maven/artifact/repository/metadata0000644000175000017500000000502410772004567033403 0ustar twernertwernerpackage org.apache.maven.artifact.repository.metadata; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.repository.ArtifactRepository; /** * Metadata for the artifact version directory of the repository. * * @author Brett Porter * @version $Id: SnapshotArtifactRepositoryMetadata.java 640549 2008-03-24 20:05:11Z bentmann $ * @todo split instantiation (versioning, plugin mappings) from definition */ public class SnapshotArtifactRepositoryMetadata extends AbstractRepositoryMetadata { private Artifact artifact; public SnapshotArtifactRepositoryMetadata( Artifact artifact ) { super( createMetadata( artifact, null ) ); this.artifact = artifact; } public SnapshotArtifactRepositoryMetadata( Artifact artifact, Snapshot snapshot ) { super( createMetadata( artifact, createVersioning( snapshot ) ) ); this.artifact = artifact; } public boolean storedInGroupDirectory() { return false; } public boolean storedInArtifactVersionDirectory() { return true; } public String getGroupId() { return artifact.getGroupId(); } public String getArtifactId() { return artifact.getArtifactId(); } public String getBaseVersion() { return artifact.getBaseVersion(); } public Object getKey() { return "snapshot " + artifact.getGroupId() + ":" + artifact.getArtifactId() + ":" + artifact.getBaseVersion(); } public boolean isSnapshot() { return artifact.isSnapshot(); } public void setRepository( ArtifactRepository remoteRepository ) { artifact.setRepository( remoteRepository ); } } ././@LongLink0000000000000000000000000000021300000000000011561 Lustar rootrootmaven2-core-2.2.1/maven-artifact-manager/src/main/java/org/apache/maven/artifact/repository/metadata/DefaultRepositoryMetadataManager.javamaven2-core-2.2.1/maven-artifact-manager/src/main/java/org/apache/maven/artifact/repository/metadata0000644000175000017500000004602311151034766033403 0ustar twernertwernerpackage org.apache.maven.artifact.repository.metadata; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import org.apache.maven.artifact.manager.WagonManager; import org.apache.maven.artifact.metadata.ArtifactMetadata; import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.artifact.repository.ArtifactRepositoryPolicy; import org.apache.maven.artifact.repository.metadata.io.xpp3.MetadataXpp3Reader; import org.apache.maven.wagon.ResourceDoesNotExistException; import org.apache.maven.wagon.TransferFailedException; import org.codehaus.plexus.logging.AbstractLogEnabled; import org.codehaus.plexus.util.IOUtil; import org.codehaus.plexus.util.ReaderFactory; import org.codehaus.plexus.util.xml.pull.XmlPullParserException; import java.io.File; import java.io.FileNotFoundException; import java.io.IOException; import java.io.Reader; import java.util.Date; import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.Set; public class DefaultRepositoryMetadataManager extends AbstractLogEnabled implements RepositoryMetadataManager { // component requirement private WagonManager wagonManager; /** * @todo very primitive. Probably we can cache artifacts themselves in a central location, as well as reset the flag over time in a long running process. */ private Set cachedMetadata = new HashSet(); public void resolve( RepositoryMetadata metadata, List remoteRepositories, ArtifactRepository localRepository ) throws RepositoryMetadataResolutionException { boolean alreadyResolved = alreadyResolved( metadata ); if ( !alreadyResolved ) { for ( Iterator i = remoteRepositories.iterator(); i.hasNext(); ) { ArtifactRepository repository = (ArtifactRepository) i.next(); ArtifactRepositoryPolicy policy = metadata.isSnapshot() ? repository.getSnapshots() : repository.getReleases(); if ( !policy.isEnabled() ) { getLogger().debug( "Skipping disabled repository " + repository.getId() ); } else if ( repository.isBlacklisted() ) { getLogger().debug( "Skipping blacklisted repository " + repository.getId() ); } else { File file = new File( localRepository.getBasedir(), localRepository.pathOfLocalRepositoryMetadata( metadata, repository ) ); boolean checkForUpdates = !file.exists() || policy.checkOutOfDate( new Date( file.lastModified() ) ); if ( checkForUpdates ) { if ( wagonManager.isOnline() ) { getLogger().info( metadata.getKey() + ": checking for updates from " + repository.getId() ); boolean storeMetadata = false; try { wagonManager.getArtifactMetadata( metadata, repository, file, policy.getChecksumPolicy() ); storeMetadata = true; } catch ( ResourceDoesNotExistException e ) { getLogger().debug( metadata + " could not be found on repository: " + repository.getId() ); // delete the local copy so the old details aren't used. if ( file.exists() ) { file.delete(); } storeMetadata = true; } catch ( TransferFailedException e ) { getLogger().warn( metadata + " could not be retrieved from repository: " + repository.getId() + " due to an error: " + e.getMessage() ); getLogger().debug( "Exception", e ); getLogger().info( "Repository '" + repository.getId() + "' will be blacklisted" ); repository.setBlacklisted( true ); // TODO: [jc; 08-Nov-2005] revisit this for 2.1 // suppressing logging to avoid logging this error twice. } if ( storeMetadata ) { // touch file so that this is not checked again until interval has passed if ( file.exists() ) { file.setLastModified( System.currentTimeMillis() ); } else { // this ensures that files are not continuously checked when they don't exist remotely // TODO: [jdcasey] If this happens as a result of ResourceDoesNotExistException, what effect will it have on subsequent runs? // Will the updateInterval come into play cleanly, or will this plug up the works?? try { metadata.storeInLocalRepository( localRepository, repository ); } catch ( RepositoryMetadataStoreException e ) { throw new RepositoryMetadataResolutionException( "Unable to store local copy of metadata: " + e.getMessage(), e ); } } } } else { getLogger().debug( "System is offline. Cannot resolve metadata:\n" + metadata.extendedToString() + "\n\n" ); } } } } // TODO: [jdcasey] what happens here when the system is offline, or there is a TransferFailedException // ...and no metadata file is written? cachedMetadata.add( metadata.getKey() ); } try { mergeMetadata( metadata, remoteRepositories, localRepository ); } catch ( RepositoryMetadataStoreException e ) { throw new RepositoryMetadataResolutionException( "Unable to store local copy of metadata: " + e.getMessage(), e ); } catch ( RepositoryMetadataReadException e ) { throw new RepositoryMetadataResolutionException( "Unable to read local copy of metadata: " + e.getMessage(), e ); } } private void mergeMetadata( RepositoryMetadata metadata, List remoteRepositories, ArtifactRepository localRepository ) throws RepositoryMetadataStoreException, RepositoryMetadataReadException { // TODO: currently this is first wins, but really we should take the latest by comparing either the // snapshot timestamp, or some other timestamp later encoded into the metadata. // TODO: this needs to be repeated here so the merging doesn't interfere with the written metadata // - we'd be much better having a pristine input, and an ongoing metadata for merging instead Map previousMetadata = new HashMap(); ArtifactRepository selected = null; for ( Iterator i = remoteRepositories.iterator(); i.hasNext(); ) { ArtifactRepository repository = (ArtifactRepository) i.next(); ArtifactRepositoryPolicy policy = metadata.isSnapshot() ? repository.getSnapshots() : repository.getReleases(); if ( policy.isEnabled() && loadMetadata( metadata, repository, localRepository, previousMetadata ) ) { metadata.setRepository( repository ); selected = repository; } } if ( loadMetadata( metadata, localRepository, localRepository, previousMetadata ) ) { metadata.setRepository( null ); selected = localRepository; } updateSnapshotMetadata( metadata, previousMetadata, selected, localRepository ); } private void updateSnapshotMetadata( RepositoryMetadata metadata, Map previousMetadata, ArtifactRepository selected, ArtifactRepository localRepository ) throws RepositoryMetadataStoreException { // TODO: this could be a lot nicer... should really be in the snapshot transformation? if ( metadata.isSnapshot() ) { Metadata prevMetadata = metadata.getMetadata(); for ( Iterator i = previousMetadata.keySet().iterator(); i.hasNext(); ) { ArtifactRepository repository = (ArtifactRepository) i.next(); Metadata m = (Metadata) previousMetadata.get( repository ); if ( repository.equals( selected ) ) { if ( m.getVersioning() == null ) { m.setVersioning( new Versioning() ); } if ( m.getVersioning().getSnapshot() == null ) { m.getVersioning().setSnapshot( new Snapshot() ); } /* if ( !m.getVersioning().getSnapshot().isLocalCopy() ) { // TODO: I think this is incorrect (it results in localCopy set in a remote profile). Probably // harmless so not removing at this point until full tests in place. m.getVersioning().getSnapshot().setLocalCopy( true ); metadata.setMetadata( m ); metadata.storeInLocalRepository( localRepository, repository ); } */ } else { if ( ( m.getVersioning() != null ) && ( m.getVersioning().getSnapshot() != null ) && m.getVersioning().getSnapshot().isLocalCopy() ) { m.getVersioning().getSnapshot().setLocalCopy( false ); metadata.setMetadata( m ); metadata.storeInLocalRepository( localRepository, repository ); } } } metadata.setMetadata( prevMetadata ); } } private boolean loadMetadata( RepositoryMetadata repoMetadata, ArtifactRepository remoteRepository, ArtifactRepository localRepository, Map previousMetadata ) throws RepositoryMetadataReadException { boolean setRepository = false; File metadataFile = new File( localRepository.getBasedir(), localRepository.pathOfLocalRepositoryMetadata( repoMetadata, remoteRepository ) ); if ( metadataFile.exists() ) { Metadata metadata = readMetadata( metadataFile ); if ( repoMetadata.isSnapshot() && ( previousMetadata != null ) ) { previousMetadata.put( remoteRepository, metadata ); } if ( repoMetadata.getMetadata() != null ) { setRepository = repoMetadata.getMetadata().merge( metadata ); } else { repoMetadata.setMetadata( metadata ); setRepository = true; } } return setRepository; } /** * @todo share with DefaultPluginMappingManager. */ protected static Metadata readMetadata( File mappingFile ) throws RepositoryMetadataReadException { Metadata result; Reader reader = null; try { reader = ReaderFactory.newXmlReader( mappingFile ); MetadataXpp3Reader mappingReader = new MetadataXpp3Reader(); result = mappingReader.read( reader, false ); } catch ( FileNotFoundException e ) { throw new RepositoryMetadataReadException( "Cannot read metadata from '" + mappingFile + "'", e ); } catch ( IOException e ) { throw new RepositoryMetadataReadException( "Cannot read metadata from '" + mappingFile + "': " + e.getMessage(), e ); } catch ( XmlPullParserException e ) { throw new RepositoryMetadataReadException( "Cannot read metadata from '" + mappingFile + "': " + e.getMessage(), e ); } finally { IOUtil.close( reader ); } return result; } public void resolveAlways( RepositoryMetadata metadata, ArtifactRepository localRepository, ArtifactRepository remoteRepository ) throws RepositoryMetadataResolutionException { if ( !wagonManager.isOnline() ) { // metadata is required for deployment, can't be offline throw new RepositoryMetadataResolutionException( "System is offline. Cannot resolve required metadata:\n" + metadata.extendedToString() ); } File file; try { file = getArtifactMetadataFromDeploymentRepository( metadata, localRepository, remoteRepository ); } catch ( TransferFailedException e ) { throw new RepositoryMetadataResolutionException( metadata + " could not be retrieved from repository: " + remoteRepository.getId() + " due to an error: " + e.getMessage(), e ); } try { if ( file.exists() ) { Metadata prevMetadata = readMetadata( file ); metadata.setMetadata( prevMetadata ); } } catch ( RepositoryMetadataReadException e ) { throw new RepositoryMetadataResolutionException( e.getMessage(), e ); } } private File getArtifactMetadataFromDeploymentRepository( ArtifactMetadata metadata, ArtifactRepository localRepository, ArtifactRepository remoteRepository ) throws TransferFailedException { File file = new File( localRepository.getBasedir(), localRepository.pathOfLocalRepositoryMetadata( metadata, remoteRepository ) ); try { wagonManager.getArtifactMetadataFromDeploymentRepository( metadata, remoteRepository, file, ArtifactRepositoryPolicy.CHECKSUM_POLICY_WARN ); } catch ( ResourceDoesNotExistException e ) { getLogger().info( metadata + " could not be found on repository: " + remoteRepository.getId() + ", so will be created" ); // delete the local copy so the old details aren't used. if ( file.exists() ) { file.delete(); } } return file; } private boolean alreadyResolved( ArtifactMetadata metadata ) { return cachedMetadata.contains( metadata.getKey() ); } public void deploy( ArtifactMetadata metadata, ArtifactRepository localRepository, ArtifactRepository deploymentRepository ) throws RepositoryMetadataDeploymentException { if ( !wagonManager.isOnline() ) { // deployment shouldn't silently fail when offline throw new RepositoryMetadataDeploymentException( "System is offline. Cannot deploy metadata:\n" + metadata.extendedToString() ); } File file; if ( metadata instanceof RepositoryMetadata ) { getLogger().info( "Retrieving previous metadata from " + deploymentRepository.getId() ); try { file = getArtifactMetadataFromDeploymentRepository( metadata, localRepository, deploymentRepository ); } catch ( TransferFailedException e ) { throw new RepositoryMetadataDeploymentException( metadata + " could not be retrieved from repository: " + deploymentRepository.getId() + " due to an error: " + e.getMessage(), e ); } } else { // It's a POM - we don't need to retrieve it first file = new File( localRepository.getBasedir(), localRepository.pathOfLocalRepositoryMetadata( metadata, deploymentRepository ) ); } try { metadata.storeInLocalRepository( localRepository, deploymentRepository ); } catch ( RepositoryMetadataStoreException e ) { throw new RepositoryMetadataDeploymentException( "Error installing metadata: " + e.getMessage(), e ); } try { wagonManager.putArtifactMetadata( file, metadata, deploymentRepository ); } catch ( TransferFailedException e ) { throw new RepositoryMetadataDeploymentException( "Error while deploying metadata: " + e.getMessage(), e ); } } public void install( ArtifactMetadata metadata, ArtifactRepository localRepository ) throws RepositoryMetadataInstallationException { try { metadata.storeInLocalRepository( localRepository, localRepository ); } catch ( RepositoryMetadataStoreException e ) { throw new RepositoryMetadataInstallationException( "Error installing metadata: " + e.getMessage(), e ); } } } ././@LongLink0000000000000000000000000000017500000000000011570 Lustar rootrootmaven2-core-2.2.1/maven-artifact-manager/src/main/java/org/apache/maven/artifact/repository/metadata/RepositoryMetadata.javamaven2-core-2.2.1/maven-artifact-manager/src/main/java/org/apache/maven/artifact/repository/metadata0000644000175000017500000000363410772004567033410 0ustar twernertwernerpackage org.apache.maven.artifact.repository.metadata; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import org.apache.maven.artifact.metadata.ArtifactMetadata; import org.apache.maven.artifact.repository.ArtifactRepository; /** * Describes repository directory metadata. * * @author Brett Porter * @version $Id: RepositoryMetadata.java 640549 2008-03-24 20:05:11Z bentmann $ * @todo not happy about the store method - they use "this" */ public interface RepositoryMetadata extends ArtifactMetadata { /** * Set the repository the metadata was located in. * * @param remoteRepository the repository */ void setRepository( ArtifactRepository remoteRepository ); /** * Get the repository metadata associated with this marker. * * @return the metadata, or null if none loaded */ Metadata getMetadata(); /** * Set the metadata contents. * * @param metadata the metadata */ void setMetadata( Metadata metadata ); /** * Whether this represents a snapshot. * * @return if it is a snapshot */ boolean isSnapshot(); } ././@LongLink0000000000000000000000000000020400000000000011561 Lustar rootrootmaven2-core-2.2.1/maven-artifact-manager/src/main/java/org/apache/maven/artifact/repository/metadata/RepositoryMetadataManager.javamaven2-core-2.2.1/maven-artifact-manager/src/main/java/org/apache/maven/artifact/repository/metadata0000644000175000017500000000421410772004567033403 0ustar twernertwernerpackage org.apache.maven.artifact.repository.metadata; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import org.apache.maven.artifact.metadata.ArtifactMetadata; import org.apache.maven.artifact.repository.ArtifactRepository; import java.util.List; public interface RepositoryMetadataManager { void resolve( RepositoryMetadata repositoryMetadata, List repositories, ArtifactRepository localRepository ) throws RepositoryMetadataResolutionException; void resolveAlways( RepositoryMetadata metadata, ArtifactRepository localRepository, ArtifactRepository remoteRepository ) throws RepositoryMetadataResolutionException; /** * Deploy metadata to the remote repository. * * @param metadata the metadata to deploy * @param localRepository the local repository to install to first * @param deploymentRepository the remote repository to deploy to */ void deploy( ArtifactMetadata metadata, ArtifactRepository localRepository, ArtifactRepository deploymentRepository ) throws RepositoryMetadataDeploymentException; /** * Install the metadata in the local repository. * * @param metadata the metadata * @param localRepository the local repository */ void install( ArtifactMetadata metadata, ArtifactRepository localRepository ) throws RepositoryMetadataInstallationException; } maven2-core-2.2.1/maven-artifact-manager/pom.xml0000644000175000017500000000603711236625310021423 0ustar twernertwerner 4.0.0 org.apache.maven maven 2.2.1 maven-artifact-manager Maven Artifact Manager org.apache.maven maven-repository-metadata org.apache.maven.wagon wagon-file test org.apache.maven.wagon wagon-http test org.codehaus.plexus plexus-utils org.apache.maven maven-artifact org.codehaus.plexus plexus-container-default org.apache.maven.wagon wagon-provider-api backport-util-concurrent backport-util-concurrent easymock easymock 1.2_Java1.3 test edu.umd.cs.mtc multithreadedtc-jdk14 1.01 test maven-surefire-plugin **/testutils/** maven2-core-2.2.1/maven-artifact/0000755000175000017500000000000011250552242016467 5ustar twernertwernermaven2-core-2.2.1/maven-artifact/src/0000755000175000017500000000000011250552242017256 5ustar twernertwernermaven2-core-2.2.1/maven-artifact/src/site/0000755000175000017500000000000011250552242020222 5ustar twernertwernermaven2-core-2.2.1/maven-artifact/src/site/site.xml0000644000175000017500000000013211002611514021675 0ustar twernertwerner maven2-core-2.2.1/maven-artifact/src/test/0000755000175000017500000000000011250552241020234 5ustar twernertwernermaven2-core-2.2.1/maven-artifact/src/test/java/0000755000175000017500000000000011250552241021155 5ustar twernertwernermaven2-core-2.2.1/maven-artifact/src/test/java/org/0000755000175000017500000000000011250552241021744 5ustar twernertwernermaven2-core-2.2.1/maven-artifact/src/test/java/org/apache/0000755000175000017500000000000011250552241023165 5ustar twernertwernermaven2-core-2.2.1/maven-artifact/src/test/java/org/apache/maven/0000755000175000017500000000000011250552241024273 5ustar twernertwernermaven2-core-2.2.1/maven-artifact/src/test/java/org/apache/maven/artifact/0000755000175000017500000000000011250552242026071 5ustar twernertwernermaven2-core-2.2.1/maven-artifact/src/test/java/org/apache/maven/artifact/DefaultArtifactTest.java0000644000175000017500000001022110763616045032644 0ustar twernertwernerpackage org.apache.maven.artifact; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import org.apache.maven.artifact.handler.ArtifactHandlerMock; import org.apache.maven.artifact.versioning.VersionRange; import junit.framework.TestCase; public class DefaultArtifactTest extends TestCase { private DefaultArtifact artifact; private DefaultArtifact snapshotArtifact; private String groupId = "groupid", artifactId = "artifactId", version = "1.0", scope = "scope", type = "type", classifier = "classifier"; private String snapshotSpecVersion = "1.0-SNAPSHOT"; private String snapshotResolvedVersion = "1.0-20070606.010101-1"; private VersionRange versionRange; private VersionRange snapshotVersionRange; private ArtifactHandlerMock artifactHandler; protected void setUp() throws Exception { super.setUp(); artifactHandler = new ArtifactHandlerMock(); versionRange = VersionRange.createFromVersion( version ); artifact = new DefaultArtifact( groupId, artifactId, versionRange, scope, type, classifier, artifactHandler ); snapshotVersionRange = VersionRange.createFromVersion( snapshotResolvedVersion ); snapshotArtifact = new DefaultArtifact( groupId, artifactId, snapshotVersionRange, scope, type, classifier, artifactHandler ); } public void testGetVersionReturnsResolvedVersionOnSnapshot() { assertEquals( snapshotResolvedVersion, snapshotArtifact.getVersion() ); // this is FOUL! // snapshotArtifact.isSnapshot(); assertEquals( snapshotSpecVersion, snapshotArtifact.getBaseVersion() ); } public void testGetDependencyConflictId() { assertEquals( groupId + ":" + artifactId + ":" + type + ":" + classifier, artifact.getDependencyConflictId() ); } public void testGetDependencyConflictIdNullGroupId() { artifact.setGroupId( null ); assertEquals( null + ":" + artifactId + ":" + type + ":" + classifier, artifact.getDependencyConflictId() ); } public void testGetDependencyConflictIdNullClassifier() { artifact = new DefaultArtifact( groupId, artifactId, versionRange, scope, type, null, artifactHandler ); assertEquals( groupId + ":" + artifactId + ":" + type, artifact.getDependencyConflictId() ); } public void testGetDependencyConflictIdNullScope() { artifact.setScope( null ); assertEquals( groupId + ":" + artifactId + ":" + type + ":" + classifier, artifact.getDependencyConflictId() ); } public void testToString() { assertEquals( groupId + ":" + artifactId + ":" + type + ":" + classifier + ":" + version + ":" + scope, artifact.toString() ); } public void testToStringNullGroupId() { artifact.setGroupId( null ); assertEquals( artifactId + ":" + type + ":" + classifier + ":" + version + ":" + scope, artifact.toString() ); } public void testToStringNullClassifier() { artifact = new DefaultArtifact( groupId, artifactId, versionRange, scope, type, null, artifactHandler ); assertEquals( groupId + ":" + artifactId + ":" + type + ":" + version + ":" + scope, artifact.toString() ); } public void testToStringNullScope() { artifact.setScope( null ); assertEquals( groupId + ":" + artifactId + ":" + type + ":" + classifier + ":" + version, artifact.toString() ); } } maven2-core-2.2.1/maven-artifact/src/test/java/org/apache/maven/artifact/handler/0000755000175000017500000000000011250552242027506 5ustar twernertwerner././@LongLink0000000000000000000000000000015200000000000011563 Lustar rootrootmaven2-core-2.2.1/maven-artifact/src/test/java/org/apache/maven/artifact/handler/ArtifactHandlerMock.javamaven2-core-2.2.1/maven-artifact/src/test/java/org/apache/maven/artifact/handler/ArtifactHandlerMock0000644000175000017500000000446510551365651033320 0ustar twernertwernerpackage org.apache.maven.artifact.handler; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ public class ArtifactHandlerMock implements ArtifactHandler { private String extension, directory, classifier, packaging, language; private boolean includesDependencies, addedToClasspath; public void setExtension( String extension ) { this.extension = extension; } public String getExtension() { return extension; } public void setDirectory( String directory ) { this.directory = directory; } public String getDirectory() { return directory; } public void setClassifier( String classifier ) { this.classifier = classifier; } public String getClassifier() { return classifier; } public void setPackaging( String packaging ) { this.packaging = packaging; } public String getPackaging() { return packaging; } public void setIncludesDependencies( boolean includesDependencies ) { this.includesDependencies = includesDependencies; } public boolean isIncludesDependencies() { return includesDependencies; } public void setLanguage( String language ) { this.language = language; } public String getLanguage() { return language; } public void setAddedToClasspath( boolean addedToClasspath ) { this.addedToClasspath = addedToClasspath; } public boolean isAddedToClasspath() { return addedToClasspath; } } maven2-core-2.2.1/maven-artifact/src/test/java/org/apache/maven/artifact/resolver/0000755000175000017500000000000011250552242027732 5ustar twernertwerner././@LongLink0000000000000000000000000000016700000000000011571 Lustar rootrootmaven2-core-2.2.1/maven-artifact/src/test/java/org/apache/maven/artifact/resolver/ArtifactResolutionExceptionTest.javamaven2-core-2.2.1/maven-artifact/src/test/java/org/apache/maven/artifact/resolver/ArtifactResolution0000644000175000017500000000537110772004567033516 0ustar twernertwernerpackage org.apache.maven.artifact.resolver; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import java.util.Arrays; import java.util.List; import junit.framework.TestCase; /** * Test the artifact resolution exception message * * @author Mauro Talevi */ public class ArtifactResolutionExceptionTest extends TestCase { private static final String LS = System.getProperty( "line.separator" ); public void testMissingArtifactMessageFormat() { String message = "Missing artifact"; String indentation = " "; String groupId = "aGroupId"; String artifactId = "anArtifactId"; String version = "aVersion"; String type = "jar"; String classifier = "aClassifier"; String downloadUrl = "http://somewhere.com/download"; List path = Arrays.asList(new String[]{"dependency1", "dependency2"}); String expected = "Missing artifact" + LS + LS + " Try downloading the file manually from: " + LS + " http://somewhere.com/download" + LS + LS + " Then, install it using the command: " + LS + " mvn install:install-file -DgroupId=aGroupId -DartifactId=anArtifactId -Dversion=aVersion "+ "-Dclassifier=aClassifier -Dpackaging=jar -Dfile=/path/to/file" + LS + LS + " Alternatively, if you host your own repository you can deploy the file there: " + LS + " mvn deploy:deploy-file -DgroupId=aGroupId -DartifactId=anArtifactId"+ " -Dversion=aVersion -Dclassifier=aClassifier -Dpackaging=jar -Dfile=/path/to/file"+ " -Durl=[url] -DrepositoryId=[id]" + LS + LS + " Path to dependency: " + LS + " \t1) dependency1" + LS + " \t2) dependency2" + LS + LS; String actual = AbstractArtifactResolutionException.constructMissingArtifactMessage(message, indentation, groupId, artifactId, version, type, classifier, downloadUrl, path); assertEquals(expected, actual); } } ././@LongLink0000000000000000000000000000016400000000000011566 Lustar rootrootmaven2-core-2.2.1/maven-artifact/src/test/java/org/apache/maven/artifact/resolver/DefaultArtifactCollectorTest.javamaven2-core-2.2.1/maven-artifact/src/test/java/org/apache/maven/artifact/resolver/DefaultArtifactCol0000644000175000017500000013723611035020441033361 0ustar twernertwernerpackage org.apache.maven.artifact.resolver; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.factory.ArtifactFactory; import org.apache.maven.artifact.metadata.ArtifactMetadataRetrievalException; import org.apache.maven.artifact.metadata.ArtifactMetadataSource; import org.apache.maven.artifact.metadata.ResolutionGroup; import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.artifact.resolver.filter.ArtifactFilter; import org.apache.maven.artifact.resolver.filter.ExclusionSetFilter; import org.apache.maven.artifact.resolver.filter.ScopeArtifactFilter; import org.apache.maven.artifact.versioning.DefaultArtifactVersion; import org.apache.maven.artifact.versioning.InvalidVersionSpecificationException; import org.apache.maven.artifact.versioning.OverConstrainedVersionException; import org.apache.maven.artifact.versioning.VersionRange; import org.codehaus.plexus.PlexusTestCase; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; import java.util.LinkedHashSet; import java.util.List; import java.util.Map; import java.util.Set; /** * Test the default artifact collector. * * @author Brett Porter * @version $Id: DefaultArtifactCollectorTest.java 675087 2008-07-09 02:23:29Z jdcasey $ */ public class DefaultArtifactCollectorTest extends PlexusTestCase { private ArtifactCollector artifactCollector; private ArtifactFactory artifactFactory; private ArtifactSpec projectArtifact; private Source source; private static final String GROUP_ID = "test"; protected void setUp() throws Exception { super.setUp(); source = new Source(); artifactFactory = (ArtifactFactory) lookup( ArtifactFactory.ROLE ); artifactCollector = new DefaultArtifactCollector(); projectArtifact = createArtifactSpec( "project", "1.0", null ); } // works, but we don't fail on cycles presently public void disabledtestCircularDependencyNotIncludingCurrentProject() throws ArtifactResolutionException, InvalidVersionSpecificationException { ArtifactSpec a = createArtifactSpec( "a", "1.0" ); ArtifactSpec b = a.addDependency( "b", "1.0" ); b.addDependency( "a", "1.0" ); try { collect( a ); fail( "Should have failed on cyclic dependency not involving project" ); } catch ( CyclicDependencyException expected ) { assertTrue( true ); } } // works, but we don't fail on cycles presently public void disabledtestCircularDependencyIncludingCurrentProject() throws ArtifactResolutionException, InvalidVersionSpecificationException { ArtifactSpec a = createArtifactSpec( "a", "1.0" ); ArtifactSpec b = a.addDependency( "b", "1.0" ); b.addDependency( "project", "1.0" ); try { collect( a ); fail( "Should have failed on cyclic dependency involving project" ); } catch ( CyclicDependencyException expected ) { assertTrue( true ); } } public void testResolveWithFilter() throws ArtifactResolutionException, InvalidVersionSpecificationException { ArtifactSpec a = createArtifactSpec( "a", "1.0" ); ArtifactSpec b = a.addDependency( "b", "1.0" ); ArtifactSpec c = a.addDependency( "c", "3.0" ); b.addDependency( "c", "2.0" ); ArtifactSpec d = b.addDependency( "d", "4.0" ); ArtifactResolutionResult res = collect( a ); assertEquals( "Check artifact list", createSet( new Object[]{a.artifact, b.artifact, c.artifact, d.artifact} ), res.getArtifacts() ); ArtifactFilter filter = new ExclusionSetFilter( new String[]{"b"} ); res = collect( a, filter ); assertEquals( "Check artifact list", createSet( new Object[]{a.artifact, c.artifact} ), res.getArtifacts() ); } public void testResolveCorrectDependenciesWhenDifferentDependenciesOnNearest() throws ArtifactResolutionException, InvalidVersionSpecificationException { ArtifactSpec a = createArtifactSpec( "a", "1.0" ); ArtifactSpec b = a.addDependency( "b", "1.0" ); ArtifactSpec c2 = b.addDependency( "c", "2.0" ); c2.addDependency( "d", "1.0" ); ArtifactSpec e = createArtifactSpec( "e", "1.0" ); ArtifactSpec c1 = e.addDependency( "c", "1.0" ); ArtifactSpec f = c1.addDependency( "f", "1.0" ); ArtifactResolutionResult res = collect( createSet( new Object[]{a.artifact, e.artifact} ) ); assertEquals( "Check artifact list", createSet( new Object[]{a.artifact, b.artifact, e.artifact, c1.artifact, f.artifact} ), res.getArtifacts() ); assertEquals( "Check version", "1.0", getArtifact( "c", res.getArtifacts() ).getVersion() ); } public void disabledtestResolveCorrectDependenciesWhenDifferentDependenciesOnNewest() throws ArtifactResolutionException, InvalidVersionSpecificationException { // TODO: use newest conflict resolver ArtifactSpec a = createArtifactSpec( "a", "1.0" ); ArtifactSpec b = a.addDependency( "b", "1.0" ); ArtifactSpec c2 = b.addDependency( "c", "2.0" ); ArtifactSpec d = c2.addDependency( "d", "1.0" ); ArtifactSpec e = createArtifactSpec( "e", "1.0" ); ArtifactSpec c1 = e.addDependency( "c", "1.0" ); c1.addDependency( "f", "1.0" ); ArtifactResolutionResult res = collect( createSet( new Object[]{a.artifact, e.artifact} ) ); assertEquals( "Check artifact list", createSet( new Object[]{a.artifact, b.artifact, e.artifact, c2.artifact, d.artifact} ), res.getArtifacts() ); assertEquals( "Check version", "2.0", getArtifact( "c", res.getArtifacts() ).getVersion() ); } public void disabledtestResolveCorrectDependenciesWhenDifferentDependenciesOnNewestVersionReplaced() throws ArtifactResolutionException, InvalidVersionSpecificationException { // TODO: use newest conflict resolver ArtifactSpec a = createArtifactSpec( "a", "1.0" ); ArtifactSpec b1 = a.addDependency( "b", "1.0" ); ArtifactSpec c = a.addDependency( "c", "1.0" ); ArtifactSpec d2 = b1.addDependency( "d", "2.0" ); d2.addDependency( "h", "1.0" ); ArtifactSpec d1 = c.addDependency( "d", "1.0" ); ArtifactSpec b2 = c.addDependency( "b", "2.0" ); ArtifactSpec e = b2.addDependency( "e", "1.0" ); ArtifactSpec g = d1.addDependency( "g", "1.0" ); ArtifactResolutionResult res = collect( createSet( new Object[]{a.artifact} ) ); Object[] artifacts = new Object[]{a.artifact, c.artifact, d1.artifact, b2.artifact, e.artifact, g.artifact}; assertEquals( "Check artifact list", createSet( artifacts ), res.getArtifacts() ); assertEquals( "Check version", "1.0", getArtifact( "d", res.getArtifacts() ).getVersion() ); assertEquals( "Check version", "2.0", getArtifact( "b", res.getArtifacts() ).getVersion() ); } public void testResolveNearestNewestIsNearest() throws ArtifactResolutionException, InvalidVersionSpecificationException { ArtifactSpec a = createArtifactSpec( "a", "1.0" ); ArtifactSpec b = a.addDependency( "b", "1.0" ); ArtifactSpec c = a.addDependency( "c", "3.0" ); b.addDependency( "c", "2.0" ); ArtifactResolutionResult res = collect( a ); assertEquals( "Check artifact list", createSet( new Object[]{a.artifact, b.artifact, c.artifact} ), res.getArtifacts() ); assertEquals( "Check version", "3.0", getArtifact( "c", res.getArtifacts() ).getVersion() ); } public void testResolveNearestOldestIsNearest() throws ArtifactResolutionException, InvalidVersionSpecificationException { ArtifactSpec a = createArtifactSpec( "a", "1.0" ); ArtifactSpec b = a.addDependency( "b", "1.0" ); ArtifactSpec c = a.addDependency( "c", "2.0" ); b.addDependency( "c", "3.0" ); ArtifactResolutionResult res = collect( a ); assertEquals( "Check artifact list", createSet( new Object[]{a.artifact, b.artifact, c.artifact} ), res.getArtifacts() ); assertEquals( "Check version", "2.0", getArtifact( "c", res.getArtifacts() ).getVersion() ); } public void testResolveLocalNewestIsLocal() throws ArtifactResolutionException, InvalidVersionSpecificationException { ArtifactSpec a = createArtifactSpec( "a", "1.0" ); a.addDependency( "b", "2.0" ); ArtifactSpec b = createArtifactSpec( "b", "3.0" ); ArtifactResolutionResult res = collect( createSet( new Object[]{a.artifact, b.artifact} ) ); assertEquals( "Check artifact list", createSet( new Object[]{a.artifact, b.artifact} ), res.getArtifacts() ); assertEquals( "Check version", "3.0", getArtifact( "b", res.getArtifacts() ).getVersion() ); } public void testResolveLocalOldestIsLocal() throws ArtifactResolutionException, InvalidVersionSpecificationException { ArtifactSpec a = createArtifactSpec( "a", "1.0" ); a.addDependency( "b", "3.0" ); ArtifactSpec b = createArtifactSpec( "b", "2.0" ); ArtifactResolutionResult res = collect( createSet( new Object[]{a.artifact, b.artifact} ) ); assertEquals( "Check artifact list", createSet( new Object[]{a.artifact, b.artifact} ), res.getArtifacts() ); assertEquals( "Check version", "2.0", getArtifact( "b", res.getArtifacts() ).getVersion() ); } public void testResolveLocalWithNewerVersionButLesserScope() throws ArtifactResolutionException, InvalidVersionSpecificationException { ArtifactSpec a = createArtifactSpec( "commons-logging", "1.0" ); a.addDependency( "junit", "3.7" ); ArtifactSpec b = createArtifactSpec( "junit", "3.8.1", Artifact.SCOPE_TEST ); ArtifactResolutionResult res = collect( createSet( new Object[]{a.artifact, b.artifact} ) ); assertEquals( "Check artifact list", createSet( new Object[]{a.artifact, b.artifact} ), res.getArtifacts() ); assertEquals( "Check version", "3.8.1", getArtifact( "junit", res.getArtifacts() ).getVersion() ); assertEquals( "Check scope", Artifact.SCOPE_TEST, getArtifact( "junit", res.getArtifacts() ).getScope() ); } public void testResolveLocalWithNewerVersionButLesserScopeResolvedFirst() throws ArtifactResolutionException, InvalidVersionSpecificationException { ArtifactSpec b = createArtifactSpec( "junit", "3.8.1", Artifact.SCOPE_TEST ); ArtifactSpec a = createArtifactSpec( "commons-logging", "1.0" ); a.addDependency( "junit", "3.7" ); ArtifactResolutionResult res = collect( createSet( new Object[]{a.artifact, b.artifact} ) ); assertEquals( "Check artifact list", createSet( new Object[]{a.artifact, b.artifact} ), res.getArtifacts() ); assertEquals( "Check version", "3.8.1", getArtifact( "junit", res.getArtifacts() ).getVersion() ); assertEquals( "Check scope", Artifact.SCOPE_TEST, getArtifact( "junit", res.getArtifacts() ).getScope() ); } public void testResolveNearestWithRanges() throws ArtifactResolutionException, InvalidVersionSpecificationException { ArtifactSpec a = createArtifactSpec( "a", "1.0" ); ArtifactSpec b = a.addDependency( "b", "1.0" ); ArtifactSpec c = a.addDependency( "c", "2.0" ); b.addDependency( "c", "[1.0,3.0]" ); ArtifactResolutionResult res = collect( a ); assertEquals( "Check artifact list", createSet( new Object[]{a.artifact, b.artifact, c.artifact} ), res.getArtifacts() ); assertEquals( "Check version", "2.0", getArtifact( "c", res.getArtifacts() ).getVersion() ); } public void testResolveRangeWithManagedVersion() throws ArtifactResolutionException, InvalidVersionSpecificationException { ArtifactSpec a = createArtifactSpec( "a", "1.0" ); ArtifactSpec b = a.addDependency( "b", "[1.0,3.0]" ); ArtifactSpec managedB = createArtifactSpec( "b", "5.0" ); ArtifactResolutionResult res = collect( a, managedB.artifact ); assertEquals( "Check artifact list", createSet( new Object[] { a.artifact, managedB.artifact } ), res.getArtifacts() ); assertEquals( "Check version", "5.0", getArtifact( "b", res.getArtifacts() ).getVersion() ); } public void testCompatibleRanges() throws ArtifactResolutionException, InvalidVersionSpecificationException { ArtifactSpec a = createArtifactSpec( "a", "1.0" ); ArtifactSpec b = a.addDependency( "b", "1.0" ); a.addDependency( "c", "[2.0,2.5]" ); b.addDependency( "c", "[1.0,3.0]" ); ArtifactSpec c = createArtifactSpec( "c", "2.5" ); ArtifactResolutionResult res = collect( a ); assertEquals( "Check artifact list", createSet( new Object[]{a.artifact, b.artifact, c.artifact} ), res.getArtifacts() ); assertEquals( "Check version", "2.5", getArtifact( "c", res.getArtifacts() ).getVersion() ); } public void testCompatibleRecommendedVersion() throws ArtifactResolutionException, InvalidVersionSpecificationException { //this test puts two dependencies on C with 3.2 and [1.0,3.0] as the version. //it puts 2.5 in the pretend repo...we should get back 2.5 ArtifactSpec a = createArtifactSpec( "a", "1.0" ); ArtifactSpec b = a.addDependency( "b", "1.0" ); ArtifactSpec b1 = a.addDependency( "b1", "1.0" ); b.addDependency( "c", "3.2" ); b1.addDependency( "c", "[1.0,3.0]" ); //put it in the repo ArtifactSpec c = createArtifactSpec( "c", "2.5" ); source.addArtifact( createArtifactSpec( "c", "2.5" )); ArtifactResolutionResult res = collect( a ); assertEquals( "Check artifact list", createSet( new Object[] { a.artifact, b.artifact,b1.artifact,c.artifact } ), res.getArtifacts() ); assertEquals( "Check version", "2.5", getArtifact( "c", res.getArtifacts() ).getVersion() ); } public void testCompatibleRecommendedVersionWithChildren() throws ArtifactResolutionException, InvalidVersionSpecificationException { // this test puts two dependencies on C with 3.2 and [1.0,3.0] as the version. // it puts 2.5 in the pretend repo...we should get back c2.5 and d1.0 ArtifactSpec a = createArtifactSpec( "a", "1.0" ); ArtifactSpec b = a.addDependency( "b", "1.0" ); ArtifactSpec e = a.addDependency( "e", "1.0" ); ArtifactSpec c1 = b.addDependency( "c", "3.2" ); ArtifactSpec d1 = c1.addDependency( "d","1.1" ); e.addDependency( "c", "[1.0,3.0]" ); // put it in the repo ArtifactSpec c = createArtifactSpec( "c", "2.5" ); ArtifactSpec d = c.addDependency( "d","1.0" ); source.addArtifact( c ); source.addArtifact( d ); source.addArtifact( c1 ); source.addArtifact( d1 ); ArtifactResolutionResult res = collect( a ); assertEquals( "Check artifact list", createSet( new Object[] { a.artifact, b.artifact, e.artifact, c.artifact,d.artifact } ), res.getArtifacts() ); assertEquals( "Check version", "2.5", getArtifact( "c", res.getArtifacts() ).getVersion() ); } public void testInCompatibleRecommendedVersion() throws ArtifactResolutionException, InvalidVersionSpecificationException { // this test puts two dependencies on C with 3.2 and [1.0,3.0] as the version. // it puts 2.5 and 3.0 in the pretend repo...we should get back 3.0 ArtifactSpec a = createArtifactSpec( "a", "1.0" ); ArtifactSpec b = a.addDependency( "b", "1.0" ); ArtifactSpec b1 = a.addDependency( "b1", "1.0" ); b.addDependency( "c", "3.2" ); b1.addDependency( "c", "[1.0,3.0]" ); // put it in the repo ArtifactSpec c = createArtifactSpec( "c", "3.0" ); source.addArtifact( createArtifactSpec( "c", "2.5" ) ); source.addArtifact( createArtifactSpec( "c", "3.0" ) ); source.addArtifact( createArtifactSpec( "c", "3.2" ) ); ArtifactResolutionResult res = collect( a ); assertEquals( "Check artifact list", createSet( new Object[] { a.artifact, b.artifact, b1.artifact, c.artifact } ), res.getArtifacts() ); assertEquals( "Check version", "3.0", getArtifact( "c", res.getArtifacts() ).getVersion() ); } //MNG-2123: this version of the test caused the crash seen in the IT. It was //only happening if the first dependency was not a range but the second one was. public void testInCompatibleRecommendedVersion2() throws ArtifactResolutionException, InvalidVersionSpecificationException { // this test puts two dependencies on C with 3.2 and [1.0,3.0] as the version. // it puts 2.5 and 3.0 in the pretend repo...we should get back 3.0 ArtifactSpec a = createArtifactSpec( "a", "1.0" ); ArtifactSpec b = a.addDependency( "b", "1.0" ); ArtifactSpec b1 = a.addDependency( "b1", "1.0" ); b1.addDependency( "c", "3.2" ); b.addDependency( "c", "[1.0,3.0]" ); // put it in the repo ArtifactSpec c = createArtifactSpec( "c", "3.0" ); source.addArtifact( createArtifactSpec( "c", "2.5" ) ); source.addArtifact( createArtifactSpec( "c", "3.0" ) ); source.addArtifact( createArtifactSpec( "c", "3.2" ) ); ArtifactResolutionResult res = collect( a ); assertEquals( "Check artifact list", createSet( new Object[] { a.artifact, b.artifact, b1.artifact, c.artifact } ), res.getArtifacts() ); assertEquals( "Check version", "3.0", getArtifact( "c", res.getArtifacts() ).getVersion() ); } public void testIncompatibleRanges() throws ArtifactResolutionException, InvalidVersionSpecificationException { ArtifactSpec a = createArtifactSpec( "a", "1.0" ); ArtifactSpec b = a.addDependency( "b", "1.0" ); a.addDependency( "c", "[2.4,3.0]" ); b.addDependency( "c", "[1.0,2.0]" ); try { ArtifactResolutionResult res = collect( a ); fail( "Should not succeed collecting, got: " + res.getArtifacts() ); } catch ( ArtifactResolutionException expected ) { } } public void testUnboundedRangeWhenVersionUnavailable() throws ArtifactResolutionException, InvalidVersionSpecificationException { ArtifactSpec a = createArtifactSpec( "a", "1.0" ); ArtifactSpec b = a.addDependency( "b", "1.0" ); a.addDependency( "c", "[2.0,]" ); b.addDependency( "c", "[1.0,]" ); try { ArtifactResolutionResult res = collect( a ); fail( "Should not succeed collecting, got: " + res.getArtifacts() ); } catch ( ArtifactResolutionException expected ) { assertTrue( true ); } } public void testUnboundedRangeBelowLastRelease() throws ArtifactResolutionException, InvalidVersionSpecificationException { ArtifactSpec a = createArtifactSpec( "a", "1.0" ); createArtifactSpec( "c", "1.5" ); ArtifactSpec c = createArtifactSpec( "c", "2.0" ); createArtifactSpec( "c", "1.1" ); a.addDependency( "c", "[1.0,)" ); ArtifactResolutionResult res = collect( a ); assertEquals( "Check artifact list", createSet( new Object[]{a.artifact, c.artifact} ), res.getArtifacts() ); assertEquals( "Check version", "2.0", getArtifact( "c", res.getArtifacts() ).getVersion() ); } public void testUnboundedRangeAboveLastRelease() throws ArtifactResolutionException, InvalidVersionSpecificationException { ArtifactSpec a = createArtifactSpec( "a", "1.0" ); createArtifactSpec( "c", "2.0" ); a.addDependency( "c", "[10.0,)" ); try { ArtifactResolutionResult res = collect( a ); fail( "Should not succeed collecting, got: " + res.getArtifacts() ); } catch ( ArtifactResolutionException expected ) { assertTrue( true ); } } public void testResolveManagedVersion() throws ArtifactResolutionException, InvalidVersionSpecificationException { ArtifactSpec a = createArtifactSpec( "a", "1.0" ); a.addDependency( "b", "3.0", Artifact.SCOPE_RUNTIME ); Artifact managedVersion = createArtifactSpec( "b", "5.0" ).artifact; Artifact modifiedB = createArtifactSpec( "b", "5.0", Artifact.SCOPE_RUNTIME ).artifact; ArtifactResolutionResult res = collect( a, managedVersion ); assertEquals( "Check artifact list", createSet( new Object[]{a.artifact, modifiedB} ), res.getArtifacts() ); } public void testCollectChangesVersionOfOriginatingArtifactIfInDependencyManagementHasDifferentVersion() throws ArtifactResolutionException, InvalidVersionSpecificationException { ArtifactSpec a = createArtifactSpec( "a", "1.0" ); Artifact artifact = projectArtifact.artifact; Artifact managedVersion = createArtifactSpec( artifact.getArtifactId(), "2.0" ).artifact; ArtifactResolutionResult result = collect( a, managedVersion ); assertEquals( "collect has modified version in originating artifact", "1.0", artifact.getVersion() ); Artifact resolvedArtifact = (Artifact) result.getArtifacts().iterator().next(); assertEquals( "Resolved version don't match original artifact version", "1.0", resolvedArtifact.getVersion() ); } public void testResolveCompileScopeOverTestScope() throws ArtifactResolutionException, InvalidVersionSpecificationException { ArtifactSpec a = createArtifactSpec( "a", "1.0" ); ArtifactSpec c = createArtifactSpec( "c", "3.0", Artifact.SCOPE_TEST ); a.addDependency( "c", "2.0", Artifact.SCOPE_COMPILE ); Artifact modifiedC = createArtifactSpec( "c", "3.0", Artifact.SCOPE_COMPILE ).artifact; ArtifactResolutionResult res = collect( createSet( new Object[]{a.artifact, c.artifact} ) ); assertEquals( "Check artifact list", createSet( new Object[]{a.artifact, modifiedC} ), res.getArtifacts() ); Artifact artifact = getArtifact( "c", res.getArtifacts() ); // local wins now, and irrelevant if not local as test/provided aren't transitive // assertEquals( "Check scope", Artifact.SCOPE_COMPILE, artifact.getScope() ); assertEquals( "Check scope", Artifact.SCOPE_TEST, artifact.getScope() ); } public void testResolveRuntimeScopeOverTestScope() throws ArtifactResolutionException, InvalidVersionSpecificationException { ArtifactSpec a = createArtifactSpec( "a", "1.0" ); ArtifactSpec c = createArtifactSpec( "c", "3.0", Artifact.SCOPE_TEST ); a.addDependency( "c", "2.0", Artifact.SCOPE_RUNTIME ); Artifact modifiedC = createArtifactSpec( "c", "3.0", Artifact.SCOPE_RUNTIME ).artifact; ArtifactResolutionResult res = collect( createSet( new Object[]{a.artifact, c.artifact} ) ); assertEquals( "Check artifact list", createSet( new Object[]{a.artifact, modifiedC} ), res.getArtifacts() ); Artifact artifact = getArtifact( "c", res.getArtifacts() ); // local wins now, and irrelevant if not local as test/provided aren't transitive // assertEquals( "Check scope", Artifact.SCOPE_RUNTIME, artifact.getScope() ); assertEquals( "Check scope", Artifact.SCOPE_TEST, artifact.getScope() ); } public void testResolveCompileScopeOverRuntimeScope() throws ArtifactResolutionException, InvalidVersionSpecificationException { ArtifactSpec root = createArtifactSpec( "root", "1.0" ); ArtifactSpec a = root.addDependency( "a", "1.0" ); root.addDependency( "c", "3.0", Artifact.SCOPE_RUNTIME ); a.addDependency( "c", "2.0", Artifact.SCOPE_COMPILE ); Artifact modifiedC = createArtifactSpec( "c", "3.0", Artifact.SCOPE_COMPILE ).artifact; ArtifactResolutionResult res = collect( createSet( new Object[]{root.artifact} ) ); assertEquals( "Check artifact list", createSet( new Object[]{a.artifact, root.artifact, modifiedC} ), res.getArtifacts() ); Artifact artifact = getArtifact( "c", res.getArtifacts() ); assertEquals( "Check scope", Artifact.SCOPE_COMPILE, artifact.getScope() ); } public void testResolveCompileScopeOverProvidedScope() throws ArtifactResolutionException, InvalidVersionSpecificationException { ArtifactSpec a = createArtifactSpec( "a", "1.0" ); ArtifactSpec c = createArtifactSpec( "c", "3.0", Artifact.SCOPE_PROVIDED ); a.addDependency( "c", "2.0", Artifact.SCOPE_COMPILE ); Artifact modifiedC = createArtifactSpec( "c", "3.0", Artifact.SCOPE_COMPILE ).artifact; ArtifactResolutionResult res = collect( createSet( new Object[]{a.artifact, c.artifact} ) ); assertEquals( "Check artifact list", createSet( new Object[]{a.artifact, modifiedC} ), res.getArtifacts() ); Artifact artifact = getArtifact( "c", res.getArtifacts() ); // local wins now, and irrelevant if not local as test/provided aren't transitive // assertEquals( "Check scope", Artifact.SCOPE_COMPILE, artifact.getScope() ); assertEquals( "Check scope", Artifact.SCOPE_PROVIDED, artifact.getScope() ); } public void testResolveRuntimeScopeOverProvidedScope() throws ArtifactResolutionException, InvalidVersionSpecificationException { ArtifactSpec a = createArtifactSpec( "a", "1.0" ); ArtifactSpec c = createArtifactSpec( "c", "3.0", Artifact.SCOPE_PROVIDED ); a.addDependency( "c", "2.0", Artifact.SCOPE_RUNTIME ); Artifact modifiedC = createArtifactSpec( "c", "3.0", Artifact.SCOPE_RUNTIME ).artifact; ArtifactResolutionResult res = collect( createSet( new Object[]{a.artifact, c.artifact} ) ); assertEquals( "Check artifact list", createSet( new Object[]{a.artifact, modifiedC} ), res.getArtifacts() ); Artifact artifact = getArtifact( "c", res.getArtifacts() ); // local wins now, and irrelevant if not local as test/provided aren't transitive // assertEquals( "Check scope", Artifact.SCOPE_RUNTIME, artifact.getScope() ); assertEquals( "Check scope", Artifact.SCOPE_PROVIDED, artifact.getScope() ); } public void testProvidedScopeNotTransitive() throws ArtifactResolutionException, InvalidVersionSpecificationException { ArtifactSpec a = createArtifactSpec( "a", "1.0", Artifact.SCOPE_PROVIDED ); ArtifactSpec b = createArtifactSpec( "b", "1.0" ); b.addDependency( "c", "3.0", Artifact.SCOPE_PROVIDED ); ArtifactResolutionResult res = collect( createSet( new Object[]{a.artifact, b.artifact} ) ); assertEquals( "Check artifact list", createSet( new Object[]{a.artifact, b.artifact} ), res.getArtifacts() ); } public void testOptionalNotTransitive() throws ArtifactResolutionException, InvalidVersionSpecificationException { ArtifactSpec a = createArtifactSpec( "a", "1.0" ); ArtifactSpec b = createArtifactSpec( "b", "1.0" ); b.addDependency( "c", "3.0", true ); ArtifactResolutionResult res = collect( createSet( new Object[]{a.artifact, b.artifact} ) ); assertEquals( "Check artifact list", createSet( new Object[]{a.artifact, b.artifact} ), res.getArtifacts() ); } public void testOptionalIncludedAtRoot() throws ArtifactResolutionException, InvalidVersionSpecificationException { ArtifactSpec a = createArtifactSpec( "a", "1.0" ); ArtifactSpec b = createArtifactSpec( "b", "1.0", true ); ArtifactResolutionResult res = collect( createSet( new Object[]{a.artifact, b.artifact} ) ); assertEquals( "Check artifact list", createSet( new Object[]{a.artifact, b.artifact} ), res.getArtifacts() ); } public void testScopeUpdate() throws InvalidVersionSpecificationException, ArtifactResolutionException { /* farthest = compile */ checkScopeUpdate( Artifact.SCOPE_COMPILE, Artifact.SCOPE_COMPILE, Artifact.SCOPE_COMPILE ); checkScopeUpdate( Artifact.SCOPE_COMPILE, Artifact.SCOPE_PROVIDED, Artifact.SCOPE_COMPILE ); checkScopeUpdate( Artifact.SCOPE_COMPILE, Artifact.SCOPE_RUNTIME, Artifact.SCOPE_COMPILE ); checkScopeUpdate( Artifact.SCOPE_COMPILE, Artifact.SCOPE_SYSTEM, Artifact.SCOPE_COMPILE ); checkScopeUpdate( Artifact.SCOPE_COMPILE, Artifact.SCOPE_TEST, Artifact.SCOPE_COMPILE ); /* farthest = provided */ checkScopeUpdate( Artifact.SCOPE_PROVIDED, Artifact.SCOPE_COMPILE, Artifact.SCOPE_COMPILE ); checkScopeUpdate( Artifact.SCOPE_PROVIDED, Artifact.SCOPE_PROVIDED, Artifact.SCOPE_PROVIDED ); checkScopeUpdate( Artifact.SCOPE_PROVIDED, Artifact.SCOPE_RUNTIME, Artifact.SCOPE_RUNTIME ); checkScopeUpdate( Artifact.SCOPE_PROVIDED, Artifact.SCOPE_SYSTEM, Artifact.SCOPE_SYSTEM ); checkScopeUpdate( Artifact.SCOPE_PROVIDED, Artifact.SCOPE_TEST, Artifact.SCOPE_TEST ); /* farthest = runtime */ checkScopeUpdate( Artifact.SCOPE_RUNTIME, Artifact.SCOPE_COMPILE, Artifact.SCOPE_COMPILE ); checkScopeUpdate( Artifact.SCOPE_RUNTIME, Artifact.SCOPE_PROVIDED, Artifact.SCOPE_RUNTIME ); checkScopeUpdate( Artifact.SCOPE_RUNTIME, Artifact.SCOPE_RUNTIME, Artifact.SCOPE_RUNTIME ); checkScopeUpdate( Artifact.SCOPE_RUNTIME, Artifact.SCOPE_SYSTEM, Artifact.SCOPE_SYSTEM ); checkScopeUpdate( Artifact.SCOPE_RUNTIME, Artifact.SCOPE_TEST, Artifact.SCOPE_RUNTIME ); /* farthest = system */ checkScopeUpdate( Artifact.SCOPE_SYSTEM, Artifact.SCOPE_COMPILE, Artifact.SCOPE_COMPILE ); checkScopeUpdate( Artifact.SCOPE_SYSTEM, Artifact.SCOPE_PROVIDED, Artifact.SCOPE_PROVIDED ); checkScopeUpdate( Artifact.SCOPE_SYSTEM, Artifact.SCOPE_RUNTIME, Artifact.SCOPE_RUNTIME ); checkScopeUpdate( Artifact.SCOPE_SYSTEM, Artifact.SCOPE_SYSTEM, Artifact.SCOPE_SYSTEM ); checkScopeUpdate( Artifact.SCOPE_SYSTEM, Artifact.SCOPE_TEST, Artifact.SCOPE_TEST ); /* farthest = test */ checkScopeUpdate( Artifact.SCOPE_TEST, Artifact.SCOPE_COMPILE, Artifact.SCOPE_COMPILE ); checkScopeUpdate( Artifact.SCOPE_TEST, Artifact.SCOPE_PROVIDED, Artifact.SCOPE_PROVIDED ); checkScopeUpdate( Artifact.SCOPE_TEST, Artifact.SCOPE_RUNTIME, Artifact.SCOPE_RUNTIME ); checkScopeUpdate( Artifact.SCOPE_TEST, Artifact.SCOPE_SYSTEM, Artifact.SCOPE_SYSTEM ); checkScopeUpdate( Artifact.SCOPE_TEST, Artifact.SCOPE_TEST, Artifact.SCOPE_TEST ); } private void checkScopeUpdate( String farthestScope, String nearestScope, String expectedScope ) throws ArtifactResolutionException, InvalidVersionSpecificationException { checkScopeUpdateDirect( farthestScope, nearestScope, expectedScope ); checkScopeUpdateTransitively( farthestScope, nearestScope, expectedScope ); } private void checkScopeUpdateTransitively( String farthestScope, String nearestScope, String expectedScope ) throws ArtifactResolutionException, InvalidVersionSpecificationException { ArtifactSpec a = createArtifactSpec( "a", "1.0" ); ArtifactSpec b = createArtifactSpec( "b", "1.0", nearestScope ); ArtifactSpec c = createArtifactSpec( "c", "1.0" ); a.addDependency( c ); ArtifactSpec dNearest = createArtifactSpec( "d", "2.0" ); b.addDependency( dNearest ); ArtifactSpec dFarthest = createArtifactSpec( "d", "3.0", farthestScope ); c.addDependency( dFarthest ); /* system and provided dependencies are not transitive */ if ( !Artifact.SCOPE_SYSTEM.equals( nearestScope ) && !Artifact.SCOPE_PROVIDED.equals( nearestScope ) ) { checkScopeUpdate( a, b, expectedScope, "2.0" ); } } private void checkScopeUpdateDirect( String farthestScope, String nearestScope, String expectedScope ) throws ArtifactResolutionException, InvalidVersionSpecificationException { ArtifactSpec a = createArtifactSpec( "a", "1.0" ); ArtifactSpec b = createArtifactSpec( "b", "1.0" ); ArtifactSpec c = createArtifactSpec( "c", "1.0" ); a.addDependency( c ); ArtifactSpec dNearest = createArtifactSpec( "d", "2.0", nearestScope ); b.addDependency( dNearest ); ArtifactSpec dFarthest = createArtifactSpec( "d", "3.0", farthestScope ); c.addDependency( dFarthest ); checkScopeUpdate( a, b, expectedScope, "2.0" ); } private void checkScopeUpdate( ArtifactSpec a, ArtifactSpec b, String expectedScope, String expectedVersion ) throws ArtifactResolutionException, InvalidVersionSpecificationException { ScopeArtifactFilter filter; if ( Artifact.SCOPE_PROVIDED.equals( expectedScope ) ) { filter = new ScopeArtifactFilter( Artifact.SCOPE_COMPILE ); } else if ( Artifact.SCOPE_SYSTEM.equals( expectedScope ) ) { filter = new ScopeArtifactFilter( Artifact.SCOPE_COMPILE ); } else { filter = new ScopeArtifactFilter( expectedScope ); } ArtifactResolutionResult res = collect( createSet( new Object[]{a.artifact, b.artifact} ), filter ); Artifact artifact = getArtifact( "d", res.getArtifacts() ); assertNotNull( "MNG-1895 Dependency was not added to resolution", artifact ); assertEquals( "Check scope", expectedScope, artifact.getScope() ); assertEquals( "Check version", expectedVersion, artifact.getVersion() ); ArtifactSpec d = createArtifactSpec( "d", "1.0" ); res = collect( createSet( new Object[]{a.artifact, b.artifact, d.artifact} ), filter ); artifact = getArtifact( "d", res.getArtifacts() ); assertNotNull( "MNG-1895 Dependency was not added to resolution", artifact ); assertEquals( "Check scope", d.artifact.getScope(), artifact.getScope() ); assertEquals( "Check version", "1.0", artifact.getVersion() ); } public void disabledtestOptionalNotTransitiveButVersionIsInfluential() throws ArtifactResolutionException, InvalidVersionSpecificationException { ArtifactSpec a = createArtifactSpec( "a", "1.0" ); ArtifactSpec b = createArtifactSpec( "b", "1.0" ); b.addDependency( "c", "3.0", true ); ArtifactSpec d = a.addDependency( "d", "1.0" ); ArtifactSpec e = d.addDependency( "e", "1.0" ); e.addDependency( "c", "2.0" ); ArtifactSpec c = createArtifactSpec( "c", "3.0" ); ArtifactResolutionResult res = collect( createSet( new Object[]{a.artifact, b.artifact} ) ); assertEquals( "Check artifact list", createSet( new Object[]{a.artifact, b.artifact, c.artifact, d.artifact, e.artifact} ), res.getArtifacts() ); Artifact artifact = getArtifact( "c", res.getArtifacts() ); assertEquals( "Check version", "3.0", artifact.getVersion() ); } public void testTestScopeNotTransitive() throws ArtifactResolutionException, InvalidVersionSpecificationException { ArtifactSpec a = createArtifactSpec( "a", "1.0", Artifact.SCOPE_TEST ); ArtifactSpec b = createArtifactSpec( "b", "1.0" ); b.addDependency( "c", "3.0", Artifact.SCOPE_TEST ); ArtifactResolutionResult res = collect( createSet( new Object[]{a.artifact, b.artifact} ) ); assertEquals( "Check artifact list", createSet( new Object[]{a.artifact, b.artifact} ), res.getArtifacts() ); } public void testResolveOrder() throws ArtifactResolutionException, InvalidVersionSpecificationException { ArtifactSpec m = createArtifactSpec( "m", "1.0" ); ArtifactSpec n = createArtifactSpec( "n", "1.0" ); ArtifactResolutionResult res = collect( createSet( new Object[]{m.artifact, n.artifact} ) ); Iterator i = res.getArtifacts().iterator(); assertEquals( "m should be first", m.artifact, i.next() ); assertEquals( "n should be second", n.artifact, i.next() ); res = collect( createSet( new Object[]{n.artifact, m.artifact} ) ); i = res.getArtifacts().iterator(); assertEquals( "n should be first", n.artifact, i.next() ); assertEquals( "m should be second", m.artifact, i.next() ); } public void testOverConstrainedVersionException() throws ArtifactResolutionException, InvalidVersionSpecificationException { ArtifactSpec a = createArtifactSpec( "a", "1.0" ); a.addDependency( "b", "[1.0, 2.0)" ); a.addDependency( "c", "[3.3.0,4.0.0)" ); ArtifactSpec b = createArtifactSpec( "b", "1.0.0" ); b.addDependency( "c", "3.3.0-v3346" ); ArtifactSpec c = createArtifactSpec( "c", "3.2.1-v3235e" ); try { ArtifactResolutionResult res = collect( createSet( new Object[]{a.artifact} ) ); } catch ( OverConstrainedVersionException e ) { assertTrue( "Versions unordered", e.getMessage().indexOf( "[3.2.1-v3235e, 3.3.0-v3346]" ) != -1); assertTrue( "DependencyTrail not resolved", e.getMessage().indexOf( "Path to dependency:" ) != -1); } } private Artifact getArtifact( String id, Set artifacts ) { for ( Iterator i = artifacts.iterator(); i.hasNext(); ) { Artifact a = (Artifact) i.next(); if ( a.getArtifactId().equals( id ) && a.getGroupId().equals( GROUP_ID ) ) { return a; } } return null; } private ArtifactResolutionResult collect( Set artifacts ) throws ArtifactResolutionException { return collect( artifacts, null ); } private ArtifactResolutionResult collect( Set artifacts, ArtifactFilter filter ) throws ArtifactResolutionException { return artifactCollector.collect( artifacts, projectArtifact.artifact, null, null, source, filter, Collections.EMPTY_LIST ); } private ArtifactResolutionResult collect( ArtifactSpec a ) throws ArtifactResolutionException { return artifactCollector.collect( Collections.singleton( a.artifact ), projectArtifact.artifact, null, null, source, null, Collections.EMPTY_LIST ); } private ArtifactResolutionResult collect( ArtifactSpec a, ArtifactFilter filter ) throws ArtifactResolutionException { return artifactCollector.collect( Collections.singleton( a.artifact ), projectArtifact.artifact, null, null, source, filter, Collections.EMPTY_LIST ); } private ArtifactResolutionResult collect( ArtifactSpec a, Artifact managedVersion ) throws ArtifactResolutionException { Map managedVersions = Collections.singletonMap( managedVersion.getDependencyConflictId(), managedVersion ); return artifactCollector.collect( Collections.singleton( a.artifact ), projectArtifact.artifact, managedVersions, null, null, source, null, Collections.EMPTY_LIST ); } private ArtifactSpec createArtifactSpec( String id, String version ) throws InvalidVersionSpecificationException { return createArtifactSpec( id, version, Artifact.SCOPE_COMPILE ); } private ArtifactSpec createArtifactSpec( String id, String version, boolean optional ) throws InvalidVersionSpecificationException { return createArtifactSpec( id, version, Artifact.SCOPE_COMPILE, null, optional ); } private ArtifactSpec createArtifactSpec( String id, String version, String scope ) throws InvalidVersionSpecificationException { return createArtifactSpec( id, version, scope, null, false ); } private ArtifactSpec createArtifactSpec( String id, String version, String scope, String inheritedScope, boolean optional ) throws InvalidVersionSpecificationException { VersionRange versionRange = VersionRange.createFromVersionSpec( version ); Artifact artifact = artifactFactory.createDependencyArtifact( GROUP_ID, id, versionRange, "jar", null, scope, inheritedScope, optional ); ArtifactSpec spec = null; if ( artifact != null ) { spec = new ArtifactSpec(); spec.artifact = artifact; source.addArtifact( spec ); } return spec; } private static Set createSet( Object[] x ) { return new LinkedHashSet( Arrays.asList( x ) ); } private class ArtifactSpec { private Artifact artifact; private Set dependencies = new HashSet(); public ArtifactSpec addDependency( String id, String version ) throws InvalidVersionSpecificationException { return addDependency( id, version, Artifact.SCOPE_COMPILE ); } public ArtifactSpec addDependency( String id, String version, String scope ) throws InvalidVersionSpecificationException { return addDependency( id, version, scope, false ); } private ArtifactSpec addDependency( ArtifactSpec dep ) throws InvalidVersionSpecificationException { if ( dep != null ) { dependencies.add( dep.artifact ); } return dep; } private ArtifactSpec addDependency( String id, String version, String scope, boolean optional ) throws InvalidVersionSpecificationException { ArtifactSpec dep = createArtifactSpec( id, version, scope, artifact.getScope(), optional ); return addDependency( dep ); } public ArtifactSpec addDependency( String id, String version, boolean optional ) throws InvalidVersionSpecificationException { return addDependency( id, version, Artifact.SCOPE_COMPILE, optional ); } } private class Source implements ArtifactMetadataSource { private Map artifacts = new HashMap(); private Map versions = new HashMap(); public ResolutionGroup retrieve( Artifact artifact, ArtifactRepository localRepository, List remoteRepositories ) throws ArtifactMetadataRetrievalException { String key = getKey( artifact ); ArtifactSpec a = (ArtifactSpec) artifacts.get( key ); try { return new ResolutionGroup( artifact, createArtifacts( artifactFactory, a.dependencies, artifact.getScope(), artifact.getDependencyFilter() ), Collections.EMPTY_LIST ); } catch ( InvalidVersionSpecificationException e ) { throw new ArtifactMetadataRetrievalException( "Invalid version creating artifacts", e, artifact ); } } private String getKey( Artifact artifact ) { return artifact.getDependencyConflictId() + ":" + artifact.getVersion(); //return artifact.getDependencyConflictId(); } private Set createArtifacts( ArtifactFactory artifactFactory, Set dependencies, String inheritedScope, ArtifactFilter dependencyFilter ) throws InvalidVersionSpecificationException { Set projectArtifacts = new LinkedHashSet(); for ( Iterator i = dependencies.iterator(); i.hasNext(); ) { Artifact d = (Artifact) i.next(); VersionRange versionRange; if ( d.getVersionRange() != null ) { versionRange = d.getVersionRange(); } else { versionRange = VersionRange.createFromVersionSpec( d.getVersion() ); } Artifact artifact; if ( d.getScope().equals( Artifact.SCOPE_TEST ) || d.getScope().equals( Artifact.SCOPE_PROVIDED ) ) { /* don't call createDependencyArtifact as it'll ignore test and provided scopes */ artifact = artifactFactory.createArtifact( d.getGroupId(), d.getArtifactId(), d.getVersion(), d .getScope(), d.getType() ); } else { artifact = artifactFactory.createDependencyArtifact( d.getGroupId(), d.getArtifactId(), versionRange, d.getType(), d.getClassifier(), d.getScope(), inheritedScope, d.isOptional() ); } if ( artifact != null && ( dependencyFilter == null || dependencyFilter.include( artifact ) ) ) { artifact.setDependencyFilter( dependencyFilter ); projectArtifacts.add( artifact ); } } return projectArtifacts; } public List retrieveAvailableVersions( Artifact artifact, ArtifactRepository localRepository, List remoteRepositories ) throws ArtifactMetadataRetrievalException { List artifactVersions = (List) versions.get( artifact.getDependencyConflictId() ); if ( artifactVersions == null ) { artifactVersions = Collections.EMPTY_LIST; } return artifactVersions; } public void addArtifact( ArtifactSpec spec ) { artifacts.put( getKey( spec.artifact ), spec ); String key = spec.artifact.getDependencyConflictId(); List artifactVersions = (List) versions.get( key ); if ( artifactVersions == null ) { artifactVersions = new ArrayList(); versions.put( key, artifactVersions ); } if ( spec.artifact.getVersion() != null ) { artifactVersions.add( new DefaultArtifactVersion( spec.artifact.getVersion() ) ); } } public Artifact retrieveRelocatedArtifact( Artifact artifact, ArtifactRepository localRepository, List remoteRepositories ) throws ArtifactMetadataRetrievalException { return artifact; } } } maven2-core-2.2.1/maven-artifact/src/test/java/org/apache/maven/artifact/ArtifactUtilsTest.java0000644000175000017500000000515611143535775032376 0ustar twernertwernerpackage org.apache.maven.artifact; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import java.util.ArrayList; import java.util.List; import java.util.Map; import org.apache.maven.artifact.versioning.VersionRange; import junit.framework.TestCase; /** * Tests {@link ArtifactUtils}. * * @author Benjamin Bentmann * @version $Id: ArtifactUtilsTest.java 742050 2009-02-08 11:03:25Z bentmann $ */ public class ArtifactUtilsTest extends TestCase { /** * Tests that the ordering of the map resembles the ordering of the input collection of artifacts. */ public void testArtifactMapByArtifactIdOrdering() throws Exception { List list = new ArrayList(); list.add( newArtifact( "b" ) ); list.add( newArtifact( "a" ) ); list.add( newArtifact( "c" ) ); list.add( newArtifact( "e" ) ); list.add( newArtifact( "d" ) ); Map map = ArtifactUtils.artifactMapByArtifactId( list ); assertNotNull( map ); assertEquals( list, new ArrayList( map.values() ) ); } /** * Tests that the ordering of the map resembles the ordering of the input collection of artifacts. */ public void testArtifactMapByVersionlessIdOrdering() throws Exception { List list = new ArrayList(); list.add( newArtifact( "b" ) ); list.add( newArtifact( "a" ) ); list.add( newArtifact( "c" ) ); list.add( newArtifact( "e" ) ); list.add( newArtifact( "d" ) ); Map map = ArtifactUtils.artifactMapByVersionlessId( list ); assertNotNull( map ); assertEquals( list, new ArrayList( map.values() ) ); } private Artifact newArtifact( String aid ) { return new DefaultArtifact( "org.apache.maven.ut", aid, VersionRange.createFromVersion( "1.0" ), "test", "jar", "tests", null ); } } maven2-core-2.2.1/maven-artifact/src/test/java/org/apache/maven/artifact/factory/0000755000175000017500000000000011250552242027540 5ustar twernertwerner././@LongLink0000000000000000000000000000016100000000000011563 Lustar rootrootmaven2-core-2.2.1/maven-artifact/src/test/java/org/apache/maven/artifact/factory/DefaultArtifactFactoryTest.javamaven2-core-2.2.1/maven-artifact/src/test/java/org/apache/maven/artifact/factory/DefaultArtifactFact0000644000175000017500000000464110772004567033342 0ustar twernertwernerpackage org.apache.maven.artifact.factory; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.versioning.VersionRange; import org.codehaus.plexus.PlexusTestCase; public class DefaultArtifactFactoryTest extends PlexusTestCase { public void testPropagationOfSystemScopeRegardlessOfInheritedScope() throws Exception { ArtifactFactory factory = (ArtifactFactory) lookup( ArtifactFactory.ROLE ); Artifact artifact = factory.createDependencyArtifact( "test-grp", "test-artifact", VersionRange.createFromVersion("1.0"), "type", null, "system", "provided" ); Artifact artifact2 = factory.createDependencyArtifact( "test-grp", "test-artifact-2", VersionRange.createFromVersion("1.0"), "type", null, "system", "test" ); Artifact artifact3 = factory.createDependencyArtifact( "test-grp", "test-artifact-3", VersionRange.createFromVersion("1.0"), "type", null, "system", "runtime" ); Artifact artifact4 = factory.createDependencyArtifact( "test-grp", "test-artifact-4", VersionRange.createFromVersion("1.0"), "type", null, "system", "compile" ); // this one should never happen in practice... Artifact artifact5 = factory.createDependencyArtifact( "test-grp", "test-artifact-5", VersionRange.createFromVersion("1.0"), "type", null, "system", "system" ); assertEquals( "system", artifact.getScope() ); assertEquals( "system", artifact2.getScope() ); assertEquals( "system", artifact3.getScope() ); assertEquals( "system", artifact4.getScope() ); assertEquals( "system", artifact5.getScope() ); } } maven2-core-2.2.1/maven-artifact/src/test/java/org/apache/maven/artifact/versioning/0000755000175000017500000000000011250552242030254 5ustar twernertwerner././@LongLink0000000000000000000000000000016400000000000011566 Lustar rootrootmaven2-core-2.2.1/maven-artifact/src/test/java/org/apache/maven/artifact/versioning/DefaultArtifactVersionTest.javamaven2-core-2.2.1/maven-artifact/src/test/java/org/apache/maven/artifact/versioning/DefaultArtifactV0000644000175000017500000003344311033426750033401 0ustar twernertwernerpackage org.apache.maven.artifact.versioning; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import junit.framework.TestCase; /** * Test DefaultArtifactVersion. * * @author Brett Porter * @version $Id: DefaultArtifactVersionTest.java 674059 2008-07-04 14:04:24Z brett $ */ public class DefaultArtifactVersionTest extends TestCase { private ArtifactVersion newArtifactVersion( String version ) { return new DefaultArtifactVersion( version ); } private void checkVersionParsing( String version, int major, int minor, int incremental, int buildnumber, String qualifier ) { ArtifactVersion artifactVersion = newArtifactVersion( version ); String parsed = "'" + version + "' parsed as ('" + artifactVersion.getMajorVersion() + "', '" + artifactVersion.getMinorVersion() + "', '" + artifactVersion.getIncrementalVersion() + "', '" + artifactVersion.getBuildNumber() + "', '" + artifactVersion.getQualifier() + "'), "; assertEquals( parsed + "check major version", major, artifactVersion.getMajorVersion() ); assertEquals( parsed + "check minor version", minor, artifactVersion.getMinorVersion() ); assertEquals( parsed + "check incremental version", incremental, artifactVersion.getIncrementalVersion() ); assertEquals( parsed + "check build number", buildnumber, artifactVersion.getBuildNumber() ); assertEquals( parsed + "check qualifier", qualifier, artifactVersion.getQualifier() ); assertEquals( "check " + version + " string value", version, artifactVersion.toString() ); } public void testVersionParsing() { checkVersionParsing( "1" , 1, 0, 0, 0, null ); checkVersionParsing( "1.2" , 1, 2, 0, 0, null ); checkVersionParsing( "1.2.3" , 1, 2, 3, 0, null ); checkVersionParsing( "1.2.3-1" , 1, 2, 3, 1, null ); checkVersionParsing( "1.2.3-alpha-1" , 1, 2, 3, 0, "alpha-1" ); checkVersionParsing( "1.2-alpha-1" , 1, 2, 0, 0, "alpha-1" ); checkVersionParsing( "1.2-alpha-1-20050205.060708-1" , 1, 2, 0, 0, "alpha-1-20050205.060708-1" ); checkVersionParsing( "RELEASE" , 0, 0, 0, 0, "RELEASE" ); checkVersionParsing( "2.0-1" , 2, 0, 0, 1, null ); // 0 at the beginning of a number has a special handling checkVersionParsing( "02" , 0, 0, 0, 0, "02" ); checkVersionParsing( "0.09" , 0, 0, 0, 0, "0.09" ); checkVersionParsing( "0.2.09" , 0, 0, 0, 0, "0.2.09" ); checkVersionParsing( "2.0-01" , 2, 0, 0, 0, "01" ); // version schemes not really supported: fully transformed as qualifier checkVersionParsing( "1.0.1b" , 0, 0, 0, 0, "1.0.1b" ); checkVersionParsing( "1.0M2" , 0, 0, 0, 0, "1.0M2" ); checkVersionParsing( "1.0RC2" , 0, 0, 0, 0, "1.0RC2" ); checkVersionParsing( "1.7.3.0" , 0, 0, 0, 0, "1.7.3.0" ); checkVersionParsing( "1.7.3.0-1" , 0, 0, 0, 0, "1.7.3.0-1" ); checkVersionParsing( "PATCH-1193602" , 0, 0, 0, 0, "PATCH-1193602" ); checkVersionParsing( "5.0.0alpha-2006020117" , 0, 0, 0, 0, "5.0.0alpha-2006020117" ); checkVersionParsing( "1.0.0.-SNAPSHOT", 0, 0, 0, 0, "1.0.0.-SNAPSHOT" ); checkVersionParsing( "1..0-SNAPSHOT", 0, 0, 0, 0, "1..0-SNAPSHOT" ); checkVersionParsing( "1.0.-SNAPSHOT", 0, 0, 0, 0, "1.0.-SNAPSHOT" ); checkVersionParsing( ".1.0-SNAPSHOT", 0, 0, 0, 0, ".1.0-SNAPSHOT" ); checkVersionParsing( "1.2.3.200705301630" , 0, 0, 0, 0, "1.2.3.200705301630" ); checkVersionParsing( "1.2.3-200705301630" , 1, 2, 3, 0, "200705301630" ); } public void testVersionComparing() { assertVersionEqual( "1", "1" ); assertVersionOlder( "1", "2" ); assertVersionOlder( "1.5", "2" ); assertVersionOlder( "1", "2.5" ); assertVersionEqual( "1", "1.0" ); assertVersionEqual( "1", "1.0.0" ); assertVersionOlder( "1.0", "1.1" ); assertVersionOlder( "1.1", "1.2" ); assertVersionOlder( "1.0.0", "1.1" ); assertVersionOlder( "1.1", "1.2.0" ); assertVersionOlder( "1.2", "1.10" ); assertVersionOlder( "1.0-alpha-1", "1.0" ); assertVersionOlder( "1.0-alpha-1", "1.0-alpha-2" ); //assertVersionOlder( "1.0-alpha-2", "1.0-alpha-15" ); assertVersionOlder( "1.0-alpha-1", "1.0-beta-1" ); assertVersionOlder( "1.0-SNAPSHOT", "1.0-beta-1" ); assertVersionOlder( "1.0-SNAPSHOT", "1.0" ); assertVersionOlder( "1.0-alpha-1-SNAPSHOT", "1.0-alpha-1" ); assertVersionOlder( "1.0", "1.0-1" ); assertVersionOlder( "1.0-1", "1.0-2" ); assertVersionEqual( "2.0-0", "2.0" ); assertVersionOlder( "2.0", "2.0-1" ); assertVersionOlder( "2.0.0", "2.0-1" ); assertVersionOlder( "2.0-1", "2.0.1" ); assertVersionOlder( "2.0.1-klm", "2.0.1-lmn" ); assertVersionOlder( "2.0.1-xyz", "2.0.1" ); assertVersionOlder( "2.0.1", "2.0.1-123" ); assertVersionOlder( "2.0.1-xyz", "2.0.1-123" ); //assertVersionOlder( "1.1-foo-2", "1.1-foo-10" ); } public void testVersionSnapshotComparing() { assertVersionEqual( "1-SNAPSHOT", "1-SNAPSHOT" ); assertVersionOlder( "1-SNAPSHOT", "2-SNAPSHOT" ); assertVersionOlder( "1.5-SNAPSHOT", "2-SNAPSHOT" ); assertVersionOlder( "1-SNAPSHOT", "2.5-SNAPSHOT" ); assertVersionEqual( "1-SNAPSHOT", "1.0-SNAPSHOT" ); assertVersionEqual( "1-SNAPSHOT", "1.0.0-SNAPSHOT" ); assertVersionOlder( "1.0-SNAPSHOT", "1.1-SNAPSHOT" ); assertVersionOlder( "1.1-SNAPSHOT", "1.2-SNAPSHOT" ); assertVersionOlder( "1.0.0-SNAPSHOT", "1.1-SNAPSHOT" ); assertVersionOlder( "1.1-SNAPSHOT", "1.2.0-SNAPSHOT" ); //assertVersionOlder( "1.0-alpha-1-SNAPSHOT", "1.0-SNAPSHOT" ); assertVersionOlder( "1.0-alpha-1-SNAPSHOT", "1.0-alpha-2-SNAPSHOT" ); assertVersionOlder( "1.0-alpha-1-SNAPSHOT", "1.0-beta-1-SNAPSHOT" ); assertVersionOlder( "1.0-SNAPSHOT-SNAPSHOT", "1.0-beta-1-SNAPSHOT" ); assertVersionOlder( "1.0-SNAPSHOT-SNAPSHOT", "1.0-SNAPSHOT" ); assertVersionOlder( "1.0-alpha-1-SNAPSHOT-SNAPSHOT", "1.0-alpha-1-SNAPSHOT" ); //assertVersionOlder( "1.0-SNAPSHOT", "1.0-1-SNAPSHOT" ); //assertVersionOlder( "1.0-1-SNAPSHOT", "1.0-2-SNAPSHOT" ); //assertVersionEqual( "2.0-0-SNAPSHOT", "2.0-SNAPSHOT" ); //assertVersionOlder( "2.0-SNAPSHOT", "2.0-1-SNAPSHOT" ); //assertVersionOlder( "2.0.0-SNAPSHOT", "2.0-1-SNAPSHOT" ); assertVersionOlder( "2.0-1-SNAPSHOT", "2.0.1-SNAPSHOT" ); assertVersionOlder( "2.0.1-klm-SNAPSHOT", "2.0.1-lmn-SNAPSHOT" ); // assertVersionOlder( "2.0.1-xyz-SNAPSHOT", "2.0.1-SNAPSHOT" ); //assertVersionOlder( "2.0.1-SNAPSHOT", "2.0.1-123-SNAPSHOT" ); //assertVersionOlder( "2.0.1-xyz-SNAPSHOT", "2.0.1-123-SNAPSHOT" ); } public void testSnapshotVsReleases() { assertVersionOlder( "1.0-RC1", "1.0-SNAPSHOT" ); //assertVersionOlder( "1.0-rc1", "1.0-SNAPSHOT" ); //assertVersionOlder( "1.0-rc-1", "1.0-SNAPSHOT" ); } private void assertVersionOlder( String left, String right ) { assertTrue( left + " should be older than " + right, newArtifactVersion( left ).compareTo( newArtifactVersion( right ) ) < 0 ); assertTrue( right + " should be newer than " + left, newArtifactVersion( right ).compareTo( newArtifactVersion( left ) ) > 0 ); } private void assertVersionEqual( String left, String right ) { assertTrue( left + " should be equal to " + right, newArtifactVersion( left ).compareTo( newArtifactVersion( right ) ) == 0 ); assertTrue( right + " should be equal to " + left, newArtifactVersion( right ).compareTo( newArtifactVersion( left ) ) == 0 ); } public void testVersionComparingWithBuildNumberZero() { ArtifactVersion v1 = newArtifactVersion( "2.0" ); ArtifactVersion v2 = newArtifactVersion( "2.0-0" ); ArtifactVersion v3 = newArtifactVersion( "2.0-alpha1" ); ArtifactVersion v4 = newArtifactVersion( "2.0-1" ); // v1 and v2 are equal assertTrue( v1.compareTo( v2 ) == 0 ); assertTrue( v2.compareTo( v1 ) == 0 ); // v1 is newer than v3 assertTrue( v1.compareTo( v3 ) > 0 ); assertTrue( v3.compareTo( v1 ) < 0 ); // ergo, v2 should also be newer than v3 assertTrue( v2.compareTo( v3 ) > 0 ); assertTrue( v3.compareTo( v1 ) < 0 ); // nonzero build numbers still respected assertTrue( v1.compareTo( v4 ) < 0 ); // build number one is always newer assertTrue( v4.compareTo( v1 ) > 0 ); assertTrue( v2.compareTo( v4 ) < 0 ); // same results as v1 assertTrue( v4.compareTo( v2 ) > 0 ); assertTrue( v3.compareTo( v4 ) < 0 ); // qualifier is always older assertTrue( v4.compareTo( v3 ) > 0 ); } public void testCompareToEqualsHashCodeConsistency() { ArtifactVersion v1; ArtifactVersion v2; // equal to itself v1 = newArtifactVersion( "1.3" ); v2 = v1; assertTrue( v1.equals( v2 ) && v2.equals( v1 ) && ( v1.hashCode() == v2.hashCode() ) && ( v1.compareTo( v2 ) == 0 ) && ( v2.compareTo( v1 ) == 0 ) ); // equal to something that means the same v1 = newArtifactVersion( "1" ); v2 = newArtifactVersion( "1.0.0-0" ); assertTrue( v1.equals( v2 ) && v2.equals( v1 ) && ( v1.hashCode() == v2.hashCode() ) && ( v1.compareTo( v2 ) == 0 ) && ( v2.compareTo( v1 ) == 0 ) ); // equal with qualifier v1 = newArtifactVersion( "1.3-alpha1" ); v2 = newArtifactVersion( "1.3-alpha1" ); assertTrue( v1.equals( v2 ) && v2.equals( v1 ) && ( v1.hashCode() == v2.hashCode() ) && ( v1.compareTo( v2 ) == 0 ) && ( v2.compareTo( v1 ) == 0 ) ); // longer qualifier with same start is *newer* v1 = newArtifactVersion( "1.3-alpha1" ); v2 = newArtifactVersion( "1.3-alpha1-1" ); assertTrue( !v1.equals( v2 ) && !v2.equals( v1 ) && ( v1.compareTo( v2 ) > 0 ) && ( v2.compareTo( v1 ) < 0 ) ); // different qualifiers alpha compared v1 = newArtifactVersion( "1.3-alpha1" ); v2 = newArtifactVersion( "1.3-beta1" ); assertTrue( !v1.equals( v2 ) && !v2.equals( v1 ) && ( v1.compareTo( v2 ) < 0 ) && ( v2.compareTo( v1 ) > 0 ) ); } public void testTransitivity() { ArtifactVersion v1 = newArtifactVersion( "1" ); ArtifactVersion v2 = newArtifactVersion( "1.0-0" ); ArtifactVersion v3 = newArtifactVersion( "1.0.1" ); ArtifactVersion v4 = newArtifactVersion( "1.0-beta1" ); // v1 and v2 are equal assertTrue( v1.equals( v2 ) && v2.equals( v1 ) && ( v1.compareTo( v2 ) == 0 ) && ( v2.compareTo( v1 ) == 0 ) ); // v1 is older than v3 assertTrue( !v1.equals( v3 ) && !v3.equals( v1 ) && ( v1.compareTo( v3 ) < 0 ) && ( v3.compareTo( v1 ) > 0 ) ); // ergo, v2 is older than v3 assertTrue( !v2.equals( v3 ) && !v3.equals( v2 ) && ( v2.compareTo( v3 ) < 0 ) && ( v3.compareTo( v2 ) > 0 ) ); // v1 is newer than v4 assertTrue( !v1.equals( v4 ) && !v4.equals( v1 ) && ( v1.compareTo( v4 ) > 0 ) && ( v4.compareTo( v1 ) < 0 ) ); // ergo, v2 is newer than v4 assertTrue( !v2.equals( v4 ) && !v4.equals( v2 ) && ( v2.compareTo( v4 ) > 0 ) && ( v4.compareTo( v2 ) < 0 ) ); } private void testInterfaceCompare( String version ) { final ArtifactVersion dav = newArtifactVersion( version ); // create an anonymous instance to compare the big daddy to ArtifactVersion av = new ArtifactVersion() { public int getMajorVersion() { return dav.getMajorVersion(); } public int getMinorVersion() { return dav.getMinorVersion(); } public int getIncrementalVersion() { return dav.getIncrementalVersion(); } public int getBuildNumber() { return dav.getBuildNumber(); } public String getQualifier() { return dav.getQualifier(); } // required by interface but unused for our test public int compareTo( Object o ) { return 0; /* bogus */ } public void parseVersion( String s ) { /* bogus */ } }; assertTrue( dav.equals( av ) ); assertTrue( dav.compareTo( av ) == 0 ); } public void testInterfaceCompares() { testInterfaceCompare( "1" ); testInterfaceCompare( "1.2" ); testInterfaceCompare( "1.2.3" ); testInterfaceCompare( "1.2.3-4" ); testInterfaceCompare( "1.2.3-four" ); testInterfaceCompare( "1-2" ); testInterfaceCompare( "1-two" ); } } ././@LongLink0000000000000000000000000000015200000000000011563 Lustar rootrootmaven2-core-2.2.1/maven-artifact/src/test/java/org/apache/maven/artifact/versioning/VersionRangeTest.javamaven2-core-2.2.1/maven-artifact/src/test/java/org/apache/maven/artifact/versioning/VersionRangeTest0000644000175000017500000012277510772004567033471 0ustar twernertwernerpackage org.apache.maven.artifact.versioning; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import junit.framework.TestCase; import java.util.List; import org.apache.maven.artifact.Artifact; /** * Tests version range construction. * * @author Brett Porter * @version $Id: VersionRangeTest.java 640549 2008-03-24 20:05:11Z bentmann $ */ public class VersionRangeTest extends TestCase { private static final String CHECK_NUM_RESTRICTIONS = "check number of restrictions"; private static final String CHECK_UPPER_BOUND = "check upper bound"; private static final String CHECK_UPPER_BOUND_INCLUSIVE = "check upper bound is inclusive"; private static final String CHECK_LOWER_BOUND = "check lower bound"; private static final String CHECK_LOWER_BOUND_INCLUSIVE = "check lower bound is inclusive"; private static final String CHECK_VERSION_RECOMMENDATION = "check version recommended"; private static final String CHECK_SELECTED_VERSION_KNOWN = "check selected version known"; private static final String CHECK_SELECTED_VERSION = "check selected version"; public void testRange() throws InvalidVersionSpecificationException, OverConstrainedVersionException { Artifact artifact = null; VersionRange range = VersionRange.createFromVersionSpec( "(,1.0]" ); List restrictions = range.getRestrictions(); assertEquals( CHECK_NUM_RESTRICTIONS, 1, restrictions.size() ); Restriction restriction = (Restriction) restrictions.get( 0 ); assertNull( CHECK_LOWER_BOUND, restriction.getLowerBound() ); assertFalse( CHECK_LOWER_BOUND_INCLUSIVE, restriction.isLowerBoundInclusive() ); assertEquals( CHECK_UPPER_BOUND, "1.0", restriction.getUpperBound().toString() ); assertTrue( CHECK_UPPER_BOUND_INCLUSIVE, restriction.isUpperBoundInclusive() ); assertNull( CHECK_VERSION_RECOMMENDATION, range.getRecommendedVersion() ); assertFalse( CHECK_SELECTED_VERSION_KNOWN, range.isSelectedVersionKnown( artifact ) ); assertNull( CHECK_SELECTED_VERSION, range.getSelectedVersion( artifact ) ); range = VersionRange.createFromVersionSpec( "1.0" ); assertEquals( CHECK_VERSION_RECOMMENDATION, "1.0", range.getRecommendedVersion().toString() ); restrictions = range.getRestrictions(); assertEquals( CHECK_NUM_RESTRICTIONS, 1, restrictions.size() ); restriction = (Restriction) restrictions.get( 0 ); assertNull( CHECK_LOWER_BOUND, restriction.getLowerBound() ); assertFalse( CHECK_LOWER_BOUND_INCLUSIVE, restriction.isLowerBoundInclusive() ); assertNull( CHECK_UPPER_BOUND, restriction.getUpperBound() ); assertFalse( CHECK_UPPER_BOUND_INCLUSIVE, restriction.isUpperBoundInclusive() ); assertTrue( CHECK_SELECTED_VERSION_KNOWN, range.isSelectedVersionKnown( artifact ) ); assertEquals( CHECK_SELECTED_VERSION, "1.0", range.getSelectedVersion( artifact ).toString() ); range = VersionRange.createFromVersionSpec( "[1.0]" ); restrictions = range.getRestrictions(); assertEquals( CHECK_NUM_RESTRICTIONS, 1, restrictions.size() ); restriction = (Restriction) restrictions.get( 0 ); assertEquals( CHECK_LOWER_BOUND, "1.0", restriction.getLowerBound().toString() ); assertTrue( CHECK_LOWER_BOUND_INCLUSIVE, restriction.isLowerBoundInclusive() ); assertEquals( CHECK_UPPER_BOUND, "1.0", restriction.getUpperBound().toString() ); assertTrue( CHECK_UPPER_BOUND_INCLUSIVE, restriction.isUpperBoundInclusive() ); assertNull( CHECK_VERSION_RECOMMENDATION, range.getRecommendedVersion() ); assertFalse( CHECK_SELECTED_VERSION_KNOWN, range.isSelectedVersionKnown( artifact ) ); assertNull( CHECK_SELECTED_VERSION, range.getSelectedVersion( artifact ) ); range = VersionRange.createFromVersionSpec( "[1.2,1.3]" ); restrictions = range.getRestrictions(); assertEquals( CHECK_NUM_RESTRICTIONS, 1, restrictions.size() ); restriction = (Restriction) restrictions.get( 0 ); assertEquals( CHECK_LOWER_BOUND, "1.2", restriction.getLowerBound().toString() ); assertTrue( CHECK_LOWER_BOUND_INCLUSIVE, restriction.isLowerBoundInclusive() ); assertEquals( CHECK_UPPER_BOUND, "1.3", restriction.getUpperBound().toString() ); assertTrue( CHECK_UPPER_BOUND_INCLUSIVE, restriction.isUpperBoundInclusive() ); assertNull( CHECK_VERSION_RECOMMENDATION, range.getRecommendedVersion() ); assertFalse( CHECK_SELECTED_VERSION_KNOWN, range.isSelectedVersionKnown( artifact ) ); assertNull( CHECK_SELECTED_VERSION, range.getSelectedVersion( artifact ) ); range = VersionRange.createFromVersionSpec( "[1.0,2.0)" ); restrictions = range.getRestrictions(); assertEquals( CHECK_NUM_RESTRICTIONS, 1, restrictions.size() ); restriction = (Restriction) restrictions.get( 0 ); assertEquals( CHECK_LOWER_BOUND, "1.0", restriction.getLowerBound().toString() ); assertTrue( CHECK_LOWER_BOUND_INCLUSIVE, restriction.isLowerBoundInclusive() ); assertEquals( CHECK_UPPER_BOUND, "2.0", restriction.getUpperBound().toString() ); assertFalse( CHECK_UPPER_BOUND_INCLUSIVE, restriction.isUpperBoundInclusive() ); assertNull( CHECK_VERSION_RECOMMENDATION, range.getRecommendedVersion() ); assertFalse( CHECK_SELECTED_VERSION_KNOWN, range.isSelectedVersionKnown( artifact ) ); assertNull( CHECK_SELECTED_VERSION, range.getSelectedVersion( artifact ) ); range = VersionRange.createFromVersionSpec( "[1.5,)" ); restrictions = range.getRestrictions(); assertEquals( CHECK_NUM_RESTRICTIONS, 1, restrictions.size() ); restriction = (Restriction) restrictions.get( 0 ); assertEquals( CHECK_LOWER_BOUND, "1.5", restriction.getLowerBound().toString() ); assertTrue( CHECK_LOWER_BOUND_INCLUSIVE, restriction.isLowerBoundInclusive() ); assertNull( CHECK_UPPER_BOUND, restriction.getUpperBound() ); assertFalse( CHECK_UPPER_BOUND_INCLUSIVE, restriction.isUpperBoundInclusive() ); assertNull( CHECK_VERSION_RECOMMENDATION, range.getRecommendedVersion() ); assertFalse( CHECK_SELECTED_VERSION_KNOWN, range.isSelectedVersionKnown( artifact ) ); assertNull( CHECK_SELECTED_VERSION, range.getSelectedVersion( artifact ) ); range = VersionRange.createFromVersionSpec( "(,1.0],[1.2,)" ); restrictions = range.getRestrictions(); assertEquals( CHECK_NUM_RESTRICTIONS, 2, restrictions.size() ); restriction = (Restriction) restrictions.get( 0 ); assertNull( CHECK_LOWER_BOUND, restriction.getLowerBound() ); assertFalse( CHECK_LOWER_BOUND_INCLUSIVE, restriction.isLowerBoundInclusive() ); assertEquals( CHECK_UPPER_BOUND, "1.0", restriction.getUpperBound().toString() ); assertTrue( CHECK_UPPER_BOUND_INCLUSIVE, restriction.isUpperBoundInclusive() ); assertNull( CHECK_VERSION_RECOMMENDATION, range.getRecommendedVersion() ); restriction = (Restriction) restrictions.get( 1 ); assertEquals( CHECK_LOWER_BOUND, "1.2", restriction.getLowerBound().toString() ); assertTrue( CHECK_LOWER_BOUND_INCLUSIVE, restriction.isLowerBoundInclusive() ); assertNull( CHECK_UPPER_BOUND, restriction.getUpperBound() ); assertFalse( CHECK_UPPER_BOUND_INCLUSIVE, restriction.isUpperBoundInclusive() ); assertNull( CHECK_VERSION_RECOMMENDATION, range.getRecommendedVersion() ); assertFalse( CHECK_SELECTED_VERSION_KNOWN, range.isSelectedVersionKnown( artifact ) ); assertNull( CHECK_SELECTED_VERSION, range.getSelectedVersion( artifact ) ); } public void testInvalidRanges() { checkInvalidRange( "(1.0)" ); checkInvalidRange( "[1.0)" ); checkInvalidRange( "(1.0]" ); checkInvalidRange( "(1.0,1.0]" ); checkInvalidRange( "[1.0,1.0)" ); checkInvalidRange( "(1.0,1.0)" ); checkInvalidRange( "[1.1,1.0]" ); checkInvalidRange( "[1.0,1.2),1.3" ); // overlap checkInvalidRange( "[1.0,1.2),(1.1,1.3]" ); // overlap checkInvalidRange( "[1.1,1.3),(1.0,1.2]" ); // ordering checkInvalidRange( "(1.1,1.2],[1.0,1.1)" ); } public void testIntersections() throws InvalidVersionSpecificationException { VersionRange range1 = VersionRange.createFromVersionSpec( "1.0" ); VersionRange range2 = VersionRange.createFromVersionSpec( "1.1" ); VersionRange mergedRange = range1.restrict( range2 ); // TODO: current policy is to retain the original version - is this correct, do we need strategies or is that handled elsewhere? // assertEquals( CHECK_VERSION_RECOMMENDATION, "1.1", mergedRange.getRecommendedVersion().toString() ); assertEquals( CHECK_VERSION_RECOMMENDATION, "1.0", mergedRange.getRecommendedVersion().toString() ); List restrictions = mergedRange.getRestrictions(); assertEquals( CHECK_NUM_RESTRICTIONS, 1, restrictions.size() ); Restriction restriction = (Restriction) restrictions.get( 0 ); assertNull( CHECK_LOWER_BOUND, restriction.getLowerBound() ); assertFalse( CHECK_LOWER_BOUND_INCLUSIVE, restriction.isLowerBoundInclusive() ); assertNull( CHECK_UPPER_BOUND, restriction.getUpperBound() ); assertFalse( CHECK_UPPER_BOUND_INCLUSIVE, restriction.isUpperBoundInclusive() ); mergedRange = range2.restrict( range1 ); assertEquals( CHECK_VERSION_RECOMMENDATION, "1.1", mergedRange.getRecommendedVersion().toString() ); restrictions = mergedRange.getRestrictions(); assertEquals( CHECK_NUM_RESTRICTIONS, 1, restrictions.size() ); restriction = (Restriction) restrictions.get( 0 ); assertNull( CHECK_LOWER_BOUND, restriction.getLowerBound() ); assertFalse( CHECK_LOWER_BOUND_INCLUSIVE, restriction.isLowerBoundInclusive() ); assertNull( CHECK_UPPER_BOUND, restriction.getUpperBound() ); assertFalse( CHECK_UPPER_BOUND_INCLUSIVE, restriction.isUpperBoundInclusive() ); // TODO: test reversed restrictions on all below range1 = VersionRange.createFromVersionSpec( "[1.0,)" ); range2 = VersionRange.createFromVersionSpec( "1.1" ); mergedRange = range1.restrict( range2 ); assertEquals( CHECK_VERSION_RECOMMENDATION, "1.1", mergedRange.getRecommendedVersion().toString() ); restrictions = mergedRange.getRestrictions(); assertEquals( CHECK_NUM_RESTRICTIONS, 1, restrictions.size() ); restriction = (Restriction) restrictions.get( 0 ); assertEquals( CHECK_LOWER_BOUND, "1.0", restriction.getLowerBound().toString() ); assertTrue( CHECK_LOWER_BOUND_INCLUSIVE, restriction.isLowerBoundInclusive() ); assertNull( CHECK_UPPER_BOUND, restriction.getUpperBound() ); assertFalse( CHECK_UPPER_BOUND_INCLUSIVE, restriction.isUpperBoundInclusive() ); range1 = VersionRange.createFromVersionSpec( "[1.1,)" ); range2 = VersionRange.createFromVersionSpec( "1.1" ); mergedRange = range1.restrict( range2 ); assertEquals( CHECK_VERSION_RECOMMENDATION, "1.1", mergedRange.getRecommendedVersion().toString() ); restrictions = mergedRange.getRestrictions(); assertEquals( CHECK_NUM_RESTRICTIONS, 1, restrictions.size() ); restriction = (Restriction) restrictions.get( 0 ); assertEquals( CHECK_LOWER_BOUND, "1.1", restriction.getLowerBound().toString() ); assertTrue( CHECK_LOWER_BOUND_INCLUSIVE, restriction.isLowerBoundInclusive() ); assertNull( CHECK_UPPER_BOUND, restriction.getUpperBound() ); assertFalse( CHECK_UPPER_BOUND_INCLUSIVE, restriction.isUpperBoundInclusive() ); range1 = VersionRange.createFromVersionSpec( "[1.1]" ); range2 = VersionRange.createFromVersionSpec( "1.1" ); mergedRange = range1.restrict( range2 ); assertEquals( CHECK_VERSION_RECOMMENDATION, "1.1", mergedRange.getRecommendedVersion().toString() ); restrictions = mergedRange.getRestrictions(); assertEquals( CHECK_NUM_RESTRICTIONS, 1, restrictions.size() ); restriction = (Restriction) restrictions.get( 0 ); assertEquals( CHECK_LOWER_BOUND, "1.1", restriction.getLowerBound().toString() ); assertTrue( CHECK_LOWER_BOUND_INCLUSIVE, restriction.isLowerBoundInclusive() ); assertEquals( CHECK_UPPER_BOUND, "1.1", restriction.getLowerBound().toString() ); assertTrue( CHECK_UPPER_BOUND_INCLUSIVE, restriction.isUpperBoundInclusive() ); range1 = VersionRange.createFromVersionSpec( "(1.1,)" ); range2 = VersionRange.createFromVersionSpec( "1.1" ); mergedRange = range1.restrict( range2 ); assertNull( CHECK_VERSION_RECOMMENDATION, mergedRange.getRecommendedVersion() ); restrictions = mergedRange.getRestrictions(); assertEquals( CHECK_NUM_RESTRICTIONS, 1, restrictions.size() ); restriction = (Restriction) restrictions.get( 0 ); assertEquals( CHECK_LOWER_BOUND, "1.1", restriction.getLowerBound().toString() ); assertFalse( CHECK_LOWER_BOUND_INCLUSIVE, restriction.isLowerBoundInclusive() ); assertNull( CHECK_UPPER_BOUND, restriction.getUpperBound() ); assertFalse( CHECK_UPPER_BOUND_INCLUSIVE, restriction.isUpperBoundInclusive() ); range1 = VersionRange.createFromVersionSpec( "[1.2,)" ); range2 = VersionRange.createFromVersionSpec( "1.1" ); mergedRange = range1.restrict( range2 ); assertNull( CHECK_VERSION_RECOMMENDATION, mergedRange.getRecommendedVersion() ); restrictions = mergedRange.getRestrictions(); assertEquals( CHECK_NUM_RESTRICTIONS, 1, restrictions.size() ); restriction = (Restriction) restrictions.get( 0 ); assertEquals( CHECK_LOWER_BOUND, "1.2", restriction.getLowerBound().toString() ); assertTrue( CHECK_LOWER_BOUND_INCLUSIVE, restriction.isLowerBoundInclusive() ); assertNull( CHECK_UPPER_BOUND, restriction.getUpperBound() ); assertFalse( CHECK_UPPER_BOUND_INCLUSIVE, restriction.isUpperBoundInclusive() ); range1 = VersionRange.createFromVersionSpec( "(,1.2]" ); range2 = VersionRange.createFromVersionSpec( "1.1" ); mergedRange = range1.restrict( range2 ); assertEquals( CHECK_VERSION_RECOMMENDATION, "1.1", mergedRange.getRecommendedVersion().toString() ); restrictions = mergedRange.getRestrictions(); assertEquals( CHECK_NUM_RESTRICTIONS, 1, restrictions.size() ); restriction = (Restriction) restrictions.get( 0 ); assertNull( CHECK_LOWER_BOUND, restriction.getLowerBound() ); assertFalse( CHECK_LOWER_BOUND_INCLUSIVE, restriction.isLowerBoundInclusive() ); assertEquals( CHECK_UPPER_BOUND, "1.2", restriction.getUpperBound().toString() ); assertTrue( CHECK_UPPER_BOUND_INCLUSIVE, restriction.isUpperBoundInclusive() ); range1 = VersionRange.createFromVersionSpec( "(,1.1]" ); range2 = VersionRange.createFromVersionSpec( "1.1" ); mergedRange = range1.restrict( range2 ); assertEquals( CHECK_VERSION_RECOMMENDATION, "1.1", mergedRange.getRecommendedVersion().toString() ); restrictions = mergedRange.getRestrictions(); assertEquals( CHECK_NUM_RESTRICTIONS, 1, restrictions.size() ); restriction = (Restriction) restrictions.get( 0 ); assertNull( CHECK_LOWER_BOUND, restriction.getLowerBound() ); assertFalse( CHECK_LOWER_BOUND_INCLUSIVE, restriction.isLowerBoundInclusive() ); assertEquals( CHECK_UPPER_BOUND, "1.1", restriction.getUpperBound().toString() ); assertTrue( CHECK_UPPER_BOUND_INCLUSIVE, restriction.isUpperBoundInclusive() ); range1 = VersionRange.createFromVersionSpec( "(,1.1)" ); range2 = VersionRange.createFromVersionSpec( "1.1" ); mergedRange = range1.restrict( range2 ); assertNull( CHECK_VERSION_RECOMMENDATION, mergedRange.getRecommendedVersion() ); restrictions = mergedRange.getRestrictions(); assertEquals( CHECK_NUM_RESTRICTIONS, 1, restrictions.size() ); restriction = (Restriction) restrictions.get( 0 ); assertNull( CHECK_LOWER_BOUND, restriction.getLowerBound() ); assertFalse( CHECK_LOWER_BOUND_INCLUSIVE, restriction.isLowerBoundInclusive() ); assertEquals( CHECK_UPPER_BOUND, "1.1", restriction.getUpperBound().toString() ); assertFalse( CHECK_UPPER_BOUND_INCLUSIVE, restriction.isUpperBoundInclusive() ); range1 = VersionRange.createFromVersionSpec( "(,1.0]" ); range2 = VersionRange.createFromVersionSpec( "1.1" ); mergedRange = range1.restrict( range2 ); assertNull( CHECK_VERSION_RECOMMENDATION, mergedRange.getRecommendedVersion() ); restrictions = mergedRange.getRestrictions(); assertEquals( CHECK_NUM_RESTRICTIONS, 1, restrictions.size() ); restriction = (Restriction) restrictions.get( 0 ); assertNull( CHECK_LOWER_BOUND, restriction.getLowerBound() ); assertFalse( CHECK_LOWER_BOUND_INCLUSIVE, restriction.isLowerBoundInclusive() ); assertEquals( CHECK_UPPER_BOUND, "1.0", restriction.getUpperBound().toString() ); assertTrue( CHECK_UPPER_BOUND_INCLUSIVE, restriction.isUpperBoundInclusive() ); range1 = VersionRange.createFromVersionSpec( "(,1.0], [1.1,)" ); range2 = VersionRange.createFromVersionSpec( "1.2" ); mergedRange = range1.restrict( range2 ); assertEquals( CHECK_VERSION_RECOMMENDATION, "1.2", mergedRange.getRecommendedVersion().toString() ); restrictions = mergedRange.getRestrictions(); assertEquals( CHECK_NUM_RESTRICTIONS, 2, restrictions.size() ); restriction = (Restriction) restrictions.get( 0 ); assertNull( CHECK_LOWER_BOUND, restriction.getLowerBound() ); assertFalse( CHECK_LOWER_BOUND_INCLUSIVE, restriction.isLowerBoundInclusive() ); assertEquals( CHECK_UPPER_BOUND, "1.0", restriction.getUpperBound().toString() ); assertTrue( CHECK_UPPER_BOUND_INCLUSIVE, restriction.isUpperBoundInclusive() ); restriction = (Restriction) restrictions.get( 1 ); assertEquals( CHECK_LOWER_BOUND, "1.1", restriction.getLowerBound().toString() ); assertTrue( CHECK_LOWER_BOUND_INCLUSIVE, restriction.isLowerBoundInclusive() ); assertNull( CHECK_UPPER_BOUND, restriction.getUpperBound() ); assertFalse( CHECK_UPPER_BOUND_INCLUSIVE, restriction.isUpperBoundInclusive() ); range1 = VersionRange.createFromVersionSpec( "(,1.0], [1.1,)" ); range2 = VersionRange.createFromVersionSpec( "1.0.5" ); mergedRange = range1.restrict( range2 ); assertNull( CHECK_VERSION_RECOMMENDATION, mergedRange.getRecommendedVersion() ); restrictions = mergedRange.getRestrictions(); assertEquals( CHECK_NUM_RESTRICTIONS, 2, restrictions.size() ); restriction = (Restriction) restrictions.get( 0 ); assertNull( CHECK_LOWER_BOUND, restriction.getLowerBound() ); assertFalse( CHECK_LOWER_BOUND_INCLUSIVE, restriction.isLowerBoundInclusive() ); assertEquals( CHECK_UPPER_BOUND, "1.0", restriction.getUpperBound().toString() ); assertTrue( CHECK_UPPER_BOUND_INCLUSIVE, restriction.isUpperBoundInclusive() ); restriction = (Restriction) restrictions.get( 1 ); assertEquals( CHECK_LOWER_BOUND, "1.1", restriction.getLowerBound().toString() ); assertTrue( CHECK_LOWER_BOUND_INCLUSIVE, restriction.isLowerBoundInclusive() ); assertNull( CHECK_UPPER_BOUND, restriction.getUpperBound() ); assertFalse( CHECK_UPPER_BOUND_INCLUSIVE, restriction.isUpperBoundInclusive() ); range1 = VersionRange.createFromVersionSpec( "(,1.1), (1.1,)" ); range2 = VersionRange.createFromVersionSpec( "1.1" ); mergedRange = range1.restrict( range2 ); assertNull( CHECK_VERSION_RECOMMENDATION, mergedRange.getRecommendedVersion() ); restrictions = mergedRange.getRestrictions(); assertEquals( CHECK_NUM_RESTRICTIONS, 2, restrictions.size() ); restriction = (Restriction) restrictions.get( 0 ); assertNull( CHECK_LOWER_BOUND, restriction.getLowerBound() ); assertFalse( CHECK_LOWER_BOUND_INCLUSIVE, restriction.isLowerBoundInclusive() ); assertEquals( CHECK_UPPER_BOUND, "1.1", restriction.getUpperBound().toString() ); assertFalse( CHECK_UPPER_BOUND_INCLUSIVE, restriction.isUpperBoundInclusive() ); restriction = (Restriction) restrictions.get( 1 ); assertEquals( CHECK_LOWER_BOUND, "1.1", restriction.getLowerBound().toString() ); assertFalse( CHECK_LOWER_BOUND_INCLUSIVE, restriction.isLowerBoundInclusive() ); assertNull( CHECK_UPPER_BOUND, restriction.getUpperBound() ); assertFalse( CHECK_UPPER_BOUND_INCLUSIVE, restriction.isUpperBoundInclusive() ); range1 = VersionRange.createFromVersionSpec( "[1.1,1.3]" ); range2 = VersionRange.createFromVersionSpec( "(1.1,)" ); mergedRange = range1.restrict( range2 ); assertNull( CHECK_VERSION_RECOMMENDATION, mergedRange.getRecommendedVersion() ); restrictions = mergedRange.getRestrictions(); assertEquals( CHECK_NUM_RESTRICTIONS, 1, restrictions.size() ); restriction = (Restriction) restrictions.get( 0 ); assertEquals( CHECK_LOWER_BOUND, "1.1", restriction.getLowerBound().toString() ); assertFalse( CHECK_LOWER_BOUND_INCLUSIVE, restriction.isLowerBoundInclusive() ); assertEquals( CHECK_UPPER_BOUND, "1.3", restriction.getUpperBound().toString() ); assertTrue( CHECK_UPPER_BOUND_INCLUSIVE, restriction.isUpperBoundInclusive() ); range1 = VersionRange.createFromVersionSpec( "(,1.3)" ); range2 = VersionRange.createFromVersionSpec( "[1.2,1.3]" ); mergedRange = range1.restrict( range2 ); assertNull( CHECK_VERSION_RECOMMENDATION, mergedRange.getRecommendedVersion() ); restrictions = mergedRange.getRestrictions(); assertEquals( CHECK_NUM_RESTRICTIONS, 1, restrictions.size() ); restriction = (Restriction) restrictions.get( 0 ); assertEquals( CHECK_LOWER_BOUND, "1.2", restriction.getLowerBound().toString() ); assertTrue( CHECK_LOWER_BOUND_INCLUSIVE, restriction.isLowerBoundInclusive() ); assertEquals( CHECK_UPPER_BOUND, "1.3", restriction.getUpperBound().toString() ); assertFalse( CHECK_UPPER_BOUND_INCLUSIVE, restriction.isUpperBoundInclusive() ); range1 = VersionRange.createFromVersionSpec( "[1.1,1.3]" ); range2 = VersionRange.createFromVersionSpec( "[1.2,)" ); mergedRange = range1.restrict( range2 ); assertNull( CHECK_VERSION_RECOMMENDATION, mergedRange.getRecommendedVersion() ); restrictions = mergedRange.getRestrictions(); assertEquals( CHECK_NUM_RESTRICTIONS, 1, restrictions.size() ); restriction = (Restriction) restrictions.get( 0 ); assertEquals( CHECK_LOWER_BOUND, "1.2", restriction.getLowerBound().toString() ); assertTrue( CHECK_LOWER_BOUND_INCLUSIVE, restriction.isLowerBoundInclusive() ); assertEquals( CHECK_UPPER_BOUND, "1.3", restriction.getUpperBound().toString() ); assertTrue( CHECK_UPPER_BOUND_INCLUSIVE, restriction.isUpperBoundInclusive() ); range1 = VersionRange.createFromVersionSpec( "(,1.3]" ); range2 = VersionRange.createFromVersionSpec( "[1.2,1.4]" ); mergedRange = range1.restrict( range2 ); assertNull( CHECK_VERSION_RECOMMENDATION, mergedRange.getRecommendedVersion() ); restrictions = mergedRange.getRestrictions(); assertEquals( CHECK_NUM_RESTRICTIONS, 1, restrictions.size() ); restriction = (Restriction) restrictions.get( 0 ); assertEquals( CHECK_LOWER_BOUND, "1.2", restriction.getLowerBound().toString() ); assertTrue( CHECK_LOWER_BOUND_INCLUSIVE, restriction.isLowerBoundInclusive() ); assertEquals( CHECK_UPPER_BOUND, "1.3", restriction.getUpperBound().toString() ); assertTrue( CHECK_UPPER_BOUND_INCLUSIVE, restriction.isUpperBoundInclusive() ); range1 = VersionRange.createFromVersionSpec( "(1.2,1.3]" ); range2 = VersionRange.createFromVersionSpec( "[1.1,1.4]" ); mergedRange = range1.restrict( range2 ); assertNull( CHECK_VERSION_RECOMMENDATION, mergedRange.getRecommendedVersion() ); restrictions = mergedRange.getRestrictions(); assertEquals( CHECK_NUM_RESTRICTIONS, 1, restrictions.size() ); restriction = (Restriction) restrictions.get( 0 ); assertEquals( CHECK_LOWER_BOUND, "1.2", restriction.getLowerBound().toString() ); assertFalse( CHECK_LOWER_BOUND_INCLUSIVE, restriction.isLowerBoundInclusive() ); assertEquals( CHECK_UPPER_BOUND, "1.3", restriction.getUpperBound().toString() ); assertTrue( CHECK_UPPER_BOUND_INCLUSIVE, restriction.isUpperBoundInclusive() ); range1 = VersionRange.createFromVersionSpec( "(1.2,1.3)" ); range2 = VersionRange.createFromVersionSpec( "[1.1,1.4]" ); mergedRange = range1.restrict( range2 ); assertNull( CHECK_VERSION_RECOMMENDATION, mergedRange.getRecommendedVersion() ); restrictions = mergedRange.getRestrictions(); assertEquals( CHECK_NUM_RESTRICTIONS, 1, restrictions.size() ); restriction = (Restriction) restrictions.get( 0 ); assertEquals( CHECK_LOWER_BOUND, "1.2", restriction.getLowerBound().toString() ); assertFalse( CHECK_LOWER_BOUND_INCLUSIVE, restriction.isLowerBoundInclusive() ); assertEquals( CHECK_UPPER_BOUND, "1.3", restriction.getUpperBound().toString() ); assertFalse( CHECK_UPPER_BOUND_INCLUSIVE, restriction.isUpperBoundInclusive() ); range1 = VersionRange.createFromVersionSpec( "[1.2,1.3)" ); range2 = VersionRange.createFromVersionSpec( "[1.1,1.4]" ); mergedRange = range1.restrict( range2 ); assertNull( CHECK_VERSION_RECOMMENDATION, mergedRange.getRecommendedVersion() ); restrictions = mergedRange.getRestrictions(); assertEquals( CHECK_NUM_RESTRICTIONS, 1, restrictions.size() ); restriction = (Restriction) restrictions.get( 0 ); assertEquals( CHECK_LOWER_BOUND, "1.2", restriction.getLowerBound().toString() ); assertTrue( CHECK_LOWER_BOUND_INCLUSIVE, restriction.isLowerBoundInclusive() ); assertEquals( CHECK_UPPER_BOUND, "1.3", restriction.getUpperBound().toString() ); assertFalse( CHECK_UPPER_BOUND_INCLUSIVE, restriction.isUpperBoundInclusive() ); range1 = VersionRange.createFromVersionSpec( "[1.0,1.1]" ); range2 = VersionRange.createFromVersionSpec( "[1.1,1.4]" ); mergedRange = range1.restrict( range2 ); assertNull( CHECK_VERSION_RECOMMENDATION, mergedRange.getRecommendedVersion() ); restrictions = mergedRange.getRestrictions(); assertEquals( CHECK_NUM_RESTRICTIONS, 1, restrictions.size() ); restriction = (Restriction) restrictions.get( 0 ); assertEquals( CHECK_LOWER_BOUND, "1.1", restriction.getLowerBound().toString() ); assertTrue( CHECK_LOWER_BOUND_INCLUSIVE, restriction.isLowerBoundInclusive() ); assertEquals( CHECK_UPPER_BOUND, "1.1", restriction.getUpperBound().toString() ); assertTrue( CHECK_UPPER_BOUND_INCLUSIVE, restriction.isUpperBoundInclusive() ); range1 = VersionRange.createFromVersionSpec( "[1.0,1.1)" ); range2 = VersionRange.createFromVersionSpec( "[1.1,1.4]" ); mergedRange = range1.restrict( range2 ); assertNull( CHECK_VERSION_RECOMMENDATION, mergedRange.getRecommendedVersion() ); restrictions = mergedRange.getRestrictions(); assertEquals( CHECK_NUM_RESTRICTIONS, 0, restrictions.size() ); range1 = VersionRange.createFromVersionSpec( "[1.0,1.2],[1.3,1.5]" ); range2 = VersionRange.createFromVersionSpec( "[1.1]" ); mergedRange = range1.restrict( range2 ); assertNull( CHECK_VERSION_RECOMMENDATION, mergedRange.getRecommendedVersion() ); restrictions = mergedRange.getRestrictions(); assertEquals( CHECK_NUM_RESTRICTIONS, 1, restrictions.size() ); restriction = (Restriction) restrictions.get( 0 ); assertEquals( CHECK_LOWER_BOUND, "1.1", restriction.getLowerBound().toString() ); assertTrue( CHECK_LOWER_BOUND_INCLUSIVE, restriction.isLowerBoundInclusive() ); assertEquals( CHECK_UPPER_BOUND, "1.1", restriction.getUpperBound().toString() ); assertTrue( CHECK_UPPER_BOUND_INCLUSIVE, restriction.isUpperBoundInclusive() ); range1 = VersionRange.createFromVersionSpec( "[1.0,1.2],[1.3,1.5]" ); range2 = VersionRange.createFromVersionSpec( "[1.4]" ); mergedRange = range1.restrict( range2 ); assertNull( CHECK_VERSION_RECOMMENDATION, mergedRange.getRecommendedVersion() ); restrictions = mergedRange.getRestrictions(); assertEquals( CHECK_NUM_RESTRICTIONS, 1, restrictions.size() ); restriction = (Restriction) restrictions.get( 0 ); assertEquals( CHECK_LOWER_BOUND, "1.4", restriction.getLowerBound().toString() ); assertTrue( CHECK_LOWER_BOUND_INCLUSIVE, restriction.isLowerBoundInclusive() ); assertEquals( CHECK_UPPER_BOUND, "1.4", restriction.getUpperBound().toString() ); assertTrue( CHECK_UPPER_BOUND_INCLUSIVE, restriction.isUpperBoundInclusive() ); range1 = VersionRange.createFromVersionSpec( "[1.0,1.2],[1.3,1.5]" ); range2 = VersionRange.createFromVersionSpec( "[1.1,1.4]" ); mergedRange = range1.restrict( range2 ); assertNull( CHECK_VERSION_RECOMMENDATION, mergedRange.getRecommendedVersion() ); restrictions = mergedRange.getRestrictions(); assertEquals( CHECK_NUM_RESTRICTIONS, 2, restrictions.size() ); restriction = (Restriction) restrictions.get( 0 ); assertEquals( CHECK_LOWER_BOUND, "1.1", restriction.getLowerBound().toString() ); assertTrue( CHECK_LOWER_BOUND_INCLUSIVE, restriction.isLowerBoundInclusive() ); assertEquals( CHECK_UPPER_BOUND, "1.2", restriction.getUpperBound().toString() ); assertTrue( CHECK_UPPER_BOUND_INCLUSIVE, restriction.isUpperBoundInclusive() ); restriction = (Restriction) restrictions.get( 1 ); assertEquals( CHECK_LOWER_BOUND, "1.3", restriction.getLowerBound().toString() ); assertTrue( CHECK_LOWER_BOUND_INCLUSIVE, restriction.isLowerBoundInclusive() ); assertEquals( CHECK_UPPER_BOUND, "1.4", restriction.getUpperBound().toString() ); assertTrue( CHECK_UPPER_BOUND_INCLUSIVE, restriction.isUpperBoundInclusive() ); range1 = VersionRange.createFromVersionSpec( "[1.0,1.2),(1.3,1.5]" ); range2 = VersionRange.createFromVersionSpec( "[1.1,1.4]" ); mergedRange = range1.restrict( range2 ); assertNull( CHECK_VERSION_RECOMMENDATION, mergedRange.getRecommendedVersion() ); restrictions = mergedRange.getRestrictions(); assertEquals( CHECK_NUM_RESTRICTIONS, 2, restrictions.size() ); restriction = (Restriction) restrictions.get( 0 ); assertEquals( CHECK_LOWER_BOUND, "1.1", restriction.getLowerBound().toString() ); assertTrue( CHECK_LOWER_BOUND_INCLUSIVE, restriction.isLowerBoundInclusive() ); assertEquals( CHECK_UPPER_BOUND, "1.2", restriction.getUpperBound().toString() ); assertFalse( CHECK_UPPER_BOUND_INCLUSIVE, restriction.isUpperBoundInclusive() ); restriction = (Restriction) restrictions.get( 1 ); assertEquals( CHECK_LOWER_BOUND, "1.3", restriction.getLowerBound().toString() ); assertFalse( CHECK_LOWER_BOUND_INCLUSIVE, restriction.isLowerBoundInclusive() ); assertEquals( CHECK_UPPER_BOUND, "1.4", restriction.getUpperBound().toString() ); assertTrue( CHECK_UPPER_BOUND_INCLUSIVE, restriction.isUpperBoundInclusive() ); range1 = VersionRange.createFromVersionSpec( "[1.0,1.2],[1.3,1.5]" ); range2 = VersionRange.createFromVersionSpec( "(1.1,1.4)" ); mergedRange = range1.restrict( range2 ); assertNull( CHECK_VERSION_RECOMMENDATION, mergedRange.getRecommendedVersion() ); restrictions = mergedRange.getRestrictions(); assertEquals( CHECK_NUM_RESTRICTIONS, 2, restrictions.size() ); restriction = (Restriction) restrictions.get( 0 ); assertEquals( CHECK_LOWER_BOUND, "1.1", restriction.getLowerBound().toString() ); assertFalse( CHECK_LOWER_BOUND_INCLUSIVE, restriction.isLowerBoundInclusive() ); assertEquals( CHECK_UPPER_BOUND, "1.2", restriction.getUpperBound().toString() ); assertTrue( CHECK_UPPER_BOUND_INCLUSIVE, restriction.isUpperBoundInclusive() ); restriction = (Restriction) restrictions.get( 1 ); assertEquals( CHECK_LOWER_BOUND, "1.3", restriction.getLowerBound().toString() ); assertTrue( CHECK_LOWER_BOUND_INCLUSIVE, restriction.isLowerBoundInclusive() ); assertEquals( CHECK_UPPER_BOUND, "1.4", restriction.getUpperBound().toString() ); assertFalse( CHECK_UPPER_BOUND_INCLUSIVE, restriction.isUpperBoundInclusive() ); range1 = VersionRange.createFromVersionSpec( "[1.0,1.2),(1.3,1.5]" ); range2 = VersionRange.createFromVersionSpec( "(1.1,1.4)" ); mergedRange = range1.restrict( range2 ); assertNull( CHECK_VERSION_RECOMMENDATION, mergedRange.getRecommendedVersion() ); restrictions = mergedRange.getRestrictions(); assertEquals( CHECK_NUM_RESTRICTIONS, 2, restrictions.size() ); restriction = (Restriction) restrictions.get( 0 ); assertEquals( CHECK_LOWER_BOUND, "1.1", restriction.getLowerBound().toString() ); assertFalse( CHECK_LOWER_BOUND_INCLUSIVE, restriction.isLowerBoundInclusive() ); assertEquals( CHECK_UPPER_BOUND, "1.2", restriction.getUpperBound().toString() ); assertFalse( CHECK_UPPER_BOUND_INCLUSIVE, restriction.isUpperBoundInclusive() ); restriction = (Restriction) restrictions.get( 1 ); assertEquals( CHECK_LOWER_BOUND, "1.3", restriction.getLowerBound().toString() ); assertFalse( CHECK_LOWER_BOUND_INCLUSIVE, restriction.isLowerBoundInclusive() ); assertEquals( CHECK_UPPER_BOUND, "1.4", restriction.getUpperBound().toString() ); assertFalse( CHECK_UPPER_BOUND_INCLUSIVE, restriction.isUpperBoundInclusive() ); range1 = VersionRange.createFromVersionSpec( "(,1.1),(1.4,)" ); range2 = VersionRange.createFromVersionSpec( "[1.1,1.4]" ); mergedRange = range1.restrict( range2 ); assertNull( CHECK_VERSION_RECOMMENDATION, mergedRange.getRecommendedVersion() ); restrictions = mergedRange.getRestrictions(); assertEquals( CHECK_NUM_RESTRICTIONS, 0, restrictions.size() ); range1 = VersionRange.createFromVersionSpec( "(,1.1],[1.4,)" ); range2 = VersionRange.createFromVersionSpec( "(1.1,1.4)" ); mergedRange = range1.restrict( range2 ); assertNull( CHECK_VERSION_RECOMMENDATION, mergedRange.getRecommendedVersion() ); restrictions = mergedRange.getRestrictions(); assertEquals( CHECK_NUM_RESTRICTIONS, 0, restrictions.size() ); range1 = VersionRange.createFromVersionSpec( "[,1.1],[1.4,]" ); range2 = VersionRange.createFromVersionSpec( "[1.2,1.3]" ); mergedRange = range1.restrict( range2 ); assertNull( CHECK_VERSION_RECOMMENDATION, mergedRange.getRecommendedVersion() ); restrictions = mergedRange.getRestrictions(); assertEquals( CHECK_NUM_RESTRICTIONS, 0, restrictions.size() ); range1 = VersionRange.createFromVersionSpec( "[1.0,1.2],[1.3,1.5]" ); range2 = VersionRange.createFromVersionSpec( "[1.1,1.4],[1.6,]" ); mergedRange = range1.restrict( range2 ); assertNull( CHECK_VERSION_RECOMMENDATION, mergedRange.getRecommendedVersion() ); restrictions = mergedRange.getRestrictions(); assertEquals( CHECK_NUM_RESTRICTIONS, 2, restrictions.size() ); restriction = (Restriction) restrictions.get( 0 ); assertEquals( CHECK_LOWER_BOUND, "1.1", restriction.getLowerBound().toString() ); assertTrue( CHECK_LOWER_BOUND_INCLUSIVE, restriction.isLowerBoundInclusive() ); assertEquals( CHECK_UPPER_BOUND, "1.2", restriction.getUpperBound().toString() ); assertTrue( CHECK_UPPER_BOUND_INCLUSIVE, restriction.isUpperBoundInclusive() ); restriction = (Restriction) restrictions.get( 1 ); assertEquals( CHECK_LOWER_BOUND, "1.3", restriction.getLowerBound().toString() ); assertTrue( CHECK_LOWER_BOUND_INCLUSIVE, restriction.isLowerBoundInclusive() ); assertEquals( CHECK_UPPER_BOUND, "1.4", restriction.getUpperBound().toString() ); assertTrue( CHECK_UPPER_BOUND_INCLUSIVE, restriction.isUpperBoundInclusive() ); range1 = VersionRange.createFromVersionSpec( "[1.0,1.2],[1.3,1.5]" ); range2 = VersionRange.createFromVersionSpec( "[1.1,1.4],[1.5,]" ); mergedRange = range1.restrict( range2 ); assertNull( CHECK_VERSION_RECOMMENDATION, mergedRange.getRecommendedVersion() ); restrictions = mergedRange.getRestrictions(); assertEquals( CHECK_NUM_RESTRICTIONS, 3, restrictions.size() ); restriction = (Restriction) restrictions.get( 0 ); assertEquals( CHECK_LOWER_BOUND, "1.1", restriction.getLowerBound().toString() ); assertTrue( CHECK_LOWER_BOUND_INCLUSIVE, restriction.isLowerBoundInclusive() ); assertEquals( CHECK_UPPER_BOUND, "1.2", restriction.getUpperBound().toString() ); assertTrue( CHECK_UPPER_BOUND_INCLUSIVE, restriction.isUpperBoundInclusive() ); restriction = (Restriction) restrictions.get( 1 ); assertEquals( CHECK_LOWER_BOUND, "1.3", restriction.getLowerBound().toString() ); assertTrue( CHECK_LOWER_BOUND_INCLUSIVE, restriction.isLowerBoundInclusive() ); assertEquals( CHECK_UPPER_BOUND, "1.4", restriction.getUpperBound().toString() ); assertTrue( CHECK_UPPER_BOUND_INCLUSIVE, restriction.isUpperBoundInclusive() ); restriction = (Restriction) restrictions.get( 2 ); assertEquals( CHECK_LOWER_BOUND, "1.5", restriction.getLowerBound().toString() ); assertTrue( CHECK_LOWER_BOUND_INCLUSIVE, restriction.isLowerBoundInclusive() ); assertEquals( CHECK_UPPER_BOUND, "1.5", restriction.getUpperBound().toString() ); assertTrue( CHECK_UPPER_BOUND_INCLUSIVE, restriction.isUpperBoundInclusive() ); range1 = VersionRange.createFromVersionSpec( "[1.0,1.2],[1.3,1.7]" ); range2 = VersionRange.createFromVersionSpec( "[1.1,1.4],[1.5,1.6]" ); mergedRange = range1.restrict( range2 ); assertNull( CHECK_VERSION_RECOMMENDATION, mergedRange.getRecommendedVersion() ); restrictions = mergedRange.getRestrictions(); assertEquals( CHECK_NUM_RESTRICTIONS, 3, restrictions.size() ); restriction = (Restriction) restrictions.get( 0 ); assertEquals( CHECK_LOWER_BOUND, "1.1", restriction.getLowerBound().toString() ); assertTrue( CHECK_LOWER_BOUND_INCLUSIVE, restriction.isLowerBoundInclusive() ); assertEquals( CHECK_UPPER_BOUND, "1.2", restriction.getUpperBound().toString() ); assertTrue( CHECK_UPPER_BOUND_INCLUSIVE, restriction.isUpperBoundInclusive() ); restriction = (Restriction) restrictions.get( 1 ); assertEquals( CHECK_LOWER_BOUND, "1.3", restriction.getLowerBound().toString() ); assertTrue( CHECK_LOWER_BOUND_INCLUSIVE, restriction.isLowerBoundInclusive() ); assertEquals( CHECK_UPPER_BOUND, "1.4", restriction.getUpperBound().toString() ); assertTrue( CHECK_UPPER_BOUND_INCLUSIVE, restriction.isUpperBoundInclusive() ); restriction = (Restriction) restrictions.get( 2 ); assertEquals( CHECK_LOWER_BOUND, "1.5", restriction.getLowerBound().toString() ); assertTrue( CHECK_LOWER_BOUND_INCLUSIVE, restriction.isLowerBoundInclusive() ); assertEquals( CHECK_UPPER_BOUND, "1.6", restriction.getUpperBound().toString() ); assertTrue( CHECK_UPPER_BOUND_INCLUSIVE, restriction.isUpperBoundInclusive() ); // test restricting empty sets range1 = VersionRange.createFromVersionSpec( "[,1.1],[1.4,]" ); range2 = VersionRange.createFromVersionSpec( "[1.2,1.3]" ); range1 = range1.restrict( range2 ); mergedRange = range1.restrict( range2 ); assertNull( CHECK_VERSION_RECOMMENDATION, mergedRange.getRecommendedVersion() ); restrictions = mergedRange.getRestrictions(); assertEquals( CHECK_NUM_RESTRICTIONS, 0, restrictions.size() ); range1 = VersionRange.createFromVersionSpec( "[,1.1],[1.4,]" ); range2 = VersionRange.createFromVersionSpec( "[1.2,1.3]" ); range2 = range1.restrict( range2 ); mergedRange = range1.restrict( range2 ); assertNull( CHECK_VERSION_RECOMMENDATION, mergedRange.getRecommendedVersion() ); restrictions = mergedRange.getRestrictions(); assertEquals( CHECK_NUM_RESTRICTIONS, 0, restrictions.size() ); } private void checkInvalidRange( String version ) { try { VersionRange.createFromVersionSpec( version ); fail( "Version " + version + " should have failed to construct" ); } catch ( InvalidVersionSpecificationException expected ) { // expected } } } maven2-core-2.2.1/maven-artifact/src/main/0000755000175000017500000000000011250552242020202 5ustar twernertwernermaven2-core-2.2.1/maven-artifact/src/main/resources/0000755000175000017500000000000011250552242022214 5ustar twernertwernermaven2-core-2.2.1/maven-artifact/src/main/resources/META-INF/0000755000175000017500000000000011250552242023354 5ustar twernertwernermaven2-core-2.2.1/maven-artifact/src/main/resources/META-INF/plexus/0000755000175000017500000000000011250552242024674 5ustar twernertwernermaven2-core-2.2.1/maven-artifact/src/main/resources/META-INF/plexus/components.xml0000644000175000017500000001776710777503072027637 0ustar twernertwerner org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout default org.apache.maven.artifact.repository.layout.DefaultRepositoryLayout org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout legacy org.apache.maven.artifact.repository.layout.LegacyRepositoryLayout org.apache.maven.artifact.handler.manager.ArtifactHandlerManager org.apache.maven.artifact.handler.manager.DefaultArtifactHandlerManager org.apache.maven.artifact.handler.ArtifactHandler artifactHandlers org.apache.maven.artifact.handler.ArtifactHandler ejb org.apache.maven.artifact.handler.DefaultArtifactHandler ejb jar java true org.apache.maven.artifact.handler.ArtifactHandler jar org.apache.maven.artifact.handler.DefaultArtifactHandler jar java true org.apache.maven.artifact.handler.ArtifactHandler test-jar org.apache.maven.artifact.handler.DefaultArtifactHandler tests jar test-jar jar java true org.apache.maven.artifact.handler.ArtifactHandler maven-plugin org.apache.maven.artifact.handler.DefaultArtifactHandler maven-plugin jar java true org.apache.maven.artifact.handler.ArtifactHandler pom org.apache.maven.artifact.handler.DefaultArtifactHandler pom org.apache.maven.artifact.handler.ArtifactHandler java-source org.apache.maven.artifact.handler.DefaultArtifactHandler sources java-source jar java false org.apache.maven.artifact.handler.ArtifactHandler javadoc org.apache.maven.artifact.handler.DefaultArtifactHandler javadoc javadoc jar java true org.apache.maven.artifact.handler.ArtifactHandler war org.apache.maven.artifact.handler.DefaultArtifactHandler war true java false org.apache.maven.artifact.handler.ArtifactHandler ear org.apache.maven.artifact.handler.DefaultArtifactHandler ear true java false org.apache.maven.artifact.handler.ArtifactHandler ejb-client org.apache.maven.artifact.handler.DefaultArtifactHandler ejb-client jar ejb client java true org.apache.maven.artifact.handler.ArtifactHandler rar org.apache.maven.artifact.handler.DefaultArtifactHandler rar true java false org.apache.maven.artifact.handler.ArtifactHandler par org.apache.maven.artifact.handler.DefaultArtifactHandler par true java false org.apache.maven.artifact.handler.ArtifactHandler ejb3 org.apache.maven.artifact.handler.DefaultArtifactHandler ejb3 true java false org.apache.maven.artifact.factory.ArtifactFactory org.apache.maven.artifact.factory.DefaultArtifactFactory org.apache.maven.artifact.handler.manager.ArtifactHandlerManager org.apache.maven.artifact.resolver.ArtifactCollector org.apache.maven.artifact.resolver.DefaultArtifactCollector maven2-core-2.2.1/maven-artifact/src/main/java/0000755000175000017500000000000011250552242021123 5ustar twernertwernermaven2-core-2.2.1/maven-artifact/src/main/java/org/0000755000175000017500000000000011250552242021712 5ustar twernertwernermaven2-core-2.2.1/maven-artifact/src/main/java/org/apache/0000755000175000017500000000000011250552242023133 5ustar twernertwernermaven2-core-2.2.1/maven-artifact/src/main/java/org/apache/maven/0000755000175000017500000000000011250552242024241 5ustar twernertwernermaven2-core-2.2.1/maven-artifact/src/main/java/org/apache/maven/artifact/0000755000175000017500000000000011250552242026036 5ustar twernertwerner././@LongLink0000000000000000000000000000015100000000000011562 Lustar rootrootmaven2-core-2.2.1/maven-artifact/src/main/java/org/apache/maven/artifact/InvalidRepositoryException.javamaven2-core-2.2.1/maven-artifact/src/main/java/org/apache/maven/artifact/InvalidRepositoryException.0000644000175000017500000000233210551365651033415 0ustar twernertwernerpackage org.apache.maven.artifact; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ /** * Error constructing an artifact repository. * * @author Brett Porter * @version $Id: InvalidRepositoryException.java 495147 2007-01-11 07:47:53Z jvanzyl $ */ public class InvalidRepositoryException extends Exception { public InvalidRepositoryException( String message, Throwable throwable ) { super( message, throwable ); } } maven2-core-2.2.1/maven-artifact/src/main/java/org/apache/maven/artifact/handler/0000755000175000017500000000000011250552242027453 5ustar twernertwerner././@LongLink0000000000000000000000000000015500000000000011566 Lustar rootrootmaven2-core-2.2.1/maven-artifact/src/main/java/org/apache/maven/artifact/handler/DefaultArtifactHandler.javamaven2-core-2.2.1/maven-artifact/src/main/java/org/apache/maven/artifact/handler/DefaultArtifactHand0000644000175000017500000000457310772004567033256 0ustar twernertwernerpackage org.apache.maven.artifact.handler; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ /** * @author Brett Porter * @version $Id: DefaultArtifactHandler.java 640549 2008-03-24 20:05:11Z bentmann $ */ public class DefaultArtifactHandler implements ArtifactHandler { private String extension; private String type; private String classifier; private String directory; private String packaging; private boolean includesDependencies; private String language; private boolean addedToClasspath; public DefaultArtifactHandler() { } public DefaultArtifactHandler( String type ) { this.type = type; } public String getExtension() { if ( extension == null ) { extension = type; } return extension; } public String getType() { return type; } public String getClassifier() { return classifier; } public String getDirectory() { if ( directory == null ) { directory = getPackaging() + "s"; } return directory; } public String getPackaging() { if ( packaging == null ) { packaging = type; } return packaging; } public boolean isIncludesDependencies() { return includesDependencies; } public String getLanguage() { if ( language == null ) { language = "none"; } return language; } public boolean isAddedToClasspath() { return addedToClasspath; } } maven2-core-2.2.1/maven-artifact/src/main/java/org/apache/maven/artifact/handler/manager/0000755000175000017500000000000011250552242031065 5ustar twernertwerner././@LongLink0000000000000000000000000000017400000000000011567 Lustar rootrootmaven2-core-2.2.1/maven-artifact/src/main/java/org/apache/maven/artifact/handler/manager/DefaultArtifactHandlerManager.javamaven2-core-2.2.1/maven-artifact/src/main/java/org/apache/maven/artifact/handler/manager/DefaultArti0000644000175000017500000000342010772004567033225 0ustar twernertwernerpackage org.apache.maven.artifact.handler.manager; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import org.apache.maven.artifact.handler.ArtifactHandler; import org.apache.maven.artifact.handler.DefaultArtifactHandler; import java.util.Map; import java.util.Set; /** * @author Jason van Zyl * @version $Id: DefaultArtifactHandlerManager.java,v 1.1.1.1 2004/08/09 * 18:37:32 jvanzyl Exp $ */ public class DefaultArtifactHandlerManager implements ArtifactHandlerManager { private Map artifactHandlers; public ArtifactHandler getArtifactHandler( String type ) { ArtifactHandler handler = (ArtifactHandler) artifactHandlers.get( type ); if ( handler == null ) { handler = new DefaultArtifactHandler( type ); } return handler; } public void addHandlers( Map handlers ) { artifactHandlers.putAll( handlers ); } public Set getHandlerTypes() { return artifactHandlers.keySet(); } } ././@LongLink0000000000000000000000000000016500000000000011567 Lustar rootrootmaven2-core-2.2.1/maven-artifact/src/main/java/org/apache/maven/artifact/handler/manager/ArtifactHandlerManager.javamaven2-core-2.2.1/maven-artifact/src/main/java/org/apache/maven/artifact/handler/manager/ArtifactHan0000644000175000017500000000241410772004567033207 0ustar twernertwernerpackage org.apache.maven.artifact.handler.manager; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import org.apache.maven.artifact.handler.ArtifactHandler; import java.util.Map; /** * @author Jason van Zyl * @version $Id: ArtifactHandlerManager.java 640549 2008-03-24 20:05:11Z bentmann $ */ public interface ArtifactHandlerManager { String ROLE = ArtifactHandlerManager.class.getName(); ArtifactHandler getArtifactHandler( String type ); void addHandlers( Map handlers ); }././@LongLink0000000000000000000000000000014600000000000011566 Lustar rootrootmaven2-core-2.2.1/maven-artifact/src/main/java/org/apache/maven/artifact/handler/ArtifactHandler.javamaven2-core-2.2.1/maven-artifact/src/main/java/org/apache/maven/artifact/handler/ArtifactHandler.jav0000644000175000017500000000242410551365651033223 0ustar twernertwernerpackage org.apache.maven.artifact.handler; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ /** * @author Jason van Zyl * @version $Id: ArtifactHandler.java 495147 2007-01-11 07:47:53Z jvanzyl $ */ public interface ArtifactHandler { String ROLE = ArtifactHandler.class.getName(); String getExtension(); String getDirectory(); String getClassifier(); String getPackaging(); boolean isIncludesDependencies(); String getLanguage(); boolean isAddedToClasspath(); } maven2-core-2.2.1/maven-artifact/src/main/java/org/apache/maven/artifact/deployer/0000755000175000017500000000000011250552242027661 5ustar twernertwerner././@LongLink0000000000000000000000000000015000000000000011561 Lustar rootrootmaven2-core-2.2.1/maven-artifact/src/main/java/org/apache/maven/artifact/deployer/ArtifactDeployer.javamaven2-core-2.2.1/maven-artifact/src/main/java/org/apache/maven/artifact/deployer/ArtifactDeployer.j0000644000175000017500000000471010551365651033310 0ustar twernertwernerpackage org.apache.maven.artifact.deployer; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.repository.ArtifactRepository; import java.io.File; public interface ArtifactDeployer { String ROLE = ArtifactDeployer.class.getName(); /** * Deploy an artifact from a particular directory. The artifact handler is used to determine the filename * of the source file. * * @param basedir the directory where the artifact is stored * @param finalName the name of the artifact sans extension * @param artifact the artifact definition * @param deploymentRepository the repository to deploy to * @param localRepository the local repository to install into * @throws ArtifactDeploymentException if an error occurred deploying the artifact * @deprecated to be removed before 2.0 after the instlal/deploy plugins use the alternate method */ void deploy( String basedir, String finalName, Artifact artifact, ArtifactRepository deploymentRepository, ArtifactRepository localRepository ) throws ArtifactDeploymentException; /** * Deploy an artifact from a particular file. * * @param source the file to deploy * @param artifact the artifact definition * @param deploymentRepository the repository to deploy to * @param localRepository the local repository to install into * @throws ArtifactDeploymentException if an error occurred deploying the artifact */ void deploy( File source, Artifact artifact, ArtifactRepository deploymentRepository, ArtifactRepository localRepository ) throws ArtifactDeploymentException; } ././@LongLink0000000000000000000000000000016300000000000011565 Lustar rootrootmaven2-core-2.2.1/maven-artifact/src/main/java/org/apache/maven/artifact/deployer/ArtifactDeploymentException.javamaven2-core-2.2.1/maven-artifact/src/main/java/org/apache/maven/artifact/deployer/ArtifactDeployment0000644000175000017500000000255410551365651033421 0ustar twernertwernerpackage org.apache.maven.artifact.deployer; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ /** * @author Jason van Zyl * @version $Id: ArtifactDeploymentException.java 495147 2007-01-11 07:47:53Z jvanzyl $ */ public class ArtifactDeploymentException extends Exception { public ArtifactDeploymentException( String message ) { super( message ); } public ArtifactDeploymentException( Throwable cause ) { super( cause ); } public ArtifactDeploymentException( String message, Throwable cause ) { super( message, cause ); } } maven2-core-2.2.1/maven-artifact/src/main/java/org/apache/maven/artifact/ArtifactUtils.java0000644000175000017500000001177311177667427031514 0ustar twernertwernerpackage org.apache.maven.artifact; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import org.apache.maven.artifact.versioning.VersionRange; import java.util.ArrayList; import java.util.Collection; import java.util.Iterator; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; import java.util.regex.Matcher; public final class ArtifactUtils { private ArtifactUtils() { } public static boolean isSnapshot( String version ) { return version != null && ( version.toUpperCase().endsWith( Artifact.SNAPSHOT_VERSION ) || Artifact.VERSION_FILE_PATTERN.matcher( version ) .matches() ); } public static String toSnapshotVersion( String version ) { Matcher m = Artifact.VERSION_FILE_PATTERN.matcher( version ); if ( m.matches() ) { return m.group( 1 ) + '-' + Artifact.SNAPSHOT_VERSION; } else { return version; } } public static String versionlessKey( Artifact artifact ) { return versionlessKey( artifact.getGroupId(), artifact.getArtifactId() ); } public static String versionlessKey( String groupId, String artifactId ) { if ( groupId == null ) { throw new NullPointerException( "groupId was null" ); } if ( artifactId == null ) { throw new NullPointerException( "artifactId was null" ); } return groupId + ":" + artifactId; } public static String artifactId( String groupId, String artifactId, String type, String version ) { return artifactId( groupId, artifactId, type, null, version ); } public static String artifactId( String groupId, String artifactId, String type, String classifier, String baseVersion ) { return groupId + ":" + artifactId + ":" + type + ( classifier != null ? ":" + classifier : "" ) + ":" + baseVersion; } public static Map artifactMapByVersionlessId( Collection artifacts ) { Map artifactMap = new LinkedHashMap(); if ( artifacts != null ) { for ( Iterator it = artifacts.iterator(); it.hasNext(); ) { Artifact artifact = (Artifact) it.next(); artifactMap.put( versionlessKey( artifact ), artifact ); } } return artifactMap; } public static Map artifactMapByArtifactId( Collection artifacts ) { Map artifactMap = new LinkedHashMap(); if ( artifacts != null ) { for ( Iterator it = artifacts.iterator(); it.hasNext(); ) { Artifact artifact = (Artifact) it.next(); artifactMap.put( artifact.getId(), artifact ); } } return artifactMap; } public static Artifact copyArtifact( Artifact artifact ) { VersionRange range = artifact.getVersionRange(); DefaultArtifact clone = new DefaultArtifact( artifact.getGroupId(), artifact.getArtifactId(), range.cloneOf(), artifact.getScope(), artifact.getType(), artifact.getClassifier(), artifact.getArtifactHandler(), artifact.isOptional() ); clone.setRelease( artifact.isRelease() ); clone.setResolvedVersion( artifact.getVersion() ); clone.setResolved( artifact.isResolved() ); clone.setFile( artifact.getFile() ); clone.setAvailableVersions( copyList( artifact.getAvailableVersions() ) ); clone.setBaseVersion( artifact.getBaseVersion() ); clone.setDependencyFilter( artifact.getDependencyFilter() ); clone.setDependencyTrail( copyList( artifact.getDependencyTrail() ) ); clone.setDownloadUrl( artifact.getDownloadUrl() ); clone.setRepository( artifact.getRepository() ); return clone; } private static List copyList( List original ) { List copy = null; if ( original != null ) { copy = new ArrayList(); if ( !original.isEmpty() ) { copy.addAll( original ); } } return copy; } } maven2-core-2.2.1/maven-artifact/src/main/java/org/apache/maven/artifact/DefaultArtifact.java0000644000175000017500000003760011173447106031757 0ustar twernertwernerpackage org.apache.maven.artifact; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import org.apache.maven.artifact.handler.ArtifactHandler; import org.apache.maven.artifact.metadata.ArtifactMetadata; import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.artifact.resolver.filter.ArtifactFilter; import org.apache.maven.artifact.versioning.ArtifactVersion; import org.apache.maven.artifact.versioning.OverConstrainedVersionException; import org.apache.maven.artifact.versioning.VersionRange; import org.codehaus.plexus.util.StringUtils; import java.io.File; import java.util.Collection; import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.regex.Matcher; /** * @author Jason van Zyl * @version $Id: DefaultArtifact.java 767322 2009-04-21 22:52:54Z jdcasey $ * @todo this should possibly be replaced by type handler */ public class DefaultArtifact implements Artifact { private String groupId; private String artifactId; /** * The resolved version for the artifact after conflict resolution, that has not been transformed. * * @todo should be final */ private String baseVersion; private final String type; private final String classifier; private String scope; private File file; private ArtifactRepository repository; private String downloadUrl; private ArtifactFilter dependencyFilter; private ArtifactHandler artifactHandler; private List dependencyTrail; private String version; private VersionRange versionRange; private boolean resolved; private boolean release; private List availableVersions; private Map metadataMap; private boolean optional; public DefaultArtifact( String groupId, String artifactId, VersionRange versionRange, String scope, String type, String classifier, ArtifactHandler artifactHandler ) { this( groupId, artifactId, versionRange, scope, type, classifier, artifactHandler, false ); } public DefaultArtifact( String groupId, String artifactId, VersionRange versionRange, String scope, String type, String classifier, ArtifactHandler artifactHandler, boolean optional ) { this.groupId = groupId; this.artifactId = artifactId; this.versionRange = versionRange; selectVersionFromNewRangeIfAvailable(); this.artifactHandler = artifactHandler; this.scope = scope; this.type = type; if ( classifier == null ) { classifier = artifactHandler.getClassifier(); } this.classifier = classifier; this.optional = optional; validateIdentity(); } private void validateIdentity() { if ( empty( groupId ) ) { throw new InvalidArtifactRTException( groupId, artifactId, getVersion(), type, "The groupId cannot be empty." ); } if ( artifactId == null ) { throw new InvalidArtifactRTException( groupId, artifactId, getVersion(), type, "The artifactId cannot be empty." ); } if ( type == null ) { throw new InvalidArtifactRTException( groupId, artifactId, getVersion(), type, "The type cannot be empty." ); } if ( ( version == null ) && ( versionRange == null ) ) { throw new InvalidArtifactRTException( groupId, artifactId, getVersion(), type, "The version cannot be empty." ); } } private boolean empty( String value ) { return ( value == null ) || ( value.trim().length() < 1 ); } public String getClassifier() { return classifier; } public boolean hasClassifier() { return StringUtils.isNotEmpty( classifier ); } public String getScope() { return scope; } public String getGroupId() { return groupId; } public String getArtifactId() { return artifactId; } public String getVersion() { return version; } public void setVersion( String version ) { this.version = version; setBaseVersionInternal( version ); versionRange = null; } public String getType() { return type; } public void setFile( File file ) { this.file = file; } public File getFile() { return file; } public ArtifactRepository getRepository() { return repository; } public void setRepository( ArtifactRepository repository ) { this.repository = repository; } // ---------------------------------------------------------------------- // // ---------------------------------------------------------------------- public String getId() { return getDependencyConflictId() + ":" + getBaseVersion(); } public String getDependencyConflictId() { StringBuffer sb = new StringBuffer(); sb.append( getGroupId() ); sb.append( ":" ); appendArtifactTypeClassifierString( sb ); return sb.toString(); } private void appendArtifactTypeClassifierString( StringBuffer sb ) { sb.append( getArtifactId() ); sb.append( ":" ); sb.append( getType() ); if ( hasClassifier() ) { sb.append( ":" ); sb.append( getClassifier() ); } } public void addMetadata( ArtifactMetadata metadata ) { if ( metadataMap == null ) { metadataMap = new HashMap(); } ArtifactMetadata m = (ArtifactMetadata) metadataMap.get( metadata.getKey() ); if ( m != null ) { m.merge( metadata ); } else { metadataMap.put( metadata.getKey(), metadata ); } } public ArtifactMetadata getMetadata( Class metadataClass ) { Collection metadata = getMetadataList(); if ( metadata != null ) { for ( ArtifactMetadata m : metadata ) { if ( metadataClass.isAssignableFrom( m.getClass() ) ) { return m; } } } return null; } public Collection getMetadataList() { Collection result; if ( metadataMap == null ) { result = Collections.emptyList(); } else { result = metadataMap.values(); } return result; } // ---------------------------------------------------------------------- // Object overrides // ---------------------------------------------------------------------- public String toString() { StringBuffer sb = new StringBuffer(); if ( getGroupId() != null ) { sb.append( getGroupId() ); sb.append( ":" ); } appendArtifactTypeClassifierString( sb ); sb.append( ":" ); if ( getBaseVersionInternal() != null ) { sb.append( getBaseVersionInternal() ); } else { sb.append( versionRange.toString() ); } if ( scope != null ) { sb.append( ":" ); sb.append( scope ); } return sb.toString(); } public int hashCode() { int result = 17; result = 37 * result + groupId.hashCode(); result = 37 * result + artifactId.hashCode(); result = 37 * result + type.hashCode(); if ( version != null ) { result = 37 * result + version.hashCode(); } result = 37 * result + ( classifier != null ? classifier.hashCode() : 0 ); return result; } public boolean equals( Object o ) { if ( o == this ) { return true; } if ( !( o instanceof Artifact ) ) { return false; } Artifact a = (Artifact) o; if ( !a.getGroupId().equals( groupId ) ) { return false; } else if ( !a.getArtifactId().equals( artifactId ) ) { return false; } else if ( !a.getVersion().equals( version ) ) { return false; } else if ( !a.getType().equals( type ) ) { return false; } else if ( a.getClassifier() == null ? classifier != null : !a.getClassifier().equals( classifier ) ) { return false; } // We don't consider the version range in the comparison, just the resolved version return true; } public String getBaseVersion() { if ( baseVersion == null ) { if ( version == null ) { throw new NullPointerException( "version was null for " + groupId + ":" + artifactId ); } setBaseVersionInternal( version ); } return baseVersion; } protected String getBaseVersionInternal() { if ( ( baseVersion == null ) && ( version != null ) ) { setBaseVersionInternal( version ); } return baseVersion; } public void setBaseVersion( String baseVersion ) { setBaseVersionInternal( baseVersion ); } protected void setBaseVersionInternal( String baseVersion ) { Matcher m = VERSION_FILE_PATTERN.matcher( baseVersion ); if ( m.matches() ) { this.baseVersion = m.group( 1 ) + "-" + SNAPSHOT_VERSION; } else { this.baseVersion = baseVersion; } } public int compareTo( Artifact a ) { int result = groupId.compareTo( a.getGroupId() ); if ( result == 0 ) { result = artifactId.compareTo( a.getArtifactId() ); if ( result == 0 ) { result = type.compareTo( a.getType() ); if ( result == 0 ) { if ( classifier == null ) { if ( a.getClassifier() != null ) { result = 1; } } else { if ( a.getClassifier() != null ) { result = classifier.compareTo( a.getClassifier() ); } else { result = -1; } } if ( result == 0 ) { // We don't consider the version range in the comparison, just the resolved version result = version.compareTo( a.getVersion() ); } } } } return result; } public void updateVersion( String version, ArtifactRepository localRepository ) { setResolvedVersion( version ); setFile( new File( localRepository.getBasedir(), localRepository.pathOf( this ) ) ); } public String getDownloadUrl() { return downloadUrl; } public void setDownloadUrl( String downloadUrl ) { this.downloadUrl = downloadUrl; } public ArtifactFilter getDependencyFilter() { return dependencyFilter; } public void setDependencyFilter( ArtifactFilter artifactFilter ) { dependencyFilter = artifactFilter; } public ArtifactHandler getArtifactHandler() { return artifactHandler; } public List getDependencyTrail() { return dependencyTrail; } public void setDependencyTrail( List dependencyTrail ) { this.dependencyTrail = dependencyTrail; } public void setScope( String scope ) { this.scope = scope; } public VersionRange getVersionRange() { // I am assuming this is happening as a result of the MNG-1577 work, but somehow the value // of versionRange just goes null or is not set. But this is happeningin Yoko and the value is // set when attaching the JAR and not set when attaching the test JAR. if ( versionRange == null ) { versionRange = VersionRange.createFromVersion( version ); } return versionRange; } public void setVersionRange( VersionRange versionRange ) { this.versionRange = versionRange; selectVersionFromNewRangeIfAvailable(); } private void selectVersionFromNewRangeIfAvailable() { if ( ( versionRange != null ) && ( versionRange.getRecommendedVersion() != null ) ) { selectVersion( versionRange.getRecommendedVersion().toString() ); } else { version = null; baseVersion = null; } } public void selectVersion( String version ) { this.version = version; setBaseVersionInternal( version ); } public void setGroupId( String groupId ) { this.groupId = groupId; } public void setArtifactId( String artifactId ) { this.artifactId = artifactId; } public boolean isSnapshot() { if ( getBaseVersion() != null ) { return getBaseVersion().endsWith( SNAPSHOT_VERSION ) || getBaseVersion().equals( LATEST_VERSION ); } else { return false; } } public void setResolved( boolean resolved ) { this.resolved = resolved; } public boolean isResolved() { return resolved; } public void setResolvedVersion( String version ) { this.version = version; // retain baseVersion } public void setArtifactHandler( ArtifactHandler artifactHandler ) { this.artifactHandler = artifactHandler; } public void setRelease( boolean release ) { this.release = release; } public boolean isRelease() { return release; } public List getAvailableVersions() { return availableVersions; } public void setAvailableVersions( List availableVersions ) { this.availableVersions = availableVersions; } public boolean isOptional() { return optional; } public ArtifactVersion getSelectedVersion() throws OverConstrainedVersionException { return versionRange.getSelectedVersion( this ); } public boolean isSelectedVersionKnown() throws OverConstrainedVersionException { return versionRange.isSelectedVersionKnown( this ); } public void setOptional( boolean optional ) { this.optional = optional; } } maven2-core-2.2.1/maven-artifact/src/main/java/org/apache/maven/artifact/resolver/0000755000175000017500000000000011250552242027677 5ustar twernertwernermaven2-core-2.2.1/maven-artifact/src/main/java/org/apache/maven/artifact/resolver/filter/0000755000175000017500000000000011250552242031164 5ustar twernertwerner././@LongLink0000000000000000000000000000016200000000000011564 Lustar rootrootmaven2-core-2.2.1/maven-artifact/src/main/java/org/apache/maven/artifact/resolver/filter/ScopeArtifactFilter.javamaven2-core-2.2.1/maven-artifact/src/main/java/org/apache/maven/artifact/resolver/filter/ScopeArtifa0000644000175000017500000000615110551365651033323 0ustar twernertwernerpackage org.apache.maven.artifact.resolver.filter; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.DefaultArtifact; /** * Filter to only retain objects in the given scope or better. * * @author Brett Porter * @version $Id: ScopeArtifactFilter.java 495147 2007-01-11 07:47:53Z jvanzyl $ */ public class ScopeArtifactFilter implements ArtifactFilter { private final boolean compileScope; private final boolean runtimeScope; private final boolean testScope; private final boolean providedScope; private final boolean systemScope; public ScopeArtifactFilter( String scope ) { if ( DefaultArtifact.SCOPE_COMPILE.equals( scope ) ) { systemScope = true; providedScope = true; compileScope = true; runtimeScope = false; testScope = false; } else if ( DefaultArtifact.SCOPE_RUNTIME.equals( scope ) ) { systemScope = false; providedScope = false; compileScope = true; runtimeScope = true; testScope = false; } else if ( DefaultArtifact.SCOPE_TEST.equals( scope ) ) { systemScope = true; providedScope = true; compileScope = true; runtimeScope = true; testScope = true; } else { systemScope = false; providedScope = false; compileScope = false; runtimeScope = false; testScope = false; } } public boolean include( Artifact artifact ) { if ( Artifact.SCOPE_COMPILE.equals( artifact.getScope() ) ) { return compileScope; } else if ( Artifact.SCOPE_RUNTIME.equals( artifact.getScope() ) ) { return runtimeScope; } else if ( Artifact.SCOPE_TEST.equals( artifact.getScope() ) ) { return testScope; } else if ( Artifact.SCOPE_PROVIDED.equals( artifact.getScope() ) ) { return providedScope; } else if ( Artifact.SCOPE_SYSTEM.equals( artifact.getScope() ) ) { return systemScope; } else { return true; } } } ././@LongLink0000000000000000000000000000016100000000000011563 Lustar rootrootmaven2-core-2.2.1/maven-artifact/src/main/java/org/apache/maven/artifact/resolver/filter/TypeArtifactFilter.javamaven2-core-2.2.1/maven-artifact/src/main/java/org/apache/maven/artifact/resolver/filter/TypeArtifac0000644000175000017500000000235010772004567033334 0ustar twernertwernerpackage org.apache.maven.artifact.resolver.filter; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import org.apache.maven.artifact.Artifact; /** * Artifact Filter which filters on artifact type */ public class TypeArtifactFilter implements ArtifactFilter { private String type = "jar"; public TypeArtifactFilter( String type ) { this.type = type; } public boolean include( Artifact artifact ) { return type.equals( artifact.getType() ); } } ././@LongLink0000000000000000000000000000015500000000000011566 Lustar rootrootmaven2-core-2.2.1/maven-artifact/src/main/java/org/apache/maven/artifact/resolver/filter/ArtifactFilter.javamaven2-core-2.2.1/maven-artifact/src/main/java/org/apache/maven/artifact/resolver/filter/ArtifactFil0000644000175000017500000000214710551365651033314 0ustar twernertwernerpackage org.apache.maven.artifact.resolver.filter; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import org.apache.maven.artifact.Artifact; /** * @author Jason van Zyl * @version $Id: ArtifactFilter.java 495147 2007-01-11 07:47:53Z jvanzyl $ */ public interface ArtifactFilter { boolean include( Artifact artifact ); } ././@LongLink0000000000000000000000000000016100000000000011563 Lustar rootrootmaven2-core-2.2.1/maven-artifact/src/main/java/org/apache/maven/artifact/resolver/filter/ExclusionSetFilter.javamaven2-core-2.2.1/maven-artifact/src/main/java/org/apache/maven/artifact/resolver/filter/ExclusionSe0000644000175000017500000000314010551365651033357 0ustar twernertwernerpackage org.apache.maven.artifact.resolver.filter; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import org.apache.maven.artifact.Artifact; import java.util.Arrays; import java.util.HashSet; import java.util.Set; /** * @author Jason van Zyl * @version $Id: ExclusionSetFilter.java 495147 2007-01-11 07:47:53Z jvanzyl $ */ public class ExclusionSetFilter implements ArtifactFilter { private Set excludes; public ExclusionSetFilter( String[] excludes ) { this.excludes = new HashSet( Arrays.asList( excludes ) ); } public ExclusionSetFilter( Set excludes ) { this.excludes = excludes; } public boolean include( Artifact artifact ) { if ( excludes.contains( artifact.getArtifactId() ) ) { return false; } return true; } } ././@LongLink0000000000000000000000000000016500000000000011567 Lustar rootrootmaven2-core-2.2.1/maven-artifact/src/main/java/org/apache/maven/artifact/resolver/filter/IncludesArtifactFilter.javamaven2-core-2.2.1/maven-artifact/src/main/java/org/apache/maven/artifact/resolver/filter/IncludesArt0000644000175000017500000000345210551365651033341 0ustar twernertwernerpackage org.apache.maven.artifact.resolver.filter; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import org.apache.maven.artifact.Artifact; import java.util.Iterator; import java.util.List; /** * Filter to include from a list of artifact patterns. * * @author Brett Porter * @version $Id: IncludesArtifactFilter.java 495147 2007-01-11 07:47:53Z jvanzyl $ */ public class IncludesArtifactFilter implements ArtifactFilter { private final List patterns; public IncludesArtifactFilter( List patterns ) { this.patterns = patterns; } public boolean include( Artifact artifact ) { String id = artifact.getGroupId() + ":" + artifact.getArtifactId(); boolean matched = false; for ( Iterator i = patterns.iterator(); i.hasNext() & !matched; ) { // TODO: what about wildcards? Just specifying groups? versions? if ( id.equals( i.next() ) ) { matched = true; } } return matched; } } ././@LongLink0000000000000000000000000000016000000000000011562 Lustar rootrootmaven2-core-2.2.1/maven-artifact/src/main/java/org/apache/maven/artifact/resolver/filter/AndArtifactFilter.javamaven2-core-2.2.1/maven-artifact/src/main/java/org/apache/maven/artifact/resolver/filter/AndArtifact0000644000175000017500000000334210551365651033302 0ustar twernertwernerpackage org.apache.maven.artifact.resolver.filter; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import org.apache.maven.artifact.Artifact; import java.util.ArrayList; import java.util.Iterator; import java.util.List; /** * Apply multiple filters. * * @author Brett Porter * @version $Id: AndArtifactFilter.java 495147 2007-01-11 07:47:53Z jvanzyl $ */ public class AndArtifactFilter implements ArtifactFilter { private final List filters = new ArrayList(); public boolean include( Artifact artifact ) { boolean include = true; for ( Iterator i = filters.iterator(); i.hasNext() && include; ) { ArtifactFilter filter = (ArtifactFilter) i.next(); if ( !filter.include( artifact ) ) { include = false; } } return include; } public void add( ArtifactFilter artifactFilter ) { filters.add( artifactFilter ); } } ././@LongLink0000000000000000000000000000016600000000000011570 Lustar rootrootmaven2-core-2.2.1/maven-artifact/src/main/java/org/apache/maven/artifact/resolver/filter/InversionArtifactFilter.javamaven2-core-2.2.1/maven-artifact/src/main/java/org/apache/maven/artifact/resolver/filter/InversionAr0000644000175000017500000000233010772004567033356 0ustar twernertwernerpackage org.apache.maven.artifact.resolver.filter; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import org.apache.maven.artifact.Artifact; public class InversionArtifactFilter implements ArtifactFilter { private final ArtifactFilter toInvert; public InversionArtifactFilter( ArtifactFilter toInvert ) { this.toInvert = toInvert; } public boolean include( Artifact artifact ) { return !toInvert.include( artifact ); } } ././@LongLink0000000000000000000000000000016500000000000011567 Lustar rootrootmaven2-core-2.2.1/maven-artifact/src/main/java/org/apache/maven/artifact/resolver/filter/ExcludesArtifactFilter.javamaven2-core-2.2.1/maven-artifact/src/main/java/org/apache/maven/artifact/resolver/filter/ExcludesArt0000644000175000017500000000270610551365651033350 0ustar twernertwernerpackage org.apache.maven.artifact.resolver.filter; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import org.apache.maven.artifact.Artifact; import java.util.List; /** * Filter to exclude from a list of artifact patterns. * * @author Brett Porter * @version $Id: ExcludesArtifactFilter.java 495147 2007-01-11 07:47:53Z jvanzyl $ * @todo I think this is equiv. to exclusion set filter in maven-core */ public class ExcludesArtifactFilter extends IncludesArtifactFilter { public ExcludesArtifactFilter( List patterns ) { super( patterns ); } public boolean include( Artifact artifact ) { return !super.include( artifact ); } } ././@LongLink0000000000000000000000000000016400000000000011566 Lustar rootrootmaven2-core-2.2.1/maven-artifact/src/main/java/org/apache/maven/artifact/resolver/ResolutionListenerForDepMgmt.javamaven2-core-2.2.1/maven-artifact/src/main/java/org/apache/maven/artifact/resolver/ResolutionListener0000644000175000017500000000263210772004567033510 0ustar twernertwernerpackage org.apache.maven.artifact.resolver; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import org.apache.maven.artifact.Artifact; /** * Do not use! * * Should only be implmemented by DebugResolutionListener. Remove this * when the ResolutionListener interface deprecation of the manageArtifact * method (and the [yet to be done] addition of these methods to that * interface) has had a chance to propagate to all interested plugins. * * @deprecated */ public interface ResolutionListenerForDepMgmt { void manageArtifactVersion( Artifact artifact, Artifact replacement ); void manageArtifactScope( Artifact artifact, Artifact replacement ); }././@LongLink0000000000000000000000000000017200000000000011565 Lustar rootrootmaven2-core-2.2.1/maven-artifact/src/main/java/org/apache/maven/artifact/resolver/MultipleArtifactsNotFoundException.javamaven2-core-2.2.1/maven-artifact/src/main/java/org/apache/maven/artifact/resolver/MultipleArtifactsN0000644000175000017500000000755710772004567033424 0ustar twernertwernerpackage org.apache.maven.artifact.resolver; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import java.util.ArrayList; import java.util.Iterator; import java.util.List; import org.apache.maven.artifact.Artifact; /** * Exception caused when one or more artifacts can not be resolved because they are not found in the * local or remote repositories. */ public class MultipleArtifactsNotFoundException extends ArtifactResolutionException { private final List resolvedArtifacts; private final List missingArtifacts; /** * @deprecated use {@link #MultipleArtifactsNotFoundException(Artifact, List, List, List)} */ public MultipleArtifactsNotFoundException( Artifact originatingArtifact, List missingArtifacts, List remoteRepositories ) { this( originatingArtifact, new ArrayList(), missingArtifacts, remoteRepositories ); } /** * Create an instance of the exception with allrequired information. * * @param originatingArtifact the artifact that was being resolved * @param resolvedArtifacts artifacts that could be resolved * @param missingArtifacts artifacts that could not be resolved * @param remoteRepositories remote repositories where the missing artifacts were not found */ public MultipleArtifactsNotFoundException( Artifact originatingArtifact, List resolvedArtifacts, List missingArtifacts, List remoteRepositories ) { super( constructMessage( missingArtifacts ), originatingArtifact, remoteRepositories ); this.resolvedArtifacts = resolvedArtifacts; this.missingArtifacts = missingArtifacts; } /** * artifacts that could be resolved * @return {@link List} of {@link Artifact} */ public List getResolvedArtifacts() { return resolvedArtifacts; } /** * artifacts that could NOT be resolved * @return {@link List} of {@link Artifact} */ public List getMissingArtifacts() { return missingArtifacts; } private static String constructMessage( List artifacts ) { StringBuffer buffer = new StringBuffer( "Missing:\n" ); buffer.append( "----------\n" ); int counter = 0; for ( Iterator i = artifacts.iterator(); i.hasNext(); ) { Artifact artifact = (Artifact) i.next(); String message = ( ++counter ) + ") " + artifact.getId(); buffer.append( constructMissingArtifactMessage( message, " ", artifact.getGroupId(), artifact .getArtifactId(), artifact.getVersion(), artifact.getType(), artifact.getClassifier(), artifact.getDownloadUrl(), artifact .getDependencyTrail() ) ); } buffer.append( "----------\n" ); int size = artifacts.size(); buffer.append( size ).append( " required artifact" ); if ( size > 1 ) { buffer.append( "s are" ); } else { buffer.append( " is" ); } buffer.append( " missing.\n\nfor artifact: " ); return buffer.toString(); } } ././@LongLink0000000000000000000000000000016000000000000011562 Lustar rootrootmaven2-core-2.2.1/maven-artifact/src/main/java/org/apache/maven/artifact/resolver/DefaultArtifactCollector.javamaven2-core-2.2.1/maven-artifact/src/main/java/org/apache/maven/artifact/resolver/DefaultArtifactCol0000644000175000017500000007225511236401176033340 0ustar twernertwernerpackage org.apache.maven.artifact.resolver; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.metadata.ArtifactMetadataRetrievalException; import org.apache.maven.artifact.metadata.ArtifactMetadataSource; import org.apache.maven.artifact.metadata.ResolutionGroup; import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.artifact.resolver.filter.AndArtifactFilter; import org.apache.maven.artifact.resolver.filter.ArtifactFilter; import org.apache.maven.artifact.versioning.ArtifactVersion; import org.apache.maven.artifact.versioning.ManagedVersionMap; import org.apache.maven.artifact.versioning.OverConstrainedVersionException; import org.apache.maven.artifact.versioning.VersionRange; import java.util.ArrayList; import java.util.Collections; import java.util.Iterator; import java.util.LinkedHashMap; import java.util.LinkedHashSet; import java.util.List; import java.util.Map; import java.util.Set; /** * Default implementation of the artifact collector. * * @author Brett Porter * @version $Id: DefaultArtifactCollector.java 801437 2009-08-05 22:06:54Z jdcasey $ */ public class DefaultArtifactCollector implements ArtifactCollector { public ArtifactResolutionResult collect( Set artifacts, Artifact originatingArtifact, ArtifactRepository localRepository, List remoteRepositories, ArtifactMetadataSource source, ArtifactFilter filter, List listeners ) throws ArtifactResolutionException { return collect( artifacts, originatingArtifact, Collections.EMPTY_MAP, localRepository, remoteRepositories, source, filter, listeners ); } public ArtifactResolutionResult collect( Set artifacts, Artifact originatingArtifact, Map managedVersions, ArtifactRepository localRepository, List remoteRepositories, ArtifactMetadataSource source, ArtifactFilter filter, List listeners ) throws ArtifactResolutionException { Map resolvedArtifacts = new LinkedHashMap(); ResolutionNode root = new ResolutionNode( originatingArtifact, remoteRepositories ); root.addDependencies( artifacts, remoteRepositories, filter ); ManagedVersionMap versionMap = getManagedVersionsMap( originatingArtifact, managedVersions ); recurse( originatingArtifact, root, resolvedArtifacts, versionMap, localRepository, remoteRepositories, source, filter, listeners ); Set set = new LinkedHashSet(); for ( Iterator i = resolvedArtifacts.values().iterator(); i.hasNext(); ) { List nodes = (List) i.next(); for ( Iterator j = nodes.iterator(); j.hasNext(); ) { ResolutionNode node = (ResolutionNode) j.next(); if ( !node.equals( root ) && node.isActive() ) { Artifact artifact = node.getArtifact(); if ( node.filterTrail( filter ) ) { // If it was optional and not a direct dependency, // we don't add it or its children, just allow the update of the version and scope if ( node.isChildOfRootNode() || !artifact.isOptional() ) { artifact.setDependencyTrail( node.getDependencyTrail() ); set.add( node ); } } } } } ArtifactResolutionResult result = new ArtifactResolutionResult(); result.setArtifactResolutionNodes( set ); return result; } /** * Get the map of managed versions, removing the originating artifact if it is also in managed versions * @param originatingArtifact artifact we are processing * @param managedVersions original managed versions */ private ManagedVersionMap getManagedVersionsMap( Artifact originatingArtifact, Map managedVersions ) { ManagedVersionMap versionMap; if ( managedVersions != null && managedVersions instanceof ManagedVersionMap ) { versionMap = (ManagedVersionMap) managedVersions; } else { versionMap = new ManagedVersionMap( managedVersions ); } /* remove the originating artifact if it is also in managed versions to avoid being modified during resolution */ Artifact managedOriginatingArtifact = (Artifact) versionMap.get( originatingArtifact.getDependencyConflictId() ); if ( managedOriginatingArtifact != null ) { // TODO we probably want to warn the user that he is building an artifact with // different values than in dependencyManagement if ( managedVersions instanceof ManagedVersionMap ) { /* avoid modifying the managedVersions parameter creating a new map */ versionMap = new ManagedVersionMap( managedVersions ); } versionMap.remove( originatingArtifact.getDependencyConflictId() ); } return versionMap; } private void recurse( Artifact originatingArtifact, ResolutionNode node, Map resolvedArtifacts, ManagedVersionMap managedVersions, ArtifactRepository localRepository, List remoteRepositories, ArtifactMetadataSource source, ArtifactFilter filter, List listeners ) throws CyclicDependencyException, ArtifactResolutionException, OverConstrainedVersionException { fireEvent( ResolutionListener.TEST_ARTIFACT, listeners, node ); Object key = node.getKey(); // TODO: Does this check need to happen here? Had to add the same call // below when we iterate on child nodes -- will that suffice? if ( managedVersions.containsKey( key )) { manageArtifact( node, managedVersions, listeners ); } List previousNodes = (List) resolvedArtifacts.get( key ); if ( previousNodes != null ) { for ( Iterator i = previousNodes.iterator(); i.hasNext(); ) { ResolutionNode previous = (ResolutionNode) i.next(); if ( previous.isActive() ) { // Version mediation VersionRange previousRange = previous.getArtifact().getVersionRange(); VersionRange currentRange = node.getArtifact().getVersionRange(); if ( previousRange != null && currentRange != null ) { // TODO: shouldn't need to double up on this work, only done for simplicity of handling recommended // version but the restriction is identical VersionRange newRange = previousRange.restrict( currentRange ); // TODO: ick. this forces the OCE that should have come from the previous call. It is still correct if ( newRange.isSelectedVersionKnown( previous.getArtifact() ) ) { fireEvent( ResolutionListener.RESTRICT_RANGE, listeners, node, previous.getArtifact(), newRange ); } previous.getArtifact().setVersionRange( newRange ); node.getArtifact().setVersionRange( currentRange.restrict( previousRange ) ); //Select an appropriate available version from the (now restricted) range //Note this version was selected before to get the appropriate POM //But it was reset by the call to setVersionRange on restricting the version ResolutionNode[] resetNodes = {previous, node}; for ( int j = 0; j < 2; j++ ) { Artifact resetArtifact = resetNodes[j].getArtifact(); //MNG-2123: if the previous node was not a range, then it wouldn't have any available //versions. We just clobbered the selected version above. (why? i have no idea.) //So since we are here and this is ranges we must go figure out the version (for a third time...) if ( resetArtifact.getVersion() == null && resetArtifact.getVersionRange() != null ) { // go find the version. This is a total hack. See previous comment. List versions = resetArtifact.getAvailableVersions(); if ( versions == null ) { try { versions = source.retrieveAvailableVersions( resetArtifact, localRepository, remoteRepositories ); resetArtifact.setAvailableVersions( versions ); } catch ( ArtifactMetadataRetrievalException e ) { resetArtifact.setDependencyTrail( node.getDependencyTrail() ); throw new ArtifactResolutionException( "Unable to get dependency information: " + e.getMessage(), resetArtifact, remoteRepositories, e ); } } //end hack //MNG-2861: match version can return null ArtifactVersion selectedVersion = resetArtifact.getVersionRange().matchVersion( resetArtifact.getAvailableVersions() ); if (selectedVersion != null) { resetArtifact.selectVersion( selectedVersion.toString() ); } else { throw new OverConstrainedVersionException(" Unable to find a version in "+ resetArtifact.getAvailableVersions()+" to match the range "+ resetArtifact.getVersionRange(), resetArtifact); } fireEvent( ResolutionListener.SELECT_VERSION_FROM_RANGE, listeners, resetNodes[j] ); } } } // Conflict Resolution // TODO: use as conflict resolver(s), chain // TODO: should this be part of mediation? // previous one is more dominant ResolutionNode nearest; ResolutionNode farthest; if ( previous.getDepth() <= node.getDepth() ) { nearest = previous; farthest = node; } else { nearest = node; farthest = previous; } if ( checkScopeUpdate( farthest, nearest, listeners ) ) { // if we need to update scope of nearest to use farthest scope, use the nearest version, but farthest scope nearest.disable(); farthest.getArtifact().setVersion( nearest.getArtifact().getVersion() ); fireEvent( ResolutionListener.OMIT_FOR_NEARER, listeners, nearest, farthest.getArtifact() ); } else { farthest.disable(); fireEvent( ResolutionListener.OMIT_FOR_NEARER, listeners, farthest, nearest.getArtifact() ); } } } } else { previousNodes = new ArrayList(); resolvedArtifacts.put( key, previousNodes ); } previousNodes.add( node ); if ( node.isActive() ) { fireEvent( ResolutionListener.INCLUDE_ARTIFACT, listeners, node ); } // don't pull in the transitive deps of a system-scoped dependency. if ( node.isActive() && !Artifact.SCOPE_SYSTEM.equals( node.getArtifact().getScope() ) ) { fireEvent( ResolutionListener.PROCESS_CHILDREN, listeners, node ); Artifact parentArtifact = node.getArtifact(); for ( Iterator i = node.getChildrenIterator(); i.hasNext(); ) { ResolutionNode child = (ResolutionNode) i.next(); // We leave in optional ones, but don't pick up its dependencies if ( !child.isResolved() && ( !child.getArtifact().isOptional() || child.isChildOfRootNode() ) ) { Artifact artifact = child.getArtifact(); artifact.setDependencyTrail( node.getDependencyTrail() ); List childRemoteRepositories = child.getRemoteRepositories(); try { Object childKey; do { childKey = child.getKey(); if ( managedVersions.containsKey( childKey ) ) { // If this child node is a managed dependency, ensure // we are using the dependency management version // of this child if applicable b/c we want to use the // managed version's POM, *not* any other version's POM. // We retrieve the POM below in the retrieval step. manageArtifact( child, managedVersions, listeners ); // Also, we need to ensure that any exclusions it presents are // added to the artifact before we retrieve the metadata // for the artifact; otherwise we may end up with unwanted // dependencies. Artifact ma = (Artifact) managedVersions.get( childKey ); ArtifactFilter managedExclusionFilter = ma.getDependencyFilter(); if ( null != managedExclusionFilter ) { if ( null != artifact.getDependencyFilter() ) { AndArtifactFilter aaf = new AndArtifactFilter(); aaf.add( artifact.getDependencyFilter() ); aaf.add( managedExclusionFilter ); artifact.setDependencyFilter( aaf ); } else { artifact.setDependencyFilter( managedExclusionFilter ); } } } if ( artifact.getVersion() == null ) { // set the recommended version // TODO: maybe its better to just pass the range through to retrieval and use a transformation? ArtifactVersion version; if ( artifact.isSelectedVersionKnown() ) { version = artifact.getSelectedVersion(); } else { //go find the version List versions = artifact.getAvailableVersions(); if ( versions == null ) { versions = source.retrieveAvailableVersions( artifact, localRepository, childRemoteRepositories ); artifact.setAvailableVersions( versions ); } Collections.sort( versions ); VersionRange versionRange = artifact.getVersionRange(); version = versionRange.matchVersion( versions ); if ( version == null ) { if ( versions.isEmpty() ) { throw new OverConstrainedVersionException( "No versions are present in the repository for the artifact with a range " + versionRange, artifact, childRemoteRepositories ); } throw new OverConstrainedVersionException( "Couldn't find a version in " + versions + " to match range " + versionRange, artifact, childRemoteRepositories ); } } //this is dangerous because artifact.getSelectedVersion() can //return null. However it is ok here because we first check if the //selected version is known. As currently coded we can't get a null here. artifact.selectVersion( version.toString() ); fireEvent( ResolutionListener.SELECT_VERSION_FROM_RANGE, listeners, child ); } Artifact relocated = source.retrieveRelocatedArtifact( artifact, localRepository, childRemoteRepositories ); if ( relocated != null && !artifact.equals( relocated ) ) { relocated.setDependencyFilter( artifact.getDependencyFilter() ); artifact = relocated; child.setArtifact( artifact ); } } while( !childKey.equals( child.getKey() ) ); if ( parentArtifact != null && parentArtifact.getDependencyFilter() != null && !parentArtifact.getDependencyFilter().include( artifact ) ) { // MNG-3769: the [probably relocated] artifact is excluded. // We could process exclusions on relocated artifact details in the // MavenMetadataSource.createArtifacts(..) step, BUT that would // require resolving the POM from the repository very early on in // the build. continue; } ResolutionGroup rGroup = source.retrieve( artifact, localRepository, childRemoteRepositories ); //TODO might be better to have source.retrieve() throw a specific exception for this situation //and catch here rather than have it return null if ( rGroup == null ) { //relocated dependency artifact is declared excluded, no need to add and recurse further continue; } child.addDependencies( rGroup.getArtifacts(), rGroup.getResolutionRepositories(), filter ); } catch ( CyclicDependencyException e ) { // would like to throw this, but we have crappy stuff in the repo fireEvent( ResolutionListener.OMIT_FOR_CYCLE, listeners, new ResolutionNode( e.getArtifact(), childRemoteRepositories, child ) ); } catch ( ArtifactMetadataRetrievalException e ) { artifact.setDependencyTrail( node.getDependencyTrail() ); throw new ArtifactResolutionException( "Unable to get dependency information: " + e.getMessage(), artifact, childRemoteRepositories, e ); } recurse( originatingArtifact, child, resolvedArtifacts, managedVersions, localRepository, childRemoteRepositories, source, filter, listeners ); } } fireEvent( ResolutionListener.FINISH_PROCESSING_CHILDREN, listeners, node ); } } private void manageArtifact( ResolutionNode node, ManagedVersionMap managedVersions, List listeners ) { Artifact artifact = (Artifact) managedVersions.get( node.getKey() ); // Before we update the version of the artifact, we need to know // whether we are working on a transitive dependency or not. This // allows depMgmt to always override transitive dependencies, while // explicit child override depMgmt (viz. depMgmt should only // provide defaults to children, but should override transitives). // We can do this by calling isChildOfRootNode on the current node. if ( artifact.getVersion() != null && ( node.isChildOfRootNode() ? node.getArtifact().getVersion() == null : true ) ) { fireEvent( ResolutionListener.MANAGE_ARTIFACT_VERSION, listeners, node, artifact ); node.getArtifact().setVersion( artifact.getVersion() ); } if ( artifact.getScope() != null && ( node.isChildOfRootNode() ? node.getArtifact().getScope() == null : true ) ) { fireEvent( ResolutionListener.MANAGE_ARTIFACT_SCOPE, listeners, node, artifact ); node.getArtifact().setScope( artifact.getScope() ); } } /** * Check if the scope needs to be updated. * More info. * * @param farthest farthest resolution node * @param nearest nearest resolution node * @param listeners */ boolean checkScopeUpdate( ResolutionNode farthest, ResolutionNode nearest, List listeners ) { boolean updateScope = false; Artifact farthestArtifact = farthest.getArtifact(); Artifact nearestArtifact = nearest.getArtifact(); /* farthest is runtime and nearest has lower priority, change to runtime */ if ( Artifact.SCOPE_RUNTIME.equals( farthestArtifact.getScope() ) && ( Artifact.SCOPE_TEST.equals( nearestArtifact.getScope() ) || Artifact.SCOPE_PROVIDED.equals( nearestArtifact.getScope() ) ) ) { updateScope = true; } /* farthest is compile and nearest is not (has lower priority), change to compile */ if ( Artifact.SCOPE_COMPILE.equals( farthestArtifact.getScope() ) && !Artifact.SCOPE_COMPILE.equals( nearestArtifact.getScope() ) ) { updateScope = true; } /* current POM rules all, if nearest is in current pom, do not update its scope */ if ( nearest.getDepth() < 2 && updateScope ) { updateScope = false; fireEvent( ResolutionListener.UPDATE_SCOPE_CURRENT_POM, listeners, nearest, farthestArtifact ); } if ( updateScope ) { fireEvent( ResolutionListener.UPDATE_SCOPE, listeners, nearest, farthestArtifact ); // previously we cloned the artifact, but it is more effecient to just update the scope // if problems are later discovered that the original object needs its original scope value, cloning may // again be appropriate nearestArtifact.setScope( farthestArtifact.getScope() ); } return updateScope; } private void fireEvent( int event, List listeners, ResolutionNode node ) { fireEvent( event, listeners, node, null ); } private void fireEvent( int event, List listeners, ResolutionNode node, Artifact replacement ) { fireEvent( event, listeners, node, replacement, null ); } private void fireEvent( int event, List listeners, ResolutionNode node, Artifact replacement, VersionRange newRange ) { for ( Iterator i = listeners.iterator(); i.hasNext(); ) { ResolutionListener listener = (ResolutionListener) i.next(); switch ( event ) { case ResolutionListener.TEST_ARTIFACT: listener.testArtifact( node.getArtifact() ); break; case ResolutionListener.PROCESS_CHILDREN: listener.startProcessChildren( node.getArtifact() ); break; case ResolutionListener.FINISH_PROCESSING_CHILDREN: listener.endProcessChildren( node.getArtifact() ); break; case ResolutionListener.INCLUDE_ARTIFACT: listener.includeArtifact( node.getArtifact() ); break; case ResolutionListener.OMIT_FOR_NEARER: listener.omitForNearer( node.getArtifact(), replacement ); break; case ResolutionListener.OMIT_FOR_CYCLE: listener.omitForCycle( node.getArtifact() ); break; case ResolutionListener.UPDATE_SCOPE: listener.updateScope( node.getArtifact(), replacement.getScope() ); break; case ResolutionListener.UPDATE_SCOPE_CURRENT_POM: listener.updateScopeCurrentPom( node.getArtifact(), replacement.getScope() ); break; case ResolutionListener.MANAGE_ARTIFACT_VERSION: if (listener instanceof ResolutionListenerForDepMgmt) { ResolutionListenerForDepMgmt asImpl = (ResolutionListenerForDepMgmt) listener; asImpl.manageArtifactVersion( node.getArtifact(), replacement ); } else { listener.manageArtifact( node.getArtifact(), replacement ); } break; case ResolutionListener.MANAGE_ARTIFACT_SCOPE: if (listener instanceof ResolutionListenerForDepMgmt) { ResolutionListenerForDepMgmt asImpl = (ResolutionListenerForDepMgmt) listener; asImpl.manageArtifactScope( node.getArtifact(), replacement ); } else { listener.manageArtifact( node.getArtifact(), replacement ); } break; case ResolutionListener.SELECT_VERSION_FROM_RANGE: listener.selectVersionFromRange( node.getArtifact() ); break; case ResolutionListener.RESTRICT_RANGE: if ( node.getArtifact().getVersionRange().hasRestrictions() || replacement.getVersionRange().hasRestrictions() ) { listener.restrictRange( node.getArtifact(), replacement, newRange ); } break; default: throw new IllegalStateException( "Unknown event: " + event ); } } } } ././@LongLink0000000000000000000000000000015000000000000011561 Lustar rootrootmaven2-core-2.2.1/maven-artifact/src/main/java/org/apache/maven/artifact/resolver/ArtifactResolver.javamaven2-core-2.2.1/maven-artifact/src/main/java/org/apache/maven/artifact/resolver/ArtifactResolver.j0000644000175000017500000001236210551365651033346 0ustar twernertwernerpackage org.apache.maven.artifact.resolver; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.metadata.ArtifactMetadataSource; import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.artifact.resolver.filter.ArtifactFilter; import java.util.List; import java.util.Map; import java.util.Set; /** * I want to use it for hidding the fact that sometime artifact must be * downloaded. I am just asking LocalRepository for given artifact and I don't * care if it is alredy there or how it will get there. * * @author Michal Maczka * @version $Id: ArtifactResolver.java 495147 2007-01-11 07:47:53Z jvanzyl $ * @todo possibly fix the signatures, it's unfortunate that in some methods the local repo is listed first and second in others. */ public interface ArtifactResolver { String ROLE = ArtifactResolver.class.getName(); void resolve( Artifact artifact, List remoteRepositories, ArtifactRepository localRepository ) throws ArtifactResolutionException, ArtifactNotFoundException; ArtifactResolutionResult resolveTransitively( Set artifacts, Artifact originatingArtifact, List remoteRepositories, ArtifactRepository localRepository, ArtifactMetadataSource source ) throws ArtifactResolutionException, ArtifactNotFoundException; ArtifactResolutionResult resolveTransitively( Set artifacts, Artifact originatingArtifact, List remoteRepositories, ArtifactRepository localRepository, ArtifactMetadataSource source, List listeners ) throws ArtifactResolutionException, ArtifactNotFoundException; ArtifactResolutionResult resolveTransitively( Set artifacts, Artifact originatingArtifact, ArtifactRepository localRepository, List remoteRepositories, ArtifactMetadataSource source, ArtifactFilter filter ) throws ArtifactResolutionException, ArtifactNotFoundException; ArtifactResolutionResult resolveTransitively( Set artifacts, Artifact originatingArtifact, Map managedVersions, ArtifactRepository localRepository, List remoteRepositories, ArtifactMetadataSource source ) throws ArtifactResolutionException, ArtifactNotFoundException; ArtifactResolutionResult resolveTransitively( Set artifacts, Artifact originatingArtifact, Map managedVersions, ArtifactRepository localRepository, List remoteRepositories, ArtifactMetadataSource source, ArtifactFilter filter ) throws ArtifactResolutionException, ArtifactNotFoundException; ArtifactResolutionResult resolveTransitively( Set artifacts, Artifact originatingArtifact, Map managedVersions, ArtifactRepository localRepository, List remoteRepositories, ArtifactMetadataSource source, ArtifactFilter filter, List listeners ) throws ArtifactResolutionException, ArtifactNotFoundException; void resolveAlways( Artifact artifact, List remoteRepositories, ArtifactRepository localRepository ) throws ArtifactResolutionException, ArtifactNotFoundException; }././@LongLink0000000000000000000000000000014600000000000011566 Lustar rootrootmaven2-core-2.2.1/maven-artifact/src/main/java/org/apache/maven/artifact/resolver/ResolutionNode.javamaven2-core-2.2.1/maven-artifact/src/main/java/org/apache/maven/artifact/resolver/ResolutionNode.jav0000644000175000017500000001541011035020441033343 0ustar twernertwernerpackage org.apache.maven.artifact.resolver; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.resolver.filter.ArtifactFilter; import org.apache.maven.artifact.versioning.ArtifactVersion; import org.apache.maven.artifact.versioning.OverConstrainedVersionException; import java.util.ArrayList; import java.util.Collections; import java.util.Iterator; import java.util.LinkedList; import java.util.List; import java.util.Set; public class ResolutionNode { private Artifact artifact; private List children; private final List parents; private final int depth; private final ResolutionNode parent; private final List remoteRepositories; private boolean active = true; private List trail; public ResolutionNode( Artifact artifact, List remoteRepositories ) { this.artifact = artifact; this.remoteRepositories = remoteRepositories; depth = 0; parents = Collections.EMPTY_LIST; parent = null; } public ResolutionNode( Artifact artifact, List remoteRepositories, ResolutionNode parent ) { this.artifact = artifact; this.remoteRepositories = remoteRepositories; depth = parent.depth + 1; parents = new ArrayList(); parents.addAll( parent.parents ); parents.add( parent.getKey() ); this.parent = parent; } public void setArtifact( Artifact artifact ) { this.artifact = artifact; } public Artifact getArtifact() { return artifact; } public Object getKey() { return artifact.getDependencyConflictId(); } public void addDependencies( Set artifacts, List remoteRepositories, ArtifactFilter filter ) throws CyclicDependencyException, OverConstrainedVersionException { if ( !artifacts.isEmpty() ) { children = new ArrayList( artifacts.size() ); for ( Iterator i = artifacts.iterator(); i.hasNext(); ) { Artifact a = (Artifact) i.next(); if ( parents.contains( a.getDependencyConflictId() ) ) { a.setDependencyTrail( getDependencyTrail() ); throw new CyclicDependencyException( "A dependency has introduced a cycle", a ); } children.add( new ResolutionNode( a, remoteRepositories, this ) ); } } else { children = Collections.EMPTY_LIST; } trail = null; } /** * @return {@link List} < {@link String} > with artifact ids * @throws OverConstrainedVersionException */ public List getDependencyTrail() throws OverConstrainedVersionException { List trial = getTrail(); List ret = new ArrayList( trial.size() ); for ( Iterator i = trial.iterator(); i.hasNext(); ) { Artifact artifact = (Artifact) i.next(); ret.add( artifact.getId() ); } return ret; } private List getTrail() throws OverConstrainedVersionException { if ( trail == null ) { List ids = new LinkedList(); ResolutionNode node = this; while ( node != null ) { Artifact artifact = node.getArtifact(); if ( artifact.getVersion() == null ) { // set the recommended version ArtifactVersion selected = artifact.getSelectedVersion(); //MNG-2123: null is a valid response to getSelectedVersion, don't //assume it won't ever be. if (selected != null) { artifact.selectVersion( selected.toString() ); } else { throw new OverConstrainedVersionException("Unable to get a selected Version for "+ artifact.getArtifactId(),artifact); } } ids.add( 0, artifact ); node = node.parent; } trail = ids; } return trail; } public boolean isResolved() { return children != null; } public boolean isChildOfRootNode() { return parent != null && parent.parent == null; } public Iterator getChildrenIterator() { return children.iterator(); } public int getDepth() { return depth; } public List getRemoteRepositories() { return remoteRepositories; } public boolean isActive() { return active; } public void enable() { active = true; // TODO: if it was null, we really need to go find them now... or is this taken care of by the ordering? if ( children != null ) { for ( Iterator i = children.iterator(); i.hasNext(); ) { ResolutionNode node = (ResolutionNode) i.next(); node.enable(); } } } public void disable() { active = false; if ( children != null ) { for ( Iterator i = children.iterator(); i.hasNext(); ) { ResolutionNode node = (ResolutionNode) i.next(); node.disable(); } } } public boolean filterTrail( ArtifactFilter filter ) throws OverConstrainedVersionException { boolean success = true; if ( filter != null ) { for ( Iterator i = getTrail().iterator(); i.hasNext() && success; ) { Artifact artifact = (Artifact) i.next(); if ( !filter.include( artifact ) ) { success = false; } } } return success; } public String toString() { return artifact.toString() + " (" + depth + "; " + ( active ? "enabled" : "disabled" ) + ")"; } } ././@LongLink0000000000000000000000000000015100000000000011562 Lustar rootrootmaven2-core-2.2.1/maven-artifact/src/main/java/org/apache/maven/artifact/resolver/ArtifactCollector.javamaven2-core-2.2.1/maven-artifact/src/main/java/org/apache/maven/artifact/resolver/ArtifactCollector.0000644000175000017500000000423510772004567033322 0ustar twernertwernerpackage org.apache.maven.artifact.resolver; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.metadata.ArtifactMetadataSource; import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.artifact.resolver.filter.ArtifactFilter; import java.util.List; import java.util.Map; import java.util.Set; /** * Artifact collector - takes a set of original artifacts and resolves all of the best versions to use * along with their metadata. No artifacts are downloaded. * * @author Brett Porter * @version $Id: ArtifactCollector.java 640549 2008-03-24 20:05:11Z bentmann $ */ public interface ArtifactCollector { ArtifactResolutionResult collect( Set artifacts, Artifact originatingArtifact, ArtifactRepository localRepository, List remoteRepositories, ArtifactMetadataSource source, ArtifactFilter filter, List listeners ) throws ArtifactResolutionException; ArtifactResolutionResult collect( Set artifacts, Artifact originatingArtifact, Map managedVersions, ArtifactRepository localRepository, List remoteRepositories, ArtifactMetadataSource source, ArtifactFilter filter, List listeners ) throws ArtifactResolutionException; } maven2-core-2.2.1/maven-artifact/src/main/java/org/apache/maven/artifact/resolver/conflict/0000755000175000017500000000000011250552242031500 5ustar twernertwerner././@LongLink0000000000000000000000000000017000000000000011563 Lustar rootrootmaven2-core-2.2.1/maven-artifact/src/main/java/org/apache/maven/artifact/resolver/conflict/DefaultConflictResolver.javamaven2-core-2.2.1/maven-artifact/src/main/java/org/apache/maven/artifact/resolver/conflict/DefaultCo0000644000175000017500000000210110551365651033274 0ustar twernertwernerpackage org.apache.maven.artifact.resolver.conflict; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ /** * @author Jason van Zyl * @version $Id: DefaultConflictResolver.java 495147 2007-01-11 07:47:53Z jvanzyl $ */ public class DefaultConflictResolver implements ConflictResolver { } ././@LongLink0000000000000000000000000000016100000000000011563 Lustar rootrootmaven2-core-2.2.1/maven-artifact/src/main/java/org/apache/maven/artifact/resolver/conflict/ConflictResolver.javamaven2-core-2.2.1/maven-artifact/src/main/java/org/apache/maven/artifact/resolver/conflict/ConflictR0000644000175000017500000000212210551365651033314 0ustar twernertwernerpackage org.apache.maven.artifact.resolver.conflict; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ /** * @author Jason van Zyl * @version $Id: ConflictResolver.java 495147 2007-01-11 07:47:53Z jvanzyl $ */ public interface ConflictResolver { static String ROLE = ConflictResolver.class.getName(); } ././@LongLink0000000000000000000000000000016300000000000011565 Lustar rootrootmaven2-core-2.2.1/maven-artifact/src/main/java/org/apache/maven/artifact/resolver/ArtifactResolutionException.javamaven2-core-2.2.1/maven-artifact/src/main/java/org/apache/maven/artifact/resolver/ArtifactResolution0000644000175000017500000000461010606222572033450 0ustar twernertwernerpackage org.apache.maven.artifact.resolver; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import org.apache.maven.artifact.Artifact; import java.util.List; /** * @author Jason van Zyl * @version $Id: ArtifactResolutionException.java 526578 2007-04-08 17:25:14Z brianf $ */ public class ArtifactResolutionException extends AbstractArtifactResolutionException { public ArtifactResolutionException( String message, String groupId, String artifactId, String version, String type, String classifier, List remoteRepositories, List path, Throwable t ) { super( message, groupId, artifactId, version, type, classifier, remoteRepositories, path, t ); } public ArtifactResolutionException( String message, String groupId, String artifactId, String version, String type, String classifier, Throwable t ) { super( message, groupId, artifactId, version, type, classifier,null, null, t ); } public ArtifactResolutionException( String message, Artifact artifact ) { super( message, artifact ); } public ArtifactResolutionException( String message, Artifact artifact, List remoteRepositories ) { super( message, artifact, remoteRepositories ); } public ArtifactResolutionException( String message, Artifact artifact, Throwable t ) { super( message, artifact, null, t ); } protected ArtifactResolutionException( String message, Artifact artifact, List remoteRepositories, Throwable t ) { super( message, artifact, remoteRepositories, t ); } } ././@LongLink0000000000000000000000000000016000000000000011562 Lustar rootrootmaven2-core-2.2.1/maven-artifact/src/main/java/org/apache/maven/artifact/resolver/ArtifactResolutionResult.javamaven2-core-2.2.1/maven-artifact/src/main/java/org/apache/maven/artifact/resolver/ArtifactResolution0000644000175000017500000000405310713623665033460 0ustar twernertwernerpackage org.apache.maven.artifact.resolver; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import java.util.Iterator; import java.util.LinkedHashSet; import java.util.Set; /** * @author Jason van Zyl * @version $Id: ArtifactResolutionResult.java 592009 2007-11-05 14:24:53Z hboutemy $ */ public class ArtifactResolutionResult { private Set resolutionNodes; // calculated. private Set artifacts; public ArtifactResolutionResult() { } public Set getArtifacts() { if ( artifacts == null ) { artifacts = new LinkedHashSet(); for ( Iterator it = resolutionNodes.iterator(); it.hasNext(); ) { ResolutionNode node = (ResolutionNode) it.next(); artifacts.add( node.getArtifact() ); } } return artifacts; } public Set getArtifactResolutionNodes() { return resolutionNodes; } public void setArtifactResolutionNodes( Set resolutionNodes ) { this.resolutionNodes = resolutionNodes; // clear the cache this.artifacts = null; } public String toString() { return "Artifacts: "+this.artifacts+" Nodes: "+ this.resolutionNodes; } } ././@LongLink0000000000000000000000000000015200000000000011563 Lustar rootrootmaven2-core-2.2.1/maven-artifact/src/main/java/org/apache/maven/artifact/resolver/ResolutionListener.javamaven2-core-2.2.1/maven-artifact/src/main/java/org/apache/maven/artifact/resolver/ResolutionListener0000644000175000017500000000614410772004567033512 0ustar twernertwernerpackage org.apache.maven.artifact.resolver; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.versioning.VersionRange; /** * Listens to the resolution process and handles events. * * @author Brett Porter * @version $Id: ResolutionListener.java 640549 2008-03-24 20:05:11Z bentmann $ */ public interface ResolutionListener { String ROLE = ResolutionListener.class.getName(); int TEST_ARTIFACT = 1; int PROCESS_CHILDREN = 2; int FINISH_PROCESSING_CHILDREN = 3; int INCLUDE_ARTIFACT = 4; int OMIT_FOR_NEARER = 5; int UPDATE_SCOPE = 6; /** * @deprecated */ int MANAGE_ARTIFACT = 7; int OMIT_FOR_CYCLE = 8; /** * this event means that the scope has NOT been updated to a farther node scope because current * node is in the first level pom */ int UPDATE_SCOPE_CURRENT_POM = 9; int SELECT_VERSION_FROM_RANGE = 10; int RESTRICT_RANGE = 11; int MANAGE_ARTIFACT_VERSION = 12; int MANAGE_ARTIFACT_SCOPE = 13; void testArtifact( Artifact node ); void startProcessChildren( Artifact artifact ); void endProcessChildren( Artifact artifact ); void includeArtifact( Artifact artifact ); void omitForNearer( Artifact omitted, Artifact kept ); void updateScope( Artifact artifact, String scope ); /** * @deprecated */ void manageArtifact( Artifact artifact, Artifact replacement ); // TODO Use the following two instead of manageArtifact // TODO Remove ResolutionListenerDM interface //void manageArtifactVersion( Artifact artifact, Artifact replacement ); //void manageArtifactScope( Artifact artifact, Artifact replacement ); void omitForCycle( Artifact artifact ); /** * This event means that the scope has NOT been updated to a farther node scope because current * node is in the first level pom * * @param artifact current node artifact, the one in the first level pom * @param ignoredScope scope that was ignored because artifact was in first level pom */ void updateScopeCurrentPom( Artifact artifact, String ignoredScope ); void selectVersionFromRange( Artifact artifact ); void restrictRange( Artifact artifact, Artifact replacement, VersionRange newRange ); } ././@LongLink0000000000000000000000000000016100000000000011563 Lustar rootrootmaven2-core-2.2.1/maven-artifact/src/main/java/org/apache/maven/artifact/resolver/CyclicDependencyException.javamaven2-core-2.2.1/maven-artifact/src/main/java/org/apache/maven/artifact/resolver/CyclicDependencyEx0000644000175000017500000000264710772004567033347 0ustar twernertwernerpackage org.apache.maven.artifact.resolver; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import org.apache.maven.artifact.Artifact; /** * Indiciates a cycle in the dependency graph. * * @author Brett Porter * @version $Id: CyclicDependencyException.java 640549 2008-03-24 20:05:11Z bentmann $ */ public class CyclicDependencyException extends ArtifactResolutionException { private Artifact artifact; public CyclicDependencyException( String message, Artifact artifact ) { super( message, artifact ); this.artifact = artifact; } public Artifact getArtifact() { return artifact; } } ././@LongLink0000000000000000000000000000017300000000000011566 Lustar rootrootmaven2-core-2.2.1/maven-artifact/src/main/java/org/apache/maven/artifact/resolver/AbstractArtifactResolutionException.javamaven2-core-2.2.1/maven-artifact/src/main/java/org/apache/maven/artifact/resolver/AbstractArtifactRe0000644000175000017500000002223611000003567033331 0ustar twernertwernerpackage org.apache.maven.artifact.resolver; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.repository.ArtifactRepository; import java.util.HashSet; import java.util.Iterator; import java.util.List; /** * Base class for artifact resolution exceptions. * * @author Brett Porter * @version $Id: AbstractArtifactResolutionException.java 647357 2008-04-12 00:51:03Z vsiveton $ */ public class AbstractArtifactResolutionException extends Exception { private String groupId; private String artifactId; private String version; private String type; private String classifier; private Artifact artifact; private List remoteRepositories; private final String originalMessage; private final String path; static final String LS = System.getProperty( "line.separator" ); protected AbstractArtifactResolutionException( String message, String groupId, String artifactId, String version, String type, String classifier, List remoteRepositories, List path ) { this( message, groupId, artifactId, version, type, classifier, remoteRepositories, path, null ); } protected AbstractArtifactResolutionException( String message, String groupId, String artifactId, String version, String type, String classifier, List remoteRepositories, List path, Throwable t ) { super( constructMessageBase( message, groupId, artifactId, version, type, remoteRepositories, path ), t ); this.originalMessage = message; this.groupId = groupId; this.artifactId = artifactId; this.type = type; this.classifier = classifier; this.version = version; this.remoteRepositories = remoteRepositories; this.path = constructArtifactPath( path, "" ); } protected AbstractArtifactResolutionException( String message, Artifact artifact ) { this( message, artifact, null ); } protected AbstractArtifactResolutionException( String message, Artifact artifact, List remoteRepositories ) { this( message, artifact, remoteRepositories, null ); } protected AbstractArtifactResolutionException( String message, Artifact artifact, List remoteRepositories, Throwable t ) { this( message, artifact.getGroupId(), artifact.getArtifactId(), artifact.getVersion(), artifact.getType(), artifact.getClassifier(),remoteRepositories, artifact.getDependencyTrail(), t ); this.artifact = artifact; } public Artifact getArtifact() { return artifact; } public String getGroupId() { return groupId; } public String getArtifactId() { return artifactId; } public String getVersion() { return version; } public String getType() { return type; } /** * @return the classifier */ public String getClassifier() { return this.classifier; } /** * @return the path */ public String getPath() { return this.path; } public List getRemoteRepositories() { return remoteRepositories; } public String getOriginalMessage() { return originalMessage; } protected static String constructArtifactPath( List path, String indentation ) { StringBuffer sb = new StringBuffer(); if ( path != null ) { sb.append( LS ); sb.append( indentation ); sb.append( "Path to dependency: " ); sb.append( LS ); int num = 1; for ( Iterator i = path.iterator(); i.hasNext(); num++ ) { sb.append( indentation ); sb.append( "\t" ); sb.append( num ); sb.append( ") " ); sb.append( i.next() ); sb.append( LS ); } } return sb.toString(); } private static String constructMessageBase( String message, String groupId, String artifactId, String version, String type, List remoteRepositories, List path ) { StringBuffer sb = new StringBuffer(); sb.append( message ); sb.append( LS ); sb.append( " " + groupId + ":" + artifactId + ":" + type + ":" + version ); sb.append( LS ); if ( remoteRepositories != null && !remoteRepositories.isEmpty() ) { sb.append( LS ); sb.append( "from the specified remote repositories:" ); sb.append( LS + " " ); for ( Iterator i = new HashSet( remoteRepositories ).iterator(); i.hasNext(); ) { ArtifactRepository remoteRepository = (ArtifactRepository) i.next(); sb.append( remoteRepository.getId() ); sb.append( " (" ); sb.append( remoteRepository.getUrl() ); sb.append( ")" ); if ( i.hasNext() ) { sb.append( ",\n " ); } } } sb.append( LS ); sb.append( constructArtifactPath( path, "" ) ); sb.append( LS ); return sb.toString(); } protected static String constructMissingArtifactMessage( String message, String indentation, String groupId, String artifactId, String version, String type, String classifier, String downloadUrl, List path ) { StringBuffer sb = new StringBuffer( message ); if ( !"pom".equals( type ) ) { if ( downloadUrl != null ) { sb.append( LS ); sb.append( LS ); sb.append( indentation ); sb.append( "Try downloading the file manually from: " ); sb.append( LS ); sb.append( indentation ); sb.append( " " ); sb.append( downloadUrl ); } else { sb.append( LS ); sb.append( LS ); sb.append( indentation ); sb.append( "Try downloading the file manually from the project website." ); } sb.append( LS ); sb.append( LS ); sb.append( indentation ); sb.append( "Then, install it using the command: " ); sb.append( LS ); sb.append( indentation ); sb.append( " mvn install:install-file -DgroupId=" ); sb.append( groupId ); sb.append( " -DartifactId=" ); sb.append( artifactId ); sb.append( " -Dversion=" ); sb.append( version ); //insert classifier only if it was used in the artifact if (classifier !=null && !classifier.equals( "" )) { sb.append( " -Dclassifier=" ); sb.append( classifier ); } sb.append( " -Dpackaging=" ); sb.append( type ); sb.append( " -Dfile=/path/to/file" ); sb.append( LS ); // If people want to deploy it sb.append( LS ); sb.append( indentation ); sb.append( "Alternatively, if you host your own repository you can deploy the file there: " ); sb.append( LS ); sb.append( indentation ); sb.append( " mvn deploy:deploy-file -DgroupId=" ); sb.append( groupId ); sb.append( " -DartifactId=" ); sb.append( artifactId ); sb.append( " -Dversion=" ); sb.append( version ); //insert classifier only if it was used in the artifact if (classifier !=null && !classifier.equals( "" )) { sb.append( " -Dclassifier=" ); sb.append( classifier ); } sb.append( " -Dpackaging=" ); sb.append( type ); sb.append( " -Dfile=/path/to/file" ); sb.append( " -Durl=[url] -DrepositoryId=[id]" ); sb.append( LS ); } sb.append( constructArtifactPath( path, indentation ) ); sb.append( LS ); return sb.toString(); } public String getArtifactPath() { return path; } } ././@LongLink0000000000000000000000000000016100000000000011563 Lustar rootrootmaven2-core-2.2.1/maven-artifact/src/main/java/org/apache/maven/artifact/resolver/ArtifactNotFoundException.javamaven2-core-2.2.1/maven-artifact/src/main/java/org/apache/maven/artifact/resolver/ArtifactNotFoundEx0000644000175000017500000000613210772004567033345 0ustar twernertwernerpackage org.apache.maven.artifact.resolver; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import org.apache.maven.artifact.Artifact; import java.util.List; /** * @author Jason van Zyl * @version $Id: ArtifactNotFoundException.java 640549 2008-03-24 20:05:11Z bentmann $ */ public class ArtifactNotFoundException extends AbstractArtifactResolutionException { private String downloadUrl; protected ArtifactNotFoundException( String message, Artifact artifact, List remoteRepositories ) { super( message, artifact, remoteRepositories ); } public ArtifactNotFoundException( String message, Artifact artifact ) { this( message, artifact.getGroupId(), artifact.getArtifactId(), artifact.getVersion(), artifact.getType(), artifact.getClassifier(), null, artifact.getDownloadUrl(), artifact.getDependencyTrail() ); } protected ArtifactNotFoundException( String message, Artifact artifact, List remoteRepositories, Throwable t ) { this( message, artifact.getGroupId(), artifact.getArtifactId(), artifact.getVersion(), artifact.getType(), artifact.getClassifier(), remoteRepositories, artifact.getDownloadUrl(), artifact.getDependencyTrail(), t ); } public ArtifactNotFoundException( String message, String groupId, String artifactId, String version, String type, String classifier, List remoteRepositories, String downloadUrl, List path, Throwable t ) { super( constructMissingArtifactMessage( message, "", groupId, artifactId, version, type, classifier,downloadUrl, path ), groupId, artifactId, version, type, classifier, remoteRepositories, null, t ); this.downloadUrl = downloadUrl; } private ArtifactNotFoundException( String message, String groupId, String artifactId, String version, String type, String classifier, List remoteRepositories, String downloadUrl, List path ) { super( constructMissingArtifactMessage( message, "", groupId, artifactId, version, type, classifier, downloadUrl, path ), groupId, artifactId, version, type, classifier, remoteRepositories, null ); this.downloadUrl = downloadUrl; } public String getDownloadUrl() { return downloadUrl; } } maven2-core-2.2.1/maven-artifact/src/main/java/org/apache/maven/artifact/transform/0000755000175000017500000000000011250552242030051 5ustar twernertwerner././@LongLink0000000000000000000000000000016600000000000011570 Lustar rootrootmaven2-core-2.2.1/maven-artifact/src/main/java/org/apache/maven/artifact/transform/ArtifactTransformationManager.javamaven2-core-2.2.1/maven-artifact/src/main/java/org/apache/maven/artifact/transform/ArtifactTransform0000644000175000017500000000602111173447106033432 0ustar twernertwernerpackage org.apache.maven.artifact.transform; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.deployer.ArtifactDeploymentException; import org.apache.maven.artifact.installer.ArtifactInstallationException; import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.artifact.resolver.ArtifactNotFoundException; import org.apache.maven.artifact.resolver.ArtifactResolutionException; import java.util.List; /** * Manages multiple ArtifactTransformation instances and applies them in succession. */ public interface ArtifactTransformationManager { String ROLE = ArtifactTransformationManager.class.getName(); /** * Take in a artifact and return the transformed artifact for locating in the remote repository. If no * transformation has occured the original artifact is returned. * * @param artifact Artifact to be transformed. * @param remoteRepositories the repositories to check * @param localRepository the local repository */ void transformForResolve( Artifact artifact, List remoteRepositories, ArtifactRepository localRepository ) throws ArtifactResolutionException, ArtifactNotFoundException; /** * Take in a artifact and return the transformed artifact for locating in the local repository. If no * transformation has occured the original artifact is returned. * * @param artifact Artifact to be transformed. * @param localRepository the local repository it will be stored in */ void transformForInstall( Artifact artifact, ArtifactRepository localRepository ) throws ArtifactInstallationException; /** * Take in a artifact and return the transformed artifact for distributing toa remote repository. If no * transformation has occured the original artifact is returned. * * @param artifact Artifact to be transformed. * @param remoteRepository the repository to deploy to * @param localRepository the local repository the metadata is stored in */ void transformForDeployment( Artifact artifact, ArtifactRepository remoteRepository, ArtifactRepository localRepository ) throws ArtifactDeploymentException; } ././@LongLink0000000000000000000000000000015700000000000011570 Lustar rootrootmaven2-core-2.2.1/maven-artifact/src/main/java/org/apache/maven/artifact/transform/ArtifactTransformation.javamaven2-core-2.2.1/maven-artifact/src/main/java/org/apache/maven/artifact/transform/ArtifactTransform0000644000175000017500000000606411173447106033441 0ustar twernertwernerpackage org.apache.maven.artifact.transform; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.deployer.ArtifactDeploymentException; import org.apache.maven.artifact.installer.ArtifactInstallationException; import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.artifact.resolver.ArtifactNotFoundException; import org.apache.maven.artifact.resolver.ArtifactResolutionException; import java.util.List; /** * @author Jason van Zyl * @version $Id: ArtifactTransformation.java,v 1.1 2005/03/03 15:37:25 * jvanzyl Exp $ */ public interface ArtifactTransformation { String ROLE = ArtifactTransformation.class.getName(); /** * Take in a artifact and return the transformed artifact for locating in the remote repository. If no * transformation has occured the original artifact is returned. * * @param artifact Artifact to be transformed. * @param remoteRepositories the repositories to check * @param localRepository the local repository */ void transformForResolve( Artifact artifact, List remoteRepositories, ArtifactRepository localRepository ) throws ArtifactResolutionException, ArtifactNotFoundException; /** * Take in a artifact and return the transformed artifact for locating in the local repository. If no * transformation has occured the original artifact is returned. * * @param artifact Artifact to be transformed. * @param localRepository the local repository it will be stored in */ void transformForInstall( Artifact artifact, ArtifactRepository localRepository ) throws ArtifactInstallationException; /** * Take in a artifact and return the transformed artifact for distributing toa remote repository. If no * transformation has occured the original artifact is returned. * * @param artifact Artifact to be transformed. * @param remoteRepository the repository to deploy to * @param localRepository the local repository */ void transformForDeployment( Artifact artifact, ArtifactRepository remoteRepository, ArtifactRepository localRepository ) throws ArtifactDeploymentException; } ././@LongLink0000000000000000000000000000016400000000000011566 Lustar rootrootmaven2-core-2.2.1/maven-artifact/src/main/java/org/apache/maven/artifact/DependencyResolutionRequiredException.javamaven2-core-2.2.1/maven-artifact/src/main/java/org/apache/maven/artifact/DependencyResolutionRequire0000644000175000017500000000266210551365651033477 0ustar twernertwernerpackage org.apache.maven.artifact; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ /** * Exception that occurs when an artifact file is used, but has not been resolved. * * @author Brett Porter * @version $Id: DependencyResolutionRequiredException.java 495147 2007-01-11 07:47:53Z jvanzyl $ * @todo it may be better for artifact.getFile() to throw it - perhaps it is a runtime exception? */ public class DependencyResolutionRequiredException extends Exception { public DependencyResolutionRequiredException( Artifact artifact ) { super( "Attempted to access the artifact " + artifact + "; which has not yet been resolved" ); } } maven2-core-2.2.1/maven-artifact/src/main/java/org/apache/maven/artifact/ArtifactStatus.java0000644000175000017500000000631210772004567031656 0ustar twernertwernerpackage org.apache.maven.artifact; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import java.util.HashMap; import java.util.Map; /** * Type safe enumeration for the artifact status field. * * @author Brett Porter * @version $Id: ArtifactStatus.java 640549 2008-03-24 20:05:11Z bentmann $ */ public final class ArtifactStatus implements Comparable { /** * No trust - no information about status. */ public static final ArtifactStatus NONE = new ArtifactStatus( "none", 0 ); /** * No trust - information was generated with defaults. */ public static final ArtifactStatus GENERATED = new ArtifactStatus( "generated", 1 ); /** * Low trust - was converted from the Maven 1.x repository. */ public static final ArtifactStatus CONVERTED = new ArtifactStatus( "converted", 2 ); /** * Moderate trust - it was deployed directly from a partner. */ public static final ArtifactStatus PARTNER = new ArtifactStatus( "partner", 3 ); /** * Moderate trust - it was deployed directly by a user. */ public static final ArtifactStatus DEPLOYED = new ArtifactStatus( "deployed", 4 ); /** * Trusted, as it has had its data verified by hand. */ public static final ArtifactStatus VERIFIED = new ArtifactStatus( "verified", 5 ); private final int rank; private final String key; private static Map map; private ArtifactStatus( String key, int rank ) { this.rank = rank; this.key = key; if ( map == null ) { map = new HashMap(); } map.put( key, this ); } public static ArtifactStatus valueOf( String status ) { ArtifactStatus retVal = null; if ( status != null ) { retVal = (ArtifactStatus) map.get( status ); } return retVal != null ? retVal : NONE; } public boolean equals( Object o ) { if ( this == o ) { return true; } if ( o == null || getClass() != o.getClass() ) { return false; } final ArtifactStatus that = (ArtifactStatus) o; return rank == that.rank; } public int hashCode() { return rank; } public String toString() { return key; } public int compareTo( Object o ) { ArtifactStatus s = (ArtifactStatus) o; return rank - s.rank; } } maven2-core-2.2.1/maven-artifact/src/main/java/org/apache/maven/artifact/installer/0000755000175000017500000000000011250552242030033 5ustar twernertwerner././@LongLink0000000000000000000000000000016600000000000011570 Lustar rootrootmaven2-core-2.2.1/maven-artifact/src/main/java/org/apache/maven/artifact/installer/ArtifactInstallationException.javamaven2-core-2.2.1/maven-artifact/src/main/java/org/apache/maven/artifact/installer/ArtifactInstallat0000644000175000017500000000256710551365651033412 0ustar twernertwernerpackage org.apache.maven.artifact.installer; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ /** * @author Jason van Zyl * @version $Id: ArtifactInstallationException.java 495147 2007-01-11 07:47:53Z jvanzyl $ */ public class ArtifactInstallationException extends Exception { public ArtifactInstallationException( String message ) { super( message ); } public ArtifactInstallationException( Throwable cause ) { super( cause ); } public ArtifactInstallationException( String message, Throwable cause ) { super( message, cause ); } } ././@LongLink0000000000000000000000000000015200000000000011563 Lustar rootrootmaven2-core-2.2.1/maven-artifact/src/main/java/org/apache/maven/artifact/installer/ArtifactInstaller.javamaven2-core-2.2.1/maven-artifact/src/main/java/org/apache/maven/artifact/installer/ArtifactInstaller0000644000175000017500000000457210551365651033412 0ustar twernertwernerpackage org.apache.maven.artifact.installer; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.repository.ArtifactRepository; import java.io.File; /** * @author Michal Maczka * @version $Id: ArtifactInstaller.java 495147 2007-01-11 07:47:53Z jvanzyl $ */ public interface ArtifactInstaller { String ROLE = ArtifactInstaller.class.getName(); /** * Install an artifact from a particular directory. The artifact handler is used to determine the filename * of the source file. * * @param basedir the directory where the artifact is stored * @param finalName the name of the artifact sans extension * @param artifact the artifact definition * @param localRepository the local repository to install into * @throws ArtifactInstallationException if an error occurred installing the artifact * @deprecated to be removed before 2.0 after the instlal/deploy plugins use the alternate method */ void install( String basedir, String finalName, Artifact artifact, ArtifactRepository localRepository ) throws ArtifactInstallationException; /** * Install an artifact from a particular file. * * @param source the file to install * @param artifact the artifact definition * @param localRepository the local repository to install into * @throws ArtifactInstallationException if an error occurred installing the artifact */ void install( File source, Artifact artifact, ArtifactRepository localRepository ) throws ArtifactInstallationException; } ././@LongLink0000000000000000000000000000015100000000000011562 Lustar rootrootmaven2-core-2.2.1/maven-artifact/src/main/java/org/apache/maven/artifact/InvalidArtifactRTException.javamaven2-core-2.2.1/maven-artifact/src/main/java/org/apache/maven/artifact/InvalidArtifactRTException.0000644000175000017500000000467010772004567033251 0ustar twernertwernerpackage org.apache.maven.artifact; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ /** * Exception thrown when the identity of an artifact can not be established, * eg. one of groupId, artifactId, version or type is null. */ public class InvalidArtifactRTException extends RuntimeException { private final String groupId; private final String artifactId; private final String version; private final String type; private final String baseMessage; public InvalidArtifactRTException( String groupId, String artifactId, String version, String type, String message ) { this.groupId = groupId; this.artifactId = artifactId; this.version = version; this.type = type; this.baseMessage = message; } public InvalidArtifactRTException( String groupId, String artifactId, String version, String type, String message, Throwable cause ) { super( cause ); this.groupId = groupId; this.artifactId = artifactId; this.version = version; this.type = type; this.baseMessage = message; } public String getMessage() { return "For artifact {" + getArtifactKey() + "}: " + getBaseMessage(); } public String getBaseMessage() { return baseMessage; } public String getArtifactId() { return artifactId; } public String getGroupId() { return groupId; } public String getType() { return type; } public String getVersion() { return version; } public String getArtifactKey() { return groupId + ":" + artifactId + ":" + version + ":" + type; } } maven2-core-2.2.1/maven-artifact/src/main/java/org/apache/maven/artifact/factory/0000755000175000017500000000000011250552242027505 5ustar twernertwerner././@LongLink0000000000000000000000000000015500000000000011566 Lustar rootrootmaven2-core-2.2.1/maven-artifact/src/main/java/org/apache/maven/artifact/factory/DefaultArtifactFactory.javamaven2-core-2.2.1/maven-artifact/src/main/java/org/apache/maven/artifact/factory/DefaultArtifactFact0000644000175000017500000001560211147323515033300 0ustar twernertwernerpackage org.apache.maven.artifact.factory; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.DefaultArtifact; import org.apache.maven.artifact.handler.ArtifactHandler; import org.apache.maven.artifact.handler.manager.ArtifactHandlerManager; import org.apache.maven.artifact.versioning.VersionRange; public class DefaultArtifactFactory implements ArtifactFactory { // TODO: remove, it doesn't know the ones from the plugins private ArtifactHandlerManager artifactHandlerManager; public DefaultArtifactFactory() { } public Artifact createArtifact( String groupId, String artifactId, String version, String scope, String type ) { return createArtifact( groupId, artifactId, version, scope, type, null, null ); } public Artifact createArtifactWithClassifier( String groupId, String artifactId, String version, String type, String classifier ) { return createArtifact( groupId, artifactId, version, null, type, classifier, null ); } public Artifact createDependencyArtifact( String groupId, String artifactId, VersionRange versionRange, String type, String classifier, String scope ) { return createArtifact( groupId, artifactId, versionRange, type, classifier, scope, null ); } public Artifact createDependencyArtifact( String groupId, String artifactId, VersionRange versionRange, String type, String classifier, String scope, boolean optional ) { return createArtifact( groupId, artifactId, versionRange, type, classifier, scope, null, optional ); } public Artifact createDependencyArtifact( String groupId, String artifactId, VersionRange versionRange, String type, String classifier, String scope, String inheritedScope ) { return createArtifact( groupId, artifactId, versionRange, type, classifier, scope, inheritedScope ); } public Artifact createDependencyArtifact( String groupId, String artifactId, VersionRange versionRange, String type, String classifier, String scope, String inheritedScope, boolean optional ) { return createArtifact( groupId, artifactId, versionRange, type, classifier, scope, inheritedScope, optional ); } public Artifact createBuildArtifact( String groupId, String artifactId, String version, String packaging ) { return createArtifact( groupId, artifactId, version, null, packaging, null, null ); } public Artifact createProjectArtifact( String groupId, String artifactId, String version ) { return createProjectArtifact( groupId, artifactId, version, null ); } public Artifact createParentArtifact( String groupId, String artifactId, String version ) { return createProjectArtifact( groupId, artifactId, version ); } public Artifact createPluginArtifact( String groupId, String artifactId, VersionRange versionRange ) { return createArtifact( groupId, artifactId, versionRange, "maven-plugin", null, Artifact.SCOPE_RUNTIME, null ); } public Artifact createProjectArtifact( String groupId, String artifactId, String version, String scope ) { return createArtifact( groupId, artifactId, version, scope, "pom" ); } public Artifact createExtensionArtifact( String groupId, String artifactId, VersionRange versionRange ) { return createArtifact( groupId, artifactId, versionRange, "jar", null, Artifact.SCOPE_RUNTIME, null ); } private Artifact createArtifact( String groupId, String artifactId, String version, String scope, String type, String classifier, String inheritedScope ) { VersionRange versionRange = null; if ( version != null ) { versionRange = VersionRange.createFromVersion( version ); } return createArtifact( groupId, artifactId, versionRange, type, classifier, scope, inheritedScope ); } private Artifact createArtifact( String groupId, String artifactId, VersionRange versionRange, String type, String classifier, String scope, String inheritedScope ) { return createArtifact( groupId, artifactId, versionRange, type, classifier, scope, inheritedScope, false ); } private Artifact createArtifact( String groupId, String artifactId, VersionRange versionRange, String type, String classifier, String scope, String inheritedScope, boolean optional ) { // TODO: can refactor - inherited scope calculation belongs in the collector, use scope handler String desiredScope = Artifact.SCOPE_RUNTIME; if ( inheritedScope == null ) { desiredScope = scope; } else if ( Artifact.SCOPE_TEST.equals( scope ) || Artifact.SCOPE_PROVIDED.equals( scope ) ) { return null; } else if ( Artifact.SCOPE_COMPILE.equals( scope ) && Artifact.SCOPE_COMPILE.equals( inheritedScope ) ) { // added to retain compile scope. Remove if you want compile inherited as runtime desiredScope = Artifact.SCOPE_COMPILE; } if ( Artifact.SCOPE_TEST.equals( inheritedScope ) ) { desiredScope = Artifact.SCOPE_TEST; } if ( Artifact.SCOPE_PROVIDED.equals( inheritedScope ) ) { desiredScope = Artifact.SCOPE_PROVIDED; } if ( Artifact.SCOPE_SYSTEM.equals( scope ) ) { // system scopes come through unchanged... desiredScope = Artifact.SCOPE_SYSTEM; } ArtifactHandler handler = artifactHandlerManager.getArtifactHandler( type ); return new DefaultArtifact( groupId, artifactId, versionRange, desiredScope, type, classifier, handler, optional ); } protected ArtifactHandlerManager getArtifactHandlerManager() { return artifactHandlerManager; } } ././@LongLink0000000000000000000000000000014600000000000011566 Lustar rootrootmaven2-core-2.2.1/maven-artifact/src/main/java/org/apache/maven/artifact/factory/ArtifactFactory.javamaven2-core-2.2.1/maven-artifact/src/main/java/org/apache/maven/artifact/factory/ArtifactFactory.jav0000644000175000017500000000541510551365651033312 0ustar twernertwernerpackage org.apache.maven.artifact.factory; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.versioning.VersionRange; public interface ArtifactFactory { String ROLE = ArtifactFactory.class.getName(); // TODO: deprecate and chase down (probably used for copying only) Artifact createArtifact( String groupId, String artifactId, String version, String scope, String type ); Artifact createArtifactWithClassifier( String groupId, String artifactId, String version, String type, String classifier ); Artifact createDependencyArtifact( String groupId, String artifactId, VersionRange versionRange, String type, String classifier, String scope ); Artifact createDependencyArtifact( String groupId, String artifactId, VersionRange versionRange, String type, String classifier, String scope, boolean optional ); Artifact createDependencyArtifact( String groupId, String artifactId, VersionRange versionRange, String type, String classifier, String scope, String inheritedScope ); Artifact createDependencyArtifact( String groupId, String artifactId, VersionRange versionRange, String type, String classifier, String scope, String inheritedScope, boolean optional ); Artifact createBuildArtifact( String groupId, String artifactId, String version, String packaging ); Artifact createProjectArtifact( String groupId, String artifactId, String version ); Artifact createParentArtifact( String groupId, String artifactId, String version ); Artifact createPluginArtifact( String groupId, String artifactId, VersionRange versionRange ); Artifact createProjectArtifact( String groupId, String artifactId, String version, String scope ); Artifact createExtensionArtifact( String groupId, String artifactId, VersionRange versionRange ); } maven2-core-2.2.1/maven-artifact/src/main/java/org/apache/maven/artifact/versioning/0000755000175000017500000000000011250552242030221 5ustar twernertwerner././@LongLink0000000000000000000000000000016000000000000011562 Lustar rootrootmaven2-core-2.2.1/maven-artifact/src/main/java/org/apache/maven/artifact/versioning/DefaultArtifactVersion.javamaven2-core-2.2.1/maven-artifact/src/main/java/org/apache/maven/artifact/versioning/DefaultArtifactV0000644000175000017500000001677311033426750033355 0ustar twernertwernerpackage org.apache.maven.artifact.versioning; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import java.util.StringTokenizer; /** * Default implementation of artifact versioning. * * @author Brett Porter * @version $Id: DefaultArtifactVersion.java 674059 2008-07-04 14:04:24Z brett $ */ public class DefaultArtifactVersion implements ArtifactVersion { private Integer majorVersion; private Integer minorVersion; private Integer incrementalVersion; private Integer buildNumber; private String qualifier; private String unparsed; public DefaultArtifactVersion( String version ) { parseVersion( version ); } public int compareTo( Object o ) { ArtifactVersion otherVersion = (ArtifactVersion) o; int result = getMajorVersion() - otherVersion.getMajorVersion(); if ( result == 0 ) { result = getMinorVersion() - otherVersion.getMinorVersion(); } if ( result == 0 ) { result = getIncrementalVersion() - otherVersion.getIncrementalVersion(); } if ( result == 0 ) { if ( qualifier != null ) { String otherQualifier = otherVersion.getQualifier(); if ( otherQualifier != null ) { if ( ( qualifier.length() > otherQualifier.length() ) && qualifier.startsWith( otherQualifier ) ) { // here, the longer one that otherwise match is considered older result = -1; } else if ( ( qualifier.length() < otherQualifier.length() ) && otherQualifier.startsWith( qualifier ) ) { // here, the longer one that otherwise match is considered older result = 1; } else { result = qualifier.compareTo( otherQualifier ); } } else { // otherVersion has no qualifier but we do - that's newer result = -1; } } else if ( otherVersion.getQualifier() != null ) { // otherVersion has a qualifier but we don't, we're newer result = 1; } else { result = getBuildNumber() - otherVersion.getBuildNumber(); } } return result; } public int getMajorVersion() { return majorVersion != null ? majorVersion.intValue() : 0; } public int getMinorVersion() { return minorVersion != null ? minorVersion.intValue() : 0; } public int getIncrementalVersion() { return incrementalVersion != null ? incrementalVersion.intValue() : 0; } public int getBuildNumber() { return buildNumber != null ? buildNumber.intValue() : 0; } public String getQualifier() { return qualifier; } public final void parseVersion( String version ) { unparsed = version; int index = version.indexOf( "-" ); String part1; String part2 = null; if ( index < 0 ) { part1 = version; } else { part1 = version.substring( 0, index ); part2 = version.substring( index + 1 ); } if ( part2 != null ) { try { if ( ( part2.length() == 1 ) || !part2.startsWith( "0" ) ) { buildNumber = Integer.valueOf( part2 ); } else { qualifier = part2; } } catch ( NumberFormatException e ) { qualifier = part2; } } if ( ( part1.indexOf( "." ) < 0 ) && !part1.startsWith( "0" ) ) { try { majorVersion = Integer.valueOf( part1 ); } catch ( NumberFormatException e ) { // qualifier is the whole version, including "-" qualifier = version; buildNumber = null; } } else { boolean fallback = false; StringTokenizer tok = new StringTokenizer( part1, "." ); try { majorVersion = getNextIntegerToken( tok ); if ( tok.hasMoreTokens() ) { minorVersion = getNextIntegerToken( tok ); } if ( tok.hasMoreTokens() ) { incrementalVersion = getNextIntegerToken( tok ); } if ( tok.hasMoreTokens() ) { fallback = true; } // string tokenzier won't detect these and ignores them if ( part1.indexOf( ".." ) >= 0 || part1.startsWith( "." ) || part1.endsWith( "." ) ) { fallback = true; } } catch ( NumberFormatException e ) { fallback = true; } if ( fallback ) { // qualifier is the whole version, including "-" qualifier = version; majorVersion = null; minorVersion = null; incrementalVersion = null; buildNumber = null; } } } private static Integer getNextIntegerToken( StringTokenizer tok ) { String s = tok.nextToken(); if ( ( s.length() > 1 ) && s.startsWith( "0" ) ) { throw new NumberFormatException( "Number part has a leading 0: '" + s + "'" ); } return Integer.valueOf( s ); } public String toString() { return unparsed; } public boolean equals( Object other ) { if ( this == other ) { return true; } if ( false == ( other instanceof ArtifactVersion ) ) { return false; } return 0 == compareTo( other ); } public int hashCode() { int result = 1229; result = 1223 * result + getMajorVersion(); result = 1223 * result + getMinorVersion(); result = 1223 * result + getIncrementalVersion(); result = 1223 * result + getBuildNumber(); if ( null != getQualifier() ) { result = 1223 * result + getQualifier().hashCode(); } return result; } } ././@LongLink0000000000000000000000000000015300000000000011564 Lustar rootrootmaven2-core-2.2.1/maven-artifact/src/main/java/org/apache/maven/artifact/versioning/ManagedVersionMap.javamaven2-core-2.2.1/maven-artifact/src/main/java/org/apache/maven/artifact/versioning/ManagedVersionMa0000644000175000017500000000304310772004567033336 0ustar twernertwernerpackage org.apache.maven.artifact.versioning; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import java.util.HashMap; import java.util.Map; import java.util.Iterator; public class ManagedVersionMap extends HashMap { public ManagedVersionMap(Map map) { super(); if (map != null) { putAll(map); } } public String toString() { StringBuffer buffer = new StringBuffer("ManagedVersionMap\n"); Iterator iter = this.keySet().iterator(); while (iter.hasNext()) { String key = (String)iter.next(); buffer.append(key).append("=").append(get(key)); if (iter.hasNext()) { buffer.append("\n"); } } return buffer.toString(); } } ././@LongLink0000000000000000000000000000015100000000000011562 Lustar rootrootmaven2-core-2.2.1/maven-artifact/src/main/java/org/apache/maven/artifact/versioning/ArtifactVersion.javamaven2-core-2.2.1/maven-artifact/src/main/java/org/apache/maven/artifact/versioning/ArtifactVersion.0000644000175000017500000000253310772004567033342 0ustar twernertwernerpackage org.apache.maven.artifact.versioning; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ /** * Describes an artifact version in terms of its components, converts it to/from a string and * compares two versions. * * @author Brett Porter * @version $Id: ArtifactVersion.java 640549 2008-03-24 20:05:11Z bentmann $ */ public interface ArtifactVersion extends Comparable { int getMajorVersion(); int getMinorVersion(); int getIncrementalVersion(); int getBuildNumber(); String getQualifier(); void parseVersion( String version ); } ././@LongLink0000000000000000000000000000014500000000000011565 Lustar rootrootmaven2-core-2.2.1/maven-artifact/src/main/java/org/apache/maven/artifact/versioning/Restriction.javamaven2-core-2.2.1/maven-artifact/src/main/java/org/apache/maven/artifact/versioning/Restriction.java0000644000175000017500000001142710772004567033410 0ustar twernertwernerpackage org.apache.maven.artifact.versioning; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ /** * Describes a restriction in versioning. * * @author Brett Porter * @version $Id: Restriction.java 640549 2008-03-24 20:05:11Z bentmann $ */ public class Restriction { private final ArtifactVersion lowerBound; private final boolean lowerBoundInclusive; private final ArtifactVersion upperBound; private final boolean upperBoundInclusive; static final Restriction EVERYTHING = new Restriction( null, false, null, false ); public Restriction( ArtifactVersion lowerBound, boolean lowerBoundInclusive, ArtifactVersion upperBound, boolean upperBoundInclusive ) { this.lowerBound = lowerBound; this.lowerBoundInclusive = lowerBoundInclusive; this.upperBound = upperBound; this.upperBoundInclusive = upperBoundInclusive; } public ArtifactVersion getLowerBound() { return lowerBound; } public boolean isLowerBoundInclusive() { return lowerBoundInclusive; } public ArtifactVersion getUpperBound() { return upperBound; } public boolean isUpperBoundInclusive() { return upperBoundInclusive; } public boolean containsVersion( ArtifactVersion version ) { if ( lowerBound != null ) { int comparison = lowerBound.compareTo( version ); if ( comparison == 0 && !lowerBoundInclusive ) { return false; } if ( comparison > 0 ) { return false; } } if ( upperBound != null ) { int comparison = upperBound.compareTo( version ); if ( comparison == 0 && !upperBoundInclusive ) { return false; } if ( comparison < 0 ) { return false; } } return true; } public int hashCode() { int result = 13; if ( lowerBound == null ) { result += 1; } else { result += lowerBound.hashCode(); } result *= lowerBoundInclusive ? 1 : 2; if ( upperBound == null ) { result -= 3; } else { result -= upperBound.hashCode(); } result *= upperBoundInclusive ? 2 : 3; return result; } public boolean equals( Object other ) { if ( this == other ) { return true; } if ( !(other instanceof Restriction ) ) { return false; } Restriction restriction = (Restriction) other; if ( lowerBound != null ) { if ( !lowerBound.equals( restriction.lowerBound ) ) { return false; } } else if ( restriction.lowerBound != null ) { return false; } if ( lowerBoundInclusive != restriction.lowerBoundInclusive ) { return false; } if ( upperBound != null ) { if ( !upperBound.equals( restriction.upperBound ) ) { return false; } } else if ( restriction.upperBound != null ) { return false; } if ( upperBoundInclusive != restriction.upperBoundInclusive ) { return false; } return true; } public String toString() { StringBuffer buf = new StringBuffer(); buf.append( isLowerBoundInclusive() ? "[" : "(" ); if ( getLowerBound() != null ) { buf.append( getLowerBound().toString() ); } buf.append( "," ); if ( getUpperBound() != null ) { buf.append( getUpperBound().toString() ); } buf.append( isUpperBoundInclusive() ? "]" : ")" ); return buf.toString(); } } ././@LongLink0000000000000000000000000000014600000000000011566 Lustar rootrootmaven2-core-2.2.1/maven-artifact/src/main/java/org/apache/maven/artifact/versioning/VersionRange.javamaven2-core-2.2.1/maven-artifact/src/main/java/org/apache/maven/artifact/versioning/VersionRange.jav0000644000175000017500000004767510772004567033362 0ustar twernertwernerpackage org.apache.maven.artifact.versioning; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import java.util.ArrayList; import java.util.Collections; import java.util.Iterator; import java.util.List; import org.apache.maven.artifact.Artifact; /** * Construct a version range from a specification. * * @author Brett Porter * @version $Id: VersionRange.java 640549 2008-03-24 20:05:11Z bentmann $ */ public class VersionRange { private final ArtifactVersion recommendedVersion; private final List restrictions; private VersionRange( ArtifactVersion recommendedVersion, List restrictions ) { this.recommendedVersion = recommendedVersion; this.restrictions = restrictions; } public ArtifactVersion getRecommendedVersion() { return recommendedVersion; } public List getRestrictions() { return restrictions; } public VersionRange cloneOf() { List copiedRestrictions = null; if ( restrictions != null ) { copiedRestrictions = new ArrayList(); if ( !restrictions.isEmpty() ) { copiedRestrictions.addAll( restrictions ); } } return new VersionRange( recommendedVersion, copiedRestrictions ); } /** * Create a version range from a string representation * * Some spec examples are *
    *
  • 1.0 Version 1.0
  • *
  • [1.0,2.0) Versions 1.0 (included) to 2.0 (not included)
  • *
  • [1.0,2.0] Versions 1.0 to 2.0 (both included)
  • *
  • [1.5,) Versions 1.5 and higher
  • *
  • (,1.0],[1.2,) Versions up to 1.0 (included) and 1.2 or higher
  • *
* * @param spec string representation of a version or version range * @return a new {@link VersionRange} object that represents the spec * @throws InvalidVersionSpecificationException */ public static VersionRange createFromVersionSpec( String spec ) throws InvalidVersionSpecificationException { if ( spec == null ) { return null; } List restrictions = new ArrayList(); String process = spec; ArtifactVersion version = null; ArtifactVersion upperBound = null; ArtifactVersion lowerBound = null; while ( process.startsWith( "[" ) || process.startsWith( "(" ) ) { int index1 = process.indexOf( ")" ); int index2 = process.indexOf( "]" ); int index = index2; if ( index2 < 0 || index1 < index2 ) { if ( index1 >= 0 ) { index = index1; } } if ( index < 0 ) { throw new InvalidVersionSpecificationException( "Unbounded range: " + spec ); } Restriction restriction = parseRestriction( process.substring( 0, index + 1 ) ); if ( lowerBound == null ) { lowerBound = restriction.getLowerBound(); } if ( upperBound != null ) { if ( restriction.getLowerBound() == null || restriction.getLowerBound().compareTo( upperBound ) < 0 ) { throw new InvalidVersionSpecificationException( "Ranges overlap: " + spec ); } } restrictions.add( restriction ); upperBound = restriction.getUpperBound(); process = process.substring( index + 1 ).trim(); if ( process.length() > 0 && process.startsWith( "," ) ) { process = process.substring( 1 ).trim(); } } if ( process.length() > 0 ) { if ( restrictions.size() > 0 ) { throw new InvalidVersionSpecificationException( "Only fully-qualified sets allowed in multiple set scenario: " + spec ); } else { version = new DefaultArtifactVersion( process ); restrictions.add( Restriction.EVERYTHING ); } } return new VersionRange( version, restrictions ); } private static Restriction parseRestriction( String spec ) throws InvalidVersionSpecificationException { boolean lowerBoundInclusive = spec.startsWith( "[" ); boolean upperBoundInclusive = spec.endsWith( "]" ); String process = spec.substring( 1, spec.length() - 1 ).trim(); Restriction restriction; int index = process.indexOf( "," ); if ( index < 0 ) { if ( !lowerBoundInclusive || !upperBoundInclusive ) { throw new InvalidVersionSpecificationException( "Single version must be surrounded by []: " + spec ); } ArtifactVersion version = new DefaultArtifactVersion( process ); restriction = new Restriction( version, lowerBoundInclusive, version, upperBoundInclusive ); } else { String lowerBound = process.substring( 0, index ).trim(); String upperBound = process.substring( index + 1 ).trim(); if ( lowerBound.equals( upperBound ) ) { throw new InvalidVersionSpecificationException( "Range cannot have identical boundaries: " + spec ); } ArtifactVersion lowerVersion = null; if ( lowerBound.length() > 0 ) { lowerVersion = new DefaultArtifactVersion( lowerBound ); } ArtifactVersion upperVersion = null; if ( upperBound.length() > 0 ) { upperVersion = new DefaultArtifactVersion( upperBound ); } if ( upperVersion != null && lowerVersion != null && upperVersion.compareTo( lowerVersion ) < 0 ) { throw new InvalidVersionSpecificationException( "Range defies version ordering: " + spec ); } restriction = new Restriction( lowerVersion, lowerBoundInclusive, upperVersion, upperBoundInclusive ); } return restriction; } public static VersionRange createFromVersion( String version ) { return new VersionRange( new DefaultArtifactVersion( version ), Collections.EMPTY_LIST ); } /** * Creates and returns a new VersionRange that is a restriction of this * version range and the specified version range. *

* Note: Precedence is given to the recommended version from this version range over the * recommended version from the specified version range. *

* @param restriction the VersionRange that will be used to restrict this version * range. * @return the VersionRange that is a restriction of this version range and the * specified version range. *

* The restrictions of the returned version range will be an intersection of the restrictions * of this version range and the specified version range if both version ranges have * restrictions. Otherwise, the restrictions on the returned range will be empty. *

*

* The recommended version of the returned version range will be the recommended version of * this version range, provided that ranges falls within the intersected restrictions. If * the restrictions are empty, this version range's recommended version is used if it is not * null. If it is null, the specified version range's recommended * version is used (provided it is non-null). If no recommended version can be * obtained, the returned version range's recommended version is set to null. *

* @throws NullPointerException if the specified VersionRange is * null. */ public VersionRange restrict( VersionRange restriction ) { List r1 = this.restrictions; List r2 = restriction.restrictions; List restrictions; if ( r1.isEmpty() || r2.isEmpty() ) { restrictions = Collections.EMPTY_LIST; } else { restrictions = intersection( r1, r2 ); } ArtifactVersion version = null; if ( restrictions.size() > 0 ) { boolean found = false; for ( Iterator i = restrictions.iterator(); i.hasNext() && !found; ) { Restriction r = (Restriction) i.next(); if ( recommendedVersion != null && r.containsVersion( recommendedVersion ) ) { // if we find the original, use that version = recommendedVersion; found = true; } else if ( version == null && restriction.getRecommendedVersion() != null && r.containsVersion( restriction.getRecommendedVersion() ) ) { // use this if we can, but prefer the original if possible version = restriction.getRecommendedVersion(); } } } // Either the original or the specified version ranges have no restructions else if ( recommendedVersion != null ) { // Use the original recommended version since it exists version = recommendedVersion; } else if (restriction.recommendedVersion != null) { // Use the recommended version from the specified VersionRange since there is no // original recommended version version = restriction.recommendedVersion; } /* TODO: should throw this immediately, but need artifact else { throw new OverConstrainedVersionException( "Restricting incompatible version ranges" ); } */ return new VersionRange( version, restrictions ); } private List intersection( List r1, List r2 ) { List restrictions = new ArrayList( r1.size() + r2.size() ); Iterator i1 = r1.iterator(); Iterator i2 = r2.iterator(); Restriction res1 = (Restriction) i1.next(); Restriction res2 = (Restriction) i2.next(); boolean done = false; while ( !done ) { if ( res1.getLowerBound() == null || res2.getUpperBound() == null || res1.getLowerBound().compareTo( res2.getUpperBound() ) <= 0 ) { if ( res1.getUpperBound() == null || res2.getLowerBound() == null || res1.getUpperBound().compareTo( res2.getLowerBound() ) >= 0 ) { ArtifactVersion lower; ArtifactVersion upper; boolean lowerInclusive; boolean upperInclusive; // overlaps if ( res1.getLowerBound() == null ) { lower = res2.getLowerBound(); lowerInclusive = res2.isLowerBoundInclusive(); } else if ( res2.getLowerBound() == null ) { lower = res1.getLowerBound(); lowerInclusive = res1.isLowerBoundInclusive(); } else { int comparison = res1.getLowerBound().compareTo( res2.getLowerBound() ); if ( comparison < 0 ) { lower = res2.getLowerBound(); lowerInclusive = res2.isLowerBoundInclusive(); } else if ( comparison == 0 ) { lower = res1.getLowerBound(); lowerInclusive = res1.isLowerBoundInclusive() && res2.isLowerBoundInclusive(); } else { lower = res1.getLowerBound(); lowerInclusive = res1.isLowerBoundInclusive(); } } if ( res1.getUpperBound() == null ) { upper = res2.getUpperBound(); upperInclusive = res2.isUpperBoundInclusive(); } else if ( res2.getUpperBound() == null ) { upper = res1.getUpperBound(); upperInclusive = res1.isUpperBoundInclusive(); } else { int comparison = res1.getUpperBound().compareTo( res2.getUpperBound() ); if ( comparison < 0 ) { upper = res1.getUpperBound(); upperInclusive = res1.isUpperBoundInclusive(); } else if ( comparison == 0 ) { upper = res1.getUpperBound(); upperInclusive = res1.isUpperBoundInclusive() && res2.isUpperBoundInclusive(); } else { upper = res2.getUpperBound(); upperInclusive = res2.isUpperBoundInclusive(); } } // don't add if they are equal and one is not inclusive if ( lower == null || upper == null || lower.compareTo( upper ) != 0 ) { restrictions.add( new Restriction( lower, lowerInclusive, upper, upperInclusive ) ); } else if ( lowerInclusive && upperInclusive ) { restrictions.add( new Restriction( lower, lowerInclusive, upper, upperInclusive ) ); } //noinspection ObjectEquality if ( upper == res2.getUpperBound() ) { // advance res2 if ( i2.hasNext() ) { res2 = (Restriction) i2.next(); } else { done = true; } } else { // advance res1 if ( i1.hasNext() ) { res1 = (Restriction) i1.next(); } else { done = true; } } } else { // move on to next in r1 if ( i1.hasNext() ) { res1 = (Restriction) i1.next(); } else { done = true; } } } else { // move on to next in r2 if ( i2.hasNext() ) { res2 = (Restriction) i2.next(); } else { done = true; } } } return restrictions; } public ArtifactVersion getSelectedVersion( Artifact artifact ) throws OverConstrainedVersionException { ArtifactVersion version; if ( recommendedVersion != null ) { version = recommendedVersion; } else { if ( restrictions.size() == 0 ) { throw new OverConstrainedVersionException( "The artifact has no valid ranges", artifact ); } version = null; } return version; } public boolean isSelectedVersionKnown( Artifact artifact ) throws OverConstrainedVersionException { boolean value = false; if ( recommendedVersion != null ) { value = true; } else { if ( restrictions.size() == 0 ) { throw new OverConstrainedVersionException( "The artifact has no valid ranges", artifact ); } } return value; } public String toString() { if ( recommendedVersion != null ) { return recommendedVersion.toString(); } else { StringBuffer buf = new StringBuffer(); for ( Iterator i = restrictions.iterator(); i.hasNext(); ) { Restriction r = (Restriction) i.next(); buf.append( r.toString() ); if ( i.hasNext() ) { buf.append( "," ); } } return buf.toString(); } } public ArtifactVersion matchVersion( List versions ) { // TODO: could be more efficient by sorting the list and then moving along the restrictions in order? ArtifactVersion matched = null; for ( Iterator i = versions.iterator(); i.hasNext(); ) { ArtifactVersion version = (ArtifactVersion) i.next(); if ( containsVersion( version ) ) { // valid - check if it is greater than the currently matched version if ( matched == null || version.compareTo( matched ) > 0 ) { matched = version; } } } return matched; } public boolean containsVersion( ArtifactVersion version ) { for ( Iterator i = restrictions.iterator(); i.hasNext(); ) { Restriction restriction = (Restriction) i.next(); if ( restriction.containsVersion( version ) ) { return true; } } return false; } public boolean hasRestrictions() { return !restrictions.isEmpty() && recommendedVersion == null; } public boolean equals( Object obj ) { if (this == obj){ return true; } if (!(obj instanceof VersionRange )) { return false; } VersionRange other = (VersionRange) obj; boolean equals = recommendedVersion == other.recommendedVersion || ( ( recommendedVersion != null ) && recommendedVersion.equals( other.recommendedVersion ) ); equals &= restrictions == other.restrictions || ( ( restrictions != null ) && restrictions.equals( other.restrictions ) ); return equals; } public int hashCode() { int hash = 7; hash = 31 * hash + ( recommendedVersion == null ? 0 : recommendedVersion.hashCode() ); hash = 31 * hash + ( restrictions == null ? 0 : restrictions.hashCode() ); return hash; } } ././@LongLink0000000000000000000000000000017100000000000011564 Lustar rootrootmaven2-core-2.2.1/maven-artifact/src/main/java/org/apache/maven/artifact/versioning/OverConstrainedVersionException.javamaven2-core-2.2.1/maven-artifact/src/main/java/org/apache/maven/artifact/versioning/OverConstrainedV0000644000175000017500000000310510772004567033410 0ustar twernertwernerpackage org.apache.maven.artifact.versioning; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.resolver.ArtifactResolutionException; import java.util.List; /** * Occurs when ranges exclude each other and no valid value remains. * * @author Brett Porter * @version $Id: OverConstrainedVersionException.java 640549 2008-03-24 20:05:11Z bentmann $ */ public class OverConstrainedVersionException extends ArtifactResolutionException { public OverConstrainedVersionException( String msg, Artifact artifact ) { super( msg, artifact ); } public OverConstrainedVersionException( String msg, Artifact artifact, List remoteRepositories ) { super( msg, artifact, remoteRepositories ); } } ././@LongLink0000000000000000000000000000017600000000000011571 Lustar rootrootmaven2-core-2.2.1/maven-artifact/src/main/java/org/apache/maven/artifact/versioning/InvalidVersionSpecificationException.javamaven2-core-2.2.1/maven-artifact/src/main/java/org/apache/maven/artifact/versioning/InvalidVersionSp0000644000175000017500000000233310772004567033416 0ustar twernertwernerpackage org.apache.maven.artifact.versioning; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ /** * Occurs when a version is invalid. * * @author Brett Porter * @version $Id: InvalidVersionSpecificationException.java 640549 2008-03-24 20:05:11Z bentmann $ */ public class InvalidVersionSpecificationException extends Exception { public InvalidVersionSpecificationException( String message ) { super( message ); } } maven2-core-2.2.1/maven-artifact/src/main/java/org/apache/maven/artifact/repository/0000755000175000017500000000000011250552242030255 5ustar twernertwerner././@LongLink0000000000000000000000000000016200000000000011564 Lustar rootrootmaven2-core-2.2.1/maven-artifact/src/main/java/org/apache/maven/artifact/repository/ArtifactRepositoryPolicy.javamaven2-core-2.2.1/maven-artifact/src/main/java/org/apache/maven/artifact/repository/ArtifactReposito0000644000175000017500000000771210772004567033503 0ustar twernertwernerpackage org.apache.maven.artifact.repository; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import java.util.Calendar; import java.util.Date; /** * Describes a set of policies for a repository to use under certain conditions. * * @author Brett Porter * @version $Id: ArtifactRepositoryPolicy.java 640549 2008-03-24 20:05:11Z bentmann $ */ public class ArtifactRepositoryPolicy { public static final String UPDATE_POLICY_NEVER = "never"; public static final String UPDATE_POLICY_ALWAYS = "always"; public static final String UPDATE_POLICY_DAILY = "daily"; public static final String UPDATE_POLICY_INTERVAL = "interval"; public static final String CHECKSUM_POLICY_FAIL = "fail"; public static final String CHECKSUM_POLICY_WARN = "warn"; public static final String CHECKSUM_POLICY_IGNORE = "ignore"; private boolean enabled; private String updatePolicy; private String checksumPolicy; public ArtifactRepositoryPolicy() { this( true, null, null ); } public ArtifactRepositoryPolicy( boolean enabled, String updatePolicy, String checksumPolicy ) { this.enabled = enabled; if ( updatePolicy == null ) { updatePolicy = UPDATE_POLICY_DAILY; } this.updatePolicy = updatePolicy; if ( checksumPolicy == null ) { checksumPolicy = CHECKSUM_POLICY_WARN; } this.checksumPolicy = checksumPolicy; } public void setEnabled( boolean enabled ) { this.enabled = enabled; } public void setUpdatePolicy( String updatePolicy ) { this.updatePolicy = updatePolicy; } public void setChecksumPolicy( String checksumPolicy ) { this.checksumPolicy = checksumPolicy; } public boolean isEnabled() { return enabled; } public String getUpdatePolicy() { return updatePolicy; } public String getChecksumPolicy() { return checksumPolicy; } public boolean checkOutOfDate( Date lastModified ) { boolean checkForUpdates = false; if ( UPDATE_POLICY_ALWAYS.equals( updatePolicy ) ) { checkForUpdates = true; } else if ( UPDATE_POLICY_DAILY.equals( updatePolicy ) ) { // Get midnight boundary Calendar cal = Calendar.getInstance(); cal.set( Calendar.HOUR_OF_DAY, 0 ); cal.set( Calendar.MINUTE, 0 ); cal.set( Calendar.SECOND, 0 ); cal.set( Calendar.MILLISECOND, 0 ); if ( cal.getTime().after( lastModified ) ) { checkForUpdates = true; } } else if ( updatePolicy.startsWith( UPDATE_POLICY_INTERVAL ) ) { String s = updatePolicy.substring( UPDATE_POLICY_INTERVAL.length() + 1 ); int minutes = Integer.valueOf( s ).intValue(); Calendar cal = Calendar.getInstance(); cal.add( Calendar.MINUTE, -minutes ); if ( cal.getTime().after( lastModified ) ) { checkForUpdates = true; } } // else assume "never" return checkForUpdates; } } maven2-core-2.2.1/maven-artifact/src/main/java/org/apache/maven/artifact/repository/layout/0000755000175000017500000000000011250552242031572 5ustar twernertwerner././@LongLink0000000000000000000000000000016700000000000011571 Lustar rootrootmaven2-core-2.2.1/maven-artifact/src/main/java/org/apache/maven/artifact/repository/layout/LegacyRepositoryLayout.javamaven2-core-2.2.1/maven-artifact/src/main/java/org/apache/maven/artifact/repository/layout/LegacyRep0000644000175000017500000000525510551365651033410 0ustar twernertwernerpackage org.apache.maven.artifact.repository.layout; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.handler.ArtifactHandler; import org.apache.maven.artifact.metadata.ArtifactMetadata; import org.apache.maven.artifact.repository.ArtifactRepository; /** * @author jdcasey */ public class LegacyRepositoryLayout implements ArtifactRepositoryLayout { private static final String PATH_SEPARATOR = "/"; public String pathOf( Artifact artifact ) { ArtifactHandler artifactHandler = artifact.getArtifactHandler(); StringBuffer path = new StringBuffer(); path.append( artifact.getGroupId() ).append( '/' ); path.append( artifactHandler.getDirectory() ).append( '/' ); path.append( artifact.getArtifactId() ).append( '-' ).append( artifact.getVersion() ); if ( artifact.hasClassifier() ) { path.append( '-' ).append( artifact.getClassifier() ); } if ( artifactHandler.getExtension() != null && artifactHandler.getExtension().length() > 0 ) { path.append( '.' ).append( artifactHandler.getExtension() ); } return path.toString(); } public String pathOfLocalRepositoryMetadata( ArtifactMetadata metadata, ArtifactRepository repository ) { return pathOfRepositoryMetadata( metadata, metadata.getLocalFilename( repository ) ); } private String pathOfRepositoryMetadata( ArtifactMetadata metadata, String filename ) { StringBuffer path = new StringBuffer(); path.append( metadata.getGroupId() ).append( PATH_SEPARATOR ).append( "poms" ).append( PATH_SEPARATOR ); path.append( filename ); return path.toString(); } public String pathOfRemoteRepositoryMetadata( ArtifactMetadata metadata ) { return pathOfRepositoryMetadata( metadata, metadata.getRemoteFilename() ); } } ././@LongLink0000000000000000000000000000017000000000000011563 Lustar rootrootmaven2-core-2.2.1/maven-artifact/src/main/java/org/apache/maven/artifact/repository/layout/DefaultRepositoryLayout.javamaven2-core-2.2.1/maven-artifact/src/main/java/org/apache/maven/artifact/repository/layout/DefaultRe0000644000175000017500000000655610551365651033415 0ustar twernertwernerpackage org.apache.maven.artifact.repository.layout; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.handler.ArtifactHandler; import org.apache.maven.artifact.metadata.ArtifactMetadata; import org.apache.maven.artifact.repository.ArtifactRepository; /** * @author jdcasey */ public class DefaultRepositoryLayout implements ArtifactRepositoryLayout { private static final char PATH_SEPARATOR = '/'; private static final char GROUP_SEPARATOR = '.'; private static final char ARTIFACT_SEPARATOR = '-'; public String pathOf( Artifact artifact ) { ArtifactHandler artifactHandler = artifact.getArtifactHandler(); StringBuffer path = new StringBuffer(); path.append( formatAsDirectory( artifact.getGroupId() ) ).append( PATH_SEPARATOR ); path.append( artifact.getArtifactId() ).append( PATH_SEPARATOR ); path.append( artifact.getBaseVersion() ).append( PATH_SEPARATOR ); path.append( artifact.getArtifactId() ).append( ARTIFACT_SEPARATOR ).append( artifact.getVersion() ); if ( artifact.hasClassifier() ) { path.append( ARTIFACT_SEPARATOR ).append( artifact.getClassifier() ); } if ( artifactHandler.getExtension() != null && artifactHandler.getExtension().length() > 0 ) { path.append( GROUP_SEPARATOR ).append( artifactHandler.getExtension() ); } return path.toString(); } public String pathOfLocalRepositoryMetadata( ArtifactMetadata metadata, ArtifactRepository repository ) { return pathOfRepositoryMetadata( metadata, metadata.getLocalFilename( repository ) ); } private String pathOfRepositoryMetadata( ArtifactMetadata metadata, String filename ) { StringBuffer path = new StringBuffer(); path.append( formatAsDirectory( metadata.getGroupId() ) ).append( PATH_SEPARATOR ); if ( !metadata.storedInGroupDirectory() ) { path.append( metadata.getArtifactId() ).append( PATH_SEPARATOR ); if ( metadata.storedInArtifactVersionDirectory() ) { path.append( metadata.getBaseVersion() ).append( PATH_SEPARATOR ); } } path.append( filename ); return path.toString(); } public String pathOfRemoteRepositoryMetadata( ArtifactMetadata metadata ) { return pathOfRepositoryMetadata( metadata, metadata.getRemoteFilename() ); } private String formatAsDirectory( String directory ) { return directory.replace( GROUP_SEPARATOR, PATH_SEPARATOR ); } } ././@LongLink0000000000000000000000000000017100000000000011564 Lustar rootrootmaven2-core-2.2.1/maven-artifact/src/main/java/org/apache/maven/artifact/repository/layout/ArtifactRepositoryLayout.javamaven2-core-2.2.1/maven-artifact/src/main/java/org/apache/maven/artifact/repository/layout/ArtifactR0000644000175000017500000000254410551365651033412 0ustar twernertwernerpackage org.apache.maven.artifact.repository.layout; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.metadata.ArtifactMetadata; import org.apache.maven.artifact.repository.ArtifactRepository; /** * @author jdcasey */ public interface ArtifactRepositoryLayout { String ROLE = ArtifactRepositoryLayout.class.getName(); String pathOf( Artifact artifact ); String pathOfLocalRepositoryMetadata( ArtifactMetadata metadata, ArtifactRepository repository ); String pathOfRemoteRepositoryMetadata( ArtifactMetadata metadata ); } ././@LongLink0000000000000000000000000000016300000000000011565 Lustar rootrootmaven2-core-2.2.1/maven-artifact/src/main/java/org/apache/maven/artifact/repository/ArtifactRepositoryFactory.javamaven2-core-2.2.1/maven-artifact/src/main/java/org/apache/maven/artifact/repository/ArtifactReposito0000644000175000017500000000321110551365651033470 0ustar twernertwernerpackage org.apache.maven.artifact.repository; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout; /** * @author jdcasey */ public interface ArtifactRepositoryFactory { String ROLE = ArtifactRepositoryFactory.class.getName(); ArtifactRepository createDeploymentArtifactRepository( String id, String url, ArtifactRepositoryLayout layout, boolean uniqueVersion ); ArtifactRepository createArtifactRepository( String id, String url, ArtifactRepositoryLayout repositoryLayout, ArtifactRepositoryPolicy snapshots, ArtifactRepositoryPolicy releases ); void setGlobalUpdatePolicy( String snapshotPolicy ); void setGlobalChecksumPolicy( String checksumPolicy ); } maven2-core-2.2.1/maven-artifact/src/main/java/org/apache/maven/artifact/repository/metadata/0000755000175000017500000000000011250552242032035 5ustar twernertwerner././@LongLink0000000000000000000000000000021000000000000011556 Lustar rootrootmaven2-core-2.2.1/maven-artifact/src/main/java/org/apache/maven/artifact/repository/metadata/RepositoryMetadataDeploymentException.javamaven2-core-2.2.1/maven-artifact/src/main/java/org/apache/maven/artifact/repository/metadata/Reposit0000644000175000017500000000255110551365651033421 0ustar twernertwernerpackage org.apache.maven.artifact.repository.metadata; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ /** * Error while deploying repository metadata. * * @author Brett Porter * @version $Id: RepositoryMetadataDeploymentException.java 495147 2007-01-11 07:47:53Z jvanzyl $ */ public class RepositoryMetadataDeploymentException extends Throwable { public RepositoryMetadataDeploymentException( String message ) { super( message ); } public RepositoryMetadataDeploymentException( String message, Exception e ) { super( message, e ); } } ././@LongLink0000000000000000000000000000021000000000000011556 Lustar rootrootmaven2-core-2.2.1/maven-artifact/src/main/java/org/apache/maven/artifact/repository/metadata/RepositoryMetadataResolutionException.javamaven2-core-2.2.1/maven-artifact/src/main/java/org/apache/maven/artifact/repository/metadata/Reposit0000644000175000017500000000257610551365651033430 0ustar twernertwernerpackage org.apache.maven.artifact.repository.metadata; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ /** * Error while retrieving repository metadata from the repository. * * @author Brett Porter * @version $Id: RepositoryMetadataResolutionException.java 495147 2007-01-11 07:47:53Z jvanzyl $ */ public class RepositoryMetadataResolutionException extends Exception { public RepositoryMetadataResolutionException( String message ) { super( message ); } public RepositoryMetadataResolutionException( String message, Exception e ) { super( message, e ); } } ././@LongLink0000000000000000000000000000020300000000000011560 Lustar rootrootmaven2-core-2.2.1/maven-artifact/src/main/java/org/apache/maven/artifact/repository/metadata/RepositoryMetadataStoreException.javamaven2-core-2.2.1/maven-artifact/src/main/java/org/apache/maven/artifact/repository/metadata/Reposit0000644000175000017500000000255310551365651033423 0ustar twernertwernerpackage org.apache.maven.artifact.repository.metadata; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ /** * Problem storing the repository metadata in the local repository. * * @author Brett Porter * @version $Id: RepositoryMetadataStoreException.java 495147 2007-01-11 07:47:53Z jvanzyl $ */ public class RepositoryMetadataStoreException extends Exception { public RepositoryMetadataStoreException( String message ) { super( message ); } public RepositoryMetadataStoreException( String message, Exception e ) { super( message, e ); } } ././@LongLink0000000000000000000000000000021200000000000011560 Lustar rootrootmaven2-core-2.2.1/maven-artifact/src/main/java/org/apache/maven/artifact/repository/metadata/RepositoryMetadataInstallationException.javamaven2-core-2.2.1/maven-artifact/src/main/java/org/apache/maven/artifact/repository/metadata/Reposit0000644000175000017500000000256210551365651033423 0ustar twernertwernerpackage org.apache.maven.artifact.repository.metadata; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ /** * Error while installing repository metadata. * * @author Brett Porter * @version $Id: RepositoryMetadataInstallationException.java 495147 2007-01-11 07:47:53Z jvanzyl $ */ public class RepositoryMetadataInstallationException extends Throwable { public RepositoryMetadataInstallationException( String message ) { super( message ); } public RepositoryMetadataInstallationException( String message, Exception e ) { super( message, e ); } } ././@LongLink0000000000000000000000000000020200000000000011557 Lustar rootrootmaven2-core-2.2.1/maven-artifact/src/main/java/org/apache/maven/artifact/repository/metadata/RepositoryMetadataReadException.javamaven2-core-2.2.1/maven-artifact/src/main/java/org/apache/maven/artifact/repository/metadata/Reposit0000644000175000017500000000254510551365651033424 0ustar twernertwernerpackage org.apache.maven.artifact.repository.metadata;/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ /** * Problem storing the repository metadata in the local repository. * * @author Brett Porter * @version $Id: RepositoryMetadataReadException.java 495147 2007-01-11 07:47:53Z jvanzyl $ */ public class RepositoryMetadataReadException extends Exception { public RepositoryMetadataReadException( String message ) { super( message ); } public RepositoryMetadataReadException( String message, Exception e ) { super( message, e ); } } ././@LongLink0000000000000000000000000000015400000000000011565 Lustar rootrootmaven2-core-2.2.1/maven-artifact/src/main/java/org/apache/maven/artifact/repository/ArtifactRepository.javamaven2-core-2.2.1/maven-artifact/src/main/java/org/apache/maven/artifact/repository/ArtifactReposito0000644000175000017500000000351710551365651033501 0ustar twernertwernerpackage org.apache.maven.artifact.repository; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.metadata.ArtifactMetadata; import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout; /** * Specifies the repository used for artifact handling. * * @author Brett Porter * @version $Id: ArtifactRepository.java 495147 2007-01-11 07:47:53Z jvanzyl $ */ public interface ArtifactRepository { String pathOf( Artifact artifact ); String pathOfRemoteRepositoryMetadata( ArtifactMetadata artifactMetadata ); String pathOfLocalRepositoryMetadata( ArtifactMetadata metadata, ArtifactRepository repository ); String getUrl(); String getBasedir(); String getProtocol(); String getId(); ArtifactRepositoryPolicy getSnapshots(); ArtifactRepositoryPolicy getReleases(); ArtifactRepositoryLayout getLayout(); String getKey(); boolean isUniqueVersion(); void setBlacklisted( boolean blackListed ); boolean isBlacklisted(); } maven2-core-2.2.1/maven-artifact/src/main/java/org/apache/maven/artifact/metadata/0000755000175000017500000000000011250552242027616 5ustar twernertwerner././@LongLink0000000000000000000000000000014700000000000011567 Lustar rootrootmaven2-core-2.2.1/maven-artifact/src/main/java/org/apache/maven/artifact/metadata/ResolutionGroup.javamaven2-core-2.2.1/maven-artifact/src/main/java/org/apache/maven/artifact/metadata/ResolutionGroup.ja0000644000175000017500000000306510772004567033330 0ustar twernertwernerpackage org.apache.maven.artifact.metadata; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import org.apache.maven.artifact.Artifact; import java.util.List; import java.util.Set; public class ResolutionGroup { private final Set artifacts; private final List resolutionRepositories; private final Artifact pomArtifact; public ResolutionGroup( Artifact pomArtifact, Set artifacts, List resolutionRepositories ) { this.pomArtifact = pomArtifact; this.artifacts = artifacts; this.resolutionRepositories = resolutionRepositories; } public Artifact getPomArtifact() { return pomArtifact; } public Set getArtifacts() { return artifacts; } public List getResolutionRepositories() { return resolutionRepositories; } } ././@LongLink0000000000000000000000000000015000000000000011561 Lustar rootrootmaven2-core-2.2.1/maven-artifact/src/main/java/org/apache/maven/artifact/metadata/ArtifactMetadata.javamaven2-core-2.2.1/maven-artifact/src/main/java/org/apache/maven/artifact/metadata/ArtifactMetadata.j0000644000175000017500000000541710551365651033207 0ustar twernertwernerpackage org.apache.maven.artifact.metadata; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.artifact.repository.metadata.RepositoryMetadataStoreException; /** * Contains metadata about an artifact, and methods to retrieve/store it from an artifact repository. * * @author Brett Porter * @version $Id: ArtifactMetadata.java 495147 2007-01-11 07:47:53Z jvanzyl $ * @todo merge with artifactmetadatasource * @todo retrieval exception not appropriate for store */ public interface ArtifactMetadata { /** * Whether this metadata should be stored alongside the artifact. */ boolean storedInArtifactVersionDirectory(); /** * Whether this metadata should be stored alongside the group. */ boolean storedInGroupDirectory(); String getGroupId(); String getArtifactId(); String getBaseVersion(); Object getKey(); /** * Get the filename of this metadata on the local repository. * * @param repository the remote repository it came from * @return the filename */ String getLocalFilename( ArtifactRepository repository ); /** * Get the filename of this metadata on the remote repository. * * @return the filename */ String getRemoteFilename(); /** * Merge a new metadata set into this piece of metadata. * * @param metadata the new metadata * @todo this should only be needed on the repository metadata */ void merge( ArtifactMetadata metadata ); /** * Store the metadata in the local repository. * * @param localRepository the local repository * @param remoteRepository the remote repository it came from * @todo this should only be needed on the repository metadata */ void storeInLocalRepository( ArtifactRepository localRepository, ArtifactRepository remoteRepository ) throws RepositoryMetadataStoreException; String extendedToString(); } ././@LongLink0000000000000000000000000000017200000000000011565 Lustar rootrootmaven2-core-2.2.1/maven-artifact/src/main/java/org/apache/maven/artifact/metadata/ArtifactMetadataRetrievalException.javamaven2-core-2.2.1/maven-artifact/src/main/java/org/apache/maven/artifact/metadata/ArtifactMetadataRe0000644000175000017500000000421110707731371033234 0ustar twernertwernerpackage org.apache.maven.artifact.metadata; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import org.apache.maven.artifact.Artifact; /** * Error while retrieving repository metadata from the repository. * * @author Jason van Zyl * @version $Id: ArtifactMetadataRetrievalException.java 588021 2007-10-24 21:02:49Z carlos $ */ public class ArtifactMetadataRetrievalException extends Exception { private Artifact artifact; /** * @deprecated use {@link #ArtifactMetadataRetrievalException(String, Throwable, Artifact)} */ public ArtifactMetadataRetrievalException( String message ) { this( message, null, null ); } /** * @deprecated use {@link #ArtifactMetadataRetrievalException(String, Throwable, Artifact)} */ public ArtifactMetadataRetrievalException( Throwable cause ) { this( null, cause, null ); } /** * @deprecated use {@link #ArtifactMetadataRetrievalException(String, Throwable, Artifact)} */ public ArtifactMetadataRetrievalException( String message, Throwable cause ) { this( message, cause, null ); } public ArtifactMetadataRetrievalException( String message, Throwable cause, Artifact artifact ) { super( message, cause ); this.artifact = artifact; } public Artifact getArtifact() { return artifact; } } ././@LongLink0000000000000000000000000000016000000000000011562 Lustar rootrootmaven2-core-2.2.1/maven-artifact/src/main/java/org/apache/maven/artifact/metadata/AbstractArtifactMetadata.javamaven2-core-2.2.1/maven-artifact/src/main/java/org/apache/maven/artifact/metadata/AbstractArtifactMe0000644000175000017500000000373010551365651033260 0ustar twernertwernerpackage org.apache.maven.artifact.metadata; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import org.apache.maven.artifact.Artifact; /** * Common elements of artifact metadata. * * @author Brett Porter * @version $Id: AbstractArtifactMetadata.java 495147 2007-01-11 07:47:53Z jvanzyl $ */ public abstract class AbstractArtifactMetadata implements ArtifactMetadata { protected Artifact artifact; protected AbstractArtifactMetadata( Artifact artifact ) { this.artifact = artifact; } public boolean storedInGroupDirectory() { return false; } public String getGroupId() { return artifact.getGroupId(); } public String getArtifactId() { return artifact.getArtifactId(); } public String extendedToString() { StringBuffer buffer = new StringBuffer(); buffer.append( "\nArtifact Metadata\n--------------------------" ); buffer.append( "\nGroupId: " ).append( getGroupId() ); buffer.append( "\nArtifactId: " ).append( getArtifactId() ); buffer.append( "\nMetadata Type: " ).append(getClass().getName() ); return buffer.toString(); } } ././@LongLink0000000000000000000000000000015600000000000011567 Lustar rootrootmaven2-core-2.2.1/maven-artifact/src/main/java/org/apache/maven/artifact/metadata/ArtifactMetadataSource.javamaven2-core-2.2.1/maven-artifact/src/main/java/org/apache/maven/artifact/metadata/ArtifactMetadataSo0000644000175000017500000000533711035020441033241 0ustar twernertwernerpackage org.apache.maven.artifact.metadata; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.artifact.versioning.ArtifactVersion; import java.util.List; /** * Provides some metadata operations, like querying the remote repository for a list of versions available for an * artifact. * * @author Jason van Zyl * @version $Id: ArtifactMetadataSource.java 675087 2008-07-09 02:23:29Z jdcasey $ */ public interface ArtifactMetadataSource { String ROLE = ArtifactMetadataSource.class.getName(); ResolutionGroup retrieve( Artifact artifact, ArtifactRepository localRepository, List remoteRepositories ) throws ArtifactMetadataRetrievalException; /** * Resolve all relocations in the POM for this artifact, and return the new artifact coordinate. */ Artifact retrieveRelocatedArtifact( Artifact artifact, ArtifactRepository localRepository, List remoteRepositories ) throws ArtifactMetadataRetrievalException; /** * Get a list of available versions for an artifact in the remote repository * * @param artifact artifact we are interested in. Only groupid and artifactId * are needed, for instance the following code will work * artifactFactory.createProjectArtifact( "org.apache.maven", "maven", "" ) * @param localRepository local repository * @param remoteRepositories remote repositories, {@link List} $lt; {@link ArtifactRepository} > * @return {@link List} $lt; {@link ArtifactVersion} > * @throws ArtifactMetadataRetrievalException in case of error while retrieving repository metadata from the repository. */ List retrieveAvailableVersions( Artifact artifact, ArtifactRepository localRepository, List remoteRepositories ) throws ArtifactMetadataRetrievalException; }maven2-core-2.2.1/maven-artifact/src/main/java/org/apache/maven/artifact/Artifact.java0000644000175000017500000001175011173447106030450 0ustar twernertwernerpackage org.apache.maven.artifact; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import org.apache.maven.artifact.handler.ArtifactHandler; import org.apache.maven.artifact.metadata.ArtifactMetadata; import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.artifact.resolver.filter.ArtifactFilter; import org.apache.maven.artifact.versioning.ArtifactVersion; import org.apache.maven.artifact.versioning.OverConstrainedVersionException; import org.apache.maven.artifact.versioning.VersionRange; import java.io.File; import java.util.Collection; import java.util.List; import java.util.regex.Pattern; /** * Description of an artifact. * * @todo do we really need an interface here? * @todo get rid of the multiple states we can have (project, parent, etc artifacts, file == null, snapshot, etc) - construct subclasses and use accordingly? */ public interface Artifact extends Comparable { String LATEST_VERSION = "LATEST"; String SNAPSHOT_VERSION = "SNAPSHOT"; Pattern VERSION_FILE_PATTERN = Pattern.compile( "^(.*)-([0-9]{8}.[0-9]{6})-([0-9]+)$" ); // TODO: into scope handler String SCOPE_COMPILE = "compile"; String SCOPE_TEST = "test"; String SCOPE_RUNTIME = "runtime"; String SCOPE_PROVIDED = "provided"; String SCOPE_SYSTEM = "system"; String SCOPE_IMPORT = "import"; // Used to import dependencyManagement dependencies String RELEASE_VERSION = "RELEASE"; String getGroupId(); String getArtifactId(); String getVersion(); void setVersion( String version ); /** * Get the scope of the artifact. If the artifact is a standalone rather than a dependency, it's scope will be * null. The scope may not be the same as it was declared on the original dependency, as this is the * result of combining it with the main project scope. * * @return the scope */ String getScope(); String getType(); String getClassifier(); // only providing this since classifier is *very* optional... boolean hasClassifier(); File getFile(); void setFile( File destination ); String getBaseVersion(); /** * @todo would like to get rid of this - or at least only have one. Base version should be immutable. */ void setBaseVersion( String baseVersion ); // ---------------------------------------------------------------------- String getId(); String getDependencyConflictId(); void addMetadata( ArtifactMetadata metadata ); ArtifactMetadata getMetadata( Class metadataClass ); Collection getMetadataList(); void setRepository( ArtifactRepository remoteRepository ); ArtifactRepository getRepository(); void updateVersion( String version, ArtifactRepository localRepository ); String getDownloadUrl(); void setDownloadUrl( String downloadUrl ); ArtifactFilter getDependencyFilter(); void setDependencyFilter( ArtifactFilter artifactFilter ); ArtifactHandler getArtifactHandler(); /** * @return {@link List} < {@link String} > with artifact ids */ List getDependencyTrail(); /** * @param dependencyTrail {@link List} < {@link String} > with artifact ids */ void setDependencyTrail( List dependencyTrail ); void setScope( String scope ); VersionRange getVersionRange(); void setVersionRange( VersionRange newRange ); void selectVersion( String version ); void setGroupId( String groupId ); void setArtifactId( String artifactId ); boolean isSnapshot(); void setResolved( boolean resolved ); boolean isResolved(); void setResolvedVersion( String version ); /** * @todo remove, a quick hack for the lifecycle executor */ void setArtifactHandler( ArtifactHandler handler ); boolean isRelease(); void setRelease( boolean release ); List getAvailableVersions(); void setAvailableVersions( List versions ); boolean isOptional(); void setOptional( boolean optional ); ArtifactVersion getSelectedVersion() throws OverConstrainedVersionException; boolean isSelectedVersionKnown() throws OverConstrainedVersionException; }maven2-core-2.2.1/maven-artifact/pom.xml0000644000175000017500000000305511236625310020010 0ustar twernertwerner 4.0.0 org.apache.maven maven 2.2.1 maven-artifact Maven Artifact org.codehaus.plexus plexus-utils org.codehaus.plexus plexus-container-default test maven2-core-2.2.1/maven-plugin-api/0000755000175000017500000000000011250552243016740 5ustar twernertwernermaven2-core-2.2.1/maven-plugin-api/src/0000755000175000017500000000000011250552243017527 5ustar twernertwernermaven2-core-2.2.1/maven-plugin-api/src/site/0000755000175000017500000000000011250552243020473 5ustar twernertwernermaven2-core-2.2.1/maven-plugin-api/src/site/site.xml0000644000175000017500000000013211002611514022145 0ustar twernertwerner maven2-core-2.2.1/maven-plugin-api/src/main/0000755000175000017500000000000011250552243020453 5ustar twernertwernermaven2-core-2.2.1/maven-plugin-api/src/main/java/0000755000175000017500000000000011250552243021374 5ustar twernertwernermaven2-core-2.2.1/maven-plugin-api/src/main/java/org/0000755000175000017500000000000011250552243022163 5ustar twernertwernermaven2-core-2.2.1/maven-plugin-api/src/main/java/org/apache/0000755000175000017500000000000011250552243023404 5ustar twernertwernermaven2-core-2.2.1/maven-plugin-api/src/main/java/org/apache/maven/0000755000175000017500000000000011250552243024512 5ustar twernertwernermaven2-core-2.2.1/maven-plugin-api/src/main/java/org/apache/maven/plugin/0000755000175000017500000000000011250552243026010 5ustar twernertwerner././@LongLink0000000000000000000000000000015500000000000011566 Lustar rootrootmaven2-core-2.2.1/maven-plugin-api/src/main/java/org/apache/maven/plugin/AbstractMojoExecutionException.javamaven2-core-2.2.1/maven-plugin-api/src/main/java/org/apache/maven/plugin/AbstractMojoExecutionExcept0000644000175000017500000000277510772004567033404 0ustar twernertwernerpackage org.apache.maven.plugin; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ /** * Base exception. * * @author Brett Porter * @version $Id: AbstractMojoExecutionException.java 640549 2008-03-24 20:05:11Z bentmann $ */ public abstract class AbstractMojoExecutionException extends Exception { protected Object source; protected String longMessage; public AbstractMojoExecutionException( String message ) { super( message ); } public AbstractMojoExecutionException( String message, Throwable cause ) { super( message, cause ); } public String getLongMessage() { return longMessage; } public Object getSource() { return source; } } maven2-core-2.2.1/maven-plugin-api/src/main/java/org/apache/maven/plugin/AbstractMojo.java0000644000175000017500000001677310743031737031267 0ustar twernertwernerpackage org.apache.maven.plugin; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import org.apache.maven.plugin.logging.Log; import org.apache.maven.plugin.logging.SystemStreamLog; import java.util.Map; /** * Abstract class to provide most of the infrastructure required to implement a Mojo except for * the execute method. *
* The implementation should have a goal annotation in the class-level javadoc annotation: *
 * /**
 *  * @goal goalName
 *  */
 * 
* * There are also a number of class-level javadoc annotations which can be used to control how and when the * Mojo is executed: *
*
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
Descriptor ElementAnnotationRequired?Notes
goal@goal <goalName>YesThe name for the Mojo that users will reference from the command line to execute the Mojo directly, * or inside a POM in order to provide Mojo-specific configuration.
implementationnone (detected)YesThe Mojo's fully-qualified class name (or script path in the case of non-Java Mojos).
languagenone (detected)No. Default: javaThe implementation language for this Mojo (Java, beanshell, etc.).
configurator@configurator <roleHint>NoThe configurator type to use when injecting parameter values into this Mojo. The value is normally * deduced from the Mojo's implementation language, but can be specified to allow a custom * ComponentConfigurator implementation to be used. *
* NOTE: This will only be used in very special cases, using a highly controlled vocabulary of possible * values. (Elements like this are why it's a good idea to use the descriptor tools.) *
phase@phase <phaseName>NoBinds this Mojo to a particular phase of the standard build lifecycle, if specified. *
* NOTE: This is only required if this Mojo is to participate in the standard build process. *
execute@execute [phase=<phaseName>|goal=<goalName>] [lifecycle=<lifecycleId>]NoWhen this goal is invoked, it will first invoke a parallel lifecycle, ending at the given phase. * If a goal is provided instead of a phase, that goal will be executed in isolation. * The execution of either will not affect the current project, but instead make available the * ${executedProject} expression if required. An alternate lifecycle can also be provided: * for more information see the documentation on the * build lifecycle. *
requiresDependencyResolution@requiresDependencyResolution <requiredScope>NoFlags this Mojo as requiring the dependencies in the specified scope (or an implied scope) to be * resolved before it can execute. *
* NOTE: Currently supports compile, runtime, and test scopes. *
descriptionnone (detected)NoThe description of this Mojo's functionality. Using the toolset, this will be the class-level * Javadoc description provided. *
* NOTE: While this is not a required part of the Mojo specification, it SHOULD be provided to * enable future tool support for browsing, etc. and for clarity. *
parametersN/ANoSpecifications for the parameters which this Mojo uses will be provided in parameter sub-elements * in this section. *
* NOTE: Parameters are discussed in more detail below. *
* * @see Guide to Developing Java Plugins * @see Guide to Configuring Plug-ins * @see Mojo API Specification * * @author Brett Porter * @author jdcasey * @author Vincent Siveton * @version $Id: AbstractMojo.java 612012 2008-01-15 04:17:35Z vsiveton $ */ public abstract class AbstractMojo implements Mojo, ContextEnabled { /** Instance logger */ private Log log; /** Plugin container context */ private Map pluginContext; /** * @see org.apache.maven.plugin.Mojo#setLog(org.apache.maven.plugin.logging.Log) */ public void setLog( Log log ) { this.log = log; } /** * Returns the logger that has been injected into this mojo. If no logger has been setup yet, a SystemStreamLog * logger will be created and returned. *

* Note: * The logger returned by this method must not be cached in an instance field during the construction of the mojo. * This would cause the mojo to use a wrongly configured default logger when being run by Maven. The proper logger * gets injected by the Plexus container after the mojo has been constructed. Therefore, simply call this * method directly whenever you need the logger, it is fast enough and needs no caching. * * @see org.apache.maven.plugin.Mojo#getLog() */ public Log getLog() { if ( log == null ) { log = new SystemStreamLog(); } return log; } /** * @see org.apache.maven.plugin.ContextEnabled#getPluginContext() */ public Map getPluginContext() { return pluginContext; } /** * @see org.apache.maven.plugin.ContextEnabled#setPluginContext(java.util.Map) */ public void setPluginContext( Map pluginContext ) { this.pluginContext = pluginContext; } } maven2-core-2.2.1/maven-plugin-api/src/main/java/org/apache/maven/plugin/MojoFailureException.java0000644000175000017500000000424510772004567032764 0ustar twernertwernerpackage org.apache.maven.plugin; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ /** * An exception occuring during the execution of a plugin (such as a compilation failure). *
* Throwing this exception causes a "BUILD FAILURE" message to be displayed. * * @author Brett Porter * @version $Id: MojoFailureException.java 640549 2008-03-24 20:05:11Z bentmann $ */ public class MojoFailureException extends AbstractMojoExecutionException { /** * Construct a new MojoFailureException exception providing the source and a short and long message. * * @param source * @param shortMessage * @param longMessage */ public MojoFailureException( Object source, String shortMessage, String longMessage ) { super( shortMessage ); this.source = source; this.longMessage = longMessage; } /** * Construct a new MojoFailureException exception providing a message. * * @param message */ public MojoFailureException( String message ) { super( message ); } /** * Construct a new MojoFailureException exception wrapping an underlying Throwable * and providing a message. * * @param message * @param cause * @since 2.0.9 */ public MojoFailureException( String message, Throwable cause ) { super( message, cause ); } } maven2-core-2.2.1/maven-plugin-api/src/main/java/org/apache/maven/plugin/ContextEnabled.java0000644000175000017500000000310710772004567031564 0ustar twernertwernerpackage org.apache.maven.plugin; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import java.util.Map; /** * Interface to allow Mojos to communicate with each others Mojos, other than * project's source root and project's attachment. *
* The plugin manager would pull the context out of the plugin container context, and populate it into the Mojo. * * @author jdcasey * @version $Id: ContextEnabled.java 640549 2008-03-24 20:05:11Z bentmann $ */ public interface ContextEnabled { /** * Set a new shared context Map to a mojo before executing it. * * @param pluginContext a new Map */ void setPluginContext( Map pluginContext ); /** * @return a Map stored in the plugin container's context. */ Map getPluginContext(); } maven2-core-2.2.1/maven-plugin-api/src/main/java/org/apache/maven/plugin/logging/0000755000175000017500000000000011250552243027436 5ustar twernertwerner././@LongLink0000000000000000000000000000014600000000000011566 Lustar rootrootmaven2-core-2.2.1/maven-plugin-api/src/main/java/org/apache/maven/plugin/logging/SystemStreamLog.javamaven2-core-2.2.1/maven-plugin-api/src/main/java/org/apache/maven/plugin/logging/SystemStreamLog.jav0000644000175000017500000001240410551365651033253 0ustar twernertwernerpackage org.apache.maven.plugin.logging; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import java.io.PrintWriter; import java.io.StringWriter; /** * Logger with "standard" output and error output stream. * * @author jdcasey * @version $Id: SystemStreamLog.java 495147 2007-01-11 07:47:53Z jvanzyl $ */ public class SystemStreamLog implements Log { /** * @see org.apache.maven.plugin.logging.Log#debug(java.lang.CharSequence) */ public void debug( CharSequence content ) { print( "debug", content ); } /** * @see org.apache.maven.plugin.logging.Log#debug(java.lang.CharSequence, java.lang.Throwable) */ public void debug( CharSequence content, Throwable error ) { print( "debug", content, error ); } /** * @see org.apache.maven.plugin.logging.Log#debug(java.lang.Throwable) */ public void debug( Throwable error ) { print( "debug", error ); } /** * @see org.apache.maven.plugin.logging.Log#info(java.lang.CharSequence) */ public void info( CharSequence content ) { print( "info", content ); } /** * @see org.apache.maven.plugin.logging.Log#info(java.lang.CharSequence, java.lang.Throwable) */ public void info( CharSequence content, Throwable error ) { print( "info", content, error ); } /** * @see org.apache.maven.plugin.logging.Log#info(java.lang.Throwable) */ public void info( Throwable error ) { print( "info", error ); } /** * @see org.apache.maven.plugin.logging.Log#warn(java.lang.CharSequence) */ public void warn( CharSequence content ) { print( "warn", content ); } /** * @see org.apache.maven.plugin.logging.Log#warn(java.lang.CharSequence, java.lang.Throwable) */ public void warn( CharSequence content, Throwable error ) { print( "warn", content, error ); } /** * @see org.apache.maven.plugin.logging.Log#warn(java.lang.Throwable) */ public void warn( Throwable error ) { print( "warn", error ); } /** * @see org.apache.maven.plugin.logging.Log#error(java.lang.CharSequence) */ public void error( CharSequence content ) { System.err.println( "[error] " + content.toString() ); } /** * @see org.apache.maven.plugin.logging.Log#error(java.lang.CharSequence, java.lang.Throwable) */ public void error( CharSequence content, Throwable error ) { StringWriter sWriter = new StringWriter(); PrintWriter pWriter = new PrintWriter( sWriter ); error.printStackTrace( pWriter ); System.err.println( "[error] " + content.toString() + "\n\n" + sWriter.toString() ); } /** * @see org.apache.maven.plugin.logging.Log#error(java.lang.Throwable) */ public void error( Throwable error ) { StringWriter sWriter = new StringWriter(); PrintWriter pWriter = new PrintWriter( sWriter ); error.printStackTrace( pWriter ); System.err.println( "[error] " + sWriter.toString() ); } /** * @see org.apache.maven.plugin.logging.Log#isDebugEnabled() */ public boolean isDebugEnabled() { // TODO: Not sure how best to set these for this implementation... return false; } /** * @see org.apache.maven.plugin.logging.Log#isInfoEnabled() */ public boolean isInfoEnabled() { return true; } /** * @see org.apache.maven.plugin.logging.Log#isWarnEnabled() */ public boolean isWarnEnabled() { return true; } /** * @see org.apache.maven.plugin.logging.Log#isErrorEnabled() */ public boolean isErrorEnabled() { return true; } private void print( String prefix, CharSequence content ) { System.out.println( "[" + prefix + "] " + content.toString() ); } private void print( String prefix, Throwable error ) { StringWriter sWriter = new StringWriter(); PrintWriter pWriter = new PrintWriter( sWriter ); error.printStackTrace( pWriter ); System.out.println( "[" + prefix + "] " + sWriter.toString() ); } private void print( String prefix, CharSequence content, Throwable error ) { StringWriter sWriter = new StringWriter(); PrintWriter pWriter = new PrintWriter( sWriter ); error.printStackTrace( pWriter ); System.out.println( "[" + prefix + "] " + content.toString() + "\n\n" + sWriter.toString() ); } }maven2-core-2.2.1/maven-plugin-api/src/main/java/org/apache/maven/plugin/logging/Log.java0000644000175000017500000001130110551365651031026 0ustar twernertwernerpackage org.apache.maven.plugin.logging; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ /** * This interface supplies the API for providing feedback to the user from the Mojo, using standard * Maven channels. *
* There should be no big surprises here, although you may notice that the methods accept * java.lang.CharSequence rather than java.lang.String. This is provided mainly as a * convenience, to enable developers to pass things like java.lang.StringBuffer directly into the logger, * rather than formatting first by calling toString(). * * @author jdcasey * @version $Id: Log.java 495147 2007-01-11 07:47:53Z jvanzyl $ */ public interface Log { /** * @return true if the debug error level is enabled */ boolean isDebugEnabled(); /** * Send a message to the user in the debug error level. * * @param content */ void debug( CharSequence content ); /** * Send a message (and accompanying exception) to the user in the debug error level. *
* The error's stacktrace will be output when this error level is enabled. * * @param content * @param error */ void debug( CharSequence content, Throwable error ); /** * Send an exception to the user in the debug error level. *
* The stack trace for this exception will be output when this error level is enabled. * * @param error */ void debug( Throwable error ); /** * @return true if the info error level is enabled */ boolean isInfoEnabled(); /** * Send a message to the user in the info error level. * * @param content */ void info( CharSequence content ); /** * Send a message (and accompanying exception) to the user in the info error level. *
* The error's stacktrace will be output when this error level is enabled. * * @param content * @param error */ void info( CharSequence content, Throwable error ); /** * Send an exception to the user in the info error level. *
* The stack trace for this exception will be output when this error level is enabled. * * @param error */ void info( Throwable error ); /** * @return true if the warn error level is enabled */ boolean isWarnEnabled(); /** * Send a message to the user in the warn error level. * * @param content */ void warn( CharSequence content ); /** * Send a message (and accompanying exception) to the user in the warn error level. *
* The error's stacktrace will be output when this error level is enabled. * * @param content * @param error */ void warn( CharSequence content, Throwable error ); /** * Send an exception to the user in the warn error level. *
* The stack trace for this exception will be output when this error level is enabled. * * @param error */ void warn( Throwable error ); /** * @return true if the error error level is enabled */ boolean isErrorEnabled(); /** * Send a message to the user in the error error level. * * @param content */ void error( CharSequence content ); /** * Send a message (and accompanying exception) to the user in the error error level. *
* The error's stacktrace will be output when this error level is enabled. * * @param content * @param error */ void error( CharSequence content, Throwable error ); /** * Send an exception to the user in the error error level. *
* The stack trace for this exception will be output when this error level is enabled. * * @param error */ void error( Throwable error ); }maven2-core-2.2.1/maven-plugin-api/src/main/java/org/apache/maven/plugin/Mojo.java0000644000175000017500000000606510772003040027560 0ustar twernertwernerpackage org.apache.maven.plugin; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import org.apache.maven.plugin.logging.Log; /** * This interface forms the contract required for Mojos to interact with the Maven * infrastructure. *
* It features an execute() method, which triggers the Mojo's build-process behavior, and can throw * a MojoExecutionException or MojoFailureException if error conditions occur. *
* Also included is the setLog(...) method, which simply allows Maven to inject a logging mechanism which will * allow the Mojo to communicate to the outside world through standard Maven channels. * * @author Jason van Zyl * @version $Id: Mojo.java 640545 2008-03-24 19:50:56Z bentmann $ */ public interface Mojo { /** The component role hint for Plexus container */ String ROLE = Mojo.class.getName(); /** * Perform whatever build-process behavior this Mojo implements. *
* This is the main trigger for the Mojo inside the Maven system, and allows * the Mojo to communicate errors. * * @throws MojoExecutionException if an unexpected problem occurs. * Throwing this exception causes a "BUILD ERROR" message to be displayed. * @throws MojoFailureException if an expected problem (such as a compilation failure) occurs. * Throwing this exception causes a "BUILD FAILURE" message to be displayed. */ void execute() throws MojoExecutionException, MojoFailureException; /** * Inject a standard Maven logging mechanism to allow this Mojo to communicate events * and feedback to the user. * * @param log a new logger */ // TODO: not sure about this here, and may want a getLog on here as well/instead void setLog( Log log ); /** * Furnish access to the standard Maven logging mechanism which is managed in this base class. * * @return a log4j-like logger object which allows plugins to create messages at levels of "debug", * "info", "warn", and "error". This logger is the accepted means to display * information to the user. */ Log getLog(); } ././@LongLink0000000000000000000000000000014500000000000011565 Lustar rootrootmaven2-core-2.2.1/maven-plugin-api/src/main/java/org/apache/maven/plugin/MojoExecutionException.javamaven2-core-2.2.1/maven-plugin-api/src/main/java/org/apache/maven/plugin/MojoExecutionException.java0000644000175000017500000000474010772003040033321 0ustar twernertwernerpackage org.apache.maven.plugin; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ /** * An exception occuring during the execution of a plugin. *
* Throwing this exception causes a "BUILD ERROR" message to be displayed. * * @author Brett Porter * @version $Id: MojoExecutionException.java 640545 2008-03-24 19:50:56Z bentmann $ */ public class MojoExecutionException extends AbstractMojoExecutionException { /** * Construct a new MojoExecutionException exception providing the source and a short and long message. * * @param source * @param shortMessage * @param longMessage */ public MojoExecutionException( Object source, String shortMessage, String longMessage ) { super( shortMessage ); this.source = source; this.longMessage = longMessage; } /** * Construct a new MojoExecutionException exception wrapping an underlying Exception * and providing a message. * * @param message * @param cause */ public MojoExecutionException( String message, Exception cause ) { super( message, cause ); } /** * Construct a new MojoExecutionException exception wrapping an underlying Throwable * and providing a message. * * @param message * @param cause */ public MojoExecutionException( String message, Throwable cause ) { super( message, cause ); } /** * Construct a new MojoExecutionException exception providing a message. * * @param message */ public MojoExecutionException( String message ) { super( message ); } } maven2-core-2.2.1/maven-plugin-api/pom.xml0000644000175000017500000000266311236625310020264 0ustar twernertwerner 4.0.0 org.apache.maven maven 2.2.1 maven-plugin-api Maven Plugin API junit junit 3.8.1 test maven2-core-2.2.1/README.txt0000644000175000017500000000263011147252453015273 0ustar twernertwerner------------------------------------------------------------------------------- Bootstrapping Maven ------------------------------------------------------------------------------- Set the environment variable M2_HOME pointing to the dir where you want Maven2 installed. NOTE: presently, the directory {M2_HOME}/bin must be in your path: set PATH=%PATH%;%M2_HOME%\bin or export PATH=$PATH:$M2_HOME/bin In addition, the last part of the M2_HOME path MUST be of the form maven-$version, eg: /usr/local/apache-maven-2.1.0-SNAPSHOT You can set the parameters passed to the Java VM when running Maven2 bootstrap, setting the environment variable MAVEN_OPTS, e.g. e.g. to run in offline mode, set MAVEN_OPTS=-o Then run `ant`. NOTE: You must run these instructions from this directory! If you are behind a firewall, you will need to let the bootstrap process know. To do this, create a file at ~/.m2/settings.xml and paste in the XML below, substituting your settings for those provided. You can safely skip the username, password and nonProxyHost elements if they are not relevant to you. true http proxy.somewhere.com 8080 proxyuser somepassword www.google.com|*.somewhere.com maven2-core-2.2.1/maven-toolchain/0000755000175000017500000000000011250552236016655 5ustar twernertwernermaven2-core-2.2.1/maven-toolchain/src/0000755000175000017500000000000011250552236017444 5ustar twernertwernermaven2-core-2.2.1/maven-toolchain/src/site/0000755000175000017500000000000011250552236020410 5ustar twernertwernermaven2-core-2.2.1/maven-toolchain/src/site/site.xml0000644000175000017500000000013211002611514022060 0ustar twernertwerner maven2-core-2.2.1/maven-toolchain/src/site/apt/0000755000175000017500000000000011250552236021174 5ustar twernertwernermaven2-core-2.2.1/maven-toolchain/src/site/apt/index.apt0000644000175000017500000000057711175144556023032 0ustar twernertwerner ----- Maven Toolchains ----- Hervé Boutemy ----- 2009-04-26 ----- Maven Toolchains This is strictly the model for Maven Toolchains, so really just plain objects. The following are generated from this model: * {{{apidocs/index.html}Java sources}} with Reader for the Xpp3 XML parser, to read <<>> file * A {{{toolchains.html}Descriptor Reference}} maven2-core-2.2.1/maven-toolchain/src/test/0000755000175000017500000000000011250552236020423 5ustar twernertwernermaven2-core-2.2.1/maven-toolchain/src/test/java/0000755000175000017500000000000011250552236021344 5ustar twernertwernermaven2-core-2.2.1/maven-toolchain/src/test/java/org/0000755000175000017500000000000011250552236022133 5ustar twernertwernermaven2-core-2.2.1/maven-toolchain/src/test/java/org/apache/0000755000175000017500000000000011250552236023354 5ustar twernertwernermaven2-core-2.2.1/maven-toolchain/src/test/java/org/apache/maven/0000755000175000017500000000000011250552236024462 5ustar twernertwernermaven2-core-2.2.1/maven-toolchain/src/test/java/org/apache/maven/toolchain/0000755000175000017500000000000011250552236026442 5ustar twernertwerner././@LongLink0000000000000000000000000000015600000000000011567 Lustar rootrootmaven2-core-2.2.1/maven-toolchain/src/test/java/org/apache/maven/toolchain/RequirementMatcherFactoryTest.javamaven2-core-2.2.1/maven-toolchain/src/test/java/org/apache/maven/toolchain/RequirementMatcherFactory0000644000175000017500000000407610772004567033537 0ustar twernertwerner/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ package org.apache.maven.toolchain; import junit.framework.TestCase; /** * * @author mkleint */ public class RequirementMatcherFactoryTest extends TestCase { public RequirementMatcherFactoryTest(String testName) { super(testName); } /** * Test of createExactMatcher method, of class RequirementMatcherFactory. */ public void testCreateExactMatcher() { RequirementMatcher matcher; matcher = RequirementMatcherFactory.createExactMatcher("foo"); assertFalse(matcher.matches("bar")); assertFalse(matcher.matches("foobar")); assertFalse(matcher.matches("foob")); assertTrue(matcher.matches("foo")); } /** * Test of createVersionMatcher method, of class RequirementMatcherFactory. */ public void testCreateVersionMatcher() { RequirementMatcher matcher; matcher = RequirementMatcherFactory.createVersionMatcher("1.5.2"); assertFalse(matcher.matches("1.5")); assertTrue(matcher.matches("1.5.2")); assertFalse(matcher.matches("[1.4,1.5)")); assertFalse(matcher.matches("[1.5,1.5.2)")); assertFalse(matcher.matches("(1.5.2,1.6)")); assertTrue(matcher.matches("(1.4,1.5.2]")); assertTrue(matcher.matches("(1.5,)")); } } maven2-core-2.2.1/maven-toolchain/src/main/0000755000175000017500000000000011250552236020370 5ustar twernertwernermaven2-core-2.2.1/maven-toolchain/src/main/mdo/0000755000175000017500000000000011250552236021147 5ustar twernertwernermaven2-core-2.2.1/maven-toolchain/src/main/mdo/toolchains.mdo0000644000175000017500000000610111175345173024017 0ustar twernertwerner toolchains MavenToolchains package org.apache.maven.toolchain.model PersistedToolchains <toolchains> element is the root of the descriptor. The following table lists all of the possible child elements. ]]> 1.0.0+ toolchains 1.0.0+ ToolchainModel * ToolchainModel 1.0.0+ type 1.0.0+ String provides 1.0.0+ DOM configuration 1.0.0+ DOM maven2-core-2.2.1/maven-toolchain/src/main/resources/0000755000175000017500000000000011250552236022402 5ustar twernertwernermaven2-core-2.2.1/maven-toolchain/src/main/resources/META-INF/0000755000175000017500000000000011250552236023542 5ustar twernertwernermaven2-core-2.2.1/maven-toolchain/src/main/resources/META-INF/plexus/0000755000175000017500000000000011250552236025062 5ustar twernertwernermaven2-core-2.2.1/maven-toolchain/src/main/resources/META-INF/plexus/components.xml0000644000175000017500000000347110772004567030005 0ustar twernertwerner org.apache.maven.toolchain.ToolchainManager org.apache.maven.toolchain.DefaultToolchainManager org.apache.maven.toolchain.ToolchainManagerPrivate org.apache.maven.toolchain.DefaultToolchainManager org.apache.maven.toolchain.ToolchainFactory jdk org.apache.maven.toolchain.java.DefaultJavaToolchainFactory org.apache.maven.toolchain.ToolchainFactory javac org.apache.maven.toolchain.java.DefaultJavaToolchainFactory maven2-core-2.2.1/maven-toolchain/src/main/java/0000755000175000017500000000000011250552236021311 5ustar twernertwernermaven2-core-2.2.1/maven-toolchain/src/main/java/org/0000755000175000017500000000000011250552236022100 5ustar twernertwernermaven2-core-2.2.1/maven-toolchain/src/main/java/org/apache/0000755000175000017500000000000011250552236023321 5ustar twernertwernermaven2-core-2.2.1/maven-toolchain/src/main/java/org/apache/maven/0000755000175000017500000000000011250552236024427 5ustar twernertwernermaven2-core-2.2.1/maven-toolchain/src/main/java/org/apache/maven/toolchain/0000755000175000017500000000000011250552236026407 5ustar twernertwerner././@LongLink0000000000000000000000000000015000000000000011561 Lustar rootrootmaven2-core-2.2.1/maven-toolchain/src/main/java/org/apache/maven/toolchain/ToolchainManagerPrivate.javamaven2-core-2.2.1/maven-toolchain/src/main/java/org/apache/maven/toolchain/ToolchainManagerPrivate.j0000644000175000017500000000270710772004567033345 0ustar twernertwerner/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ package org.apache.maven.toolchain; import org.apache.maven.execution.MavenSession; /** * Component for use by the maven-toolchains-plugin only. * @author mkleint */ public interface ToolchainManagerPrivate { String ROLE = ToolchainManagerPrivate.class.getName(); /** * Retrieves the toolchains of given type from the user settings. */ ToolchainPrivate[] getToolchainsForType( String type ) throws MisconfiguredToolchainException; /** * Stores the toolchain into build context. */ void storeToolchainToBuildContext( ToolchainPrivate toolchain, MavenSession context ); } maven2-core-2.2.1/maven-toolchain/src/main/java/org/apache/maven/toolchain/ToolchainPrivate.java0000644000175000017500000000254710772004567032544 0ustar twernertwerner/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ package org.apache.maven.toolchain; import java.util.Map; import org.apache.maven.toolchain.model.ToolchainModel; /** * a private contract between the toolchains plugin and the components. * @author mkleint */ public interface ToolchainPrivate extends Toolchain { /** * Let the toolchain decide if it matches requirements defined * in the toolchain plugin configuration. * @param requirements Map key value pair * @return */ boolean matchesRequirements( Map requirements); ToolchainModel getModel( ); }maven2-core-2.2.1/maven-toolchain/src/main/java/org/apache/maven/toolchain/Toolchain.java0000644000175000017500000000230210772004567031176 0ustar twernertwerner/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ package org.apache.maven.toolchain; /** * @author Milos Kleint * @author Jason van Zyl */ public interface Toolchain { String getType( ); /** * Gets the platform tool executable. * * @param toolName the tool platform independent tool name. * @return file representing the tool executable, or null if the tool can not be found */ String findTool( String toolName ); }maven2-core-2.2.1/maven-toolchain/src/main/java/org/apache/maven/toolchain/ToolchainFactory.java0000644000175000017500000000256110772004567032535 0ustar twernertwerner/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ package org.apache.maven.toolchain; import org.apache.maven.toolchain.model.ToolchainModel; /** * * @author mkleint */ public interface ToolchainFactory { String ROLE = ToolchainFactory.class.getName(); /** * Create instance of toolchain. **/ ToolchainPrivate createToolchain( ToolchainModel model ) throws MisconfiguredToolchainException; /** * Returns the default instance of the particular type of toolchain, can return null * if not applicable. * TODO keep around?? **/ ToolchainPrivate createDefaultToolchain( ); }maven2-core-2.2.1/maven-toolchain/src/main/java/org/apache/maven/toolchain/ToolchainManager.java0000644000175000017500000000231210772004567032472 0ustar twernertwerner/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ package org.apache.maven.toolchain; import org.apache.maven.execution.MavenSession; /** * * @author mkleint */ public interface ToolchainManager { String ROLE = ToolchainManager.class.getName(); /** * to be used from plugins capable of working with toolchains. */ Toolchain getToolchainFromBuildContext( String type, MavenSession context ); }maven2-core-2.2.1/maven-toolchain/src/main/java/org/apache/maven/toolchain/DefaultToolchain.java0000644000175000017500000000546410772004567032517 0ustar twernertwerner/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ package org.apache.maven.toolchain; import java.util.HashMap; import java.util.Iterator; import java.util.Map; import org.apache.maven.toolchain.model.ToolchainModel; import org.codehaus.plexus.logging.Logger; /** * * @author mkleint */ public abstract class DefaultToolchain implements Toolchain, ToolchainPrivate { private String type; private Map provides = new HashMap /**/ ( ); public static final String KEY_TYPE = "type"; //NOI18N private ToolchainModel model; private Logger logger; protected DefaultToolchain( ToolchainModel model, Logger logger ) { this.model = model; this.logger = logger; } protected DefaultToolchain( ToolchainModel model, String type, Logger logger ) { this( model, logger ); this.type = type; } public final String getType( ) { return type != null ? type : model.getType(); } public final ToolchainModel getModel( ) { return model; } public final void addProvideToken( String type, RequirementMatcher matcher ) { provides.put( type, matcher ); } public boolean matchesRequirements(Map requirements) { Iterator it = requirements.keySet().iterator(); while ( it.hasNext() ) { String key = (String) it.next(); RequirementMatcher matcher = (RequirementMatcher) provides.get(key); if ( matcher == null ) { getLog().debug( "Toolchain " + this + " is missing required property: " + key ); return false; } if ( !matcher.matches( (String) requirements.get(key) ) ) { getLog().debug( "Toolchain " + this + " doesn't match required property: " + key ); return false; } } return true; } protected Logger getLog() { return logger; } }maven2-core-2.2.1/maven-toolchain/src/main/java/org/apache/maven/toolchain/java/0000755000175000017500000000000011250552236027330 5ustar twernertwerner././@LongLink0000000000000000000000000000015200000000000011563 Lustar rootrootmaven2-core-2.2.1/maven-toolchain/src/main/java/org/apache/maven/toolchain/java/DefaultJavaToolChain.javamaven2-core-2.2.1/maven-toolchain/src/main/java/org/apache/maven/toolchain/java/DefaultJavaToolChain0000644000175000017500000000456010755111540033245 0ustar twernertwerner/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ package org.apache.maven.toolchain.java; import java.io.File; import org.apache.maven.toolchain.DefaultToolchain; import org.apache.maven.toolchain.model.ToolchainModel; import org.codehaus.plexus.logging.Logger; import org.codehaus.plexus.util.FileUtils; import org.codehaus.plexus.util.Os; /** * @author Milos Kleint */ public class DefaultJavaToolChain extends DefaultToolchain implements JavaToolChain { private String javaHome; public static final String KEY_JAVAHOME = "jdkHome"; //NOI18N public DefaultJavaToolChain( ToolchainModel model, Logger logger ) { super( model, "jdk", logger ); } public String getJavaHome( ) { return javaHome; } public void setJavaHome( String javaHome ) { this.javaHome = javaHome; } public String toString( ) { return "JDK[" + getJavaHome( ) + "]"; } public String findTool( String toolName ) { File toRet = findTool( toolName, new File( FileUtils.normalize( getJavaHome( ) ) ) ); if ( toRet != null ) { return toRet.getAbsolutePath( ); } return null; } private static File findTool( String toolName, File installFolder ) { File bin = new File( installFolder, "bin" ); //NOI18N if ( bin.exists( ) ) { File tool = new File( bin, toolName + (Os.isFamily( "windows" ) ? ".exe" : "") ); //NOI18N if ( tool.exists( ) ) { return tool; } } return null; } }maven2-core-2.2.1/maven-toolchain/src/main/java/org/apache/maven/toolchain/java/JavaToolChain.java0000644000175000017500000000413410673675044032672 0ustar twernertwerner/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ package org.apache.maven.toolchain.java; import org.apache.maven.toolchain.Toolchain; /** * @author Jason van Zyl * @author Milos Kleint */ public interface JavaToolChain extends Toolchain { // /** // * Returns a list of {@link java.io.File}s which represents the bootstrap libraries for the // * runtime environment. The Bootstrap libraries include libraries in JRE's // * extension directory, if there are any. // * // * @return List // */ // List getBootstrapLibraries(); // // /** // * Returns a list of {@link java.io.File}s which represent the libraries recognized by // * default by the platform. Usually it corresponds to contents of CLASSPATH // * environment variable. // * // * @return List // */ // List getStandardLibraries(); // // /** // * Returns a {@link java.io.File}s which represent the locations of the source of the JDK, // * or an empty collection when the location is not set or is invalid. // * // * @return List // */ // List getSourceDirectories(); // // /** // * Returns a {@link java.io.File}s which represent the locations of the Javadoc for this platform, // * or empty collection if the location is not set or invalid // * // * @return List // */ // List getJavadocFolders(); } ././@LongLink0000000000000000000000000000016100000000000011563 Lustar rootrootmaven2-core-2.2.1/maven-toolchain/src/main/java/org/apache/maven/toolchain/java/DefaultJavaToolchainFactory.javamaven2-core-2.2.1/maven-toolchain/src/main/java/org/apache/maven/toolchain/java/DefaultJavaToolchain0000644000175000017500000000743410772004567033321 0ustar twernertwerner/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ package org.apache.maven.toolchain.java; import java.io.File; import org.apache.maven.toolchain.MisconfiguredToolchainException; import org.apache.maven.toolchain.RequirementMatcherFactory; import org.apache.maven.toolchain.ToolchainFactory; import org.apache.maven.toolchain.ToolchainPrivate; import org.apache.maven.toolchain.model.ToolchainModel; import org.codehaus.plexus.logging.LogEnabled; import org.codehaus.plexus.logging.Logger; import org.codehaus.plexus.util.FileUtils; import org.codehaus.plexus.util.xml.Xpp3Dom; /** * * @author mkleint */ public class DefaultJavaToolchainFactory implements ToolchainFactory, LogEnabled { private Logger logger; public DefaultJavaToolchainFactory( ) { } public ToolchainPrivate createToolchain( ToolchainModel model ) throws MisconfiguredToolchainException { if (model == null) { return null; } DefaultJavaToolChain jtc = new DefaultJavaToolChain( model , logger); Xpp3Dom dom = (Xpp3Dom) model.getConfiguration(); Xpp3Dom javahome = dom.getChild( DefaultJavaToolChain.KEY_JAVAHOME ); if ( javahome == null ) { throw new MisconfiguredToolchainException( "Java toolchain without the " + DefaultJavaToolChain.KEY_JAVAHOME + " configuration element." ); } File normal = new File( FileUtils.normalize( javahome.getValue() ) ); if ( normal.exists() ) { jtc.setJavaHome( FileUtils.normalize( javahome.getValue() ) ); } else { throw new MisconfiguredToolchainException( "Non-existing JDK home configuration at " + normal.getAbsolutePath( ) ); } //now populate the provides section. //TODO possibly move at least parts to a utility method or abstract implementation. dom = (Xpp3Dom) model.getProvides(); Xpp3Dom[] provides = dom.getChildren(); for ( int i = 0; i < provides.length; i++ ) { String key = provides[i].getName(); String value = provides[i].getValue(); if ( value == null ) { throw new MisconfiguredToolchainException( "Provides token '" + key + "' doesn't have any value configured." ); } if ( "version".equals( key ) ) { jtc.addProvideToken( key, RequirementMatcherFactory.createVersionMatcher( value ) ); } else { jtc.addProvideToken( key, RequirementMatcherFactory.createExactMatcher( value ) ); } } return jtc; } public ToolchainPrivate createDefaultToolchain() { //not sure it's necessary to provide a default toolchain here. //only version can be eventually supplied, and return null; } protected Logger getLogger() { return logger; } public void enableLogging( Logger logger ) { this.logger = logger; } }././@LongLink0000000000000000000000000000016000000000000011562 Lustar rootrootmaven2-core-2.2.1/maven-toolchain/src/main/java/org/apache/maven/toolchain/MisconfiguredToolchainException.javamaven2-core-2.2.1/maven-toolchain/src/main/java/org/apache/maven/toolchain/MisconfiguredToolchainExc0000644000175000017500000000227310772004567033444 0ustar twernertwerner/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ package org.apache.maven.toolchain; /** * * @author mkleint */ public class MisconfiguredToolchainException extends Exception { public MisconfiguredToolchainException( String message ) { super( message ); } public MisconfiguredToolchainException( String message, Throwable orig ) { super( message, orig ); } }././@LongLink0000000000000000000000000000015000000000000011561 Lustar rootrootmaven2-core-2.2.1/maven-toolchain/src/main/java/org/apache/maven/toolchain/DefaultToolchainManager.javamaven2-core-2.2.1/maven-toolchain/src/main/java/org/apache/maven/toolchain/DefaultToolchainManager.j0000644000175000017500000001734611147423046033316 0ustar twernertwerner/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ package org.apache.maven.toolchain; import java.io.BufferedInputStream; import java.io.File; import java.io.FileInputStream; import java.io.InputStreamReader; import java.lang.reflect.Method; import java.util.ArrayList; import java.util.HashMap; import java.util.Iterator; import java.util.List; import java.util.Map; import org.apache.maven.execution.MavenSession; import org.apache.maven.plugin.descriptor.PluginDescriptor; import org.apache.maven.project.MavenProject; import org.apache.maven.toolchain.model.PersistedToolchains; import org.apache.maven.toolchain.model.ToolchainModel; import org.apache.maven.toolchain.model.io.xpp3.MavenToolchainsXpp3Reader; import org.codehaus.plexus.PlexusConstants; import org.codehaus.plexus.PlexusContainer; import org.codehaus.plexus.component.repository.exception.ComponentLookupException; import org.codehaus.plexus.context.Context; import org.codehaus.plexus.context.ContextException; import org.codehaus.plexus.logging.AbstractLogEnabled; import org.codehaus.plexus.personality.plexus.lifecycle.phase.Contextualizable; import org.codehaus.plexus.util.IOUtil; /** * * @author mkleint */ public class DefaultToolchainManager extends AbstractLogEnabled implements ToolchainManager, ToolchainManagerPrivate, Contextualizable { /** * @component */ private PlexusContainer container; public DefaultToolchainManager( ) { } public void contextualize( Context context ) throws ContextException { container = (PlexusContainer) context.get(PlexusConstants.PLEXUS_KEY); } public ToolchainPrivate[] getToolchainsForType( String type ) throws MisconfiguredToolchainException { try { PersistedToolchains pers = readToolchainSettings (); Map factories = container.lookupMap( ToolchainFactory.ROLE ); List toRet = new ArrayList( ); if ( pers != null ) { List lst = pers.getToolchains(); if ( lst != null ) { Iterator it = lst.iterator(); while ( it.hasNext() ) { ToolchainModel toolchainModel = (ToolchainModel) it.next(); ToolchainFactory fact = (ToolchainFactory) factories.get( toolchainModel.getType() ); if ( fact != null ) { toRet.add( fact.createToolchain( toolchainModel ) ); } else { getLogger().error("Missing toolchain factory for type:" + toolchainModel.getType() + ". Possibly caused by misconfigured project."); } } } } Iterator it = factories.values().iterator(); while ( it.hasNext() ) { ToolchainFactory fact = (ToolchainFactory) it.next(); ToolchainPrivate tool = fact.createDefaultToolchain(); if ( tool != null ) { toRet.add( tool ); } } ToolchainPrivate[] tc = new ToolchainPrivate[ toRet.size() ]; return (ToolchainPrivate[]) toRet.toArray(tc); } catch ( ComponentLookupException ex ) { getLogger().fatalError("Error in component lookup", ex); } return new ToolchainPrivate[0]; } public Toolchain getToolchainFromBuildContext( String type, MavenSession session ) { Map context = retrieveContext(session); if ( "javac".equals( type )) { //HACK to make compiler plugin happy type = "jdk"; } Object obj = context.get( getStorageKey( type ) ); ToolchainModel model = (ToolchainModel)obj; if ( model != null ) { try { ToolchainFactory fact = (ToolchainFactory) container.lookup(ToolchainFactory.ROLE, type); return fact.createToolchain( model ); } catch ( ComponentLookupException ex ) { getLogger().fatalError("Error in component lookup", ex); } catch ( MisconfiguredToolchainException ex ) { getLogger().error("Misconfigured toolchain.", ex); } } return null; } private MavenProject getCurrentProject(MavenSession session) { //use reflection since MavenSession.getCurrentProject() is not part of 2.0.8 try { Method meth = session.getClass().getMethod("getCurrentProject", new Class[0]); return (MavenProject) meth.invoke(session, null); } catch (Exception ex) { //just ignore, we're running in pre- 2.0.9 } return null; } private Map retrieveContext( MavenSession session ) { if (session == null) { return new HashMap(); } PluginDescriptor desc = new PluginDescriptor(); desc.setGroupId( PluginDescriptor.getDefaultPluginGroupId() ); desc.setArtifactId( PluginDescriptor.getDefaultPluginArtifactId ("toolchains") ); MavenProject current = getCurrentProject(session); if ( current != null ) { return session.getPluginContext( desc, current ); } return new HashMap(); } public void storeToolchainToBuildContext( ToolchainPrivate toolchain, MavenSession session ) { Map context = retrieveContext( session ); context.put( getStorageKey( toolchain.getType() ), toolchain.getModel () ); } public static final String getStorageKey( String type ) { return "toolchain-" + type; //NOI18N } private PersistedToolchains readToolchainSettings( ) throws MisconfiguredToolchainException { //TODO how to point to the local path? File tch = new File( System.getProperty( "user.home" ), ".m2/toolchains.xml" ); if ( tch.exists() ) { MavenToolchainsXpp3Reader reader = new MavenToolchainsXpp3Reader(); InputStreamReader in = null; try { in = new InputStreamReader( new BufferedInputStream( new FileInputStream( tch ) ) ); return reader.read( in ); } catch ( Exception ex ) { throw new MisconfiguredToolchainException( "Cannot read toolchains file at " + tch.getAbsolutePath( ), ex ); } finally { IOUtil.close( in ); } } else { //TODO log the fact that no toolchains file was found. } return null; } }maven2-core-2.2.1/maven-toolchain/src/main/java/org/apache/maven/toolchain/dotnet/0000755000175000017500000000000011250552236027704 5ustar twernertwernermaven2-core-2.2.1/maven-toolchain/src/main/java/org/apache/maven/toolchain/RequirementMatcher.java0000644000175000017500000000167610772004567033077 0ustar twernertwerner/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ package org.apache.maven.toolchain; /** * * @author mkleint */ public interface RequirementMatcher { boolean matches( String requirement ); }././@LongLink0000000000000000000000000000015200000000000011563 Lustar rootrootmaven2-core-2.2.1/maven-toolchain/src/main/java/org/apache/maven/toolchain/RequirementMatcherFactory.javamaven2-core-2.2.1/maven-toolchain/src/main/java/org/apache/maven/toolchain/RequirementMatcherFactory0000644000175000017500000000527410772004567033505 0ustar twernertwerner/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ package org.apache.maven.toolchain; import org.apache.maven.artifact.versioning.DefaultArtifactVersion; import org.apache.maven.artifact.versioning.InvalidVersionSpecificationException; import org.apache.maven.artifact.versioning.VersionRange; /** * * @author mkleint */ public final class RequirementMatcherFactory { private RequirementMatcherFactory( ) { } public static RequirementMatcher createExactMatcher( String provideValue ) { return new ExactMatcher( provideValue ); } public static RequirementMatcher createVersionMatcher( String provideValue ) { return new VersionMatcher( provideValue ); } private static final class ExactMatcher implements RequirementMatcher { private String provides; private ExactMatcher( String provides ) { this.provides = provides; } public boolean matches( String requirement ) { return provides.equalsIgnoreCase( requirement ); } } private static final class VersionMatcher implements RequirementMatcher { DefaultArtifactVersion version; private VersionMatcher( String version ) { this.version = new DefaultArtifactVersion(version); } public boolean matches( String requirement ) { try { VersionRange range = VersionRange.createFromVersionSpec(requirement); if (range.hasRestrictions()) { return range.containsVersion(version); } else { return range.getRecommendedVersion().compareTo(version) == 0; } } catch (InvalidVersionSpecificationException ex) { //TODO error reporting ex.printStackTrace(); return false; } } } }maven2-core-2.2.1/maven-toolchain/pom.xml0000644000175000017500000000642011236625310020172 0ustar twernertwerner 4.0.0 org.apache.maven maven 2.2.1 maven-toolchain Maven Toolchains junit junit 3.8.1 test org.apache.maven maven-core org.apache.maven maven-artifact org.codehaus.modello modello-maven-plugin java xsd xpp3-reader 1.0.0 false src/main/mdo/toolchains.mdo maven-shade-plugin org.apache.maven.plugins shading package shade ${project.groupId}:${project.artifactId} org.codehaus.plexus.util org.codehaus.plexus.util.xml.Xpp3Dom org.codehaus.plexus.util.xml.pull.* maven2-core-2.2.1/maven-integration-tests/0000755000175000017500000000000011250552240020353 5ustar twernertwernermaven2-core-2.2.1/maven-integration-tests/pom.xml0000644000175000017500000000542111176574500021704 0ustar twernertwerner 4.0.0 org.apache.maven maven-integration-tests 2.2.x Maven Integration-Test Importer trunk ${java.io.tmpdir}/${pom.artifactId}-${pom.version} ${basedir} pom.xml true maven-clean-plugin 2.3 ${itDir} maven-resources-plugin 2.2 maven-scm-plugin 1.1 scm:svn:http://svn.apache.org/repos/asf/maven/core-integration-testing/${integrationTestSVNDir} ${itDir} scm package checkout maven2-core-2.2.1/src/0000755000175000017500000000000011250552236014360 5ustar twernertwernermaven2-core-2.2.1/src/site/0000755000175000017500000000000011250552236015324 5ustar twernertwernermaven2-core-2.2.1/src/site/site.xml0000644000175000017500000000207611134110663017012 0ustar twernertwerner org.apache.maven.skins maven-stylus-skin 1.1 maven2-core-2.2.1/src/main/0000755000175000017500000000000011250552236015304 5ustar twernertwernermaven2-core-2.2.1/src/main/assembly/0000755000175000017500000000000011250552236017123 5ustar twernertwernermaven2-core-2.2.1/maven-model/0000755000175000017500000000000011250552243015773 5ustar twernertwernermaven2-core-2.2.1/maven-model/maven.xml0000644000175000017500000000437610555135606017644 0ustar twernertwerner maven2-core-2.2.1/maven-model/src/0000755000175000017500000000000011250552243016562 5ustar twernertwernermaven2-core-2.2.1/maven-model/src/site/0000755000175000017500000000000011250552243017526 5ustar twernertwernermaven2-core-2.2.1/maven-model/src/site/site.xml0000644000175000017500000000013211002611514021200 0ustar twernertwerner maven2-core-2.2.1/maven-model/src/site/apt/0000755000175000017500000000000011250552243020312 5ustar twernertwernermaven2-core-2.2.1/maven-model/src/site/apt/index.apt0000644000175000017500000000076611125703007022135 0ustar twernertwerner ----- Maven Model ----- Jason van Zyl Vincent Siveton ----- 04 November 2006 ----- Maven Model This is strictly the model for Maven, so really just plain objects. The following are generated from this model: * {{{apidocs/index.html}Java sources}} with Reader and Writers for the Xpp3 XML parser * A {{{maven.html}Descriptor Reference}} * An XSD {{{http://maven.apache.org/xsd/maven-v3_0_0.xsd}for Maven 1.1}} and {{{http://maven.apache.org/xsd/maven-4.0.0.xsd}for Maven 2.0}}. maven2-core-2.2.1/maven-model/src/test/0000755000175000017500000000000011250552243017541 5ustar twernertwernermaven2-core-2.2.1/maven-model/src/test/java/0000755000175000017500000000000011250552243020462 5ustar twernertwernermaven2-core-2.2.1/maven-model/src/test/java/org/0000755000175000017500000000000011250552243021251 5ustar twernertwernermaven2-core-2.2.1/maven-model/src/test/java/org/apache/0000755000175000017500000000000011250552243022472 5ustar twernertwernermaven2-core-2.2.1/maven-model/src/test/java/org/apache/maven/0000755000175000017500000000000011250552243023600 5ustar twernertwernermaven2-core-2.2.1/maven-model/src/test/java/org/apache/maven/model/0000755000175000017500000000000011250552243024700 5ustar twernertwernermaven2-core-2.2.1/maven-model/src/test/java/org/apache/maven/model/ProfileTest.java0000644000175000017500000000300511226335445030007 0ustar twernertwernerpackage org.apache.maven.model; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import junit.framework.TestCase; /** * Tests {@code Profile}. * * @author Benjamin Bentmann * @version $Id: ProfileTest.java 793311 2009-07-12 10:29:57Z bentmann $ */ public class ProfileTest extends TestCase { public void testHashCodeNullSafe() { new Profile().hashCode(); } public void testEqualsNullSafe() { assertFalse( new Profile().equals( null ) ); new Profile().equals( new Profile() ); } public void testEqualsIdentity() { Profile thing = new Profile(); assertTrue( thing.equals( thing ) ); } public void testToStringNullSafe() { assertNotNull( new Profile().toString() ); } } maven2-core-2.2.1/maven-model/src/test/java/org/apache/maven/model/ModelTest.java0000644000175000017500000000276111226335445027457 0ustar twernertwernerpackage org.apache.maven.model; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import junit.framework.TestCase; /** * Tests {@code Model}. * * @author Benjamin Bentmann * @version $Id: ModelTest.java 793311 2009-07-12 10:29:57Z bentmann $ */ public class ModelTest extends TestCase { public void testHashCodeNullSafe() { new Model().hashCode(); } public void testEqualsNullSafe() { assertFalse( new Model().equals( null ) ); new Model().equals( new Model() ); } public void testEqualsIdentity() { Model thing = new Model(); assertTrue( thing.equals( thing ) ); } public void testToStringNullSafe() { assertNotNull( new Model().toString() ); } } maven2-core-2.2.1/maven-model/src/test/java/org/apache/maven/model/RepositoryPolicyTest.java0000644000175000017500000000313711226335445031754 0ustar twernertwernerpackage org.apache.maven.model; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import junit.framework.TestCase; /** * Tests {@code RepositoryPolicy}. * * @author Benjamin Bentmann * @version $Id: RepositoryPolicyTest.java 793311 2009-07-12 10:29:57Z bentmann $ */ public class RepositoryPolicyTest extends TestCase { public void testHashCodeNullSafe() { new RepositoryPolicy().hashCode(); } public void testEqualsNullSafe() { assertFalse( new RepositoryPolicy().equals( null ) ); new RepositoryPolicy().equals( new RepositoryPolicy() ); } public void testEqualsIdentity() { RepositoryPolicy thing = new RepositoryPolicy(); assertTrue( thing.equals( thing ) ); } public void testToStringNullSafe() { assertNotNull( new RepositoryPolicy().toString() ); } } maven2-core-2.2.1/maven-model/src/test/java/org/apache/maven/model/ParentTest.java0000644000175000017500000000277311226335445027653 0ustar twernertwernerpackage org.apache.maven.model; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import junit.framework.TestCase; /** * Tests {@code Parent}. * * @author Benjamin Bentmann * @version $Id: ParentTest.java 793311 2009-07-12 10:29:57Z bentmann $ */ public class ParentTest extends TestCase { public void testHashCodeNullSafe() { new Parent().hashCode(); } public void testEqualsNullSafe() { assertFalse( new Parent().equals( null ) ); new Parent().equals( new Parent() ); } public void testEqualsIdentity() { Parent thing = new Parent(); assertTrue( thing.equals( thing ) ); } public void testToStringNullSafe() { assertNotNull( new Parent().toString() ); } } maven2-core-2.2.1/maven-model/src/test/java/org/apache/maven/model/PluginManagementTest.java0000644000175000017500000000313711226335445031650 0ustar twernertwernerpackage org.apache.maven.model; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import junit.framework.TestCase; /** * Tests {@code PluginManagement}. * * @author Benjamin Bentmann * @version $Id: PluginManagementTest.java 793311 2009-07-12 10:29:57Z bentmann $ */ public class PluginManagementTest extends TestCase { public void testHashCodeNullSafe() { new PluginManagement().hashCode(); } public void testEqualsNullSafe() { assertFalse( new PluginManagement().equals( null ) ); new PluginManagement().equals( new PluginManagement() ); } public void testEqualsIdentity() { PluginManagement thing = new PluginManagement(); assertTrue( thing.equals( thing ) ); } public void testToStringNullSafe() { assertNotNull( new PluginManagement().toString() ); } } maven2-core-2.2.1/maven-model/src/test/java/org/apache/maven/model/ExclusionTest.java0000644000175000017500000000303111226335445030357 0ustar twernertwernerpackage org.apache.maven.model; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import junit.framework.TestCase; /** * Tests {@code Exclusion}. * * @author Benjamin Bentmann * @version $Id: ExclusionTest.java 793311 2009-07-12 10:29:57Z bentmann $ */ public class ExclusionTest extends TestCase { public void testHashCodeNullSafe() { new Exclusion().hashCode(); } public void testEqualsNullSafe() { assertFalse( new Exclusion().equals( null ) ); new Exclusion().equals( new Exclusion() ); } public void testEqualsIdentity() { Exclusion thing = new Exclusion(); assertTrue( thing.equals( thing ) ); } public void testToStringNullSafe() { assertNotNull( new Exclusion().toString() ); } } maven2-core-2.2.1/maven-model/src/test/java/org/apache/maven/model/SiteTest.java0000644000175000017500000000274711226335445027327 0ustar twernertwernerpackage org.apache.maven.model; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import junit.framework.TestCase; /** * Tests {@code Site}. * * @author Benjamin Bentmann * @version $Id: SiteTest.java 793311 2009-07-12 10:29:57Z bentmann $ */ public class SiteTest extends TestCase { public void testHashCodeNullSafe() { new Site().hashCode(); } public void testEqualsNullSafe() { assertFalse( new Site().equals( null ) ); new Site().equals( new Site() ); } public void testEqualsIdentity() { Site thing = new Site(); assertTrue( thing.equals( thing ) ); } public void testToStringNullSafe() { assertNotNull( new Site().toString() ); } } maven2-core-2.2.1/maven-model/src/test/java/org/apache/maven/model/ScmTest.java0000644000175000017500000000273511226335445027142 0ustar twernertwernerpackage org.apache.maven.model; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import junit.framework.TestCase; /** * Tests {@code Scm}. * * @author Benjamin Bentmann * @version $Id: ScmTest.java 793311 2009-07-12 10:29:57Z bentmann $ */ public class ScmTest extends TestCase { public void testHashCodeNullSafe() { new Scm().hashCode(); } public void testEqualsNullSafe() { assertFalse( new Scm().equals( null ) ); new Scm().equals( new Scm() ); } public void testEqualsIdentity() { Scm thing = new Scm(); assertTrue( thing.equals( thing ) ); } public void testToStringNullSafe() { assertNotNull( new Scm().toString() ); } } maven2-core-2.2.1/maven-model/src/test/java/org/apache/maven/model/ActivationFileTest.java0000644000175000017500000000311311226335445031310 0ustar twernertwernerpackage org.apache.maven.model; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import junit.framework.TestCase; /** * Tests {@code ActivationFile}. * * @author Benjamin Bentmann * @version $Id: ActivationFileTest.java 793311 2009-07-12 10:29:57Z bentmann $ */ public class ActivationFileTest extends TestCase { public void testHashCodeNullSafe() { new ActivationFile().hashCode(); } public void testEqualsNullSafe() { assertFalse( new ActivationFile().equals( null ) ); new ActivationFile().equals( new ActivationFile() ); } public void testEqualsIdentity() { ActivationFile thing = new ActivationFile(); assertTrue( thing.equals( thing ) ); } public void testToStringNullSafe() { assertNotNull( new ActivationFile().toString() ); } } maven2-core-2.2.1/maven-model/src/test/java/org/apache/maven/model/IssueManagementTest.java0000644000175000017500000000312511226335445031477 0ustar twernertwernerpackage org.apache.maven.model; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import junit.framework.TestCase; /** * Tests {@code IssueManagement}. * * @author Benjamin Bentmann * @version $Id: IssueManagementTest.java 793311 2009-07-12 10:29:57Z bentmann $ */ public class IssueManagementTest extends TestCase { public void testHashCodeNullSafe() { new IssueManagement().hashCode(); } public void testEqualsNullSafe() { assertFalse( new IssueManagement().equals( null ) ); new IssueManagement().equals( new IssueManagement() ); } public void testEqualsIdentity() { IssueManagement thing = new IssueManagement(); assertTrue( thing.equals( thing ) ); } public void testToStringNullSafe() { assertNotNull( new IssueManagement().toString() ); } } maven2-core-2.2.1/maven-model/src/test/java/org/apache/maven/model/ActivationOSTest.java0000644000175000017500000000306711226335445030762 0ustar twernertwernerpackage org.apache.maven.model; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import junit.framework.TestCase; /** * Tests {@code ActivationOS}. * * @author Benjamin Bentmann * @version $Id: ActivationOSTest.java 793311 2009-07-12 10:29:57Z bentmann $ */ public class ActivationOSTest extends TestCase { public void testHashCodeNullSafe() { new ActivationOS().hashCode(); } public void testEqualsNullSafe() { assertFalse( new ActivationOS().equals( null ) ); new ActivationOS().equals( new ActivationOS() ); } public void testEqualsIdentity() { ActivationOS thing = new ActivationOS(); assertTrue( thing.equals( thing ) ); } public void testToStringNullSafe() { assertNotNull( new ActivationOS().toString() ); } } maven2-core-2.2.1/maven-model/src/test/java/org/apache/maven/model/LicenseTest.java0000644000175000017500000000300511226335445027771 0ustar twernertwernerpackage org.apache.maven.model; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import junit.framework.TestCase; /** * Tests {@code License}. * * @author Benjamin Bentmann * @version $Id: LicenseTest.java 793311 2009-07-12 10:29:57Z bentmann $ */ public class LicenseTest extends TestCase { public void testHashCodeNullSafe() { new License().hashCode(); } public void testEqualsNullSafe() { assertFalse( new License().equals( null ) ); new License().equals( new License() ); } public void testEqualsIdentity() { License thing = new License(); assertTrue( thing.equals( thing ) ); } public void testToStringNullSafe() { assertNotNull( new License().toString() ); } } maven2-core-2.2.1/maven-model/src/test/java/org/apache/maven/model/DependencyTest.java0000644000175000017500000000304311226335445030467 0ustar twernertwernerpackage org.apache.maven.model; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import junit.framework.TestCase; /** * Tests {@code Dependency}. * * @author Benjamin Bentmann * @version $Id: DependencyTest.java 793311 2009-07-12 10:29:57Z bentmann $ */ public class DependencyTest extends TestCase { public void testHashCodeNullSafe() { new Dependency().hashCode(); } public void testEqualsNullSafe() { assertFalse( new Dependency().equals( null ) ); new Dependency().equals( new Dependency() ); } public void testEqualsIdentity() { Dependency thing = new Dependency(); assertTrue( thing.equals( thing ) ); } public void testToStringNullSafe() { assertNotNull( new Dependency().toString() ); } } maven2-core-2.2.1/maven-model/src/test/java/org/apache/maven/model/ContributorTest.java0000644000175000017500000000305511226335445030726 0ustar twernertwernerpackage org.apache.maven.model; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import junit.framework.TestCase; /** * Tests {@code Contributor}. * * @author Benjamin Bentmann * @version $Id: ContributorTest.java 793311 2009-07-12 10:29:57Z bentmann $ */ public class ContributorTest extends TestCase { public void testHashCodeNullSafe() { new Contributor().hashCode(); } public void testEqualsNullSafe() { assertFalse( new Contributor().equals( null ) ); new Contributor().equals( new Contributor() ); } public void testEqualsIdentity() { Contributor thing = new Contributor(); assertTrue( thing.equals( thing ) ); } public void testToStringNullSafe() { assertNotNull( new Contributor().toString() ); } } maven2-core-2.2.1/maven-model/src/test/java/org/apache/maven/model/PluginContainerTest.java0000644000175000017500000000312511226335445031513 0ustar twernertwernerpackage org.apache.maven.model; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import junit.framework.TestCase; /** * Tests {@code PluginContainer}. * * @author Benjamin Bentmann * @version $Id: PluginContainerTest.java 793311 2009-07-12 10:29:57Z bentmann $ */ public class PluginContainerTest extends TestCase { public void testHashCodeNullSafe() { new PluginContainer().hashCode(); } public void testEqualsNullSafe() { assertFalse( new PluginContainer().equals( null ) ); new PluginContainer().equals( new PluginContainer() ); } public void testEqualsIdentity() { PluginContainer thing = new PluginContainer(); assertTrue( thing.equals( thing ) ); } public void testToStringNullSafe() { assertNotNull( new PluginContainer().toString() ); } } maven2-core-2.2.1/maven-model/src/test/java/org/apache/maven/model/ActivationPropertyTest.java0000644000175000017500000000316311226335445032262 0ustar twernertwernerpackage org.apache.maven.model; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import junit.framework.TestCase; /** * Tests {@code ActivationProperty}. * * @author Benjamin Bentmann * @version $Id: ActivationPropertyTest.java 793311 2009-07-12 10:29:57Z bentmann $ */ public class ActivationPropertyTest extends TestCase { public void testHashCodeNullSafe() { new ActivationProperty().hashCode(); } public void testEqualsNullSafe() { assertFalse( new ActivationProperty().equals( null ) ); new ActivationProperty().equals( new ActivationProperty() ); } public void testEqualsIdentity() { ActivationProperty thing = new ActivationProperty(); assertTrue( thing.equals( thing ) ); } public void testToStringNullSafe() { assertNotNull( new ActivationProperty().toString() ); } } maven2-core-2.2.1/maven-model/src/test/java/org/apache/maven/model/RepositoryTest.java0000644000175000017500000000304311226335445030570 0ustar twernertwernerpackage org.apache.maven.model; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import junit.framework.TestCase; /** * Tests {@code Repository}. * * @author Benjamin Bentmann * @version $Id: RepositoryTest.java 793311 2009-07-12 10:29:57Z bentmann $ */ public class RepositoryTest extends TestCase { public void testHashCodeNullSafe() { new Repository().hashCode(); } public void testEqualsNullSafe() { assertFalse( new Repository().equals( null ) ); new Repository().equals( new Repository() ); } public void testEqualsIdentity() { Repository thing = new Repository(); assertTrue( thing.equals( thing ) ); } public void testToStringNullSafe() { assertNotNull( new Repository().toString() ); } } maven2-core-2.2.1/maven-model/src/test/java/org/apache/maven/model/PluginTest.java0000644000175000017500000000277311226335445027660 0ustar twernertwernerpackage org.apache.maven.model; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import junit.framework.TestCase; /** * Tests {@code Plugin}. * * @author Benjamin Bentmann * @version $Id: PluginTest.java 793311 2009-07-12 10:29:57Z bentmann $ */ public class PluginTest extends TestCase { public void testHashCodeNullSafe() { new Plugin().hashCode(); } public void testEqualsNullSafe() { assertFalse( new Plugin().equals( null ) ); new Plugin().equals( new Plugin() ); } public void testEqualsIdentity() { Plugin thing = new Plugin(); assertTrue( thing.equals( thing ) ); } public void testToStringNullSafe() { assertNotNull( new Plugin().toString() ); } } maven2-core-2.2.1/maven-model/src/test/java/org/apache/maven/model/PrerequisitesTest.java0000644000175000017500000000310111226335445031250 0ustar twernertwernerpackage org.apache.maven.model; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import junit.framework.TestCase; /** * Tests {@code Prerequisites}. * * @author Benjamin Bentmann * @version $Id: PrerequisitesTest.java 793311 2009-07-12 10:29:57Z bentmann $ */ public class PrerequisitesTest extends TestCase { public void testHashCodeNullSafe() { new Prerequisites().hashCode(); } public void testEqualsNullSafe() { assertFalse( new Prerequisites().equals( null ) ); new Prerequisites().equals( new Prerequisites() ); } public void testEqualsIdentity() { Prerequisites thing = new Prerequisites(); assertTrue( thing.equals( thing ) ); } public void testToStringNullSafe() { assertNotNull( new Prerequisites().toString() ); } } maven2-core-2.2.1/maven-model/src/test/java/org/apache/maven/model/ActivationTest.java0000644000175000017500000000304311226335445030512 0ustar twernertwernerpackage org.apache.maven.model; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import junit.framework.TestCase; /** * Tests {@code Activation}. * * @author Benjamin Bentmann * @version $Id: ActivationTest.java 793311 2009-07-12 10:29:57Z bentmann $ */ public class ActivationTest extends TestCase { public void testHashCodeNullSafe() { new Activation().hashCode(); } public void testEqualsNullSafe() { assertFalse( new Activation().equals( null ) ); new Activation().equals( new Activation() ); } public void testEqualsIdentity() { Activation thing = new Activation(); assertTrue( thing.equals( thing ) ); } public void testToStringNullSafe() { assertNotNull( new Activation().toString() ); } } maven2-core-2.2.1/maven-model/src/test/java/org/apache/maven/model/ReportPluginTest.java0000644000175000017500000000545311226335445031052 0ustar twernertwernerpackage org.apache.maven.model; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import junit.framework.TestCase; /** * Tests {@code ReportPlugin}. * * @author Benjamin Bentmann * @version $Id: ReportPluginTest.java 793311 2009-07-12 10:29:57Z bentmann $ */ public class ReportPluginTest extends TestCase { public void testHashCodeNullSafe() { new ReportPlugin().hashCode(); } public void testEqualsNullSafe() { assertFalse( new ReportPlugin().equals( null ) ); new ReportPlugin().equals( new ReportPlugin() ); } public void testEqualsIsKey() { ReportPlugin thing = new ReportPlugin(); thing.setGroupId( "groupId" ); thing.setArtifactId( "artifactId" ); thing.setVersion( "1.0" ); ReportPlugin thing2 = new ReportPlugin(); thing2.setGroupId( "groupId" ); thing2.setArtifactId( "artifactId" ); thing2.setVersion( "2.0" ); assertEquals( thing2, thing ); ReportPlugin thing3 = new ReportPlugin(); thing3.setGroupId( "otherGroupId" ); thing3.setArtifactId( "artifactId" ); assertFalse( thing3.equals( thing ) ); } public void testHashcodeIsId() { ReportPlugin thing = new ReportPlugin(); thing.setGroupId( "groupId" ); thing.setArtifactId( "artifactId" ); thing.setVersion( "1.0" ); ReportPlugin thing2 = new ReportPlugin(); thing2.setGroupId( "groupId" ); thing2.setArtifactId( "artifactId" ); thing2.setVersion( "2.0" ); assertEquals( thing2.hashCode(), thing.hashCode() ); ReportPlugin thing3 = new ReportPlugin(); thing3.setGroupId( "otherGroupId" ); thing3.setArtifactId( "artifactId" ); assertFalse( thing3.hashCode() == thing.hashCode() ); } public void testEqualsIdentity() { ReportPlugin thing = new ReportPlugin(); assertTrue( thing.equals( thing ) ); } public void testToStringNullSafe() { assertNotNull( new ReportPlugin().toString() ); } } maven2-core-2.2.1/maven-model/src/test/java/org/apache/maven/model/NotifierTest.java0000644000175000017500000000301711226335445030171 0ustar twernertwernerpackage org.apache.maven.model; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import junit.framework.TestCase; /** * Tests {@code Notifier}. * * @author Benjamin Bentmann * @version $Id: NotifierTest.java 793311 2009-07-12 10:29:57Z bentmann $ */ public class NotifierTest extends TestCase { public void testHashCodeNullSafe() { new Notifier().hashCode(); } public void testEqualsNullSafe() { assertFalse( new Notifier().equals( null ) ); new Notifier().equals( new Notifier() ); } public void testEqualsIdentity() { Notifier thing = new Notifier(); assertTrue( thing.equals( thing ) ); } public void testToStringNullSafe() { assertNotNull( new Notifier().toString() ); } } maven2-core-2.2.1/maven-model/src/test/java/org/apache/maven/model/BuildTest.java0000644000175000017500000000276111226335445027456 0ustar twernertwernerpackage org.apache.maven.model; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import junit.framework.TestCase; /** * Tests {@code Build}. * * @author Benjamin Bentmann * @version $Id: BuildTest.java 793311 2009-07-12 10:29:57Z bentmann $ */ public class BuildTest extends TestCase { public void testHashCodeNullSafe() { new Build().hashCode(); } public void testEqualsNullSafe() { assertFalse( new Build().equals( null ) ); new Build().equals( new Build() ); } public void testEqualsIdentity() { Build thing = new Build(); assertTrue( thing.equals( thing ) ); } public void testToStringNullSafe() { assertNotNull( new Build().toString() ); } } maven2-core-2.2.1/maven-model/src/test/java/org/apache/maven/model/ReportingTest.java0000644000175000017500000000303111226335445030357 0ustar twernertwernerpackage org.apache.maven.model; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import junit.framework.TestCase; /** * Tests {@code Reporting}. * * @author Benjamin Bentmann * @version $Id: ReportingTest.java 793311 2009-07-12 10:29:57Z bentmann $ */ public class ReportingTest extends TestCase { public void testHashCodeNullSafe() { new Reporting().hashCode(); } public void testEqualsNullSafe() { assertFalse( new Reporting().equals( null ) ); new Reporting().equals( new Reporting() ); } public void testEqualsIdentity() { Reporting thing = new Reporting(); assertTrue( thing.equals( thing ) ); } public void testToStringNullSafe() { assertNotNull( new Reporting().toString() ); } } maven2-core-2.2.1/maven-model/src/test/java/org/apache/maven/model/OrganizationTest.java0000644000175000017500000000306711226335445031063 0ustar twernertwernerpackage org.apache.maven.model; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import junit.framework.TestCase; /** * Tests {@code Organization}. * * @author Benjamin Bentmann * @version $Id: OrganizationTest.java 793311 2009-07-12 10:29:57Z bentmann $ */ public class OrganizationTest extends TestCase { public void testHashCodeNullSafe() { new Organization().hashCode(); } public void testEqualsNullSafe() { assertFalse( new Organization().equals( null ) ); new Organization().equals( new Organization() ); } public void testEqualsIdentity() { Organization thing = new Organization(); assertTrue( thing.equals( thing ) ); } public void testToStringNullSafe() { assertNotNull( new Organization().toString() ); } } maven2-core-2.2.1/maven-model/src/test/java/org/apache/maven/model/DeveloperTest.java0000644000175000017500000000303111226335445030333 0ustar twernertwernerpackage org.apache.maven.model; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import junit.framework.TestCase; /** * Tests {@code Developer}. * * @author Benjamin Bentmann * @version $Id: DeveloperTest.java 793311 2009-07-12 10:29:57Z bentmann $ */ public class DeveloperTest extends TestCase { public void testHashCodeNullSafe() { new Developer().hashCode(); } public void testEqualsNullSafe() { assertFalse( new Developer().equals( null ) ); new Developer().equals( new Developer() ); } public void testEqualsIdentity() { Developer thing = new Developer(); assertTrue( thing.equals( thing ) ); } public void testToStringNullSafe() { assertNotNull( new Developer().toString() ); } } maven2-core-2.2.1/maven-model/src/test/java/org/apache/maven/model/DistributionManagementTest.java0000644000175000017500000000323311226335445033066 0ustar twernertwernerpackage org.apache.maven.model; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import junit.framework.TestCase; /** * Tests {@code DistributionManagement}. * * @author Benjamin Bentmann * @version $Id: DistributionManagementTest.java 793311 2009-07-12 10:29:57Z bentmann $ */ public class DistributionManagementTest extends TestCase { public void testHashCodeNullSafe() { new DistributionManagement().hashCode(); } public void testEqualsNullSafe() { assertFalse( new DistributionManagement().equals( null ) ); new DistributionManagement().equals( new DistributionManagement() ); } public void testEqualsIdentity() { DistributionManagement thing = new DistributionManagement(); assertTrue( thing.equals( thing ) ); } public void testToStringNullSafe() { assertNotNull( new DistributionManagement().toString() ); } } maven2-core-2.2.1/maven-model/src/test/java/org/apache/maven/model/DeploymentRepositoryTest.java0000644000175000017500000000320711226335445032633 0ustar twernertwernerpackage org.apache.maven.model; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import junit.framework.TestCase; /** * Tests {@code DeploymentRepository}. * * @author Benjamin Bentmann * @version $Id: DeploymentRepositoryTest.java 793311 2009-07-12 10:29:57Z bentmann $ */ public class DeploymentRepositoryTest extends TestCase { public void testHashCodeNullSafe() { new DeploymentRepository().hashCode(); } public void testEqualsNullSafe() { assertFalse( new DeploymentRepository().equals( null ) ); new DeploymentRepository().equals( new DeploymentRepository() ); } public void testEqualsIdentity() { DeploymentRepository thing = new DeploymentRepository(); assertTrue( thing.equals( thing ) ); } public void testToStringNullSafe() { assertNotNull( new DeploymentRepository().toString() ); } } maven2-core-2.2.1/maven-model/src/test/java/org/apache/maven/model/MailingListTest.java0000644000175000017500000000305511226335445030630 0ustar twernertwernerpackage org.apache.maven.model; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import junit.framework.TestCase; /** * Tests {@code MailingList}. * * @author Benjamin Bentmann * @version $Id: MailingListTest.java 793311 2009-07-12 10:29:57Z bentmann $ */ public class MailingListTest extends TestCase { public void testHashCodeNullSafe() { new MailingList().hashCode(); } public void testEqualsNullSafe() { assertFalse( new MailingList().equals( null ) ); new MailingList().equals( new MailingList() ); } public void testEqualsIdentity() { MailingList thing = new MailingList(); assertTrue( thing.equals( thing ) ); } public void testToStringNullSafe() { assertNotNull( new MailingList().toString() ); } } maven2-core-2.2.1/maven-model/src/test/java/org/apache/maven/model/PluginExecutionTest.java0000644000175000017500000000312511226335445031534 0ustar twernertwernerpackage org.apache.maven.model; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import junit.framework.TestCase; /** * Tests {@code PluginExecution}. * * @author Benjamin Bentmann * @version $Id: PluginExecutionTest.java 793311 2009-07-12 10:29:57Z bentmann $ */ public class PluginExecutionTest extends TestCase { public void testHashCodeNullSafe() { new PluginExecution().hashCode(); } public void testEqualsNullSafe() { assertFalse( new PluginExecution().equals( null ) ); new PluginExecution().equals( new PluginExecution() ); } public void testEqualsIdentity() { PluginExecution thing = new PluginExecution(); assertTrue( thing.equals( thing ) ); } public void testToStringNullSafe() { assertNotNull( new PluginExecution().toString() ); } } maven2-core-2.2.1/maven-model/src/test/java/org/apache/maven/model/ResourceTest.java0000644000175000017500000000301711226335445030201 0ustar twernertwernerpackage org.apache.maven.model; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import junit.framework.TestCase; /** * Tests {@code Resource}. * * @author Benjamin Bentmann * @version $Id: ResourceTest.java 793311 2009-07-12 10:29:57Z bentmann $ */ public class ResourceTest extends TestCase { public void testHashCodeNullSafe() { new Resource().hashCode(); } public void testEqualsNullSafe() { assertFalse( new Resource().equals( null ) ); new Resource().equals( new Resource() ); } public void testEqualsIdentity() { Resource thing = new Resource(); assertTrue( thing.equals( thing ) ); } public void testToStringNullSafe() { assertNotNull( new Resource().toString() ); } } maven2-core-2.2.1/maven-model/src/test/java/org/apache/maven/model/DependencyManagementTest.java0000644000175000017500000000320711226335445032466 0ustar twernertwernerpackage org.apache.maven.model; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import junit.framework.TestCase; /** * Tests {@code DependencyManagement}. * * @author Benjamin Bentmann * @version $Id: DependencyManagementTest.java 793311 2009-07-12 10:29:57Z bentmann $ */ public class DependencyManagementTest extends TestCase { public void testHashCodeNullSafe() { new DependencyManagement().hashCode(); } public void testEqualsNullSafe() { assertFalse( new DependencyManagement().equals( null ) ); new DependencyManagement().equals( new DependencyManagement() ); } public void testEqualsIdentity() { DependencyManagement thing = new DependencyManagement(); assertTrue( thing.equals( thing ) ); } public void testToStringNullSafe() { assertNotNull( new DependencyManagement().toString() ); } } maven2-core-2.2.1/maven-model/src/test/java/org/apache/maven/model/ReportSetTest.java0000644000175000017500000000303111226335445030335 0ustar twernertwernerpackage org.apache.maven.model; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import junit.framework.TestCase; /** * Tests {@code ReportSet}. * * @author Benjamin Bentmann * @version $Id: ReportSetTest.java 793311 2009-07-12 10:29:57Z bentmann $ */ public class ReportSetTest extends TestCase { public void testHashCodeNullSafe() { new ReportSet().hashCode(); } public void testEqualsNullSafe() { assertFalse( new ReportSet().equals( null ) ); new ReportSet().equals( new ReportSet() ); } public void testEqualsIdentity() { ReportSet thing = new ReportSet(); assertTrue( thing.equals( thing ) ); } public void testToStringNullSafe() { assertNotNull( new ReportSet().toString() ); } } maven2-core-2.2.1/maven-model/src/test/java/org/apache/maven/model/RelocationTest.java0000644000175000017500000000304311226335445030510 0ustar twernertwernerpackage org.apache.maven.model; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import junit.framework.TestCase; /** * Tests {@code Relocation}. * * @author Benjamin Bentmann * @version $Id: RelocationTest.java 793311 2009-07-12 10:29:57Z bentmann $ */ public class RelocationTest extends TestCase { public void testHashCodeNullSafe() { new Relocation().hashCode(); } public void testEqualsNullSafe() { assertFalse( new Relocation().equals( null ) ); new Relocation().equals( new Relocation() ); } public void testEqualsIdentity() { Relocation thing = new Relocation(); assertTrue( thing.equals( thing ) ); } public void testToStringNullSafe() { assertNotNull( new Relocation().toString() ); } } maven2-core-2.2.1/maven-model/src/test/java/org/apache/maven/model/ExtensionTest.java0000644000175000017500000000303111226335445030362 0ustar twernertwernerpackage org.apache.maven.model; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import junit.framework.TestCase; /** * Tests {@code Extension}. * * @author Benjamin Bentmann * @version $Id: ExtensionTest.java 793311 2009-07-12 10:29:57Z bentmann $ */ public class ExtensionTest extends TestCase { public void testHashCodeNullSafe() { new Extension().hashCode(); } public void testEqualsNullSafe() { assertFalse( new Extension().equals( null ) ); new Extension().equals( new Extension() ); } public void testEqualsIdentity() { Extension thing = new Extension(); assertTrue( thing.equals( thing ) ); } public void testToStringNullSafe() { assertNotNull( new Extension().toString() ); } } maven2-core-2.2.1/maven-model/src/test/java/org/apache/maven/model/PluginConfigurationTest.java0000644000175000017500000000317511226335445032405 0ustar twernertwernerpackage org.apache.maven.model; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import junit.framework.TestCase; /** * Tests {@code PluginConfiguration}. * * @author Benjamin Bentmann * @version $Id: PluginConfigurationTest.java 793311 2009-07-12 10:29:57Z bentmann $ */ public class PluginConfigurationTest extends TestCase { public void testHashCodeNullSafe() { new PluginConfiguration().hashCode(); } public void testEqualsNullSafe() { assertFalse( new PluginConfiguration().equals( null ) ); new PluginConfiguration().equals( new PluginConfiguration() ); } public void testEqualsIdentity() { PluginConfiguration thing = new PluginConfiguration(); assertTrue( thing.equals( thing ) ); } public void testToStringNullSafe() { assertNotNull( new PluginConfiguration().toString() ); } } maven2-core-2.2.1/maven-model/src/test/java/org/apache/maven/model/CiManagementTest.java0000644000175000017500000000306711226335445030747 0ustar twernertwernerpackage org.apache.maven.model; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import junit.framework.TestCase; /** * Tests {@code CiManagement}. * * @author Benjamin Bentmann * @version $Id: CiManagementTest.java 793311 2009-07-12 10:29:57Z bentmann $ */ public class CiManagementTest extends TestCase { public void testHashCodeNullSafe() { new CiManagement().hashCode(); } public void testEqualsNullSafe() { assertFalse( new CiManagement().equals( null ) ); new CiManagement().equals( new CiManagement() ); } public void testEqualsIdentity() { CiManagement thing = new CiManagement(); assertTrue( thing.equals( thing ) ); } public void testToStringNullSafe() { assertNotNull( new CiManagement().toString() ); } } maven2-core-2.2.1/maven-model/src/main/0000755000175000017500000000000011250552243017506 5ustar twernertwernermaven2-core-2.2.1/maven-model/src/main/mdo/0000755000175000017500000000000011250552243020265 5ustar twernertwernermaven2-core-2.2.1/maven-model/src/main/mdo/maven.mdo0000644000175000017500000035325311226335445022115 0ustar twernertwerner maven Maven This is a reference for the Maven project descriptor used in Maven.

An XSD is available at:

]]>
package org.apache.maven.model Model ModelBase <project> element is the root of the descriptor. The following table lists all of the possible child elements. ]]> 3.0.0+ pomVersion 3.0.0 true String 3. ]]> modelVersion 4.0.0 true Declares to which version of project descriptor this POM conforms. String extend 3.0.0 project.xml file. For example, <extend>${basedir}/../project.xml</extend>. ]]> String parent 4.0.0 The location of the parent project, if one exists. Values from the parent project will be the default for this project if they are left unspecified. The location is given as a group ID, artifact ID and version. Parent groupId 3.0.0+ true org.apache.maven). ]]> String artifactId 3.0.0+ true The identifier for this artifact that is unique within the group given by the group ID. An artifact is something that is either produced or used by a project. Examples of artifacts produced by Maven for a project include: JARs, source and binary distributions, and WARs. String id 3.0.0 true Deprecated. When used, this sets both the groupId and artifactId elements if they were previously empty. ]]> String currentVersion The current version of the artifact produced by this project. 3.0.0 true String version 4.0.0 true The current version of the artifact produced by this project. String versions 3.0.0 Contains information on previous versions of the project. Version * packaging 4.0.0 jar war ear pom. Plugins can create their own packaging, and therefore their own packaging types, so this list does not contain all possible types. ]]> String jar name 3.0.0+ true The full name of the project. String shortDescription 3.0.0 A short description of the project. The short description should be limited to a single line. String description 3.0.0+ A detailed description of the project, used by Maven whenever it needs to describe the project, such as on the web site. While this element can be specified as CDATA to enable the use of HTML tags within the description, it is discouraged to allow plain text representation. If you need to modify the index page of the generated web site, you are able to specify your own instead of adjusting this text. String url 3.0.0+ String siteAddress 3.0.0 The hostname of the web server that hosts the project's web site. This is used when the web site is deployed. String siteDirectory 3.0.0 The directory on the web server where the public web site for this project resides. This is used when the web site is deployed. String inceptionYear 3.0.0+ true The year of the project's inception, specified with 4 digits. This value is used when generating copyright notices as well as being informational. String logo 3.0.0 /images/project-logo.png) or an absolute URL (e.g., http://my.corp/project-logo.png). This is used when generating the project documentation. ]]> String organization 3.0.0+ This element describes various attributes of the organization to which the project belongs. These attributes are utilized when documentation is created (for copyright notices and links). organisation Organization licenses 3.0.0+ license element, which is then described by additional elements. Projects should only list the license(s) that applies to the project and not the licenses that apply to dependencies. If multiple licenses are listed, it is assumed that the user can select any of them, not that they must accept all. ]]> License * mailingLists 3.0.0+ Contains information about a project's mailing lists. MailingList * developers 3.0.0+ Describes the committers of a project. Developer * contributors 3.0.0+ Describes the contributors to a project that are not yet committers. Contributor * issueTrackingUrl 3.0.0 The URL of the project's issue tracking system. String issueManagement 4.0.0 The project's issue management system information. IssueManagement branches 3.0.0 Branch * repository 3.0.0 Specification for the SCM used by the project, such as CVS, Subversion, etc. Repository scm 4.0.0 Specification for the SCM used by the project, such as CVS, Subversion, etc. Scm gumpRepositoryId 3.0.0 This is the repository identifier in Gump that this project is part of. String ciManagement 4.0.0 The project's continuous integration information. CiManagement distributionSite 3.0.0 maven.repo.central and maven.repo.central.directory. ]]> String distributionDirectory 3.0.0 The directory on the web server where the final distributions will be published. This is used when the distributions are deployed. String packageGroups 3.0.0 Package groups required for complete javadocs. PackageGroup * reports 3.0.0 maven site. All of the reports will be included in the navigation bar for browsing in the order they are specified. ]]> String * properties 3.0.0 <name>value</name>. ]]> Properties String * packageName 3.0.0 String The Java package name of the project. This value is used when generating JavaDoc. prerequisites 4.0.0 Describes the prerequisites in the build environment for this project. Prerequisites build 3.0.0+ true Information required to build the project. Build profiles 4.0.0 A listing of project-local build profiles which will modify the build process when activated. Profile * 3.0.0 4.0.0 groupId:artifactId:packaging:version */ public String getId() { StringBuffer id = new StringBuffer(); id.append( getGroupId() ); id.append( ":" ); id.append( getArtifactId() ); id.append( ":" ); id.append( getPackaging() ); id.append( ":" ); id.append( getVersion() ); return id.toString(); } ]]> ModelBase 3.0.0+ Model and the Profile objects. ]]> distributionManagement 4.0.0 Distribution information for a project that enables deployment of the site and artifacts to remote web servers and repositories respectively. DistributionManagement modules 4.0.0 The modules (sometimes called subprojects) to build as a part of this project. Each module listed is a relative path to the directory containing the module. String * repositories 4.0.0 The lists of the remote repositories for discovering dependencies and extensions. Repository * pluginRepositories 4.0.0 The lists of the remote repositories for discovering plugins for builds and reports. Repository * dependencies 3.0.0+ the dependency mechanism for more information. ]]> Dependency * reports 4.0.0 Deprecated. Now ignored by Maven. ]]> DOM reporting 4.0.0 mvn site. All of the reports will be included in the navigation bar for browsing. ]]> Reporting dependencyManagement 4.0.0 false Default dependency information for projects that inherit from this one. The dependencies in this section are not immediately resolved. Instead, when a POM derived from this one declares a dependency described by a matching groupId and artifactId, the version and other values from this section are used for that dependency if they were not already specified. DependencyManagement properties 4.0.0 <name>value</name>. ]]> Properties String * Branch 3.0.0 Contains information on the SCM branches of the project. tag 3.0.0 true The branch tag in the version control system (e.g. cvs) used by the project for the source code associated with this branch of the project. String PluginContainer 3.0.0+ Contains the plugins informations for the project. plugins 4.0.0 The list of plugins to use. Plugin * 4.0.0 pluginsMap field to null */ public void flushPluginMap() { this.pluginMap = null; } /** * @return a Map of plugins field with Plugins#getKey() as key * @see org.apache.maven.model.Plugin#getKey() */ public java.util.Map getPluginsAsMap() { if ( pluginMap == null ) { pluginMap = new java.util.LinkedHashMap(); if ( plugins != null ) { for ( java.util.Iterator it = plugins.iterator(); it.hasNext(); ) { Plugin plugin = (Plugin) it.next(); pluginMap.put( plugin.getKey(), plugin ); } } } return pluginMap; } ]]> PluginConfiguration 3.0.0+ PluginContainer Contains the plugins management informations for the project. pluginManagement 4.0.0 false Default plugin information to be made available for reference by projects derived from this one. This plugin configuration will not be resolved or bound to the lifecycle unless referenced. Any local configuration for a given plugin will override the plugin's entire definition here. PluginManagement BuildBase 3.0.0+ PluginConfiguration Generic informations for a build. defaultGoal 3.0.0+ The default goal (or phase in Maven 2) to execute when none is specified for the project. String resources 3.0.0+ This element describes all of the classpath resources such as properties files associated with a project. These resources are often included in the final package. Resource * testResources 4.0.0 This element describes all of the classpath resources such as properties files associated with a project's unit tests. Resource * directory 4.0.0 The directory where all files generated by the build are placed. String finalName 4.0.0 ${artifactId}-${version}. ]]> String filters 4.0.0 The list of filter properties files that are used when filtering is enabled. String * Build 3.0.0+ BuildBase <build> element contains informations required to build the project. ]]> nagEmailAddress 3.0.0 An address to which notifications regarding the status of builds for this project can be sent. This is intended for use by tools which do unattended builds, for example those providing for continuous integration. String sourceDirectory 3.0.0+ true This element specifies a directory containing the source of the project. The generated build system will compile the source in this directory when the project is built. The path given is relative to the project descriptor. String scriptSourceDirectory 4.0.0 true This element specifies a directory containing the script sources of the project. This directory is meant to be different from the sourceDirectory, in that its contents will be copied to the output directory in most cases (since scripts are interpreted rather than compiled). String unitTestSourceDirectory 3.0.0 true This element specifies a directory containing the unit test source of the project. The generated build system will compile these directories when the project is being tested. The path given is relative to the project descriptor. String testSourceDirectory 4.0.0 true This element specifies a directory containing the unit test source of the project. The generated build system will compile these directories when the project is being tested. The path given is relative to the project descriptor. String aspectSourceDirectory 3.0.0 This element specifies a directory containing Aspect sources of the project. The generated build system will compile the Aspects in this directory when the project is built if Aspects have been enabled. The path given is relative to the project descriptor. String integrationUnitTestSourceDirectory 3.0.0 deprecated and should no longer be used. Initially it was used by the first Cactus plugin. Now the location of the Cactus test sources is defined through a plugin property. See the Cactus plugin properties page. ]]> String sourceModifications 3.0.0 true This element describes all of the sourceModifications associated with a project. These modifications are used to exclude or include various source depending on the environment the build is running in. SourceModification * unitTest 3.0.0 true This element specifies unit tests associated with the project. new UnitTest() UnitTest outputDirectory 4.0.0 The directory where compiled application classes are placed. String testOutputDirectory 4.0.0 The directory where compiled test classes are placed. String extensions 4.0.0 A set of build extensions to use from this project. Extension * CiManagement 4.0.0 <CiManagement> element contains informations required to the continuous integration system of the project. ]]> system 4.0.0 continuum. ]]> String url 4.0.0 URL for the continuous integration system used by the project if it has a web interface. String notifiers 4.0.0 Configuration for notifying developers/users when a build is unsuccessful, including user information and notification mode. * Notifier Notifier Configures one method for notifying users/developers when a build breaks. 4.0.0 type 4.0.0 mail String The mechanism used to deliver notifications. sendOnError 4.0.0 true boolean Whether to send notifications on error. sendOnFailure 4.0.0 true boolean Whether to send notifications on failure. sendOnSuccess 4.0.0 true boolean Whether to send notifications on success. sendOnWarning 4.0.0 true boolean Whether to send notifications on warning. address 4.0.0 String Deprecated. Where to send the notification to - eg email address. ]]> configuration Extended configuration specific to this notifier goes here. Properties String * Contributor Description of a person who has contributed to the project, but who does not have commit privileges. Usually, these contributions come in the form of patches submitted. 3.0.0+ name 3.0.0+ The full name of the contributor. String email 3.0.0+ The email address of the contributor. String url 3.0.0+ The URL for the homepage of the contributor. String organization organisation 3.0.0+ The organization to which the contributor belongs. String organizationUrl organisationUrl 3.0.0+ The URL of the organization. String roles 3.0.0+ role element, the body of which is a role name. This can also be used to describe the contribution. ]]> String * timezone 3.0.0+ The timezone the contributor is in. This is a number in the range -11 to 12. String properties 3.0.0+ Properties about the contributor, such as an instant messenger handle. Properties String * Dependency 3.0.0+ <dependency> element contains information about a dependency of the project. ]]> id 3.0.0 true Deprecated. Please use groupId and artifactId together instead. ]]> String groupId 3.0.0+ true org.apache.maven. ]]> String artifactId 3.0.0+ true maven-artifact. ]]> String version 3.0.0+ 3.2.1. In Maven 2, this can also be specified as a range of versions. ]]> String url 3.0.0 This url will be provided to the user if the jar file cannot be downloaded from the central repository. String jar 3.0.0 Literal name of the artifact in the repository. Used to override the calculated artifact name. String type 3.0.0 jar. While it usually represents the extension on the filename of the dependency, that is not always the case. Some examples are jar, war, and plugin. A dependency of type plugin is loaded as a Maven plugin and not added to the project build classpath. ]]> String jar type 4.0.0 jar. While it usually represents the extension on the filename of the dependency, that is not always the case. A type can be mapped to a different extension and a classifier. The type often correspongs to the packaging used, though this is also not always the case. Some examples are jar, war, ejb-client and test-jar. New types can be defined by plugins that set extensions to true, so this is not a complete list. ]]> String jar classifier 4.0.0 jdk14 and jdk15. ]]> String false properties 3.0.0 war.bundle property, and if found will include the dependency in WEB-INF/lib. ]]> Properties String * scope 4.0.0 compile, runtime, test, system, and provided. Used to calculate the various classpaths used for compilation, testing, and so on. It also assists in determining which artifacts to include in a distribution of this project. For more information, see the dependency mechanism. ]]> String systemPath 4.0.0 discouraged and may be replaced in later versions. This specifies the path on the filesystem for this dependency. Requires an absolute path for the value, not relative. Use a property that gives the machine specific absolute path, e.g. ${java.home}. ]]> String exclusions 4.0.0 Lists a set of artifacts that should be excluded from this dependency's artifact list when it comes to calculating transitive dependencies. Exclusion * optional 4.0.0 Indicates the dependency is optional for use of this library. While the version of the dependency will be taken into account for dependency calculation if the library is used elsewhere, it will not be passed on transitively. boolean false 3.0.0 4.0.0 4.0.0 groupId:artifactId:type */ public String getManagementKey() { return groupId + ":" + artifactId + ":" + type + ( classifier != null ? ":" + classifier : "" ); } ]]> 3.0.0 id:type */ public String getKey() { return getId() + ":" + getType(); } /** * @return the groupId as artifact directory */ public String getArtifactDirectory() { return getGroupId(); } /** * @return the artifact name as artifactId-version.extension if <jar/> not set */ public String getArtifact() { // If the jar name has been explicty set then use that. This // is when the element is explicity used in the POM. if ( getJar() != null) { return getJar(); } String artifact; if ("ejb-client".equals(getType())) { artifact = getArtifactId() + "-" + getVersion() + "-client." + getExtension(); } else { artifact = getArtifactId() + "-" + getVersion() + "." + getExtension(); } return artifact; } public String getTypeDirectory() { String path; if (getType().equals("ejb-client")) { path = "ejbs"; } else { path = getType() + "s"; } return path; } public String getExtension() { if ("ejb".equals(getType()) || "ejb-client".equals(getType()) || "plugin".equals(getType()) || "aspect".equals(getType()) || "uberjar".equals(getType())) return "jar"; return getType(); } public boolean isAddedToClasspath() { return ("jar".equals(getType()) || "ejb".equals(getType()) || "ejb-client".equals(getType()) || "sar".equals(getType())); } public boolean isPlugin() { return ("plugin".equals(getType())); } public String getProperty( String property ) { return getProperties().getProperty( property ); } /** * @see java.lang.Object#equals(java.lang.Object) */ public boolean equals( Object o ) { if ( this == o ) { return true; } if ( !( o instanceof Dependency ) ) { return false; } Dependency d = (Dependency) o; return getId().equals( d.getId() ); } /** * @see java.lang.Object#hashCode() */ public int hashCode() { return getId().hashCode(); } ]]> Contributor Developer Information about one of the committers on this project. 3.0.0+ id 3.0.0+ The unique ID of the developer in the SCM. String Exclusion 4.0.0 <exclusion> element contains informations required to exclude an artifact to the project. ]]> artifactId 4.0.0 The artifact ID of the project to exclude. String true groupId 4.0.0 The group ID of the project to exclude. String true IssueManagement Information about the issue tracking (or bug tracking) system used to manage this project. 4.0.0 system 4.0.0 The name of the issue management system, e.g. Bugzilla String url 4.0.0 URL for the issue management system used by the project. String DistributionManagement 4.0.0 This elements describes all that pertains to distribution for a project. It is primarily used for deployment of artifacts and the site produced by the build. repository 4.0.0 Information needed to deploy the artifacts generated by the project to a remote repository. DeploymentRepository snapshotRepository 4.0.0 repository element. ]]> DeploymentRepository site Information needed for deploying the web site of the project. 4.0.0 Site downloadUrl 4.0.0+ url. This is given to assist in locating artifacts that are not in the repository due to licensing restrictions. ]]> String relocation 4.0.0 Relocation information of the artifact if it has been moved to a new group ID and/or artifact ID. Relocation status 4.0.0 none (default), converted (repository manager converted this from an Maven 1 POM), partner (directly synced from a partner Maven 2 repository), deployed (was deployed from a Maven 2 instance), verified (has been hand verified as correct and final). ]]> false String License Describes the licenses for this project. This is used to generate the license page of the project's web site, as well as being taken into consideration in other reporting and validation. The licenses listed for the project are that of the project itself, and not of dependencies. 3.0.0+ name 3.0.0+ The full legal name of the license. String url 3.0.0+ The official url for the license text. String distribution 3.0.0+
repo
may be downloaded from the Maven repository
manual
user must manually download and install the dependency.
]]>
String
comments Addendum information pertaining to this license. 3.0.0+ String
MailingList 3.0.0+ This element describes all of the mailing lists associated with a project. The auto-generated site references this information. name 3.0.0+ String subscribe 3.0.0+ mailto: link will automatically be created when the documentation is created. ]]> String unsubscribe 3.0.0+ mailto: link will automatically be created when the documentation is created. ]]> String post 3.0.0+ mailto: link will automatically be created when the documentation is created. ]]> String archive 3.0.0+ The link to a URL where you can browse the mailing list archive. String otherArchives 3.0.0+ The link to alternate URLs where you can browse the list archive. String * We could probably have a specific element for a dev mailing list for things like CI, and maybe even a specific element for the user and scm mailing lists. Then leave the more lose structure for any other type of mailing list. Organization Specifies the organization that produces this project. 3.0.0+ name 3.0.0+ The full name of the organization. String url 3.0.0+ The URL to the organization's home page. String logo 3.0.0 /images/org-logo.png) or an absolute URL (e.g., http://my.corp/logo.png). This value is used when generating the project documentation. ]]> String PackageGroup 3.0.0 A JavaDoc package group. title 3.0.0 The title to use for the package group. String packages 3.0.0 The packages in the group String PatternSet 3.0.0+ Definition of include or exclude patterns. includes 3.0.0+ **/*.xml. ]]> String * excludes 3.0.0+ **/*.xml ]]> String * 4.0.0 Parent 4.0.0 <parent> element contains informations required to the parent project. ]]> artifactId 4.0.0 The artifact id of the parent project to inherit from. true String groupId 4.0.0 The group id of the parent project to inherit from. true String version 4.0.0 The version of the parent project to inherit. String relativePath 4.0.0 pom.xml file within the check out. The default value is ../pom.xml. Maven looks for the parent pom first in the reactor of currently building projects, then in this location on the filesystem, then the local repository, and lastly in the remote repo. relativePath allows you to select a different location, for example when your structure is flat, or deeper without an intermediate parent pom. However, the group ID, artifact ID and version are still required, and must match the file in the location given or it will revert to the repository for the POM. This feature is only for enhancing the development in a local checkout of that project. ]]> String ../pom.xml 4.0.0 groupId:artifactId:version */ public String getId() { StringBuffer id = new StringBuffer(); id.append( getGroupId() ); id.append( ":" ); id.append( getArtifactId() ); id.append( ":" ); id.append( "pom" ); // id.append( getPackaging() ); id.append( ":" ); id.append( getVersion() ); return id.toString(); } ]]> Repository 3.0.0 <repository> element contains informations required to a repository used by the project. ]]> connection 3.0.0 URL format and list of supported SCMs. This connection is read-only. ]]> String developerConnection 3.0.0 connection, but for developers, i.e. this scm connection will not be read only. ]]> String url 3.0.0 The URL to the project's browsable SCM repository, such as ViewVC or Fisheye. String Scm 4.0.0 <scm> element contains informations required to the SCM (Source Control Management) of the project. ]]> connection 4.0.0 URL format and list of supported SCMs. This connection is read-only. ]]> String developerConnection 4.0.0 connection, but for developers, i.e. this scm connection will not be read only. ]]> String tag 4.0.0 The tag of current code. By default, it's set to HEAD during development. String HEAD url 4.0.0 The URL to the project's browsable SCM repository, such as ViewVC or Fisheye. String FileSet 3.0.0+ PatternSet A PatternSet for files. directory 3.0.0+ Describe the directory where the resources are stored. The path is relative to the POM. String 4.0.0 Resource This element describes all of the classpath resources associated with a project or unit tests. 3.0.0+ FileSet targetPath 3.0.0+ ${project.build.outputDirectory}). For example, if you want that resource to appear in a specific package (org.apache.maven.messages), you must specify this element with this value: org/apache/maven/messages. This is not required if you simply put the resources in that directory structure at the source, however. ]]> String filtering 3.0.0+ properties element and from the properties in the files listed in the filters element. ]]> boolean false mergeId 4.0.0+ String 4.0.0 SourceModification This element describes all of the source modifications associated with a project. These modifications are used to exclude or include various source depending on the environment the build is running in. 3.0.0 FileSet className 3.0.0 not be loaded, then the includes and excludes specified below will be applied to the contents of the sourceDirectory. ]]> String property 3.0.0 not set, then the includes and excludes specified below will be applied to the contents of the sourceDirectory. ]]> String UnitTest 3.0.0 PatternSet A PatternSet for unit tests. resources 3.0.0 The classpath resources to use when executing the unit tests. Resource * Version 3.0.0 version element ]]> name 3.0.0 1.0, 1.1-alpha1, 1.2-beta, 1.3.2 etc. ]]> String tag 3.0.0 The name given in the SCM (e.g. CVS) used by the project for the source code associated with this version of the project. String id 3.0.0 A unique identifier for a version. This is usually identical to the name. String 3.0.0 RepositoryBase 4.0.0 A repository contains the information needed for establishing connections with remote repository. id 4.0.0 true settings.xml file, for example. Furthermore, the identifier is used during POM inheritance and profile injection to detect repositories that should be merged. ]]> String name 4.0.0 Human readable name of the repository. String url 4.0.0 true protocol://hostname/path. ]]> String layout 4.0.0 legacy or default. ]]> String default 4.0.0 Repository RepositoryBase 4.0.0 A repository contains the information needed for establishing connections with remote repository. releases 4.0.0 How to handle downloading of releases from this repository. RepositoryPolicy snapshots 4.0.0 How to handle downloading of snapshots from this repository. RepositoryPolicy 4.0.0 DeploymentRepository RepositoryBase 4.0.0 Repository contains the information needed for deploying to the remote repository. uniqueVersion Whether to assign snapshots a unique version comprised of the timestamp and build number, or to use the same version each time boolean true 4.0.0 4.0.0 RepositoryPolicy 4.0.0 Download policy. enabled 4.0.0 Whether to use this repository for downloading this type of artifact. boolean true updatePolicy 4.0.0 always, daily (default), interval:XXX (in minutes) or never (only if it doesn't exist locally). ]]> String checksumPolicy 4.0.0 ignore , fail or warn (the default). ]]> String Site 4.0.0 Contains the information needed for deploying websites. id 4.0.0 settings.xml file, for example. ]]> String name 4.0.0 Human readable name of the deployment location. String url 4.0.0 protocol://hostname/path. ]]> String ConfigurationContainer 4.0.0 Contains the configuration information of the container like Plugin. inherited 4.0.0 Whether any configuration should be propagated to child POMs. String The configuration as DOM object. configuration DOM 4.0.0 Plugin 4.0.0 ConfigurationContainer <plugin> element contains informations required for a plugin. ]]> groupId The group ID of the plugin in the repository. 4.0.0 String true org.apache.maven.plugins artifactId The artifact ID of the plugin in the repository. 4.0.0 String true version 4.0.0 The version (or valid range of versions) of the plugin to be used. String extensions 4.0.0 boolean Whether to load Maven extensions (such as packaging and type handlers) from this plugin. For performance reasons, this should only be enabled when necessary. false executions 4.0.0 Multiple specifications of a set of goals to execute during the build lifecycle, each having (possibly) a different configuration. PluginExecution * dependencies Additional dependencies that this project needs to introduce to the plugin's classloader. 4.0.0 Dependency * goals 4.0.0 Deprecated. Unused by Maven. ]]> DOM 4.0.0 executionMap field to null */ public void flushExecutionMap() { this.executionMap = null; } /** * @return a Map of executions field with PluginExecution#getId() as key * @see org.apache.maven.model.PluginExecution#getId() */ public java.util.Map getExecutionsAsMap() { if ( executionMap == null ) { executionMap = new java.util.LinkedHashMap(); if ( getExecutions() != null ) { for ( java.util.Iterator i = getExecutions().iterator(); i.hasNext(); ) { PluginExecution exec = (PluginExecution) i.next(); if ( executionMap.containsKey( exec.getId() ) ) { throw new IllegalStateException( "You cannot have two plugin executions with the same (or missing) elements.\nOffending execution\n\nId: \'" + exec.getId() + "\'\nPlugin:\'" + getKey() + "\'\n\n" ); } executionMap.put( exec.getId(), exec ); } } } return executionMap; } private String key; /** * @return the key of the plugin, ie groupId:artifactId */ public String getKey() { if ( key == null ) { key = constructKey( groupId, artifactId ).intern(); } return key; } /** * @param groupId * @param artifactId * @return the key of the plugin, ie groupId:artifactId */ public static String constructKey( String groupId, String artifactId ) { return groupId + ":" + artifactId; } /** * @see java.lang.Object#equals(java.lang.Object) */ public boolean equals( Object other ) { if ( this == other ) { return true; } if ( other instanceof Plugin ) { Plugin otherPlugin = (Plugin) other; return getKey().equals( otherPlugin.getKey() ); } return false; } /** * @see java.lang.Object#hashCode() */ public int hashCode() { return getKey().hashCode(); } /** * @see java.lang.Object#toString() */ public String toString() { return "Plugin [" + getKey() + "]"; } ]]> PluginExecution 4.0.0 ConfigurationContainer <execution> element contains informations required for the execution of a plugin. ]]> id 4.0.0 true String default The identifier of this execution for labelling the goals during the build, and for matching executions to merge during inheritance and profile injection. phase 4.0.0 String The build lifecycle phase to bind the goals in this execution to. If omitted, the goals will be bound to the default phase specified in their metadata. goals 4.0.0 The goals to execute with the given configuration. String * 4.0.0 DependencyManagement 4.0.0 Section for management of default dependency information for use in a group of POMs. dependencies 4.0.0 The dependencies specified here are not used until they are referenced in a POM within the group. This allows the specification of a "standard" version for a particular dependency. Dependency * PluginManagement 4.0.0 PluginContainer Section for management of default plugin information for use in a group of POMs. Reporting 4.0.0 Section for management of reports and their configuration. excludeDefaultsValue 4.0.0 Boolean If true, then the default reports are not included in the site generation. This includes the reports in the "Project Info" menu. outputDirectory 4.0.0 String ${project.build.directory}/site . ]]> plugins 4.0.0 The reporting plugins to use and their configuration. ReportPlugin * 4.0.0 reportPluginMap field to null */ public void flushReportPluginMap() { this.reportPluginMap = null; } /** * @return a Map of plugins field with ReportPlugin#getKey() as key * @see org.apache.maven.model.ReportPlugin#getKey() */ public java.util.Map getReportPluginsAsMap() { if ( reportPluginMap == null ) { reportPluginMap = new java.util.LinkedHashMap(); if ( getPlugins() != null ) { for ( java.util.Iterator it = getPlugins().iterator(); it.hasNext(); ) { ReportPlugin reportPlugin = (ReportPlugin) it.next(); reportPluginMap.put( reportPlugin.getKey(), reportPlugin ); } } } return reportPluginMap; } public boolean isExcludeDefaults() { return excludeDefaultsValue != null ? excludeDefaultsValue.booleanValue() : false; } public void setExcludeDefaults( boolean excludeDefaults ) { excludeDefaultsValue = excludeDefaults ? Boolean.TRUE : Boolean.FALSE; } public void setExcludeDefaultsValue( String excludeDefaults ) { excludeDefaultsValue = excludeDefaults != null ? Boolean.valueOf( excludeDefaults ) : null; } ]]> Profile ModelBase 4.0.0 Modifications to the build process which is activated based on environmental parameters or command line arguments. id true 4.0.0 String The identifier of this build profile. This is used for command line activation, and identifies profiles to be merged. activation 4.0.0 The conditional logic which will automatically trigger the inclusion of this profile. Activation build 4.0.0 true Information required to build the project. BuildBase 4.0.0 Activation 4.0.0 The conditions within the build runtime environment which will trigger the automatic inclusion of the build profile. activeByDefault 4.0.0 boolean If set to true, this profile will be active unless another profile in this pom is activated using the command line -P option or by one of that profile's activators. jdk 4.0.0 String 1.4 only activates on JDKs versioned 1.4, while !1.4 matches any JDK that is not version 1.4. ]]> os 4.0.0 Specifies that this profile will be activated when matching operating system attributes are detected. ActivationOS property 4.0.0 Specifies that this profile will be activated when this system property is specified. ActivationProperty file 4.0.0 Specifies that this profile will be activated based on existence of a file. ActivationFile ActivationProperty 4.0.0 This is the property specification used to activate a profile. If the value field is empty, then the existence of the named property will activate the profile, otherwise it does a case-sensitive match against the property value as well. name 4.0.0 String true The name of the property to be used to activate a profile. value 4.0.0 String The value of the property required to activate a profile. ActivationOS 4.0.0 This is an activator which will detect an operating system's attributes in order to activate its profile. name 4.0.0 String ${os.name} Java property, such as Windows XP. ]]> family 4.0.0 String windows or unix. ]]> arch 4.0.0 String The architecture of the operating system to be used to activate the profile. version 4.0.0 String The version of the operating system to be used to activate the profile. ActivationFile 4.0.0 This is the file specification used to activate the profile. The missing value will be the location of a file that needs to exist, and if it doesn't the profile will be activated. On the other hand exists will test for the existence of the file and if it is there the profile will be activated. missing 4.0.0 String The name of the file that must be missing to activate the profile. exists 4.0.0 String The name of the file that must exist to activate the profile. ReportPlugin 4.0.0 <plugin> element contains informations required for a report plugin. ]]> groupId 4.0.0 String true org.apache.maven.plugins The group ID of the reporting plugin in the repository. artifactId 4.0.0 String true The artifact ID of the reporting plugin in the repository. version 4.0.0 The version of the reporting plugin to be used. String inherited 4.0.0 String Whether the configuration in this plugin should be made available to projects that inherit from this one. configuration 4.0.0 DOM The configuration of the reporting plugin. reportSets 4.0.0 execution in the build. ]]> ReportSet * 4.0.0 reportSetMap field to null */ public void flushReportSetMap() { this.reportSetMap = null; } /** * @return a Map of reportSets field with ReportSet#getId() as key * @see org.apache.maven.model.ReportSet#getId() */ public java.util.Map getReportSetsAsMap() { if ( reportSetMap == null ) { reportSetMap = new java.util.LinkedHashMap(); if ( getReportSets() != null ) { for ( java.util.Iterator i = getReportSets().iterator(); i.hasNext(); ) { ReportSet reportSet = (ReportSet) i.next(); reportSetMap.put( reportSet.getId(), reportSet ); } } } return reportSetMap; } /** * @return the key of the report plugin, ie groupId:artifactId */ public String getKey() { return constructKey( groupId, artifactId ); } /** * @param groupId * @param artifactId * @return the key of the report plugin, ie groupId:artifactId */ public static String constructKey( String groupId, String artifactId ) { return groupId + ":" + artifactId; } private boolean inheritanceApplied = true; public void unsetInheritanceApplied() { this.inheritanceApplied = false; } public boolean isInheritanceApplied() { return inheritanceApplied; } /** * @see java.lang.Object#equals(java.lang.Object) */ public boolean equals( Object other ) { if ( other instanceof ReportPlugin ) { ReportPlugin otherPlugin = (ReportPlugin) other; return getKey().equals( otherPlugin.getKey() ); } return false; } /** * @see java.lang.Object#hashCode() */ public int hashCode() { return getKey().hashCode(); } /** * @see java.lang.Object#toString() */ public String toString() { return "ReportPlugin [" + getKey() + "]"; } ]]> ReportSet 4.0.0 Represents a set of reports and configuration to be used to generate them. id String true The unique id for this report set, to be used during POM inheritance and profile injection for merging of report sets. default configuration 4.0.0 Configuration of the report to be used when generating this set. DOM inherited 4.0.0 String Whether any configuration should be propagated to child POMs. reports 4.0.0 true The list of reports from this plugin which should be generated from this set. String * 4.0.0 Prerequisites 4.0.0 Describes the prerequisites a project can have. maven 4.0.0 String 2.0 The minimum version of Maven required to build the project, or to use this plugin. false Relocation 4.0.0 Describes where an artifact has moved to. If any of the values are omitted, it is assumed to be the same as it was before. groupId 4.0.0 The group ID the artifact has moved to. String artifactId 4.0.0 The new artifact ID of the artifact. String version 4.0.0 The new version of the artifact. String message 4.0.0 An additional message to show the user about the move, such as the reason. String Extension 4.0.0 Describes a build extension to utilise. groupId 4.0.0 The group ID of the extension's artifact. true String artifactId 4.0.0 The artifact ID of the extension. true String version 4.0.0 The version of the extension. String 4.0.0 groupId:artifactId. */ public String getKey() { return new StringBuffer( 128 ).append( getGroupId() ).append( ':' ).append( getArtifactId() ).toString(); } /** * @see java.lang.Object#equals(java.lang.Object) */ public boolean equals( Object o ) { if ( this == o ) { return true; } if ( !( o instanceof Extension ) ) { return false; } Extension e = (Extension) o; if ( !equal( e.getArtifactId(), getArtifactId() ) ) { return false; } else if ( !equal( e.getGroupId(), getGroupId() ) ) { return false; } else if ( !equal( e.getVersion(), getVersion() ) ) { return false; } return true; } private static boolean equal( T obj1, T obj2 ) { return ( obj1 != null ) ? obj1.equals( obj2 ) : obj2 == null; } /** * @see java.lang.Object#hashCode() */ public int hashCode() { int result = 17; result = 37 * result + ( getArtifactId() != null ? getArtifactId().hashCode() : 0 ); result = 37 * result + ( getGroupId() != null ? getGroupId().hashCode() : 0 ); result = 37 * result + ( getVersion() != null ? getVersion().hashCode() : 0 ); return result; } ]]>
maven2-core-2.2.1/maven-model/project.properties0000644000175000017500000000276110555135606021574 0ustar twernertwerner# Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. The ASF licenses this file # to you under the Apache License, Version 2.0 (the # "License"); you may not use this file except in compliance # with the License. You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed on an # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY # KIND, either express or implied. See the License for the # specific language governing permissions and limitations # under the License. maven.repo.remote=http://cvs.apache.org/repository,http://www.ibiblio.org/maven maven.repo.list=apache.snapshots maven.repo.apache.snapshots=scp://cvs.apache.org maven.repo.apache.snapshots.directory=/www/cvs.apache.org/repository maven.repo.apache.snapshots.username=${maven.repo.apache.username} maven.repo.apache.snapshots.privatekey=${maven.repo.apache.privatekey} maven.repo.apache.snapshots.passphrase=${maven.repo.apache.passphrase} maven.repo.apache.snapshots.group=maven maven.repo.apache.releases=scp://people.apache.org maven.repo.apache.releases.directory=/www/www.apache.org/dist/java-repository maven.compile.source=1.4 maven.compile.target=1.4 # Modello settings maven.modello.model=${basedir}/src/main/mdo/maven.mdo maven2-core-2.2.1/maven-model/project.xml0000644000175000017500000000261210551365651020174 0ustar twernertwerner Maven Model maven maven-model 3.0.1 Maven Model Maven Model maven maven-modello-plugin 1.0-alpha-2 plugin plexus plexus-utils 1.0-alpha-3 maven2-core-2.2.1/maven-model/pom.xml0000644000175000017500000000625011236625310017313 0ustar twernertwerner 4.0.0 org.apache.maven maven 2.2.1 maven-model Maven Model Maven Model org.codehaus.plexus plexus-utils org.codehaus.modello modello-maven-plugin 4.0.0 src/main/mdo/maven.mdo maven-pmd-plugin 2.4 true all-models org.codehaus.modello modello-maven-plugin v3 xpp3-writer java xpp3-reader xsd 3.0.0 true maven-jar-plugin package jar all maven2-core-2.2.1/build.xml0000644000175000017500000003177211221205616015417 0ustar twernertwerner Using the local repository at: ${maven.repo.local} Using Maven home at: ${maven.home} maven.home = ${maven.home} maven.assembly = ${maven.assembly} The new Maven distribution was created as part of the MAVEN-COMPILE step, above. This goal just validates the presence of that distribution. Extracting assembly to ${maven.home.dirname} ... Retrieving integration tests Running integration tests Retrieving integration tests Running integration tests Integration-test results should be displayed above. Using temporary maven install directory: ${maven.home} maven2-core-2.2.1/maven-profile/0000755000175000017500000000000011250552243016333 5ustar twernertwernermaven2-core-2.2.1/maven-profile/src/0000755000175000017500000000000011250552243017122 5ustar twernertwernermaven2-core-2.2.1/maven-profile/src/site/0000755000175000017500000000000011250552243020066 5ustar twernertwernermaven2-core-2.2.1/maven-profile/src/site/site.xml0000644000175000017500000000013211002611514021540 0ustar twernertwerner maven2-core-2.2.1/maven-profile/src/main/0000755000175000017500000000000011250552243020046 5ustar twernertwernermaven2-core-2.2.1/maven-profile/src/main/mdo/0000755000175000017500000000000011250552242020624 5ustar twernertwernermaven2-core-2.2.1/maven-profile/src/main/mdo/profiles.mdo0000644000175000017500000003327711146611627023173 0ustar twernertwerner profiles Profiles package org.apache.maven.profiles ProfilesRoot 1.0.0 Root element of the profiles.xml file. profiles 1.0.0 Profile * activeProfiles 1.0.0 String * Profile 1.0.0 id true 1.0.0 String The ID of this build profile, for activation purposes. activation 1.0.0 Activation properties Extended configuration specific to this profile goes here. Properties String * repositories 1.0.0 Repository * pluginRepositories 1.0.0 Repository * Activation 1.0.0 activeByDefault 1.0.0 boolean Flag specifying whether this profile is active as a default. jdk 1.0.0 String os 1.0.0 ActivationOS property 1.0.0 ActivationProperty file 1.0.0 ActivationFile RepositoryBase 1.0.0 id 1.0.0 String name 1.0.0 String url 1.0.0 String layout 1.0.0 The type of layout this repository uses for locating and storing artifacts - can be "legacy" or "default". String default 1.0.0 Repository RepositoryBase 1.0.0 Repository contains the information needed for establishing connections with remote repoistory releases 1.0.0 How to handle downloading of releases from this repository RepositoryPolicy snapshots 1.0.0 How to handle downloading of snapshots from this repository RepositoryPolicy 1.0.0 RepositoryPolicy 1.0.0 Download policy enabled 1.0.0 Whether to use this repository for downloading this type of artifact boolean true updatePolicy 1.0.0 The frequency for downloading updates - can be "always", "daily" (default), "interval:XXX" (in minutes) or "never" (only if it doesn't exist locally). String checksumPolicy 1.0.0 What to do when verification of an artifact checksum fails - warn, fail, etc. Valid values are "fail" or "warn" String ActivationProperty 1.0.0 name 1.0.0 String true The name of the property to be used to activate a profile value 1.0.0 String The value of the property to be used to activate a profile ActivationFile 1.0.0 missing 1.0.0 String The name of the file that should be missing to activate a profile exists 1.0.0 String The name of the file that should exist to activate a profile ActivationOS 1.0.0 name 1.0.0 String The name of the OS to be used to activate a profile family 1.0.0 String The general family of the OS to be used to activate a profile (e.g. 'windows') arch 1.0.0 String The architecture of the OS to be used to activate a profile version 1.0.0 String The version of the OS to be used to activate a profile maven2-core-2.2.1/maven-profile/src/main/resources/0000755000175000017500000000000011250552243022060 5ustar twernertwernermaven2-core-2.2.1/maven-profile/src/main/resources/META-INF/0000755000175000017500000000000011250552243023220 5ustar twernertwernermaven2-core-2.2.1/maven-profile/src/main/resources/META-INF/plexus/0000755000175000017500000000000011250552243024540 5ustar twernertwernermaven2-core-2.2.1/maven-profile/src/main/resources/META-INF/plexus/components.xml0000644000175000017500000000204210772004567027456 0ustar twernertwerner org.apache.maven.profiles.MavenProfilesBuilder org.apache.maven.profiles.DefaultMavenProfilesBuilder maven2-core-2.2.1/maven-profile/src/main/java/0000755000175000017500000000000011250552242020766 5ustar twernertwernermaven2-core-2.2.1/maven-profile/src/main/java/org/0000755000175000017500000000000011250552242021555 5ustar twernertwernermaven2-core-2.2.1/maven-profile/src/main/java/org/apache/0000755000175000017500000000000011250552242022776 5ustar twernertwernermaven2-core-2.2.1/maven-profile/src/main/java/org/apache/maven/0000755000175000017500000000000011250552242024104 5ustar twernertwernermaven2-core-2.2.1/maven-profile/src/main/java/org/apache/maven/profiles/0000755000175000017500000000000011250552243025730 5ustar twernertwernermaven2-core-2.2.1/maven-profile/src/main/java/org/apache/maven/profiles/MavenProfilesBuilder.java0000644000175000017500000000236310772004567032671 0ustar twernertwernerpackage org.apache.maven.profiles; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import org.codehaus.plexus.util.xml.pull.XmlPullParserException; import java.io.File; import java.io.IOException; /** * @author jdcasey * @version $Id: MavenProfilesBuilder.java 640549 2008-03-24 20:05:11Z bentmann $ */ public interface MavenProfilesBuilder { String ROLE = MavenProfilesBuilder.class.getName(); ProfilesRoot buildProfiles( File basedir ) throws IOException, XmlPullParserException; } maven2-core-2.2.1/maven-profile/src/main/java/org/apache/maven/profiles/AlwaysOnActivation.java0000644000175000017500000000166310772004567032371 0ustar twernertwernerpackage org.apache.maven.profiles; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import org.apache.maven.model.Activation; public class AlwaysOnActivation extends Activation { } ././@LongLink0000000000000000000000000000015100000000000011562 Lustar rootrootmaven2-core-2.2.1/maven-profile/src/main/java/org/apache/maven/profiles/DefaultMavenProfilesBuilder.javamaven2-core-2.2.1/maven-profile/src/main/java/org/apache/maven/profiles/DefaultMavenProfilesBuilder.0000644000175000017500000000607411221205616033323 0ustar twernertwernerpackage org.apache.maven.profiles; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import org.apache.maven.profiles.io.xpp3.ProfilesXpp3Reader; import org.codehaus.plexus.interpolation.EnvarBasedValueSource; import org.codehaus.plexus.interpolation.RegexBasedInterpolator; import org.codehaus.plexus.logging.AbstractLogEnabled; import org.codehaus.plexus.util.IOUtil; import org.codehaus.plexus.util.ReaderFactory; import org.codehaus.plexus.util.xml.pull.XmlPullParserException; import java.io.File; import java.io.IOException; import java.io.Reader; import java.io.StringReader; import java.io.StringWriter; public class DefaultMavenProfilesBuilder extends AbstractLogEnabled implements MavenProfilesBuilder { private static final String PROFILES_XML_FILE = "profiles.xml"; public ProfilesRoot buildProfiles( File basedir ) throws IOException, XmlPullParserException { File profilesXml = new File( basedir, PROFILES_XML_FILE ); ProfilesRoot profilesRoot = null; if ( profilesXml.exists() ) { ProfilesXpp3Reader reader = new ProfilesXpp3Reader(); Reader profileReader = null; try { profileReader = ReaderFactory.newXmlReader( profilesXml ); StringWriter sWriter = new StringWriter(); IOUtil.copy( profileReader, sWriter ); String rawInput = sWriter.toString(); try { RegexBasedInterpolator interpolator = new RegexBasedInterpolator(); interpolator.addValueSource( new EnvarBasedValueSource() ); rawInput = interpolator.interpolate( rawInput, "settings" ); } catch ( Exception e ) { getLogger().warn( "Failed to initialize environment variable resolver. Skipping environment substitution in " + PROFILES_XML_FILE + "." ); getLogger().debug( "Failed to initialize envar resolver. Skipping resolution.", e ); } StringReader sReader = new StringReader( rawInput ); profilesRoot = reader.read( sReader ); } finally { IOUtil.close( profileReader ); } } return profilesRoot; } } ././@LongLink0000000000000000000000000000014500000000000011565 Lustar rootrootmaven2-core-2.2.1/maven-profile/src/main/java/org/apache/maven/profiles/ProfilesConversionUtils.javamaven2-core-2.2.1/maven-profile/src/main/java/org/apache/maven/profiles/ProfilesConversionUtils.java0000644000175000017500000001215011133716012033440 0ustar twernertwernerpackage org.apache.maven.profiles; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import org.apache.maven.model.Activation; import org.apache.maven.model.ActivationFile; import org.apache.maven.model.ActivationProperty; import org.apache.maven.model.Profile; import org.apache.maven.model.Repository; import java.util.Iterator; import java.util.List; public class ProfilesConversionUtils { private ProfilesConversionUtils() { } public static Profile convertFromProfileXmlProfile( org.apache.maven.profiles.Profile profileXmlProfile ) { Profile profile = new Profile(); profile.setId( profileXmlProfile.getId() ); profile.setSource( "profiles.xml" ); org.apache.maven.profiles.Activation profileActivation = profileXmlProfile.getActivation(); if ( profileActivation != null ) { Activation activation = new Activation(); activation.setActiveByDefault( profileActivation.isActiveByDefault() ); activation.setJdk( profileActivation.getJdk() ); org.apache.maven.profiles.ActivationProperty profileProp = profileActivation.getProperty(); if ( profileProp != null ) { ActivationProperty prop = new ActivationProperty(); prop.setName( profileProp.getName() ); prop.setValue( profileProp.getValue() ); activation.setProperty( prop ); } ActivationOS profileOs = profileActivation.getOs(); if ( profileOs != null ) { org.apache.maven.model.ActivationOS os = new org.apache.maven.model.ActivationOS(); os.setArch( profileOs.getArch() ); os.setFamily( profileOs.getFamily() ); os.setName( profileOs.getName() ); os.setVersion( profileOs.getVersion() ); activation.setOs( os ); } org.apache.maven.profiles.ActivationFile profileFile = profileActivation.getFile(); if ( profileFile != null ) { ActivationFile file = new ActivationFile(); file.setExists( profileFile.getExists() ); file.setMissing( profileFile.getMissing() ); activation.setFile( file ); } profile.setActivation( activation ); } profile.setProperties( profileXmlProfile.getProperties() ); List repos = profileXmlProfile.getRepositories(); if ( repos != null ) { for ( Iterator it = repos.iterator(); it.hasNext(); ) { profile .addRepository( convertFromProfileXmlRepository( (org.apache.maven.profiles.Repository) it.next() ) ); } } List pluginRepos = profileXmlProfile.getPluginRepositories(); if ( pluginRepos != null ) { for ( Iterator it = pluginRepos.iterator(); it.hasNext(); ) { profile.addPluginRepository( convertFromProfileXmlRepository( (org.apache.maven.profiles.Repository) it .next() ) ); } } return profile; } private static Repository convertFromProfileXmlRepository( org.apache.maven.profiles.Repository profileXmlRepo ) { Repository repo = new Repository(); repo.setId( profileXmlRepo.getId() ); repo.setLayout( profileXmlRepo.getLayout() ); repo.setName( profileXmlRepo.getName() ); repo.setUrl( profileXmlRepo.getUrl() ); if ( profileXmlRepo.getSnapshots() != null ) { repo.setSnapshots( convertRepositoryPolicy( profileXmlRepo.getSnapshots() ) ); } if ( profileXmlRepo.getReleases() != null ) { repo.setReleases( convertRepositoryPolicy( profileXmlRepo.getReleases() ) ); } return repo; } private static org.apache.maven.model.RepositoryPolicy convertRepositoryPolicy( RepositoryPolicy profileXmlRepo ) { org.apache.maven.model.RepositoryPolicy policy = new org.apache.maven.model.RepositoryPolicy(); policy.setEnabled( profileXmlRepo.isEnabled() ); policy.setUpdatePolicy( profileXmlRepo.getUpdatePolicy() ); policy.setChecksumPolicy( profileXmlRepo.getChecksumPolicy() ); return policy; } } maven2-core-2.2.1/maven-profile/pom.xml0000644000175000017500000000417311236625310017655 0ustar twernertwerner 4.0.0 org.apache.maven maven 2.2.1 maven-profile Maven Profile Model org.apache.maven maven-model org.codehaus.plexus plexus-utils org.codehaus.plexus plexus-interpolation org.codehaus.plexus plexus-container-default org.codehaus.modello modello-maven-plugin 1.0.0 src/main/mdo/profiles.mdo maven2-core-2.2.1/maven-core-it-runner/0000755000175000017500000000000011250552246017547 5ustar twernertwernermaven2-core-2.2.1/maven-core-it-runner/src/0000755000175000017500000000000011250552246020336 5ustar twernertwernermaven2-core-2.2.1/maven-core-it-runner/src/site/0000755000175000017500000000000011250552246021302 5ustar twernertwernermaven2-core-2.2.1/maven-core-it-runner/src/site/site.xml0000644000175000017500000000013211002611514022751 0ustar twernertwerner maven2-core-2.2.1/maven-core-it-runner/src/test/0000755000175000017500000000000011250552246021315 5ustar twernertwernermaven2-core-2.2.1/maven-core-it-runner/src/test/java/0000755000175000017500000000000011250552246022236 5ustar twernertwernermaven2-core-2.2.1/maven-core-it-runner/src/test/java/org/0000755000175000017500000000000011250552246023025 5ustar twernertwernermaven2-core-2.2.1/maven-core-it-runner/src/test/java/org/apache/0000755000175000017500000000000011250552246024246 5ustar twernertwernermaven2-core-2.2.1/maven-core-it-runner/src/test/java/org/apache/maven/0000755000175000017500000000000011250552246025354 5ustar twernertwernermaven2-core-2.2.1/maven-core-it-runner/src/test/java/org/apache/maven/its/0000755000175000017500000000000011250552246026153 5ustar twernertwernermaven2-core-2.2.1/maven-core-it-runner/src/test/java/org/apache/maven/its/Suite.java0000644000175000017500000000055211070537325030112 0ustar twernertwernerpackage org.apache.maven.its; import junit.framework.Test; import junit.framework.TestCase; import org.apache.maven.it.IntegrationTestSuite; import org.apache.maven.it.VerificationException; public class Suite extends TestCase { public static Test suite() throws VerificationException { return IntegrationTestSuite.suite(); } } maven2-core-2.2.1/maven-core-it-runner/pom.xml0000644000175000017500000001344411232277427021077 0ustar twernertwerner 4.0.0 org.apache.maven 2.2.1-RC2-SNAPSHOT maven-core-it-runner Integration Test Executor scm:svn:http://svn.apache.org/repos/asf/maven/maven-2/branches/maven-2.2.x/maven-core-it-runner scm:svn:https://svn.apache.org/repos/asf/maven/maven-2/branches/maven-2.2.x/maven-core-it-runner http://svn.apache.org/viewvc/maven/maven-2/branches/maven-2.2.x/maven-core-it-runner test-plugins http://people.apache.org/repo/m2-snapshot-repository/ false true org.apache.maven apache-maven ${project.version} bin tar.gz org.apache.maven.its core-it-suite 2.1-SNAPSHOT tests test maven-dependency-plugin org.apache.maven apache-maven ${project.version} bin tar.gz target/maven-installation unpack maven-antrun-plugin process-sources run no-local-repo-defined true maven-surefire-plugin 2.3 maven.home ${basedir}/target/maven-installation/apache-maven-${project.version} maven.test.tmpdir ${basedir}/target/it-working-folder **/Suite.java local-repo-defined maven.repo.local maven-surefire-plugin 2.3 maven.home ${basedir}/target/maven-installation/apache-maven-${project.version} maven.test.tmpdir ${basedir}/target/it-working-folder maven.repo.local ${maven.repo.local} **/Suite.java maven2-core-2.2.1/maven-script/0000755000175000017500000000000011250552243016177 5ustar twernertwernermaven2-core-2.2.1/maven-script/src/0000755000175000017500000000000011250552243016766 5ustar twernertwernermaven2-core-2.2.1/maven-script/src/site/0000755000175000017500000000000011250552243017732 5ustar twernertwernermaven2-core-2.2.1/maven-script/src/site/site.xml0000644000175000017500000000016411002611514021411 0ustar twernertwerner maven2-core-2.2.1/maven-script/maven-script-ant/0000755000175000017500000000000011250552243021367 5ustar twernertwernermaven2-core-2.2.1/maven-script/maven-script-ant/src/0000755000175000017500000000000011250552243022156 5ustar twernertwernermaven2-core-2.2.1/maven-script/maven-script-ant/src/site/0000755000175000017500000000000011250552243023122 5ustar twernertwernermaven2-core-2.2.1/maven-script/maven-script-ant/src/site/site.xml0000644000175000017500000000013211002611514024574 0ustar twernertwerner maven2-core-2.2.1/maven-script/maven-script-ant/src/test/0000755000175000017500000000000011250552243023135 5ustar twernertwernermaven2-core-2.2.1/maven-script/maven-script-ant/src/test/resources/0000755000175000017500000000000011250552243025147 5ustar twernertwernermaven2-core-2.2.1/maven-script/maven-script-ant/src/test/resources/META-INF/0000755000175000017500000000000011250552243026307 5ustar twernertwernermaven2-core-2.2.1/maven-script/maven-script-ant/src/test/resources/META-INF/maven/0000755000175000017500000000000011250552243027415 5ustar twernertwernermaven2-core-2.2.1/maven-script/maven-script-ant/src/test/resources/META-INF/maven/plugin-2.1.xml0000644000175000017500000000455711144676102031751 0ustar twernertwerner Test Plugin org.myplugin my-plugin 1 myplugin false true test Build a JAR from the current project. false false false false false true test.build.xml:test ant per-lookup once-per-session basedir true false java.io.File messageLevel true false java.lang.String project true false org.apache.maven.project.MavenProject session true false org.apache.maven.execution.MavenSession mojoExecution true false org.apache.maven.plugin.MojoExecution ${project} ${session} ${mojoExecution} ${basedir} ${messageLevel} org.apache.maven.project.path.PathTranslator maven2-core-2.2.1/maven-script/maven-script-ant/src/test/resources/META-INF/maven/plugin-2.0.xml0000644000175000017500000000265611144676102031746 0ustar twernertwerner Test Plugin org.myplugin my-plugin 1 myplugin false true test Build a JAR from the current project. false false false false false true test.build.xml:test ant per-lookup once-per-session basedir true false java.io.File messageLevel true false java.lang.String ${basedir} ${messageLevel} maven2-core-2.2.1/maven-script/maven-script-ant/src/test/resources/test.build.xml0000644000175000017500000000066611144676102027761 0ustar twernertwerner plugin classpath is: ${cp} maven2-core-2.2.1/maven-script/maven-script-ant/src/test/java/0000755000175000017500000000000011250552243024056 5ustar twernertwernermaven2-core-2.2.1/maven-script/maven-script-ant/src/test/java/org/0000755000175000017500000000000011250552243024645 5ustar twernertwernermaven2-core-2.2.1/maven-script/maven-script-ant/src/test/java/org/apache/0000755000175000017500000000000011250552243026066 5ustar twernertwernermaven2-core-2.2.1/maven-script/maven-script-ant/src/test/java/org/apache/maven/0000755000175000017500000000000011250552243027174 5ustar twernertwernermaven2-core-2.2.1/maven-script/maven-script-ant/src/test/java/org/apache/maven/script/0000755000175000017500000000000011250552243030500 5ustar twernertwernermaven2-core-2.2.1/maven-script/maven-script-ant/src/test/java/org/apache/maven/script/ant/0000755000175000017500000000000011250552243031262 5ustar twernertwerner././@LongLink0000000000000000000000000000016200000000000011564 Lustar rootrootmaven2-core-2.2.1/maven-script/maven-script-ant/src/test/java/org/apache/maven/script/ant/AntMojoWrapperTest.javamaven2-core-2.2.1/maven-script/maven-script-ant/src/test/java/org/apache/maven/script/ant/AntMojoWra0000644000175000017500000002402011144676102033227 0ustar twernertwernerpackage org.apache.maven.script.ant; import org.apache.maven.artifact.Artifact; import org.apache.maven.execution.MavenSession; import org.apache.maven.model.Build; import org.apache.maven.model.Model; import org.apache.maven.plugin.MojoExecution; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.descriptor.MojoDescriptor; import org.apache.maven.plugin.descriptor.PluginDescriptor; import org.apache.maven.plugin.descriptor.PluginDescriptorBuilder; import org.apache.maven.project.MavenProject; import org.apache.maven.project.path.PathTranslator; import org.apache.tools.ant.BuildEvent; import org.apache.tools.ant.BuildListener; import org.codehaus.plexus.archiver.ArchiverException; import org.codehaus.plexus.archiver.jar.JarArchiver; import org.codehaus.plexus.component.configurator.ComponentConfigurationException; import org.codehaus.plexus.component.factory.ComponentInstantiationException; import org.codehaus.plexus.component.factory.ant.AntScriptInvoker; import org.codehaus.plexus.component.repository.ComponentRequirement; import org.codehaus.plexus.configuration.PlexusConfigurationException; import org.codehaus.plexus.logging.Logger; import org.codehaus.plexus.logging.console.ConsoleLogger; import org.codehaus.plexus.util.IOUtil; import org.codehaus.plexus.util.StringUtils; import org.easymock.MockControl; import java.io.ByteArrayOutputStream; import java.io.File; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintStream; import java.io.Reader; import java.net.URL; import java.util.ArrayList; import java.util.Collections; import java.util.HashMap; import java.util.Iterator; import java.util.List; import java.util.Map; import junit.framework.TestCase; public class AntMojoWrapperTest extends TestCase { public void test2xStylePlugin() throws PlexusConfigurationException, IOException, ComponentInstantiationException, MojoExecutionException, ComponentConfigurationException, ArchiverException { String pluginXml = "META-INF/maven/plugin-2.1.xml"; List messages = run( pluginXml, true ); assertPresence( messages, "Unpacked Ant build scripts (in Maven build directory).", false ); assertPresence( messages, "Maven parameter expression evaluator for Ant properties.", false ); assertPresence( messages, "Maven standard project-based classpath references.", false ); assertPresence( messages, "Maven standard plugin-based classpath references.", false ); assertPresence( messages, "Maven project, session, mojo-execution, or path-translation parameter information is", false ); assertPresence( messages, "maven-script-ant < 2.1.0, or used maven-plugin-tools-ant < 2.2 during release", false ); assertPresence( messages, "path-is-missing", false ); } public void test20StylePlugin() throws PlexusConfigurationException, IOException, ComponentInstantiationException, MojoExecutionException, ComponentConfigurationException, ArchiverException { String pluginXml = "META-INF/maven/plugin-2.0.xml"; List messages = run( pluginXml, false ); assertPresence( messages, "Unpacked Ant build scripts (in Maven build directory).", true ); assertPresence( messages, "Maven parameter expression evaluator for Ant properties.", true ); assertPresence( messages, "Maven standard project-based classpath references.", true ); assertPresence( messages, "Maven standard plugin-based classpath references.", true ); assertPresence( messages, "Maven project, session, mojo-execution, or path-translation parameter information is", true ); assertPresence( messages, "maven-script-ant < 2.1.0, or used maven-plugin-tools-ant < 2.2 during release", true ); assertPresence( messages, "path-is-missing", true ); } private void assertPresence( List messages, String test, boolean shouldBePresent ) { boolean found = false; for ( Iterator it = messages.iterator(); it.hasNext(); ) { String message = (String) it.next(); if ( message.indexOf( test ) > -1 ) { found = true; break; } } if ( !shouldBePresent && found ) { fail( "Test string: '" + test + "' was found in output, but SHOULD NOT BE THERE." ); } else if ( shouldBePresent && !found ) { fail( "Test string: '" + test + "' was NOT found in output, but SHOULD BE THERE." ); } } private List run( String pluginXml, boolean includeImplied ) throws PlexusConfigurationException, IOException, ComponentInstantiationException, MojoExecutionException, ComponentConfigurationException, ArchiverException { StackTraceElement stack = new Throwable().getStackTrace()[1]; System.out.println( "\n\nRunning: " + stack.getMethodName() + "\n\n" ); URL resource = Thread.currentThread().getContextClassLoader().getResource( pluginXml ); if ( resource == null ) { fail( "plugin descriptor not found: '" + pluginXml + "'." ); } Reader reader = null; PluginDescriptor pd; try { reader = new InputStreamReader( resource.openStream() ); pd = new PluginDescriptorBuilder().build( reader, pluginXml ); } finally { IOUtil.close( reader ); } Map config = new HashMap(); config.put( "basedir", new File( "." ).getAbsoluteFile() ); config.put( "messageLevel", "info" ); MojoDescriptor md = pd.getMojo( "test" ); AntMojoWrapper wrapper = new AntMojoWrapper( new AntScriptInvoker( md, Thread.currentThread().getContextClassLoader() ) ); wrapper.enableLogging( new ConsoleLogger( Logger.LEVEL_DEBUG, "test" ) ); MockControl artifactCtl = null; MockControl pathTranslatorCtl = null; if ( includeImplied ) { File pluginXmlFile = new File( StringUtils.replace( resource.getPath(), "%20", " " ) ); File jarFile = File.createTempFile( "AntMojoWrapperTest.", ".test.jar" ); jarFile.deleteOnExit(); JarArchiver archiver = new JarArchiver(); archiver.enableLogging( new ConsoleLogger( Logger.LEVEL_ERROR, "archiver" ) ); archiver.setDestFile( jarFile ); archiver.addFile( pluginXmlFile, pluginXml ); archiver.createArchive(); artifactCtl = MockControl.createControl( Artifact.class ); Artifact artifact = (Artifact) artifactCtl.getMock(); artifact.getFile(); artifactCtl.setReturnValue( jarFile, MockControl.ZERO_OR_MORE ); artifact.getGroupId(); artifactCtl.setReturnValue( "groupId", MockControl.ZERO_OR_MORE ); artifact.getArtifactId(); artifactCtl.setReturnValue( "artifactId", MockControl.ZERO_OR_MORE ); artifact.getVersion(); artifactCtl.setReturnValue( "1", MockControl.ZERO_OR_MORE ); artifact.getId(); artifactCtl.setReturnValue( "groupId:artifactId:jar:1", MockControl.ZERO_OR_MORE ); artifact.getClassifier(); artifactCtl.setReturnValue( null, MockControl.ZERO_OR_MORE ); pathTranslatorCtl = MockControl.createControl( PathTranslator.class ); PathTranslator pt = (PathTranslator) pathTranslatorCtl.getMock(); Model model = new Model(); Build build = new Build(); build.setDirectory( "target" ); model.setBuild( build ); MavenProject project = new MavenProject( model ); project.setFile( new File( "pom.xml" ).getAbsoluteFile() ); artifactCtl.replay(); pathTranslatorCtl.replay(); pd.setPluginArtifact( artifact ); pd.setArtifacts( Collections.singletonList( artifact ) ); config.put( "project", project ); config.put( "session", new MavenSession( null, null, null, null, null, null, null, null, null, null ) ); config.put( "mojoExecution", new MojoExecution( md ) ); ComponentRequirement cr = new ComponentRequirement(); cr.setRole( PathTranslator.class.getName() ); wrapper.addComponentRequirement( cr, pt ); } wrapper.setComponentConfiguration( config ); TestBuildListener tbl = new TestBuildListener(); wrapper.getAntProject().addBuildListener( tbl ); PrintStream oldOut = System.out; ByteArrayOutputStream baos = new ByteArrayOutputStream(); try { System.setOut( new PrintStream( baos ) ); wrapper.execute(); } finally { System.setOut( oldOut ); } System.out.println( "\n\n" + stack.getMethodName() + " executed; verifying...\n\n" ); if ( includeImplied ) { artifactCtl.verify(); pathTranslatorCtl.verify(); } List messages = new ArrayList(); if ( !tbl.messages.isEmpty() ) { messages.addAll( tbl.messages ); } messages.add( new String( baos.toByteArray() ) ); return messages; } private static final class TestBuildListener implements BuildListener { private List messages = new ArrayList(); public void buildFinished( BuildEvent arg0 ) { } public void buildStarted( BuildEvent arg0 ) { } public void messageLogged( BuildEvent event ) { messages.add( event.getMessage() ); } public void targetFinished( BuildEvent arg0 ) { } public void targetStarted( BuildEvent arg0 ) { } public void taskFinished( BuildEvent arg0 ) { } public void taskStarted( BuildEvent arg0 ) { } }; } maven2-core-2.2.1/maven-script/maven-script-ant/src/main/0000755000175000017500000000000011250552243023102 5ustar twernertwernermaven2-core-2.2.1/maven-script/maven-script-ant/src/main/resources/0000755000175000017500000000000011250552243025114 5ustar twernertwernermaven2-core-2.2.1/maven-script/maven-script-ant/src/main/resources/META-INF/0000755000175000017500000000000011250552243026254 5ustar twernertwernermaven2-core-2.2.1/maven-script/maven-script-ant/src/main/resources/META-INF/plexus/0000755000175000017500000000000011250552243027574 5ustar twernertwernermaven2-core-2.2.1/maven-script/maven-script-ant/src/main/resources/META-INF/plexus/components.xml0000644000175000017500000000205310772004567032514 0ustar twernertwerner org.codehaus.plexus.component.factory.ComponentFactory org.apache.maven.script.ant.AntMojoComponentFactory ant-mojo maven2-core-2.2.1/maven-script/maven-script-ant/src/main/java/0000755000175000017500000000000011250552243024023 5ustar twernertwernermaven2-core-2.2.1/maven-script/maven-script-ant/src/main/java/org/0000755000175000017500000000000011250552243024612 5ustar twernertwernermaven2-core-2.2.1/maven-script/maven-script-ant/src/main/java/org/apache/0000755000175000017500000000000011250552243026033 5ustar twernertwernermaven2-core-2.2.1/maven-script/maven-script-ant/src/main/java/org/apache/maven/0000755000175000017500000000000011250552243027141 5ustar twernertwernermaven2-core-2.2.1/maven-script/maven-script-ant/src/main/java/org/apache/maven/script/0000755000175000017500000000000011250552243030445 5ustar twernertwernermaven2-core-2.2.1/maven-script/maven-script-ant/src/main/java/org/apache/maven/script/ant/0000755000175000017500000000000011250552243031227 5ustar twernertwerner././@LongLink0000000000000000000000000000016700000000000011571 Lustar rootrootmaven2-core-2.2.1/maven-script/maven-script-ant/src/main/java/org/apache/maven/script/ant/AntMojoComponentFactory.javamaven2-core-2.2.1/maven-script/maven-script-ant/src/main/java/org/apache/maven/script/ant/AntMojoCom0000644000175000017500000000304110772004567033167 0ustar twernertwernerpackage org.apache.maven.script.ant; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import org.codehaus.classworlds.ClassRealm; import org.codehaus.plexus.PlexusContainer; import org.codehaus.plexus.component.factory.ComponentInstantiationException; import org.codehaus.plexus.component.factory.ant.AntComponentFactory; import org.codehaus.plexus.component.factory.ant.AntScriptInvoker; import org.codehaus.plexus.component.repository.ComponentDescriptor; public class AntMojoComponentFactory extends AntComponentFactory { public Object newInstance( ComponentDescriptor descriptor, ClassRealm realm, PlexusContainer container ) throws ComponentInstantiationException { return new AntMojoWrapper( (AntScriptInvoker) super.newInstance( descriptor, realm, container ) ); } } ././@LongLink0000000000000000000000000000015600000000000011567 Lustar rootrootmaven2-core-2.2.1/maven-script/maven-script-ant/src/main/java/org/apache/maven/script/ant/AntMojoWrapper.javamaven2-core-2.2.1/maven-script/maven-script-ant/src/main/java/org/apache/maven/script/ant/AntMojoWra0000644000175000017500000003050711144676102033203 0ustar twernertwernerpackage org.apache.maven.script.ant; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.DependencyResolutionRequiredException; import org.apache.maven.execution.MavenSession; import org.apache.maven.plugin.AbstractMojo; import org.apache.maven.plugin.ContextEnabled; import org.apache.maven.plugin.MojoExecution; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.PluginParameterExpressionEvaluator; import org.apache.maven.plugin.descriptor.PluginDescriptor; import org.apache.maven.project.MavenProject; import org.apache.maven.project.path.PathTranslator; import org.apache.tools.ant.Project; import org.apache.tools.ant.PropertyHelper; import org.apache.tools.ant.types.Path; import org.codehaus.plexus.archiver.ArchiverException; import org.codehaus.plexus.archiver.UnArchiver; import org.codehaus.plexus.archiver.zip.ZipUnArchiver; import org.codehaus.plexus.component.MapOrientedComponent; import org.codehaus.plexus.component.configurator.ComponentConfigurationException; import org.codehaus.plexus.component.configurator.expression.ExpressionEvaluator; import org.codehaus.plexus.component.factory.ant.AntComponentExecutionException; import org.codehaus.plexus.component.factory.ant.AntScriptInvoker; import org.codehaus.plexus.component.repository.ComponentRequirement; import org.codehaus.plexus.logging.LogEnabled; import org.codehaus.plexus.logging.Logger; import org.codehaus.plexus.util.StringUtils; import java.io.File; import java.util.ArrayList; import java.util.Collection; import java.util.HashMap; import java.util.Iterator; import java.util.List; import java.util.Map; public class AntMojoWrapper extends AbstractMojo implements ContextEnabled, MapOrientedComponent, LogEnabled { private Map pluginContext; private final AntScriptInvoker scriptInvoker; private Project antProject; private MavenProject mavenProject; private MojoExecution mojoExecution; private MavenSession session; private PathTranslator pathTranslator; private Logger logger; private transient List unconstructedParts = new ArrayList(); public AntMojoWrapper( AntScriptInvoker scriptInvoker ) { this.scriptInvoker = scriptInvoker; } public void execute() throws MojoExecutionException { if ( antProject == null ) { antProject = scriptInvoker.getProject(); } Map allConfig = new HashMap(); if ( pluginContext != null && !pluginContext.isEmpty() ) { allConfig.putAll( pluginContext ); } Map refs = scriptInvoker.getReferences(); if ( refs != null ) { allConfig.putAll( refs ); for ( Iterator it = refs.entrySet().iterator(); it.hasNext(); ) { Map.Entry entry = (Map.Entry) it.next(); String key = (String) entry.getKey(); if ( key.startsWith( PathTranslator.class.getName() ) ) { pathTranslator = (PathTranslator) entry.getValue(); } } } mavenProject = (MavenProject) allConfig.get( "project" ); mojoExecution = (MojoExecution) allConfig.get( "mojoExecution" ); session = (MavenSession) allConfig.get( "session" ); unpackFileBasedResources(); addClasspathReferences(); if ( logger.isDebugEnabled() && !unconstructedParts.isEmpty() ) { StringBuffer buffer = new StringBuffer(); buffer.append( "The following standard Maven Ant-mojo support objects could not be created:\n\n" ); for ( Iterator it = unconstructedParts.iterator(); it.hasNext(); ) { String part = (String) it.next(); buffer.append( "\n- " ).append( part ); } buffer.append( "\n\nMaven project, session, mojo-execution, or path-translation parameter information is " ); buffer.append( "\nmissing from this mojo's plugin descriptor." ); buffer.append( "\n\nPerhaps this Ant-based mojo depends on maven-script-ant < 2.1.0, " ); buffer.append( "or used maven-plugin-tools-ant < 2.2 during release?\n\n" ); logger.debug( buffer.toString() ); } try { scriptInvoker.invoke(); } catch ( AntComponentExecutionException e ) { throw new MojoExecutionException( "Failed to execute: " + e.getMessage(), e ); } unconstructedParts.clear(); } public void setPluginContext( Map pluginContext ) { this.pluginContext = pluginContext; } public Map getPluginContext() { return pluginContext; } public void addComponentRequirement( ComponentRequirement requirementDescriptor, Object requirementValue ) throws ComponentConfigurationException { scriptInvoker.addComponentRequirement( requirementDescriptor, requirementValue ); } public void setComponentConfiguration( Map componentConfiguration ) throws ComponentConfigurationException { scriptInvoker.setComponentConfiguration( componentConfiguration ); antProject = scriptInvoker.getProject(); } private void unpackFileBasedResources() throws MojoExecutionException { if ( mojoExecution == null || mavenProject == null ) { unconstructedParts.add( "Unpacked Ant build scripts (in Maven build directory)." ); return; } // What we need to write out any resources in the plugin to the target directory of the // mavenProject using the Ant-based plugin: // // 1. Need a reference to the plugin JAR itself // 2. Need a reference to the ${basedir} of the mavenProject PluginDescriptor pluginDescriptor = mojoExecution.getMojoDescriptor().getPluginDescriptor(); File pluginJar = pluginDescriptor.getPluginArtifact().getFile(); String resourcesPath = pluginDescriptor.getArtifactId(); File outputDirectory = new File( mavenProject.getBuild().getDirectory() ); try { UnArchiver ua = new ZipUnArchiver( pluginJar ); ua.extract( resourcesPath, outputDirectory ); } catch ( ArchiverException e ) { throw new MojoExecutionException( "Error extracting resources from your Ant-based plugin.", e ); } } private void addClasspathReferences() throws MojoExecutionException { try { if ( mavenProject != null && session != null && pathTranslator != null ) { ExpressionEvaluator exprEvaluator = new PluginParameterExpressionEvaluator( session, mojoExecution, pathTranslator, logger, mavenProject, mavenProject.getProperties() ); PropertyHelper propertyHelper = PropertyHelper.getPropertyHelper( antProject ); propertyHelper.setNext( new AntPropertyHelper( exprEvaluator, mavenProject.getArtifacts(), getLog() ) ); } else { unconstructedParts.add( "Maven parameter expression evaluator for Ant properties." ); } if ( mavenProject != null ) { // Compile classpath Path p = new Path( antProject ); p.setPath( StringUtils.join( mavenProject.getCompileClasspathElements().iterator(), File.pathSeparator ) ); /* maven.dependency.classpath it's deprecated as it's equal to maven.compile.classpath */ scriptInvoker.getReferences().put( "maven.dependency.classpath", p ); antProject.addReference( "maven.dependency.classpath", p ); scriptInvoker.getReferences().put( "maven.compile.classpath", p ); antProject.addReference( "maven.compile.classpath", p ); // Runtime classpath p = new Path( antProject ); p.setPath( StringUtils.join( mavenProject.getRuntimeClasspathElements().iterator(), File.pathSeparator ) ); scriptInvoker.getReferences().put( "maven.runtime.classpath", p ); antProject.addReference( "maven.runtime.classpath", p ); // Test classpath p = new Path( antProject ); p.setPath( StringUtils.join( mavenProject.getTestClasspathElements().iterator(), File.pathSeparator ) ); scriptInvoker.getReferences().put( "maven.test.classpath", p ); antProject.addReference( "maven.test.classpath", p ); } else { unconstructedParts.add( "Maven standard project-based classpath references." ); } if ( mojoExecution != null ) { // Plugin dependency classpath Path p = getPathFromArtifacts( mojoExecution.getMojoDescriptor().getPluginDescriptor().getArtifacts(), antProject ); scriptInvoker.getReferences().put( "maven.plugin.classpath", p ); antProject.addReference( "maven.plugin.classpath", p ); } else { unconstructedParts.add( "Maven standard plugin-based classpath references." ); } } catch ( DependencyResolutionRequiredException e ) { throw new MojoExecutionException( "Error creating classpath references for Ant-based plugin scripts.", e ); } } public Path getPathFromArtifacts( Collection artifacts, Project antProject ) throws DependencyResolutionRequiredException { List list = new ArrayList( artifacts.size() ); for ( Iterator i = artifacts.iterator(); i.hasNext(); ) { Artifact a = (Artifact) i.next(); File file = a.getFile(); if ( file == null ) { throw new DependencyResolutionRequiredException( a ); } list.add( file.getPath() ); } Path p = new Path( antProject ); p.setPath( StringUtils.join( list.iterator(), File.pathSeparator ) ); return p; } public Project getAntProject() { return antProject; } public void setAntProject( Project antProject ) { this.antProject = antProject; } public MavenProject getMavenProject() { return mavenProject; } public void setMavenProject( MavenProject mavenProject ) { this.mavenProject = mavenProject; } public MojoExecution getMojoExecution() { return mojoExecution; } public void setMojoExecution( MojoExecution mojoExecution ) { this.mojoExecution = mojoExecution; } public MavenSession getSession() { return session; } public void setSession( MavenSession session ) { this.session = session; } public PathTranslator getPathTranslator() { return pathTranslator; } public void setPathTranslator( PathTranslator pathTranslator ) { this.pathTranslator = pathTranslator; } public AntScriptInvoker getScriptInvoker() { return scriptInvoker; } public void enableLogging( Logger logger ) { this.logger = logger; } } ././@LongLink0000000000000000000000000000016100000000000011563 Lustar rootrootmaven2-core-2.2.1/maven-script/maven-script-ant/src/main/java/org/apache/maven/script/ant/AntPropertyHelper.javamaven2-core-2.2.1/maven-script/maven-script-ant/src/main/java/org/apache/maven/script/ant/AntPropert0000644000175000017500000001377511144676102033270 0ustar twernertwernerpackage org.apache.maven.script.ant; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import java.io.File; import java.util.Collections; import java.util.Hashtable; import java.util.Iterator; import java.util.Map; import java.util.Set; import org.apache.maven.artifact.Artifact; import org.apache.maven.plugin.logging.Log; import org.apache.maven.project.MavenProject; import org.apache.tools.ant.PropertyHelper; import org.codehaus.plexus.component.configurator.expression.ExpressionEvaluationException; import org.codehaus.plexus.component.configurator.expression.ExpressionEvaluator; import org.codehaus.plexus.util.introspection.ReflectionValueExtractor; /** * Makes the ${expressions} used in Maven available to Ant as properties. * * @author Kenney Westerhof */ public class AntPropertyHelper extends PropertyHelper { private static final String DEPENDENCY_PREFIX = "maven.dependency."; private Log log; private ExpressionEvaluator exprEvaluator; private MavenProject mavenProject; private Map artifactMap = new Hashtable(); /** * @deprecated use the other constructor * @param project * @param l */ public AntPropertyHelper( MavenProject project, Log l ) { mavenProject = project; log = l; } /** * @deprecated use {@link #AntPropertyHelper(ExpressionEvaluator, Set, Log)} to resolve maven.dependency.* properties * @param exprEvaluator * @param l */ public AntPropertyHelper( ExpressionEvaluator exprEvaluator, Log l ) { this( exprEvaluator, Collections.EMPTY_SET, l ); } /** * @param exprEvaluator * @param artifacts * @param l */ public AntPropertyHelper( ExpressionEvaluator exprEvaluator, Set artifacts, Log l ) { this.mavenProject = null; this.exprEvaluator = exprEvaluator; this.log = l; for ( Iterator it = artifacts.iterator(); it.hasNext(); ) { Artifact artifact = (Artifact) it.next(); String key = DEPENDENCY_PREFIX + artifact.getGroupId() + "." + artifact.getArtifactId() + ( artifact.getClassifier() != null ? "." + artifact.getClassifier() : "" ) + ( artifact.getType() != null ? "." + artifact.getType() : "" ) + ".path"; log.debug( "Storing: " + key + "=" + artifact.getFile().getPath() ); artifactMap.put( key, artifact.getFile().getPath() ); } } /** * @see org.apache.tools.ant.PropertyHelper#getPropertyHook(java.lang.String, java.lang.String, boolean) */ public synchronized Object getPropertyHook( String ns, String name, boolean user ) { if ( log.isDebugEnabled() ) { log.debug( "getProperty(ns=" + ns + ", name=" + name + ", user=" + user + ")" ); } /* keep old behaviour */ if ( mavenProject != null ) { return getPropertyHook( ns, name, user, mavenProject ); } Object val = null; if ( name.startsWith( DEPENDENCY_PREFIX ) ) { val = (String) artifactMap.get( name ); } if ( val == null ) { try { val = exprEvaluator.evaluate( "${" + name + "}" ); } catch ( ExpressionEvaluationException e ) { if ( log.isErrorEnabled() ) { log.error( "Failed to evaluate expression", e ); } } } if ( val == null ) { val = super.getPropertyHook( ns, name, user ); if ( val == null ) { val = System.getProperty( name.toString() ); } } return val; } /** * @deprecated added to keep backwards compatibility * @param ns * @param name * @param user * @param mavenProject * @return The property value. */ private Object getPropertyHook( String ns, String name, boolean user, MavenProject mavenProject ) { Object val = null; try { if ( name.startsWith( DEPENDENCY_PREFIX ) ) { val = (String) artifactMap.get( name ); } else if ( name.startsWith( "project." ) ) { val = ReflectionValueExtractor.evaluate( name, mavenProject, true ); } else if ( name.equals( "basedir" ) ) { val = ReflectionValueExtractor.evaluate( "basedir.path", mavenProject, false ); } } catch ( Exception e ) { if ( log.isWarnEnabled() ) { log.warn( "Error evaluating expression '" + name + "'", e ); } } if ( val == null ) { val = super.getPropertyHook( ns, name, user ); if ( val == null ) { val = System.getProperty( name.toString() ); } } if ( val instanceof File ) { val = ( (File) val ).getAbsoluteFile(); } return val; } } maven2-core-2.2.1/maven-script/maven-script-ant/pom.xml0000644000175000017500000000522211236625310022705 0ustar twernertwerner 4.0.0 org.apache.maven maven-script 2.2.1 maven-script-ant Maven Ant Mojo Support org.apache.ant ant 1.7.1 org.apache.ant ant-launcher 1.7.1 org.apache.maven maven-plugin-api org.codehaus.plexus plexus-ant-factory 1.0-alpha-2.1 org.codehaus.plexus plexus-container-default org.apache.maven maven-project org.apache.maven maven-plugin-descriptor org.codehaus.plexus plexus-archiver 1.0-alpha-11 org.apache.maven maven-core easymock easymock test maven2-core-2.2.1/maven-script/maven-script-beanshell/0000755000175000017500000000000011250552243022542 5ustar twernertwernermaven2-core-2.2.1/maven-script/maven-script-beanshell/src/0000755000175000017500000000000011250552243023331 5ustar twernertwernermaven2-core-2.2.1/maven-script/maven-script-beanshell/src/site/0000755000175000017500000000000011250552243024275 5ustar twernertwernermaven2-core-2.2.1/maven-script/maven-script-beanshell/src/site/site.xml0000644000175000017500000000013211002611514025747 0ustar twernertwerner maven2-core-2.2.1/maven-script/maven-script-beanshell/src/main/0000755000175000017500000000000011250552243024255 5ustar twernertwernermaven2-core-2.2.1/maven-script/maven-script-beanshell/src/main/java/0000755000175000017500000000000011250552243025176 5ustar twernertwernermaven2-core-2.2.1/maven-script/maven-script-beanshell/src/main/java/org/0000755000175000017500000000000011250552243025765 5ustar twernertwernermaven2-core-2.2.1/maven-script/maven-script-beanshell/src/main/java/org/apache/0000755000175000017500000000000011250552243027206 5ustar twernertwernermaven2-core-2.2.1/maven-script/maven-script-beanshell/src/main/java/org/apache/maven/0000755000175000017500000000000011250552243030314 5ustar twernertwernermaven2-core-2.2.1/maven-script/maven-script-beanshell/src/main/java/org/apache/maven/script/0000755000175000017500000000000011250552243031620 5ustar twernertwerner././@LongLink0000000000000000000000000000014700000000000011567 Lustar rootrootmaven2-core-2.2.1/maven-script/maven-script-beanshell/src/main/java/org/apache/maven/script/beanshell/maven2-core-2.2.1/maven-script/maven-script-beanshell/src/main/java/org/apache/maven/script/beanshel0000755000175000017500000000000011250552243033322 5ustar twernertwerner././@LongLink0000000000000000000000000000020000000000000011555 Lustar rootrootmaven2-core-2.2.1/maven-script/maven-script-beanshell/src/main/java/org/apache/maven/script/beanshell/BeanshellMojoAdapter.javamaven2-core-2.2.1/maven-script/maven-script-beanshell/src/main/java/org/apache/maven/script/beanshel0000644000175000017500000000427110772004567033341 0ustar twernertwernerpackage org.apache.maven.script.beanshell; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import bsh.EvalError; import bsh.Interpreter; import org.apache.maven.plugin.AbstractMojo; import org.apache.maven.plugin.Mojo; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.MojoFailureException; import org.codehaus.plexus.component.factory.bsh.BshComponent; /** * Mojo adapter for a Beanshell Mojo. * * @todo should log be passed in, or rely on getLog() ? * * @author Brett Porter * @version $Id: BeanshellMojoAdapter.java 640549 2008-03-24 20:05:11Z bentmann $ */ public class BeanshellMojoAdapter extends AbstractMojo implements BshComponent { private Mojo mojo; private Interpreter interpreter; public BeanshellMojoAdapter( Mojo mojo, Interpreter interpreter ) { this.mojo = mojo; this.interpreter = interpreter; } public void execute() throws MojoExecutionException, MojoFailureException { try { interpreter.set( "logger", getLog() ); // TODO: set out, err to a print stream that will log at info, error respectively } catch ( EvalError evalError ) { throw new MojoExecutionException( "Unable to establish mojo", evalError ); } mojo.execute(); } public Interpreter getInterpreter() { return interpreter; } } maven2-core-2.2.1/maven-script/maven-script-beanshell/pom.xml0000644000175000017500000000312011236625310024053 0ustar twernertwerner 4.0.0 org.apache.maven maven-script 2.2.1 maven-script-beanshell Maven Beanshell Mojo Support org.apache.maven maven-plugin-api org.codehaus.plexus plexus-bsh-factory 1.0-alpha-7 maven2-core-2.2.1/maven-script/pom.xml0000644000175000017500000000257511236625310017525 0ustar twernertwerner 4.0.0 org.apache.maven maven 2.2.1 maven-script pom Maven Script Support Root maven-script-ant maven-script-beanshell maven2-core-2.2.1/maven-project/0000755000175000017500000000000011250552246016344 5ustar twernertwernermaven2-core-2.2.1/maven-project/src/0000755000175000017500000000000011250552246017133 5ustar twernertwernermaven2-core-2.2.1/maven-project/src/site/0000755000175000017500000000000011250552246020077 5ustar twernertwernermaven2-core-2.2.1/maven-project/src/site/site.xml0000644000175000017500000000013211002611514021546 0ustar twernertwerner maven2-core-2.2.1/maven-project/src/test/0000755000175000017500000000000011250552245020111 5ustar twernertwernermaven2-core-2.2.1/maven-project/src/test/resources/0000755000175000017500000000000011250552245022123 5ustar twernertwernermaven2-core-2.2.1/maven-project/src/test/resources/project-dynamism/0000755000175000017500000000000011250552245025410 5ustar twernertwernermaven2-core-2.2.1/maven-project/src/test/resources/project-dynamism/pom-interp.xml0000644000175000017500000000162211035274553030231 0ustar twernertwerner 4.0.0 org.test test-build-dynamism 1 ${project.groupId}/src/main/java ${pom.groupId}/src/test/java ${groupId}/src/main/scripts my-plugin ${project.groupId} ${pom.groupId} ${groupId} maven2-core-2.2.1/maven-project/src/test/resources/project-dynamism/pom-plugins.xml0000644000175000017500000000143211101576271030404 0ustar twernertwerner 4.0.0 org.test test-build-dynamism 1 ${pom.build.directory} one first-maven-plugin 1 two second-maven-plugin 2 maven2-core-2.2.1/maven-project/src/test/resources/project-dynamism/pom-source-roots.xml0000644000175000017500000000110011101576271031357 0ustar twernertwerner 4.0.0 org.test test-build-dynamism 1 src/main/java src/test/java src/main/scripts maven2-core-2.2.1/maven-project/src/test/resources/project-dynamism/plugin-level-dep.pom.xml0000644000175000017500000000140311101576271032073 0ustar twernertwerner 4.0.0 testing plugin-level-dep jar 3.8.1 maven-compiler-plugin 2.0.2 junit junit ${pom.version} maven2-core-2.2.1/maven-project/src/test/resources/project-dynamism/pom-relative.xml0000644000175000017500000000214011030240413030516 0ustar twernertwerner 4.0.0 org.test test-build-dynamism 1 ${pom.build.directory} ${pom.build.directory}/generated-resources/plexus ${pom.build.directory}/generated-filters.properties target src/main/java src/test/java src/main/scripts ${pom.build.directory}/classes ${pom.build.directory}/test-classes maven2-core-2.2.1/maven-project/src/test/resources/project-dynamism/pom.xml0000644000175000017500000000221511030240413026710 0ustar twernertwerner 4.0.0 org.test test-build-dynamism 1 ${pom.build.directory} ${pom.build.directory}/generated-resources/plexus ${pom.build.directory}/generated-filters.properties target ${pom.basedir}/src/main/java ${pom.basedir}/src/test/java ${pom.basedir}/src/main/scripts ${pom.build.directory}/classes ${pom.build.directory}/test-classes maven2-core-2.2.1/maven-project/src/test/resources/dependencyManagement-pom.xml0000644000175000017500000000232010772004567027555 0ustar twernertwerner 4.0.0 maven maven-core Maven 2.0-SNAPSHOT maven-test maven-test-b 1.0 maven-plexus-plugin 1.0 src/conf/plexus.conf src/conf/plexus.properties Continuum plexus:runtime ContinuumPro maven2-core-2.2.1/maven-project/src/test/resources/inheritance-repo/0000755000175000017500000000000011250552245025357 5ustar twernertwernermaven2-core-2.2.1/maven-project/src/test/resources/inheritance-repo/t01/0000755000175000017500000000000011250552245025763 5ustar twernertwernermaven2-core-2.2.1/maven-project/src/test/resources/inheritance-repo/t01/maven/0000755000175000017500000000000011250552245027071 5ustar twernertwernermaven2-core-2.2.1/maven-project/src/test/resources/inheritance-repo/t01/maven/poms/0000755000175000017500000000000011250552245030047 5ustar twernertwernermaven2-core-2.2.1/maven-project/src/test/resources/inheritance-repo/t01/maven/poms/p0-1.0.pom0000644000175000017500000000036510337155225031405 0ustar twernertwerner 4.0.0 maven p0 pom p0 1.0 p0-org maven2-core-2.2.1/maven-project/src/test/resources/inheritance-repo/t01/maven/poms/p2-1.0.pom0000644000175000017500000000054410337155225031406 0ustar twernertwerner p1 maven 1.0 4.0.0 maven p2 pom p2 1.0 p2-org maven2-core-2.2.1/maven-project/src/test/resources/inheritance-repo/t01/maven/poms/p3-1.0.pom0000644000175000017500000000054410337155225031407 0ustar twernertwerner p2 maven 1.0 4.0.0 maven p3 pom p3 1.0 p3-org maven2-core-2.2.1/maven-project/src/test/resources/inheritance-repo/t01/maven/poms/p4-1.0.pom0000644000175000017500000000054410255443072031407 0ustar twernertwerner p3 maven 1.0 4.0.0 maven p4 jar p4 1.0 p4-org maven2-core-2.2.1/maven-project/src/test/resources/inheritance-repo/t01/maven/poms/p1-1.0.pom0000644000175000017500000000054410337155225031405 0ustar twernertwerner p0 maven 1.0 4.0.0 maven p1 pom p1 1.0 p1-org maven2-core-2.2.1/maven-project/src/test/resources/inheritance-repo/t11/0000755000175000017500000000000011250552245025764 5ustar twernertwernermaven2-core-2.2.1/maven-project/src/test/resources/inheritance-repo/t11/p0/0000755000175000017500000000000011250552245026303 5ustar twernertwernermaven2-core-2.2.1/maven-project/src/test/resources/inheritance-repo/t11/p0/pom.xml0000644000175000017500000000077610772004567027641 0ustar twernertwerner 4.0.0 maven p0 pom p0 1.0 Codehaus maven p1 1.0 test maven2-core-2.2.1/maven-project/src/test/resources/inheritance-repo/t11/p0/p1/0000755000175000017500000000000011250552245026623 5ustar twernertwernermaven2-core-2.2.1/maven-project/src/test/resources/inheritance-repo/t11/p0/p1/pom.xml0000644000175000017500000000052110772004567030145 0ustar twernertwerner p0 maven 1.0 4.0.0 maven p1 jar p1 1.0 scm-url maven2-core-2.2.1/maven-project/src/test/resources/inheritance-repo/t02/0000755000175000017500000000000011250552245025764 5ustar twernertwernermaven2-core-2.2.1/maven-project/src/test/resources/inheritance-repo/t02/p0/0000755000175000017500000000000011250552245026303 5ustar twernertwernermaven2-core-2.2.1/maven-project/src/test/resources/inheritance-repo/t02/p0/pom.xml0000644000175000017500000000176610772004567027641 0ustar twernertwerner 4.0.0 maven p0 pom p0 1.0 Codehaus maven2-core-2.2.1/maven-project/src/test/resources/inheritance-repo/t02/p0/p1/0000755000175000017500000000000011250552245026623 5ustar twernertwernermaven2-core-2.2.1/maven-project/src/test/resources/inheritance-repo/t02/p0/p1/p2/0000755000175000017500000000000011250552245027144 5ustar twernertwernermaven2-core-2.2.1/maven-project/src/test/resources/inheritance-repo/t02/p0/p1/p2/p3/0000755000175000017500000000000011250552245027466 5ustar twernertwernermaven2-core-2.2.1/maven-project/src/test/resources/inheritance-repo/t02/p0/p1/p2/p3/p4/0000755000175000017500000000000011250552245030011 5ustar twernertwernermaven2-core-2.2.1/maven-project/src/test/resources/inheritance-repo/t02/p0/p1/p2/p3/p4/p5/0000755000175000017500000000000011250552245030335 5ustar twernertwernermaven2-core-2.2.1/maven-project/src/test/resources/inheritance-repo/t02/p0/p1/p2/p3/p4/p5/pom.xml0000644000175000017500000000205010772004567031656 0ustar twernertwerner p3 maven 1.0 4.0.0 maven p5 jar p5 1.0 maven2-core-2.2.1/maven-project/src/test/resources/inheritance-repo/t02/p0/p1/p2/p3/p4/pom.xml0000644000175000017500000000205010772004567031332 0ustar twernertwerner p3 maven 1.0 4.0.0 maven p4 jar p4 1.0 maven2-core-2.2.1/maven-project/src/test/resources/inheritance-repo/t02/p0/p1/p2/p3/pom.xml0000644000175000017500000000211610772004567031012 0ustar twernertwerner p2 maven 1.0 4.0.0 maven p3 pom p3 1.0 2000 maven2-core-2.2.1/maven-project/src/test/resources/inheritance-repo/t02/p0/p1/p2/pom.xml0000644000175000017500000000222010772004567030464 0ustar twernertwerner p1 maven 1.0 4.0.0 maven p2 pom p2 1.0 mailing-list maven2-core-2.2.1/maven-project/src/test/resources/inheritance-repo/t02/p0/p1/pom.xml0000644000175000017500000000267110772004567030155 0ustar twernertwerner p0 maven 1.0 4.0.0 maven p1 pom p1 1.0 scm-url maven-compiler-plugin test package compile maven2-core-2.2.1/maven-project/src/test/resources/inheritance-repo/t10/0000755000175000017500000000000011250552245025763 5ustar twernertwernermaven2-core-2.2.1/maven-project/src/test/resources/inheritance-repo/t10/maven-test/0000755000175000017500000000000011250552245030046 5ustar twernertwernermaven2-core-2.2.1/maven-project/src/test/resources/inheritance-repo/t10/maven-test/poms/0000755000175000017500000000000011250552245031024 5ustar twernertwerner././@LongLink0000000000000000000000000000015500000000000011566 Lustar rootrootmaven2-core-2.2.1/maven-project/src/test/resources/inheritance-repo/t10/maven-test/poms/maven-test-b-1.0.pommaven2-core-2.2.1/maven-project/src/test/resources/inheritance-repo/t10/maven-test/poms/maven-test-b0000644000175000017500000000026710574736620033267 0ustar twernertwerner 4.0.0 maven-test maven-test-b jar 1.0 ././@LongLink0000000000000000000000000000015500000000000011566 Lustar rootrootmaven2-core-2.2.1/maven-project/src/test/resources/inheritance-repo/t10/maven-test/poms/maven-test-a-1.0.pommaven2-core-2.2.1/maven-project/src/test/resources/inheritance-repo/t10/maven-test/poms/maven-test-a0000644000175000017500000000106510574736620033263 0ustar twernertwerner 4.0.0 maven-test maven-test-a jar 1.0 central Fake Maven Central Repository file://dummy maven-test maven-test-b 1.0 compile ././@LongLink0000000000000000000000000000015500000000000011566 Lustar rootrootmaven2-core-2.2.1/maven-project/src/test/resources/inheritance-repo/t10/maven-test/poms/maven-test-c-1.0.pommaven2-core-2.2.1/maven-project/src/test/resources/inheritance-repo/t10/maven-test/poms/maven-test-c0000644000175000017500000000026710574736620033270 0ustar twernertwerner 4.0.0 maven-test maven-test-c jar 1.0 maven2-core-2.2.1/maven-project/src/test/resources/inheritance-repo/t10/maven-test/jars/0000755000175000017500000000000011250552245031005 5ustar twernertwernermaven2-core-2.2.1/maven-project/src/test/resources/inheritance-repo/t10/p0/0000755000175000017500000000000011250552245026302 5ustar twernertwernermaven2-core-2.2.1/maven-project/src/test/resources/inheritance-repo/t10/p0/pom.xml0000644000175000017500000000155410772004567027633 0ustar twernertwerner 4.0.0 maven p0 pom p0 1.0 Codehaus maven-test maven-test-a 1.0 test maven-test maven-test-b 1.0 runtime maven-test maven-test-c 1.0 test maven2-core-2.2.1/maven-project/src/test/resources/inheritance-repo/t10/p0/p1/0000755000175000017500000000000011250552245026622 5ustar twernertwernermaven2-core-2.2.1/maven-project/src/test/resources/inheritance-repo/t10/p0/p1/pom.xml0000644000175000017500000000156310772004567030153 0ustar twernertwerner p0 maven 1.0 4.0.0 maven p1 pom p1 1.0 scm-url maven-test maven-test-a maven-test maven-test-c runtime maven-antrun-plugin ${project.parent.basedir} maven2-core-2.2.1/maven-project/src/test/resources/inheritance-repo/t08/0000755000175000017500000000000011250552245025772 5ustar twernertwernermaven2-core-2.2.1/maven-project/src/test/resources/inheritance-repo/t08/maven-test/0000755000175000017500000000000011250552245030055 5ustar twernertwernermaven2-core-2.2.1/maven-project/src/test/resources/inheritance-repo/t08/maven-test/poms/0000755000175000017500000000000011250552245031033 5ustar twernertwerner././@LongLink0000000000000000000000000000015500000000000011566 Lustar rootrootmaven2-core-2.2.1/maven-project/src/test/resources/inheritance-repo/t08/maven-test/poms/maven-test-d-1.0.pommaven2-core-2.2.1/maven-project/src/test/resources/inheritance-repo/t08/maven-test/poms/maven-test-d0000644000175000017500000000026710574736620033300 0ustar twernertwerner 4.0.0 maven-test maven-test-d jar 1.0 ././@LongLink0000000000000000000000000000015500000000000011566 Lustar rootrootmaven2-core-2.2.1/maven-project/src/test/resources/inheritance-repo/t08/maven-test/poms/maven-test-b-1.0.pommaven2-core-2.2.1/maven-project/src/test/resources/inheritance-repo/t08/maven-test/poms/maven-test-b0000644000175000017500000000120310574736620033265 0ustar twernertwerner 4.0.0 maven-test maven-test-b jar 1.0 maven-test maven-test-c 1.0 jar compile maven-test maven-test-d 1.1 jar compile false ././@LongLink0000000000000000000000000000015500000000000011566 Lustar rootrootmaven2-core-2.2.1/maven-project/src/test/resources/inheritance-repo/t08/maven-test/poms/maven-test-a-1.0.pommaven2-core-2.2.1/maven-project/src/test/resources/inheritance-repo/t08/maven-test/poms/maven-test-a0000644000175000017500000000111210574736620033263 0ustar twernertwerner 4.0.0 maven-test maven-test-a jar 1.0 central Fake Maven Central Repository file://dummy maven-test maven-test-b 1.0 jar compile ././@LongLink0000000000000000000000000000015500000000000011566 Lustar rootrootmaven2-core-2.2.1/maven-project/src/test/resources/inheritance-repo/t08/maven-test/poms/maven-test-b-1.1.pommaven2-core-2.2.1/maven-project/src/test/resources/inheritance-repo/t08/maven-test/poms/maven-test-b0000644000175000017500000000120310574736620033265 0ustar twernertwerner 4.0.0 maven-test maven-test-b jar 1.1 maven-test maven-test-c 1.0 jar compile maven-test maven-test-d 1.1 jar compile false ././@LongLink0000000000000000000000000000015500000000000011566 Lustar rootrootmaven2-core-2.2.1/maven-project/src/test/resources/inheritance-repo/t08/maven-test/poms/maven-test-d-1.1.pommaven2-core-2.2.1/maven-project/src/test/resources/inheritance-repo/t08/maven-test/poms/maven-test-d0000644000175000017500000000026710574736620033300 0ustar twernertwerner 4.0.0 maven-test maven-test-d jar 1.1 ././@LongLink0000000000000000000000000000015500000000000011566 Lustar rootrootmaven2-core-2.2.1/maven-project/src/test/resources/inheritance-repo/t08/maven-test/poms/maven-test-c-1.0.pommaven2-core-2.2.1/maven-project/src/test/resources/inheritance-repo/t08/maven-test/poms/maven-test-c0000644000175000017500000000067610574736620033303 0ustar twernertwerner 4.0.0 maven-test maven-test-c jar 1.0 maven-test maven-test-d 1.1 jar compile true ././@LongLink0000000000000000000000000000015500000000000011566 Lustar rootrootmaven2-core-2.2.1/maven-project/src/test/resources/inheritance-repo/t08/maven-test/poms/maven-test-d-1.2.pommaven2-core-2.2.1/maven-project/src/test/resources/inheritance-repo/t08/maven-test/poms/maven-test-d0000644000175000017500000000026710574736620033300 0ustar twernertwerner 4.0.0 maven-test maven-test-d jar 1.2 maven2-core-2.2.1/maven-project/src/test/resources/inheritance-repo/t08/maven-test/jars/0000755000175000017500000000000011250552245031014 5ustar twernertwernermaven2-core-2.2.1/maven-project/src/test/resources/inheritance-repo/t08/p0/0000755000175000017500000000000011250552245026311 5ustar twernertwernermaven2-core-2.2.1/maven-project/src/test/resources/inheritance-repo/t08/p0/pom.xml0000644000175000017500000000177010772004567027642 0ustar twernertwerner 4.0.0 maven p0 pom p0 1.0 Codehaus maven-test maven-test-a 1.0 maven-test maven-test-b 1.1 maven-test maven-test-c 1.0 maven-test maven-test-d 1.2 test false maven2-core-2.2.1/maven-project/src/test/resources/inheritance-repo/t08/p0/p1/0000755000175000017500000000000011250552245026631 5ustar twernertwernermaven2-core-2.2.1/maven-project/src/test/resources/inheritance-repo/t08/p0/p1/pom.xml0000644000175000017500000000274710772004567030167 0ustar twernertwerner p0 maven 1.0 4.0.0 maven p1 pom p1 1.0 scm-url maven-test maven-test-b 1.0 maven-test maven-test-d 1.0 test true maven-test maven-test-a 1.0 maven-test maven-test-c 1.0 maven-test maven-test-d 1.0 maven-antrun-plugin ${project.parent.basedir} maven2-core-2.2.1/maven-project/src/test/resources/inheritance-repo/t03/0000755000175000017500000000000011250552245025765 5ustar twernertwernermaven2-core-2.2.1/maven-project/src/test/resources/inheritance-repo/t03/p0/0000755000175000017500000000000011250552245026304 5ustar twernertwernermaven2-core-2.2.1/maven-project/src/test/resources/inheritance-repo/t03/p0/pom.xml0000644000175000017500000000176610772004567027642 0ustar twernertwerner 4.0.0 maven p0 pom p0 1.0 Codehaus maven2-core-2.2.1/maven-project/src/test/resources/inheritance-repo/t03/p0/p1/0000755000175000017500000000000011250552245026624 5ustar twernertwernermaven2-core-2.2.1/maven-project/src/test/resources/inheritance-repo/t03/p0/p1/pom.xml0000644000175000017500000000250710772004567030154 0ustar twernertwerner p0 maven 1.0 4.0.0 maven p1 pom p1 1.0 scm-url maven-antrun-plugin ${project.parent.basedir} maven2-core-2.2.1/maven-project/src/test/resources/inheritance-repo/t13/0000755000175000017500000000000011250552245025766 5ustar twernertwernermaven2-core-2.2.1/maven-project/src/test/resources/inheritance-repo/t13/repo/0000755000175000017500000000000011250552245026733 5ustar twernertwernermaven2-core-2.2.1/maven-project/src/test/resources/inheritance-repo/t13/repo/tests/0000755000175000017500000000000011250552245030075 5ustar twernertwerner././@LongLink0000000000000000000000000000014500000000000011565 Lustar rootrootmaven2-core-2.2.1/maven-project/src/test/resources/inheritance-repo/t13/repo/tests/test-from-parent/maven2-core-2.2.1/maven-project/src/test/resources/inheritance-repo/t13/repo/tests/test-from-parent/0000755000175000017500000000000011250552245033304 5ustar twernertwerner././@LongLink0000000000000000000000000000014700000000000011567 Lustar rootrootmaven2-core-2.2.1/maven-project/src/test/resources/inheritance-repo/t13/repo/tests/test-from-parent/1/maven2-core-2.2.1/maven-project/src/test/resources/inheritance-repo/t13/repo/tests/test-from-parent/0000755000175000017500000000000011250552245033304 5ustar twernertwerner././@LongLink0000000000000000000000000000017500000000000011570 Lustar rootrootmaven2-core-2.2.1/maven-project/src/test/resources/inheritance-repo/t13/repo/tests/test-from-parent/1/test-from-parent-1.pommaven2-core-2.2.1/maven-project/src/test/resources/inheritance-repo/t13/repo/tests/test-from-parent/0000644000175000017500000000023210774506642033315 0ustar twernertwerner 4.0.0 tests test-from-parent 1 maven2-core-2.2.1/maven-project/src/test/resources/inheritance-repo/t13/repo/tests/test-from-child/0000755000175000017500000000000011250552245033076 5ustar twernertwerner././@LongLink0000000000000000000000000000015000000000000011561 Lustar rootrootmaven2-core-2.2.1/maven-project/src/test/resources/inheritance-repo/t13/repo/tests/test-from-child/0.5/maven2-core-2.2.1/maven-project/src/test/resources/inheritance-repo/t13/repo/tests/test-from-child/00000755000175000017500000000000011250552245033156 5ustar twernertwerner././@LongLink0000000000000000000000000000017700000000000011572 Lustar rootrootmaven2-core-2.2.1/maven-project/src/test/resources/inheritance-repo/t13/repo/tests/test-from-child/0.5/test-from-child-0.5.pommaven2-core-2.2.1/maven-project/src/test/resources/inheritance-repo/t13/repo/tests/test-from-child/00000644000175000017500000000023310774515477033176 0ustar twernertwerner 4.0.0 tests test-from-child 0.5 ././@LongLink0000000000000000000000000000014600000000000011566 Lustar rootrootmaven2-core-2.2.1/maven-project/src/test/resources/inheritance-repo/t13/repo/tests/test-from-child/1/maven2-core-2.2.1/maven-project/src/test/resources/inheritance-repo/t13/repo/tests/test-from-child/10000755000175000017500000000000011250552245033157 5ustar twernertwerner././@LongLink0000000000000000000000000000017300000000000011566 Lustar rootrootmaven2-core-2.2.1/maven-project/src/test/resources/inheritance-repo/t13/repo/tests/test-from-child/1/test-from-child-1.pommaven2-core-2.2.1/maven-project/src/test/resources/inheritance-repo/t13/repo/tests/test-from-child/10000644000175000017500000000023110774506642033167 0ustar twernertwerner 4.0.0 tests test-from-child 1 maven2-core-2.2.1/maven-project/src/test/resources/inheritance-repo/t13/p0/0000755000175000017500000000000011250552245026305 5ustar twernertwernermaven2-core-2.2.1/maven-project/src/test/resources/inheritance-repo/t13/p0/pom.xml0000644000175000017500000000075210774515477027646 0ustar twernertwerner 4.0.0 maven p0 pom 1.0 tests test-from-parent 1 tests test-from-child 0.5 maven2-core-2.2.1/maven-project/src/test/resources/inheritance-repo/t13/p0/p1/0000755000175000017500000000000011250552245026625 5ustar twernertwernermaven2-core-2.2.1/maven-project/src/test/resources/inheritance-repo/t13/p0/p1/pom.xml0000644000175000017500000000057110774506642030157 0ustar twernertwerner p0 maven 1.0 4.0.0 p1 tests test-from-child 1 maven2-core-2.2.1/maven-project/src/test/resources/inheritance-repo/t09/0000755000175000017500000000000011250552245025773 5ustar twernertwernermaven2-core-2.2.1/maven-project/src/test/resources/inheritance-repo/t09/maven-test/0000755000175000017500000000000011250552245030056 5ustar twernertwernermaven2-core-2.2.1/maven-project/src/test/resources/inheritance-repo/t09/maven-test/poms/0000755000175000017500000000000011250552245031034 5ustar twernertwerner././@LongLink0000000000000000000000000000015500000000000011566 Lustar rootrootmaven2-core-2.2.1/maven-project/src/test/resources/inheritance-repo/t09/maven-test/poms/maven-test-d-1.0.pommaven2-core-2.2.1/maven-project/src/test/resources/inheritance-repo/t09/maven-test/poms/maven-test-d0000644000175000017500000000061110574736620033272 0ustar twernertwerner 4.0.0 maven-test maven-test-d jar 1.0 maven-test maven-test-c 1.0 compile ././@LongLink0000000000000000000000000000015500000000000011566 Lustar rootrootmaven2-core-2.2.1/maven-project/src/test/resources/inheritance-repo/t09/maven-test/poms/maven-test-b-1.0.pommaven2-core-2.2.1/maven-project/src/test/resources/inheritance-repo/t09/maven-test/poms/maven-test-b0000644000175000017500000000061110574736620033270 0ustar twernertwerner 4.0.0 maven-test maven-test-b jar 1.0 maven-test maven-test-c 1.0 compile ././@LongLink0000000000000000000000000000015500000000000011566 Lustar rootrootmaven2-core-2.2.1/maven-project/src/test/resources/inheritance-repo/t09/maven-test/poms/maven-test-a-1.0.pommaven2-core-2.2.1/maven-project/src/test/resources/inheritance-repo/t09/maven-test/poms/maven-test-a0000644000175000017500000000106510574736620033273 0ustar twernertwerner 4.0.0 maven-test maven-test-a jar 1.0 central Fake Maven Central Repository file://dummy maven-test maven-test-b 1.0 compile ././@LongLink0000000000000000000000000000015500000000000011566 Lustar rootrootmaven2-core-2.2.1/maven-project/src/test/resources/inheritance-repo/t09/maven-test/poms/maven-test-c-1.0.pommaven2-core-2.2.1/maven-project/src/test/resources/inheritance-repo/t09/maven-test/poms/maven-test-c0000644000175000017500000000026710574736620033300 0ustar twernertwerner 4.0.0 maven-test maven-test-c jar 1.0 maven2-core-2.2.1/maven-project/src/test/resources/inheritance-repo/t09/maven-test/jars/0000755000175000017500000000000011250552245031015 5ustar twernertwernermaven2-core-2.2.1/maven-project/src/test/resources/inheritance-repo/t09/p0/0000755000175000017500000000000011250552245026312 5ustar twernertwernermaven2-core-2.2.1/maven-project/src/test/resources/inheritance-repo/t09/p0/p2/0000755000175000017500000000000011250552245026633 5ustar twernertwernermaven2-core-2.2.1/maven-project/src/test/resources/inheritance-repo/t09/p0/p2/pom.xml0000644000175000017500000000156310772004567030164 0ustar twernertwerner p0 maven 1.0 4.0.0 maven p2 pom p2 1.0 scm-url maven-test maven-test-a maven-test maven-test-d 1.0 maven-antrun-plugin ${project.parent.basedir} maven2-core-2.2.1/maven-project/src/test/resources/inheritance-repo/t09/p0/pom.xml0000644000175000017500000000150010772004567027632 0ustar twernertwerner 4.0.0 maven p0 pom p0 1.0 Codehaus maven-test maven-test-a 1.0 maven-test maven-test-b 1.0 maven-test maven-test-c maven2-core-2.2.1/maven-project/src/test/resources/inheritance-repo/t09/p0/p1/0000755000175000017500000000000011250552245026632 5ustar twernertwernermaven2-core-2.2.1/maven-project/src/test/resources/inheritance-repo/t09/p0/p1/pom.xml0000644000175000017500000000134210772004567030156 0ustar twernertwerner p0 maven 1.0 4.0.0 maven p1 pom p1 1.0 scm-url maven-test maven-test-a maven-antrun-plugin ${project.parent.basedir} maven2-core-2.2.1/maven-project/src/test/resources/inheritance-repo/t06/0000755000175000017500000000000011250552245025770 5ustar twernertwernermaven2-core-2.2.1/maven-project/src/test/resources/inheritance-repo/t06/maven-test/0000755000175000017500000000000011250552245030053 5ustar twernertwernermaven2-core-2.2.1/maven-project/src/test/resources/inheritance-repo/t06/maven-test/poms/0000755000175000017500000000000011250552245031031 5ustar twernertwerner././@LongLink0000000000000000000000000000015500000000000011566 Lustar rootrootmaven2-core-2.2.1/maven-project/src/test/resources/inheritance-repo/t06/maven-test/poms/maven-test-d-1.0.pommaven2-core-2.2.1/maven-project/src/test/resources/inheritance-repo/t06/maven-test/poms/maven-test-d0000644000175000017500000000026710574736620033276 0ustar twernertwerner 4.0.0 maven-test maven-test-d jar 1.0 ././@LongLink0000000000000000000000000000015500000000000011566 Lustar rootrootmaven2-core-2.2.1/maven-project/src/test/resources/inheritance-repo/t06/maven-test/poms/maven-test-b-1.0.pommaven2-core-2.2.1/maven-project/src/test/resources/inheritance-repo/t06/maven-test/poms/maven-test-b0000644000175000017500000000120310574736620033263 0ustar twernertwerner 4.0.0 maven-test maven-test-b jar 1.0 maven-test maven-test-c 1.0 jar compile maven-test maven-test-d 1.1 jar compile false ././@LongLink0000000000000000000000000000015500000000000011566 Lustar rootrootmaven2-core-2.2.1/maven-project/src/test/resources/inheritance-repo/t06/maven-test/poms/maven-test-a-1.0.pommaven2-core-2.2.1/maven-project/src/test/resources/inheritance-repo/t06/maven-test/poms/maven-test-a0000644000175000017500000000111210574736620033261 0ustar twernertwerner 4.0.0 maven-test maven-test-a jar 1.0 central Fake Maven Central Repository file://dummy maven-test maven-test-b 1.0 jar compile ././@LongLink0000000000000000000000000000015500000000000011566 Lustar rootrootmaven2-core-2.2.1/maven-project/src/test/resources/inheritance-repo/t06/maven-test/poms/maven-test-b-1.1.pommaven2-core-2.2.1/maven-project/src/test/resources/inheritance-repo/t06/maven-test/poms/maven-test-b0000644000175000017500000000120310574736620033263 0ustar twernertwerner 4.0.0 maven-test maven-test-b jar 1.0 maven-test maven-test-c 1.0 jar compile maven-test maven-test-d 1.1 jar compile false ././@LongLink0000000000000000000000000000015500000000000011566 Lustar rootrootmaven2-core-2.2.1/maven-project/src/test/resources/inheritance-repo/t06/maven-test/poms/maven-test-d-1.1.pommaven2-core-2.2.1/maven-project/src/test/resources/inheritance-repo/t06/maven-test/poms/maven-test-d0000644000175000017500000000026710574736620033276 0ustar twernertwerner 4.0.0 maven-test maven-test-d jar 1.1 ././@LongLink0000000000000000000000000000015500000000000011566 Lustar rootrootmaven2-core-2.2.1/maven-project/src/test/resources/inheritance-repo/t06/maven-test/poms/maven-test-c-1.0.pommaven2-core-2.2.1/maven-project/src/test/resources/inheritance-repo/t06/maven-test/poms/maven-test-c0000644000175000017500000000067610574736620033301 0ustar twernertwerner 4.0.0 maven-test maven-test-c jar 1.0 maven-test maven-test-d 1.1 jar compile true ././@LongLink0000000000000000000000000000015500000000000011566 Lustar rootrootmaven2-core-2.2.1/maven-project/src/test/resources/inheritance-repo/t06/maven-test/poms/maven-test-d-1.2.pommaven2-core-2.2.1/maven-project/src/test/resources/inheritance-repo/t06/maven-test/poms/maven-test-d0000644000175000017500000000026710574736620033276 0ustar twernertwerner 4.0.0 maven-test maven-test-d jar 1.2 maven2-core-2.2.1/maven-project/src/test/resources/inheritance-repo/t06/maven-test/jars/0000755000175000017500000000000011250552245031012 5ustar twernertwernermaven2-core-2.2.1/maven-project/src/test/resources/inheritance-repo/t06/p0/0000755000175000017500000000000011250552245026307 5ustar twernertwernermaven2-core-2.2.1/maven-project/src/test/resources/inheritance-repo/t06/p0/pom.xml0000644000175000017500000000177010772004567027640 0ustar twernertwerner 4.0.0 maven p0 pom p0 1.0 Codehaus maven-test maven-test-a 1.0 maven-test maven-test-b 1.1 maven-test maven-test-c 1.0 maven-test maven-test-d 1.2 test false maven2-core-2.2.1/maven-project/src/test/resources/inheritance-repo/t06/p0/p1/0000755000175000017500000000000011250552245026627 5ustar twernertwernermaven2-core-2.2.1/maven-project/src/test/resources/inheritance-repo/t06/p0/p1/pom.xml0000644000175000017500000000253010772004567030153 0ustar twernertwerner p0 maven 1.0 4.0.0 maven p1 pom p1 1.0 scm-url maven-test maven-test-b 1.0 maven-test maven-test-d 1.0 test false maven-test maven-test-a 1.0 maven-test maven-test-c 1.0 maven-antrun-plugin ${project.parent.basedir} maven2-core-2.2.1/maven-project/src/test/resources/inheritance-repo/t05/0000755000175000017500000000000011250552245025767 5ustar twernertwernermaven2-core-2.2.1/maven-project/src/test/resources/inheritance-repo/t05/maven-test/0000755000175000017500000000000011250552245030052 5ustar twernertwernermaven2-core-2.2.1/maven-project/src/test/resources/inheritance-repo/t05/maven-test/poms/0000755000175000017500000000000011250552245031030 5ustar twernertwerner././@LongLink0000000000000000000000000000015500000000000011566 Lustar rootrootmaven2-core-2.2.1/maven-project/src/test/resources/inheritance-repo/t05/maven-test/poms/maven-test-b-2.0.pommaven2-core-2.2.1/maven-project/src/test/resources/inheritance-repo/t05/maven-test/poms/maven-test-b0000644000175000017500000000120310574736620033262 0ustar twernertwerner 4.0.0 maven-test maven-test-b jar 2.0 maven-test maven-test-c 1.0 jar compile maven-test maven-test-d 1.1 jar compile false ././@LongLink0000000000000000000000000000015500000000000011566 Lustar rootrootmaven2-core-2.2.1/maven-project/src/test/resources/inheritance-repo/t05/maven-test/poms/maven-test-a-2.0.pommaven2-core-2.2.1/maven-project/src/test/resources/inheritance-repo/t05/maven-test/poms/maven-test-a0000644000175000017500000000111210574736620033260 0ustar twernertwerner 4.0.0 maven-test maven-test-a jar 2.0 central Fake Maven Central Repository file://dummy maven-test maven-test-b 1.0 jar compile ././@LongLink0000000000000000000000000000015500000000000011566 Lustar rootrootmaven2-core-2.2.1/maven-project/src/test/resources/inheritance-repo/t05/maven-test/poms/maven-test-d-1.0.pommaven2-core-2.2.1/maven-project/src/test/resources/inheritance-repo/t05/maven-test/poms/maven-test-d0000644000175000017500000000026710574736620033275 0ustar twernertwerner 4.0.0 maven-test maven-test-d jar 1.0 ././@LongLink0000000000000000000000000000015500000000000011566 Lustar rootrootmaven2-core-2.2.1/maven-project/src/test/resources/inheritance-repo/t05/maven-test/poms/maven-test-b-1.0.pommaven2-core-2.2.1/maven-project/src/test/resources/inheritance-repo/t05/maven-test/poms/maven-test-b0000644000175000017500000000120310574736620033262 0ustar twernertwerner 4.0.0 maven-test maven-test-b jar 1.0 maven-test maven-test-c 1.0 jar compile maven-test maven-test-d 1.1 jar compile false ././@LongLink0000000000000000000000000000015500000000000011566 Lustar rootrootmaven2-core-2.2.1/maven-project/src/test/resources/inheritance-repo/t05/maven-test/poms/maven-test-a-1.0.pommaven2-core-2.2.1/maven-project/src/test/resources/inheritance-repo/t05/maven-test/poms/maven-test-a0000644000175000017500000000111210574736620033260 0ustar twernertwerner 4.0.0 maven-test maven-test-a jar 1.0 central Fake Maven Central Repository file://dummy maven-test maven-test-b 1.0 jar compile ././@LongLink0000000000000000000000000000015500000000000011566 Lustar rootrootmaven2-core-2.2.1/maven-project/src/test/resources/inheritance-repo/t05/maven-test/poms/maven-test-b-1.1.pommaven2-core-2.2.1/maven-project/src/test/resources/inheritance-repo/t05/maven-test/poms/maven-test-b0000644000175000017500000000120310574736620033262 0ustar twernertwerner 4.0.0 maven-test maven-test-b jar 1.1 maven-test maven-test-c 1.0 jar compile maven-test maven-test-d 1.1 jar compile false ././@LongLink0000000000000000000000000000015500000000000011566 Lustar rootrootmaven2-core-2.2.1/maven-project/src/test/resources/inheritance-repo/t05/maven-test/poms/maven-test-d-1.1.pommaven2-core-2.2.1/maven-project/src/test/resources/inheritance-repo/t05/maven-test/poms/maven-test-d0000644000175000017500000000026710574736620033275 0ustar twernertwerner 4.0.0 maven-test maven-test-d jar 1.1 ././@LongLink0000000000000000000000000000015500000000000011566 Lustar rootrootmaven2-core-2.2.1/maven-project/src/test/resources/inheritance-repo/t05/maven-test/poms/maven-test-c-1.0.pommaven2-core-2.2.1/maven-project/src/test/resources/inheritance-repo/t05/maven-test/poms/maven-test-c0000644000175000017500000000067610574736620033300 0ustar twernertwerner 4.0.0 maven-test maven-test-c jar 1.0 maven-test maven-test-d 1.1 jar compile true ././@LongLink0000000000000000000000000000015500000000000011566 Lustar rootrootmaven2-core-2.2.1/maven-project/src/test/resources/inheritance-repo/t05/maven-test/poms/maven-test-d-1.2.pommaven2-core-2.2.1/maven-project/src/test/resources/inheritance-repo/t05/maven-test/poms/maven-test-d0000644000175000017500000000026710574736620033275 0ustar twernertwerner 4.0.0 maven-test maven-test-d jar 1.2 maven2-core-2.2.1/maven-project/src/test/resources/inheritance-repo/t05/maven-test/jars/0000755000175000017500000000000011250552245031011 5ustar twernertwernermaven2-core-2.2.1/maven-project/src/test/resources/inheritance-repo/t05/p0/0000755000175000017500000000000011250552245026306 5ustar twernertwernermaven2-core-2.2.1/maven-project/src/test/resources/inheritance-repo/t05/p0/pom.xml0000644000175000017500000000173010772004567027633 0ustar twernertwerner 4.0.0 maven p0 pom p0 1.0 Codehaus maven-test maven-test-a 1.0 maven-test maven-test-b 1.1 maven-test maven-test-c 1.0 compile maven-test maven-test-d 1.2 maven2-core-2.2.1/maven-project/src/test/resources/inheritance-repo/t05/p0/p1/0000755000175000017500000000000011250552245026626 5ustar twernertwernermaven2-core-2.2.1/maven-project/src/test/resources/inheritance-repo/t05/p0/p1/pom.xml0000644000175000017500000000252310772004567030154 0ustar twernertwerner p0 maven 1.0 4.0.0 maven p1 pom p1 1.0 scm-url maven-test maven-test-b 1.0 maven-test maven-test-d 1.0 maven-test maven-test-a 1.0 runtime maven-test maven-test-c 1.0 runtime maven-antrun-plugin ${project.parent.basedir} maven2-core-2.2.1/maven-project/src/test/resources/inheritance-repo/t00/0000755000175000017500000000000011250552245025762 5ustar twernertwernermaven2-core-2.2.1/maven-project/src/test/resources/inheritance-repo/t00/maven/0000755000175000017500000000000011250552245027070 5ustar twernertwernermaven2-core-2.2.1/maven-project/src/test/resources/inheritance-repo/t00/maven/poms/0000755000175000017500000000000011250552245030046 5ustar twernertwernermaven2-core-2.2.1/maven-project/src/test/resources/inheritance-repo/t00/maven/poms/p0-1.0.pom0000644000175000017500000000036710337155225031406 0ustar twernertwerner 4.0.0 maven p0 pom p0 1.0 Codehaus maven2-core-2.2.1/maven-project/src/test/resources/inheritance-repo/t00/maven/poms/p2-1.0.pom0000644000175000017500000000062110337155225031401 0ustar twernertwerner p1 maven 1.0 4.0.0 maven p2 pom p2 1.0 mailing-list maven2-core-2.2.1/maven-project/src/test/resources/inheritance-repo/t00/maven/poms/p3-1.0.pom0000644000175000017500000000051710337155225031406 0ustar twernertwerner p2 maven 1.0 4.0.0 maven p3 pom p3 1.0 2000 maven2-core-2.2.1/maven-project/src/test/resources/inheritance-repo/t00/maven/poms/p4-1.0.pom0000644000175000017500000000045110255443072031403 0ustar twernertwerner p3 maven 1.0 4.0.0 maven p4 jar p4 1.0 maven2-core-2.2.1/maven-project/src/test/resources/inheritance-repo/t00/maven/poms/p1-1.0.pom0000644000175000017500000000052110337155225031377 0ustar twernertwerner p0 maven 1.0 4.0.0 maven p1 pom p1 1.0 scm-url maven2-core-2.2.1/maven-project/src/test/resources/inheritance-repo/t04/0000755000175000017500000000000011250552245025766 5ustar twernertwernermaven2-core-2.2.1/maven-project/src/test/resources/inheritance-repo/t04/maven-test/0000755000175000017500000000000011250552245030051 5ustar twernertwernermaven2-core-2.2.1/maven-project/src/test/resources/inheritance-repo/t04/maven-test/poms/0000755000175000017500000000000011250552245031027 5ustar twernertwerner././@LongLink0000000000000000000000000000015500000000000011566 Lustar rootrootmaven2-core-2.2.1/maven-project/src/test/resources/inheritance-repo/t04/maven-test/poms/maven-test-b-2.0.pommaven2-core-2.2.1/maven-project/src/test/resources/inheritance-repo/t04/maven-test/poms/maven-test-b0000644000175000017500000000026710574736620033272 0ustar twernertwerner 4.0.0 maven-test maven-test-b jar 2.0 ././@LongLink0000000000000000000000000000015500000000000011566 Lustar rootrootmaven2-core-2.2.1/maven-project/src/test/resources/inheritance-repo/t04/maven-test/poms/maven-test-b-1.0.pommaven2-core-2.2.1/maven-project/src/test/resources/inheritance-repo/t04/maven-test/poms/maven-test-b0000644000175000017500000000026710574736620033272 0ustar twernertwerner 4.0.0 maven-test maven-test-b jar 1.0 ././@LongLink0000000000000000000000000000015500000000000011566 Lustar rootrootmaven2-core-2.2.1/maven-project/src/test/resources/inheritance-repo/t04/maven-test/poms/maven-test-c-2.0.pommaven2-core-2.2.1/maven-project/src/test/resources/inheritance-repo/t04/maven-test/poms/maven-test-c0000644000175000017500000000026710574736620033273 0ustar twernertwerner 4.0.0 maven-test maven-test-b jar 2.0 ././@LongLink0000000000000000000000000000015500000000000011566 Lustar rootrootmaven2-core-2.2.1/maven-project/src/test/resources/inheritance-repo/t04/maven-test/poms/maven-test-a-1.0.pommaven2-core-2.2.1/maven-project/src/test/resources/inheritance-repo/t04/maven-test/poms/maven-test-a0000644000175000017500000000102610574736620033263 0ustar twernertwerner 4.0.0 maven-test maven-test-a jar 1.0 central Fake Maven Central Repository file://dummy maven-test maven-test-b 2.0 ././@LongLink0000000000000000000000000000015500000000000011566 Lustar rootrootmaven2-core-2.2.1/maven-project/src/test/resources/inheritance-repo/t04/maven-test/poms/maven-test-c-1.0.pommaven2-core-2.2.1/maven-project/src/test/resources/inheritance-repo/t04/maven-test/poms/maven-test-c0000644000175000017500000000026710574736620033273 0ustar twernertwerner 4.0.0 maven-test maven-test-c jar 1.0 maven2-core-2.2.1/maven-project/src/test/resources/inheritance-repo/t04/maven-test/jars/0000755000175000017500000000000011250552245031010 5ustar twernertwernermaven2-core-2.2.1/maven-project/src/test/resources/inheritance-repo/t04/p0/0000755000175000017500000000000011250552245026305 5ustar twernertwernermaven2-core-2.2.1/maven-project/src/test/resources/inheritance-repo/t04/p0/pom.xml0000644000175000017500000000142710772004567027635 0ustar twernertwerner 4.0.0 maven p0 pom p0 1.0 Codehaus maven-test maven-test-a 1.0 maven-test maven-test-b 1.0 maven-test maven-test-c 2.0 maven2-core-2.2.1/maven-project/src/test/resources/inheritance-repo/t04/p0/p1/0000755000175000017500000000000011250552245026625 5ustar twernertwernermaven2-core-2.2.1/maven-project/src/test/resources/inheritance-repo/t04/p0/p1/pom.xml0000644000175000017500000000156210772004567030155 0ustar twernertwerner p0 maven 1.0 4.0.0 maven p1 pom p1 1.0 scm-url maven-test maven-test-a maven-test maven-test-c 1.0 maven-antrun-plugin ${project.parent.basedir} maven2-core-2.2.1/maven-project/src/test/resources/inheritance-repo/t12/0000755000175000017500000000000011250552245025765 5ustar twernertwernermaven2-core-2.2.1/maven-project/src/test/resources/inheritance-repo/t12/p0/0000755000175000017500000000000011250552245026304 5ustar twernertwernermaven2-core-2.2.1/maven-project/src/test/resources/inheritance-repo/t12/p0/pom.xml0000644000175000017500000000127210772004567027632 0ustar twernertwerner 4.0.0 maven p0 pom 1.0 org.apache.maven.plugins maven-compiler-plugin test false compile install maven2-core-2.2.1/maven-project/src/test/resources/inheritance-repo/t12/p0/p1/0000755000175000017500000000000011250552245026624 5ustar twernertwernermaven2-core-2.2.1/maven-project/src/test/resources/inheritance-repo/t12/p0/p1/pom.xml0000644000175000017500000000116010772004567030146 0ustar twernertwerner p0 maven 1.0 4.0.0 p1 jar org.apache.maven.plugins maven-compiler-plugin normal compile maven2-core-2.2.1/maven-project/src/test/resources/inheritance-repo/t07/0000755000175000017500000000000011250552245025771 5ustar twernertwernermaven2-core-2.2.1/maven-project/src/test/resources/inheritance-repo/t07/maven-test/0000755000175000017500000000000011250552245030054 5ustar twernertwernermaven2-core-2.2.1/maven-project/src/test/resources/inheritance-repo/t07/maven-test/poms/0000755000175000017500000000000011250552245031032 5ustar twernertwerner././@LongLink0000000000000000000000000000015500000000000011566 Lustar rootrootmaven2-core-2.2.1/maven-project/src/test/resources/inheritance-repo/t07/maven-test/poms/maven-test-d-1.0.pommaven2-core-2.2.1/maven-project/src/test/resources/inheritance-repo/t07/maven-test/poms/maven-test-d0000644000175000017500000000026710574736620033277 0ustar twernertwerner 4.0.0 maven-test maven-test-d jar 1.0 ././@LongLink0000000000000000000000000000015500000000000011566 Lustar rootrootmaven2-core-2.2.1/maven-project/src/test/resources/inheritance-repo/t07/maven-test/poms/maven-test-b-1.0.pommaven2-core-2.2.1/maven-project/src/test/resources/inheritance-repo/t07/maven-test/poms/maven-test-b0000644000175000017500000000120210574736620033263 0ustar twernertwerner 4.0.0 maven-test maven-test-b jar 1.0 maven-test maven-test-c 1.0 jar compile maven-test maven-test-d 1.1 jar compile true ././@LongLink0000000000000000000000000000015500000000000011566 Lustar rootrootmaven2-core-2.2.1/maven-project/src/test/resources/inheritance-repo/t07/maven-test/poms/maven-test-a-1.0.pommaven2-core-2.2.1/maven-project/src/test/resources/inheritance-repo/t07/maven-test/poms/maven-test-a0000644000175000017500000000111210574736620033262 0ustar twernertwerner 4.0.0 maven-test maven-test-a jar 1.0 central Fake Maven Central Repository file://dummy maven-test maven-test-b 1.0 jar compile ././@LongLink0000000000000000000000000000015500000000000011566 Lustar rootrootmaven2-core-2.2.1/maven-project/src/test/resources/inheritance-repo/t07/maven-test/poms/maven-test-b-1.1.pommaven2-core-2.2.1/maven-project/src/test/resources/inheritance-repo/t07/maven-test/poms/maven-test-b0000644000175000017500000000120210574736620033263 0ustar twernertwerner 4.0.0 maven-test maven-test-b jar 1.1 maven-test maven-test-c 1.0 jar compile maven-test maven-test-d 1.1 jar compile true ././@LongLink0000000000000000000000000000015500000000000011566 Lustar rootrootmaven2-core-2.2.1/maven-project/src/test/resources/inheritance-repo/t07/maven-test/poms/maven-test-d-1.1.pommaven2-core-2.2.1/maven-project/src/test/resources/inheritance-repo/t07/maven-test/poms/maven-test-d0000644000175000017500000000026710574736620033277 0ustar twernertwerner 4.0.0 maven-test maven-test-d jar 1.1 ././@LongLink0000000000000000000000000000015500000000000011566 Lustar rootrootmaven2-core-2.2.1/maven-project/src/test/resources/inheritance-repo/t07/maven-test/poms/maven-test-c-1.0.pommaven2-core-2.2.1/maven-project/src/test/resources/inheritance-repo/t07/maven-test/poms/maven-test-c0000644000175000017500000000067610574736620033302 0ustar twernertwerner 4.0.0 maven-test maven-test-c jar 1.0 maven-test maven-test-d 1.1 jar compile true ././@LongLink0000000000000000000000000000015500000000000011566 Lustar rootrootmaven2-core-2.2.1/maven-project/src/test/resources/inheritance-repo/t07/maven-test/poms/maven-test-d-1.2.pommaven2-core-2.2.1/maven-project/src/test/resources/inheritance-repo/t07/maven-test/poms/maven-test-d0000644000175000017500000000026710574736620033277 0ustar twernertwerner 4.0.0 maven-test maven-test-d jar 1.2 maven2-core-2.2.1/maven-project/src/test/resources/inheritance-repo/t07/maven-test/jars/0000755000175000017500000000000011250552245031013 5ustar twernertwernermaven2-core-2.2.1/maven-project/src/test/resources/inheritance-repo/t07/p0/0000755000175000017500000000000011250552245026310 5ustar twernertwernermaven2-core-2.2.1/maven-project/src/test/resources/inheritance-repo/t07/p0/pom.xml0000644000175000017500000000177010772004567027641 0ustar twernertwerner 4.0.0 maven p0 pom p0 1.0 Codehaus maven-test maven-test-a 1.0 maven-test maven-test-b 1.1 maven-test maven-test-c 1.0 maven-test maven-test-d 1.2 test false maven2-core-2.2.1/maven-project/src/test/resources/inheritance-repo/t07/p0/p1/0000755000175000017500000000000011250552245026630 5ustar twernertwernermaven2-core-2.2.1/maven-project/src/test/resources/inheritance-repo/t07/p0/p1/pom.xml0000644000175000017500000000253010772004567030154 0ustar twernertwerner p0 maven 1.0 4.0.0 maven p1 pom p1 1.0 scm-url maven-test maven-test-b 1.0 maven-test maven-test-d 1.0 test false maven-test maven-test-a 1.0 maven-test maven-test-c 1.0 maven-antrun-plugin ${project.parent.basedir} maven2-core-2.2.1/maven-project/src/test/resources/org/0000755000175000017500000000000011250552245022712 5ustar twernertwernermaven2-core-2.2.1/maven-project/src/test/resources/org/apache/0000755000175000017500000000000011250552245024133 5ustar twernertwernermaven2-core-2.2.1/maven-project/src/test/resources/org/apache/maven/0000755000175000017500000000000011250552245025241 5ustar twernertwernermaven2-core-2.2.1/maven-project/src/test/resources/org/apache/maven/project/0000755000175000017500000000000011250552245026707 5ustar twernertwernermaven2-core-2.2.1/maven-project/src/test/resources/org/apache/maven/project/canonical/0000755000175000017500000000000011250552245030636 5ustar twernertwerner././@LongLink0000000000000000000000000000016600000000000011570 Lustar rootrootmaven2-core-2.2.1/maven-project/src/test/resources/org/apache/maven/project/canonical/CanonicalProjectBuilderTest.xmlmaven2-core-2.2.1/maven-project/src/test/resources/org/apache/maven/project/canonical/CanonicalProje0000644000175000017500000000736211147323515033461 0ustar twernertwerner org.apache.maven.project.injection.ProfileInjector test org.apache.maven.project.injection.TestProfileInjector org.apache.maven.project.TestArtifactResolver org.apache.maven.project.TestArtifactResolver org.apache.maven.artifact.manager.WagonManager org.apache.maven.artifact.factory.ArtifactFactory org.apache.maven.artifact.repository.ArtifactRepositoryFactory org.apache.maven.artifact.resolver.ArtifactCollector org.apache.maven.project.MavenProjectBuilder test org.apache.maven.project.TestProjectBuilder org.apache.maven.profiles.MavenProfilesBuilder org.apache.maven.project.injection.ModelDefaultsInjector org.apache.maven.project.injection.ProfileInjector test org.apache.maven.project.interpolation.ModelInterpolator org.apache.maven.project.inheritance.ModelInheritanceAssembler org.apache.maven.project.validation.ModelValidator org.apache.maven.project.path.PathTranslator org.apache.maven.project.artifact.ProjectArtifactFactory maven-project org.apache.maven.artifact.resolver.ArtifactResolver org.apache.maven.artifact.repository.ArtifactRepositoryFactory ././@LongLink0000000000000000000000000000014500000000000011565 Lustar rootrootmaven2-core-2.2.1/maven-project/src/test/resources/org/apache/maven/project/ProjectClasspathTest.xmlmaven2-core-2.2.1/maven-project/src/test/resources/org/apache/maven/project/ProjectClasspathTest.xml0000644000175000017500000000736211147323515033553 0ustar twernertwerner org.apache.maven.project.injection.ProfileInjector test org.apache.maven.project.injection.TestProfileInjector org.apache.maven.project.TestArtifactResolver org.apache.maven.project.TestArtifactResolver org.apache.maven.artifact.manager.WagonManager org.apache.maven.artifact.factory.ArtifactFactory org.apache.maven.artifact.repository.ArtifactRepositoryFactory org.apache.maven.artifact.resolver.ArtifactCollector org.apache.maven.project.MavenProjectBuilder test org.apache.maven.project.TestProjectBuilder org.apache.maven.profiles.MavenProfilesBuilder org.apache.maven.project.injection.ModelDefaultsInjector org.apache.maven.project.injection.ProfileInjector test org.apache.maven.project.interpolation.ModelInterpolator org.apache.maven.project.inheritance.ModelInheritanceAssembler org.apache.maven.project.validation.ModelValidator org.apache.maven.project.path.PathTranslator org.apache.maven.project.artifact.ProjectArtifactFactory maven-project org.apache.maven.artifact.resolver.ArtifactResolver org.apache.maven.artifact.repository.ArtifactRepositoryFactory maven2-core-2.2.1/maven-project/src/test/resources/projects/0000755000175000017500000000000011250552245023754 5ustar twernertwernermaven2-core-2.2.1/maven-project/src/test/resources/projects/build-path-expression-pom.xml0000644000175000017500000000057510772004567031533 0ustar twernertwerner 4.0.0 org.apache.maven.project.tests build-path-expression 1 sources ${project.build.sourceDirectory} maven2-core-2.2.1/maven-project/src/test/resources/projects/duplicate-plugins-merged-pom.xml0000644000175000017500000000155310772004567032174 0ustar twernertwerner 4.0.0 tests.project duplicate-plugin-defs-merged 1 maven-compiler-plugin group first 1 maven-compiler-plugin group second 1 maven2-core-2.2.1/maven-project/src/test/resources/projects/grandchild-check/0000755000175000017500000000000011250552245027126 5ustar twernertwernermaven2-core-2.2.1/maven-project/src/test/resources/projects/grandchild-check/child/0000755000175000017500000000000011250552245030211 5ustar twernertwernermaven2-core-2.2.1/maven-project/src/test/resources/projects/grandchild-check/child/grandchild/0000755000175000017500000000000011250552245032310 5ustar twernertwerner././@LongLink0000000000000000000000000000014600000000000011566 Lustar rootrootmaven2-core-2.2.1/maven-project/src/test/resources/projects/grandchild-check/child/grandchild/pom.xmlmaven2-core-2.2.1/maven-project/src/test/resources/projects/grandchild-check/child/grandchild/pom.xm0000644000175000017500000000031510772004567033457 0ustar twernertwerner 4.0.0 grandchildtest child 1 grandchild maven2-core-2.2.1/maven-project/src/test/resources/projects/grandchild-check/child/pom.xml0000644000175000017500000000043710772004567031541 0ustar twernertwerner 4.0.0 grandchildtest root-pom 1 child pom grandchild maven2-core-2.2.1/maven-project/src/test/resources/projects/grandchild-check/pom.xml0000644000175000017500000000026110772004567030451 0ustar twernertwerner 4.0.0 grandchildtest root-pom 1 pom maven2-core-2.2.1/maven-project/src/test/resources/projects/base-directory-alignment/0000755000175000017500000000000011250552245030644 5ustar twernertwerner././@LongLink0000000000000000000000000000020700000000000011564 Lustar rootrootmaven2-core-2.2.1/maven-project/src/test/resources/projects/base-directory-alignment/project-which-needs-directory-alignment-child.xmlmaven2-core-2.2.1/maven-project/src/test/resources/projects/base-directory-alignment/project-which-n0000644000175000017500000000211610551365651033576 0ustar twernertwerner project-which-needs-directory-alignment.xml maven project-which-needs-directory-alignment.xml 1.0-beta-9 maven maven-foo 1.0 maven2-core-2.2.1/maven-project/src/test/resources/projects/base-directory-alignment/subproject/0000755000175000017500000000000011250552245033024 5ustar twernertwerner././@LongLink0000000000000000000000000000022200000000000011561 Lustar rootrootmaven2-core-2.2.1/maven-project/src/test/resources/projects/base-directory-alignment/subproject/project-which-needs-directory-alignment-child.xmlmaven2-core-2.2.1/maven-project/src/test/resources/projects/base-directory-alignment/subproject/proj0000644000175000017500000000176310551365651033736 0ustar twernertwerner ../project-which-needs-directory-alignment.xml maven project-which-needs-directory-alignment 1.0-beta-9 ././@LongLink0000000000000000000000000000020100000000000011556 Lustar rootrootmaven2-core-2.2.1/maven-project/src/test/resources/projects/base-directory-alignment/project-which-needs-directory-alignment.xmlmaven2-core-2.2.1/maven-project/src/test/resources/projects/base-directory-alignment/project-which-n0000644000175000017500000000711310551365651033600 0ustar twernertwerner 4.0.0 maven project-which-needs-directory-alignment Maven 1.0-beta-9 2001 Description http://maven.apache.org/ Apache Software Foundation http://apache.org/ anon-connection developer-connection repository-url Maven User List subscribe unsubscribe archive Jason van Zyl jvanzyl jason@maven.org Zenplex Founder Release Manager Martin van dem Bemt mvdb@mvdb.com g1 d1 1.0 g2 d2 2.0 g3 d3 g3 d3 3.0 sourceDirectory unitTestSourceDirectory src/test **/*.xml src/conf *.xsd *.dtd *.mod log4j.properties driver.jelly driver.properties src/messages org/apache/maven/messages messages*.properties maven2-core-2.2.1/maven-project/src/test/resources/projects/scope/0000755000175000017500000000000011250552245025065 5ustar twernertwernermaven2-core-2.2.1/maven-project/src/test/resources/projects/scope/transitive-provided-dep.xml0000644000175000017500000000320010772004567032361 0ustar twernertwerner maven-test scope-provided 1.0 maven-test-provided scope-default 1.0 maven-test-provided scope-test 1.0 test maven-test-provided scope-runtime 1.0 runtime maven-test-provided scope-compile 1.0 compile maven2-core-2.2.1/maven-project/src/test/resources/projects/scope/transitive-default-dep.xml0000644000175000017500000000317410551365651032202 0ustar twernertwerner maven-test scope-default 1.0 maven-test-default scope-default 1.0 maven-test-default scope-test 1.0 test maven-test-default scope-runtime 1.0 runtime maven-test-default scope-compile 1.0 compile maven2-core-2.2.1/maven-project/src/test/resources/projects/scope/transitive-runtime-dep.xml0000644000175000017500000000317410551365651032241 0ustar twernertwerner maven-test scope-runtime 1.0 maven-test-runtime scope-default 1.0 maven-test-runtime scope-test 1.0 test maven-test-runtime scope-runtime 1.0 runtime maven-test-runtime scope-compile 1.0 compile maven2-core-2.2.1/maven-project/src/test/resources/projects/scope/transitive-compile-dep.xml0000644000175000017500000000317310551365651032205 0ustar twernertwerner maven-test scope-compile 1.0 maven-test-compile scope-default 1.0 maven-test-compile scope-test 1.0 test maven-test-compile scope-runtime 1.0 runtime maven-test-compile scope-compile 1.0 compile ././@LongLink0000000000000000000000000000014700000000000011567 Lustar rootrootmaven2-core-2.2.1/maven-project/src/test/resources/projects/scope/project-with-scoped-dependencies.xmlmaven2-core-2.2.1/maven-project/src/test/resources/projects/scope/project-with-scoped-dependencies.x0000644000175000017500000000526010551365651033605 0ustar twernertwerner 4.0.0 maven maven-project-test Maven 1.0-beta-9 maven-test scope-default 1.0 maven-test scope-test 1.0 test maven-test scope-runtime 1.0 runtime maven-test scope-compile 1.0 compile maven-test scope-provided 1.0 provided maven-inherited scope-default 1.0 maven-inherited scope-compile 1.0 compile maven-inherited scope-runtime 1.0 runtime maven-inherited scope-test 1.0 test maven-inherited scope-provided 1.0 provided maven2-core-2.2.1/maven-project/src/test/resources/projects/scope/transitive-test-dep.xml0000644000175000017500000000315510551365651031534 0ustar twernertwerner maven-test scope-test 1.0 maven-test-test scope-default 1.0 maven-test-test scope-test 1.0 test maven-test-test scope-runtime 1.0 runtime maven-test-test scope-compile 1.0 compile maven2-core-2.2.1/maven-project/src/test/resources/validation/0000755000175000017500000000000011250552245024255 5ustar twernertwerner././@LongLink0000000000000000000000000000014600000000000011566 Lustar rootrootmaven2-core-2.2.1/maven-project/src/test/resources/validation/missing-dependency-mgmt-groupId-pom.xmlmaven2-core-2.2.1/maven-project/src/test/resources/validation/missing-dependency-mgmt-groupId-pom.xm0000644000175000017500000000217210772004567033563 0ustar twernertwerner 4.0.0 foo foo 99.44 bleh artifactId version maven2-core-2.2.1/maven-project/src/test/resources/validation/missing-modelVersion-pom.xml0000644000175000017500000000160510551365651031715 0ustar twernertwerner foo foo 99.44 bleh maven2-core-2.2.1/maven-project/src/test/resources/validation/missing-dependency-artifactId-pom.xml0000644000175000017500000000205610772004567033437 0ustar twernertwerner 4.0.0 foo foo 99.44 bleh groupId 1.0 maven2-core-2.2.1/maven-project/src/test/resources/validation/missing-dependency-groupId-pom.xml0000644000175000017500000000206710772004567033000 0ustar twernertwerner 4.0.0 foo foo 99.44 bleh artifactId 1.0 maven2-core-2.2.1/maven-project/src/test/resources/validation/missing-repository-id-pom.xml0000644000175000017500000000212010772004567032052 0ustar twernertwerner 4.0.0 foo foo 99.44 bleh maven2-core-2.2.1/maven-project/src/test/resources/validation/missing-dependency-version-pom.xml0000644000175000017500000000207310772004567033051 0ustar twernertwerner 4.0.0 foo foo 99.44 bleh artifactId groupId maven2-core-2.2.1/maven-project/src/test/resources/validation/missing-version-pom.xml0000644000175000017500000000161710551365651030737 0ustar twernertwerner 4.0.0 foo bar bleh ././@LongLink0000000000000000000000000000015100000000000011562 Lustar rootrootmaven2-core-2.2.1/maven-project/src/test/resources/validation/missing-dependency-mgmt-artifactId-pom.xmlmaven2-core-2.2.1/maven-project/src/test/resources/validation/missing-dependency-mgmt-artifactId-pom0000644000175000017500000000216110772004567033577 0ustar twernertwerner 4.0.0 foo foo 99.44 bleh groupId version maven2-core-2.2.1/maven-project/src/test/resources/validation/invalid-aggregator-packaging-pom.xml0000644000175000017500000000174710772004567033300 0ustar twernertwerner 4.0.0 foo foo 99.44 bleh test-module maven2-core-2.2.1/maven-project/src/test/resources/validation/missing-plugin-artifactId-pom.xml0000644000175000017500000000177410772004567032625 0ustar twernertwerner 4.0.0 foo foo 99.44 bleh maven2-core-2.2.1/maven-project/src/test/resources/validation/missing-resource-directory-pom.xml0000644000175000017500000000213110772004567033074 0ustar twernertwerner 4.0.0 foo foo 99.44 bleh maven2-core-2.2.1/maven-project/src/test/resources/validation/missing-groupId-pom.xml0000644000175000017500000000162110551365651030656 0ustar twernertwerner 4.0.0 bar 99.44 bleh maven2-core-2.2.1/maven-project/src/test/resources/validation/missing-1-pom.xml0000644000175000017500000000142410551365651027406 0ustar twernertwerner maven2-core-2.2.1/maven-project/src/test/resources/validation/missing-artifactId-pom.xml0000644000175000017500000000161310551365651031320 0ustar twernertwerner 4.0.0 foo 99.44 bleh maven2-core-2.2.1/maven-project/src/test/resources/validation/missing-type-pom.xml0000644000175000017500000000164610551365651030235 0ustar twernertwerner 4.0.0 foo bar 99.44 maven2-core-2.2.1/maven-project/src/test/resources/validation/missing-report-artifactId-pom.xml0000644000175000017500000000200410772004567032625 0ustar twernertwerner 4.0.0 foo foo 99.44 bleh ././@LongLink0000000000000000000000000000014600000000000011566 Lustar rootrootmaven2-core-2.2.1/maven-project/src/test/resources/validation/missing-dependency-mgmt-version-pom.xmlmaven2-core-2.2.1/maven-project/src/test/resources/validation/missing-dependency-mgmt-version-pom.xm0000644000175000017500000000217210772004567033637 0ustar twernertwerner 4.0.0 foo foo 99.44 bleh artifactId groupId maven2-core-2.2.1/maven-project/src/test/resources/validation/invalid-ids-pom.xml0000644000175000017500000000165710772004567030013 0ustar twernertwerner 4.0.0 o/a/m m$-do$ 99.44 bleh maven2-core-2.2.1/maven-project/src/test/resources/coord-expressions/0000755000175000017500000000000011250552245025611 5ustar twernertwernermaven2-core-2.2.1/maven-project/src/test/resources/coord-expressions/pom-with-comments.xml0000644000175000017500000000124011221205616031712 0ustar twernertwerner 4.0.0 org.test pom-with-comments ${testVersion} pom ${testVersion} ${testVersion} 1.0 ${testVersion} maven2-core-2.2.1/maven-project/src/test/resources/coord-expressions/invalid-pom.xml0000644000175000017500000000143511221205616030550 0ustar twernertwerner 4.0.0 org.test invalid-pom ${testVersion} pom ${testVersion} ${testVersion} junit junit 3.8.1 1.0 ${testVersion} maven2-core-2.2.1/maven-project/src/test/resources/coord-expressions/alternative-encoding-pom.xml0000644000175000017500000000123011221205616033215 0ustar twernertwerner 4.0.0 org.test pom-with-comments 1 pom ${testVersion} ${testVersion} 1.0 ${testVersion} ././@LongLink0000000000000000000000000000014700000000000011567 Lustar rootrootmaven2-core-2.2.1/maven-project/src/test/resources/coord-expressions/pom-with-build-dir-expression.xmlmaven2-core-2.2.1/maven-project/src/test/resources/coord-expressions/pom-with-build-dir-expression.x0000644000175000017500000000131711221205616033611 0ustar twernertwerner 4.0.0 org.test pom-with-comments ${testVersion} pom ${testVersion} ${testVersion} 1.0 ${testVersion} ${project.basedir}/target maven2-core-2.2.1/maven-project/src/test/resources/local-repo/0000755000175000017500000000000011250552245024160 5ustar twernertwernermaven2-core-2.2.1/maven-project/src/test/resources/local-repo/maven-test/0000755000175000017500000000000011250552245026243 5ustar twernertwernermaven2-core-2.2.1/maven-project/src/test/resources/local-repo/maven-test/poms/0000755000175000017500000000000011250552245027221 5ustar twernertwernermaven2-core-2.2.1/maven-project/src/test/resources/local-repo/maven-test/poms/maven-test-b-1.0.pom0000644000175000017500000000114210255443072032533 0ustar twernertwerner 4.0.0 maven-test maven-test-b jar 1.0 maven-test maven-test-c 1.0 jar compile maven-test maven-test-d 1.1 jar compile maven2-core-2.2.1/maven-project/src/test/resources/local-repo/maven-test/poms/maven-test-a-1.0.pom0000644000175000017500000000111210255443072032527 0ustar twernertwerner 4.0.0 maven-test maven-test-a jar 1.0 central Fake Maven Central Repository file://dummy maven-test maven-test-b 1.0 jar compile maven2-core-2.2.1/maven-project/src/test/resources/local-repo/maven-test/poms/maven-test-d-1.1.pom0000644000175000017500000000026710255443072032545 0ustar twernertwerner 4.0.0 maven-test maven-test-d jar 1.1 maven2-core-2.2.1/maven-project/src/test/resources/local-repo/maven-test/poms/maven-test-c-1.0.pom0000644000175000017500000000063610255443072032543 0ustar twernertwerner 4.0.0 maven-test maven-test-c jar 1.0 maven-test maven-test-d 1.2 jar compile maven2-core-2.2.1/maven-project/src/test/resources/local-repo/maven-test/poms/maven-test-d-1.2.pom0000644000175000017500000000026710255443072032546 0ustar twernertwerner 4.0.0 maven-test maven-test-d jar 1.1 maven2-core-2.2.1/maven-project/src/test/resources/local-repo/maven-test/jars/0000755000175000017500000000000011250552245027202 5ustar twernertwernermaven2-core-2.2.1/maven-project/src/test/resources/local-repo/snapshot-test/0000755000175000017500000000000011250552245026774 5ustar twernertwernermaven2-core-2.2.1/maven-project/src/test/resources/local-repo/snapshot-test/poms/0000755000175000017500000000000011250552245027752 5ustar twernertwerner././@LongLink0000000000000000000000000000016700000000000011571 Lustar rootrootmaven2-core-2.2.1/maven-project/src/test/resources/local-repo/snapshot-test/poms/maven-test-snapshot-resolving-1.0.pommaven2-core-2.2.1/maven-project/src/test/resources/local-repo/snapshot-test/poms/maven-test-snapshot0000644000175000017500000000260010255443072033614 0ustar twernertwerner snapshot-test maven-test-snapshot-resolving jar central Fake Maven Central Repository file://dummy snapshot-test maven-snapshot-a 1.0-SNAPSHOT jar compile snapshot-test maven-snapshot-b 1.0-SNAPSHOT jar compile snapshot-test maven-snapshot-c 1.0-SNAPSHOT jar compile snapshot-test maven-snapshot-d 1.0-SNAPSHOT jar compile snapshot-test maven-snapshot-e 1.0-SNAPSHOT jar compile maven2-core-2.2.1/maven-project/src/test/resources/local-repo/snapshot-test/jars/0000755000175000017500000000000011250552245027733 5ustar twernertwerner././@LongLink0000000000000000000000000000020400000000000011561 Lustar rootrootmaven2-core-2.2.1/maven-project/src/test/resources/local-repo/snapshot-test/jars/maven-snapshot-b-1.0-SNAPSHOT.jar.snapshot-versionmaven2-core-2.2.1/maven-project/src/test/resources/local-repo/snapshot-test/jars/maven-snapshot-b-1.0000644000175000017500000000001710154505607033254 0ustar twernertwerner20040101.101010././@LongLink0000000000000000000000000000020400000000000011561 Lustar rootrootmaven2-core-2.2.1/maven-project/src/test/resources/local-repo/snapshot-test/jars/maven-snapshot-a-1.0-SNAPSHOT.jar.snapshot-versionmaven2-core-2.2.1/maven-project/src/test/resources/local-repo/snapshot-test/jars/maven-snapshot-a-1.0000644000175000017500000000001710154505607033253 0ustar twernertwerner20040101.101010././@LongLink0000000000000000000000000000020400000000000011561 Lustar rootrootmaven2-core-2.2.1/maven-project/src/test/resources/local-repo/snapshot-test/jars/maven-snapshot-e-1.0-SNAPSHOT.jar.snapshot-versionmaven2-core-2.2.1/maven-project/src/test/resources/local-repo/snapshot-test/jars/maven-snapshot-e-1.0000644000175000017500000000001710154505607033257 0ustar twernertwerner20040101.101010maven2-core-2.2.1/maven-project/src/test/resources/local-repo/marker.txt0000644000175000017500000000003310232154615026174 0ustar twernertwernerthis is just a marker file.maven2-core-2.2.1/maven-project/src/test/resources/distributionManagement-pom.xml0000644000175000017500000000252510772004567030165 0ustar twernertwerner 4.0.0 maven maven-core Maven 2.0-SNAPSHOT repo-id my snapshot repository file:///path/to/snapshot/repo repo-id2 my repository file:///path/to/repo maven2-core-2.2.1/maven-project/src/test/resources/canonical-pom.xml0000644000175000017500000000333310551365651025375 0ustar twernertwerner 4.0.0 maven maven-core Maven 2.0-SNAPSHOT maven-plexus-plugin 1.0 src/conf/plexus.conf src/conf/plexus.properties Continuum plexus:runtime ContinuumPro maven2-core-2.2.1/maven-project/src/test/resources/imports-repo/0000755000175000017500000000000011250552245024563 5ustar twernertwernermaven2-core-2.2.1/maven-project/src/test/resources/imports-repo/t01/0000755000175000017500000000000011250552245025167 5ustar twernertwernermaven2-core-2.2.1/maven-project/src/test/resources/imports-repo/t01/maven-test/0000755000175000017500000000000011250552245027252 5ustar twernertwernermaven2-core-2.2.1/maven-project/src/test/resources/imports-repo/t01/maven-test/poms/0000755000175000017500000000000011250552245030230 5ustar twernertwerner././@LongLink0000000000000000000000000000015100000000000011562 Lustar rootrootmaven2-core-2.2.1/maven-project/src/test/resources/imports-repo/t01/maven-test/poms/maven-test-c-1.1.pommaven2-core-2.2.1/maven-project/src/test/resources/imports-repo/t01/maven-test/poms/maven-test-c-1.10000644000175000017500000000026710725634163032766 0ustar twernertwerner 4.0.0 maven-test maven-test-c jar 1.1 ././@LongLink0000000000000000000000000000015100000000000011562 Lustar rootrootmaven2-core-2.2.1/maven-project/src/test/resources/imports-repo/t01/maven-test/poms/maven-test-d-1.0.pommaven2-core-2.2.1/maven-project/src/test/resources/imports-repo/t01/maven-test/poms/maven-test-d-1.00000644000175000017500000000026710725634163032766 0ustar twernertwerner 4.0.0 maven-test maven-test-d jar 1.0 ././@LongLink0000000000000000000000000000015100000000000011562 Lustar rootrootmaven2-core-2.2.1/maven-project/src/test/resources/imports-repo/t01/maven-test/poms/maven-test-b-1.0.pommaven2-core-2.2.1/maven-project/src/test/resources/imports-repo/t01/maven-test/poms/maven-test-b-1.00000644000175000017500000000026710725634163032764 0ustar twernertwerner 4.0.0 maven-test maven-test-b jar 1.0 ././@LongLink0000000000000000000000000000015100000000000011562 Lustar rootrootmaven2-core-2.2.1/maven-project/src/test/resources/imports-repo/t01/maven-test/poms/maven-test-a-1.0.pommaven2-core-2.2.1/maven-project/src/test/resources/imports-repo/t01/maven-test/poms/maven-test-a-1.00000644000175000017500000000054310725634163032760 0ustar twernertwerner 4.0.0 maven-test maven-test-a jar 1.0 central Fake Maven Central Repository file://dummy ././@LongLink0000000000000000000000000000015100000000000011562 Lustar rootrootmaven2-core-2.2.1/maven-project/src/test/resources/imports-repo/t01/maven-test/poms/maven-test-b-1.1.pommaven2-core-2.2.1/maven-project/src/test/resources/imports-repo/t01/maven-test/poms/maven-test-b-1.10000644000175000017500000000026710725634163032765 0ustar twernertwerner 4.0.0 maven-test maven-test-b jar 1.1 ././@LongLink0000000000000000000000000000015100000000000011562 Lustar rootrootmaven2-core-2.2.1/maven-project/src/test/resources/imports-repo/t01/maven-test/poms/maven-test-d-1.1.pommaven2-core-2.2.1/maven-project/src/test/resources/imports-repo/t01/maven-test/poms/maven-test-d-1.10000644000175000017500000000026710725634163032767 0ustar twernertwerner 4.0.0 maven-test maven-test-d jar 1.1 ././@LongLink0000000000000000000000000000015100000000000011562 Lustar rootrootmaven2-core-2.2.1/maven-project/src/test/resources/imports-repo/t01/maven-test/poms/maven-test-c-1.0.pommaven2-core-2.2.1/maven-project/src/test/resources/imports-repo/t01/maven-test/poms/maven-test-c-1.00000644000175000017500000000026710725634163032765 0ustar twernertwerner 4.0.0 maven-test maven-test-c jar 1.0 ././@LongLink0000000000000000000000000000015100000000000011562 Lustar rootrootmaven2-core-2.2.1/maven-project/src/test/resources/imports-repo/t01/maven-test/poms/maven-test-a-1.1.pommaven2-core-2.2.1/maven-project/src/test/resources/imports-repo/t01/maven-test/poms/maven-test-a-1.10000644000175000017500000000054310725634163032761 0ustar twernertwerner 4.0.0 maven-test maven-test-a jar 1.1 central Fake Maven Central Repository file://dummy ././@LongLink0000000000000000000000000000015100000000000011562 Lustar rootrootmaven2-core-2.2.1/maven-project/src/test/resources/imports-repo/t01/maven-test/poms/maven-test-d-1.2.pommaven2-core-2.2.1/maven-project/src/test/resources/imports-repo/t01/maven-test/poms/maven-test-d-1.20000644000175000017500000000026710725634163032770 0ustar twernertwerner 4.0.0 maven-test maven-test-d jar 1.2 maven2-core-2.2.1/maven-project/src/test/resources/imports-repo/t01/maven-test/jars/0000755000175000017500000000000011250552245030211 5ustar twernertwernermaven2-core-2.2.1/maven-project/src/test/resources/imports-repo/t01/p0/0000755000175000017500000000000011250552245025506 5ustar twernertwernermaven2-core-2.2.1/maven-project/src/test/resources/imports-repo/t01/p0/p4/0000755000175000017500000000000011250552245026031 5ustar twernertwernermaven2-core-2.2.1/maven-project/src/test/resources/imports-repo/t01/p0/p4/pom.xml0000644000175000017500000000325710772004567027364 0ustar twernertwerner p0 maven 1.0 4.0.0 maven p4 pom p4 1.0 scm-url maven p2 1.0 pom import maven p3 1.0 pom import maven-test maven-test-b 1.1 maven-test maven-test-a maven-test maven-test-b maven-test maven-test-c maven-test maven-test-d maven-antrun-plugin ${project.parent.basedir} maven2-core-2.2.1/maven-project/src/test/resources/imports-repo/t01/p0/p3/0000755000175000017500000000000011250552245026030 5ustar twernertwernermaven2-core-2.2.1/maven-project/src/test/resources/imports-repo/t01/p0/p3/pom.xml0000644000175000017500000000275410772004567027364 0ustar twernertwerner p0 maven 1.0 4.0.0 maven p3 pom p3 1.0 scm-url maven-test maven-test-a 1.1 maven-test maven-test-c 1.1 maven-test maven-test-d 1.0 maven-test maven-test-a maven-test maven-test-c maven-test maven-test-d maven-antrun-plugin ${project.parent.basedir} maven2-core-2.2.1/maven-project/src/test/resources/imports-repo/t01/p0/p2/0000755000175000017500000000000011250552245026027 5ustar twernertwernermaven2-core-2.2.1/maven-project/src/test/resources/imports-repo/t01/p0/p2/pom.xml0000644000175000017500000000257210772004567027361 0ustar twernertwerner p0 maven 1.0 4.0.0 maven p2 pom p2 1.0 scm-url maven p1 1.0 pom import maven-test maven-test-c 1.0 maven-test maven-test-a maven-test maven-test-b maven-test maven-test-c maven-antrun-plugin ${project.parent.basedir} maven2-core-2.2.1/maven-project/src/test/resources/imports-repo/t01/p0/pom.xml0000644000175000017500000000114410772004567027032 0ustar twernertwerner 4.0.0 maven p0 pom p0 1.0 Codehaus maven-test maven-test-a 1.0 p1 p2 p3 p4 maven2-core-2.2.1/maven-project/src/test/resources/imports-repo/t01/p0/p1/0000755000175000017500000000000011250552245026026 5ustar twernertwernermaven2-core-2.2.1/maven-project/src/test/resources/imports-repo/t01/p0/p1/pom.xml0000644000175000017500000000210510772004567027350 0ustar twernertwerner p0 maven 1.0 4.0.0 maven p1 pom p1 1.0 scm-url maven-test maven-test-b 1.0 maven-test maven-test-a maven-test maven-test-b maven-antrun-plugin ${project.parent.basedir} maven2-core-2.2.1/maven-project/src/test/java/0000755000175000017500000000000011250552244021031 5ustar twernertwernermaven2-core-2.2.1/maven-project/src/test/java/org/0000755000175000017500000000000011250552244021620 5ustar twernertwernermaven2-core-2.2.1/maven-project/src/test/java/org/apache/0000755000175000017500000000000011250552244023041 5ustar twernertwernermaven2-core-2.2.1/maven-project/src/test/java/org/apache/maven/0000755000175000017500000000000011250552244024147 5ustar twernertwernermaven2-core-2.2.1/maven-project/src/test/java/org/apache/maven/profiles/0000755000175000017500000000000011250552244025772 5ustar twernertwernermaven2-core-2.2.1/maven-project/src/test/java/org/apache/maven/profiles/activation/0000755000175000017500000000000011250552244030133 5ustar twernertwerner././@LongLink0000000000000000000000000000016600000000000011570 Lustar rootrootmaven2-core-2.2.1/maven-project/src/test/java/org/apache/maven/profiles/activation/JdkPrefixProfileActivatorTest.javamaven2-core-2.2.1/maven-project/src/test/java/org/apache/maven/profiles/activation/JdkPrefixProfileA0000644000175000017500000001115611143535775033405 0ustar twernertwernerpackage org.apache.maven.profiles.activation; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import org.apache.maven.model.Activation; import org.apache.maven.model.Profile; import junit.framework.TestCase; public class JdkPrefixProfileActivatorTest extends TestCase { public void testDetectionWithoutActivationElement() { JdkPrefixProfileActivator activator = createActivator(); Profile profile = new Profile(); assertFalse( activator.canDetectActivation( profile ) ); } public void testDetectionWithoutJdkElement() { JdkPrefixProfileActivator activator = createActivator(); Profile profile = createProfile( null ); assertFalse( activator.canDetectActivation( profile ) ); } public void testDetectionWithJdkElement() { JdkPrefixProfileActivator activator = createActivator(); Profile profile = createProfile( "1.5" ); assertTrue( activator.canDetectActivation( profile ) ); } public void testActivationWithMatchingJdkVersion() throws ProfileActivationException { JdkPrefixProfileActivator activator = createActivator( "1.5.0_15" ); Profile profile = createProfile( "1.5" ); assertTrue( activator.isActive( profile ) ); } public void testActivationWithDifferentJdkVersion() throws ProfileActivationException { JdkPrefixProfileActivator activator = createActivator( "1.5.0_15" ); Profile profile = createProfile( "1.4" ); assertFalse( activator.isActive( profile ) ); } public void testActivationWithMatchingNegatedJdkVersion() throws ProfileActivationException { JdkPrefixProfileActivator activator = createActivator( "1.5.0_15" ); Profile profile = createProfile( "!1.4" ); assertTrue( activator.isActive( profile ) ); } public void testActivationWithDifferentNegatedJdkVersion() throws ProfileActivationException { JdkPrefixProfileActivator activator = createActivator( "1.5.0_15" ); Profile profile = createProfile( "!1.5" ); assertFalse( activator.isActive( profile ) ); } public void testActivationWithMatchingRangeJdkVersion() throws ProfileActivationException { JdkPrefixProfileActivator activator = createActivator( "1.5.0_15" ); Profile profile = createProfile( "[1.4,1.6)" ); assertTrue( activator.isActive( profile ) ); } public void testActivationWithDifferentRangeJdkVersion() throws ProfileActivationException { JdkPrefixProfileActivator activator = createActivator( "1.5.0_15" ); Profile profile = createProfile( "[1.4,1.5]" ); assertFalse( activator.isActive( profile ) ); } public void testActivationWithBadRangeJdkVersion() throws ProfileActivationException { JdkPrefixProfileActivator activator = createActivator( "1.5.0_15" ); Profile profile = createProfile( "[1.4," ); try { activator.isActive( profile ); fail( "Should have raised an exception for invalid format" ); } catch ( ProfileActivationException e ) { assertTrue( true ); } } private static JdkPrefixProfileActivator createActivator() { return new JdkPrefixProfileActivator(); } private static JdkPrefixProfileActivator createActivator( final String testJdkVersion ) { return new JdkPrefixProfileActivator() { protected String getJdkVersion() { return testJdkVersion; } }; } private static Profile createProfile( String jdk ) { Profile profile = new Profile(); Activation activation = new Activation(); activation.setJdk( jdk ); profile.setActivation( activation ); return profile; } } ././@LongLink0000000000000000000000000000014700000000000011567 Lustar rootrootmaven2-core-2.2.1/maven-project/src/test/java/org/apache/maven/profiles/DefaultProfileManagerTest.javamaven2-core-2.2.1/maven-project/src/test/java/org/apache/maven/profiles/DefaultProfileManagerTest.ja0000644000175000017500000002151510772004567033362 0ustar twernertwernerpackage org.apache.maven.profiles; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import java.io.File; import java.io.IOException; import java.util.List; import org.apache.maven.model.Activation; import org.apache.maven.model.ActivationOS; import org.apache.maven.model.ActivationProperty; import org.apache.maven.model.Profile; import org.apache.maven.profiles.activation.ProfileActivationException; import org.apache.maven.settings.Settings; import org.codehaus.plexus.PlexusTestCase; public class DefaultProfileManagerTest extends PlexusTestCase { public void testShouldActivateNonExistantSettingsProfile() throws ProfileActivationException { // MNG-2234 - we should activate profiles that don't exist yet so that they can be defined by a POM. Settings settings = new Settings(); settings.addActiveProfile( "testProfile" ); ProfileManager profileManager = new DefaultProfileManager( getContainer(), settings ); List activeIds = profileManager.getExplicitlyActivatedIds(); assertNotNull( activeIds ); assertEquals( 1, activeIds.size() ); assertEquals( "testProfile", activeIds.get( 0 ) ); List activeProfiles = profileManager.getActiveProfiles(); assertTrue( activeProfiles.isEmpty() ); Profile p = new Profile(); p.setId( "testProfile" ); profileManager.addProfile( p ); activeProfiles = profileManager.getActiveProfiles(); assertNotNull( activeProfiles ); assertEquals( 1, activeProfiles.size() ); assertEquals( "testProfile", ( (Profile) activeProfiles.get( 0 ) ).getId() ); } public void testShouldActivateDefaultProfile() throws ProfileActivationException { Profile notActivated = new Profile(); notActivated.setId( "notActivated" ); Activation nonActivation = new Activation(); nonActivation.setJdk( "19.2" ); notActivated.setActivation( nonActivation ); Profile defaultActivated = new Profile(); defaultActivated.setId( "defaultActivated" ); Activation defaultActivation = new Activation(); defaultActivation.setActiveByDefault( true ); defaultActivated.setActivation( defaultActivation ); ProfileManager profileManager = new DefaultProfileManager( getContainer() ); profileManager.addProfile( notActivated ); profileManager.addProfile( defaultActivated ); List active = profileManager.getActiveProfiles(); assertNotNull( active ); assertEquals( 1, active.size() ); assertEquals( "defaultActivated", ( (Profile) active.get( 0 ) ).getId() ); } public void testShouldNotActivateDefaultProfile() throws ProfileActivationException { Profile syspropActivated = new Profile(); syspropActivated.setId( "syspropActivated" ); Activation syspropActivation = new Activation(); ActivationProperty syspropProperty = new ActivationProperty(); syspropProperty.setName( "java.version" ); syspropActivation.setProperty( syspropProperty ); syspropActivated.setActivation( syspropActivation ); Profile defaultActivated = new Profile(); defaultActivated.setId( "defaultActivated" ); Activation defaultActivation = new Activation(); defaultActivation.setActiveByDefault( true ); defaultActivated.setActivation( defaultActivation ); ProfileManager profileManager = new DefaultProfileManager( getContainer() ); profileManager.addProfile( syspropActivated ); profileManager.addProfile( defaultActivated ); List active = profileManager.getActiveProfiles(); assertNotNull( active ); assertEquals( 1, active.size() ); assertEquals( "syspropActivated", ( (Profile) active.get( 0 ) ).getId() ); } public void testShouldNotActivateReversalOfPresentSystemProperty() throws ProfileActivationException { Profile syspropActivated = new Profile(); syspropActivated.setId( "syspropActivated" ); Activation syspropActivation = new Activation(); ActivationProperty syspropProperty = new ActivationProperty(); syspropProperty.setName( "!java.version" ); syspropActivation.setProperty( syspropProperty ); syspropActivated.setActivation( syspropActivation ); ProfileManager profileManager = new DefaultProfileManager( getContainer() ); profileManager.addProfile( syspropActivated ); List active = profileManager.getActiveProfiles(); assertNotNull( active ); assertEquals( 0, active.size() ); } public void testShouldOverrideAndActivateInactiveProfile() throws ProfileActivationException { Profile syspropActivated = new Profile(); syspropActivated.setId( "syspropActivated" ); Activation syspropActivation = new Activation(); ActivationProperty syspropProperty = new ActivationProperty(); syspropProperty.setName( "!java.version" ); syspropActivation.setProperty( syspropProperty ); syspropActivated.setActivation( syspropActivation ); ProfileManager profileManager = new DefaultProfileManager( getContainer() ); profileManager.addProfile( syspropActivated ); profileManager.explicitlyActivate( "syspropActivated" ); List active = profileManager.getActiveProfiles(); assertNotNull( active ); assertEquals( 1, active.size() ); assertEquals( "syspropActivated", ( (Profile) active.get( 0 ) ).getId() ); } public void testShouldOverrideAndDeactivateActiveProfile() throws ProfileActivationException { Profile syspropActivated = new Profile(); syspropActivated.setId( "syspropActivated" ); Activation syspropActivation = new Activation(); ActivationProperty syspropProperty = new ActivationProperty(); syspropProperty.setName( "java.version" ); syspropActivation.setProperty( syspropProperty ); syspropActivated.setActivation( syspropActivation ); ProfileManager profileManager = new DefaultProfileManager( getContainer() ); profileManager.addProfile( syspropActivated ); profileManager.explicitlyDeactivate( "syspropActivated" ); List active = profileManager.getActiveProfiles(); assertNotNull( active ); assertEquals( 0, active.size() ); } public void testOsActivationProfile() throws ProfileActivationException { Profile osActivated = new Profile(); osActivated.setId( "os-profile" ); Activation osActivation = new Activation(); ActivationOS activationOS = new ActivationOS(); activationOS.setName( "!dddd" ); osActivation.setOs( activationOS ); osActivated.setActivation( osActivation ); ProfileManager profileManager = new DefaultProfileManager( getContainer() ); profileManager.addProfile( osActivated ); List active = profileManager.getActiveProfiles(); assertNotNull( active ); assertEquals( 1, active.size() ); } public void testFileActivationProfile() throws ProfileActivationException, IOException { Profile osActivated = new Profile(); osActivated.setId( "os-profile" ); Activation fileActivation = new Activation(); org.apache.maven.model.ActivationFile activationFile = new org.apache.maven.model.ActivationFile(); File f = File.createTempFile( "activationTest", null ); f.createNewFile(); activationFile.setExists( f.getAbsolutePath() ); fileActivation.setFile( activationFile ); osActivated.setActivation( fileActivation ); ProfileManager profileManager = new DefaultProfileManager( getContainer() ); profileManager.addProfile( osActivated ); List active = profileManager.getActiveProfiles(); assertNotNull( active ); assertEquals( 1, active.size() ); try { f.delete(); } catch (Exception e) { //don't care. I tried. } } } maven2-core-2.2.1/maven-project/src/test/java/org/apache/maven/project/0000755000175000017500000000000011250552245025616 5ustar twernertwerner././@LongLink0000000000000000000000000000015300000000000011564 Lustar rootrootmaven2-core-2.2.1/maven-project/src/test/java/org/apache/maven/project/DefaultMavenProjectBuilderTest.javamaven2-core-2.2.1/maven-project/src/test/java/org/apache/maven/project/DefaultMavenProjectBuilderTes0000644000175000017500000001631711030240413033421 0ustar twernertwernerpackage org.apache.maven.project; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.artifact.repository.DefaultArtifactRepository; import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout; import org.apache.maven.model.Build; import org.apache.maven.model.Plugin; import org.apache.maven.model.Profile; import org.apache.maven.model.Repository; import org.apache.maven.model.Resource; import org.apache.maven.profiles.DefaultProfileManager; import org.apache.maven.profiles.ProfileManager; import org.codehaus.plexus.util.FileUtils; import java.io.File; import java.util.ArrayList; import java.util.Iterator; import java.util.List; import java.util.Properties; public class DefaultMavenProjectBuilderTest extends AbstractMavenProjectTestCase { private List filesToDelete = new ArrayList(); private File localRepoDir; public void setUp() throws Exception { super.setUp(); localRepoDir = new File( System.getProperty( "java.io.tmpdir" ), "local-repo." + System.currentTimeMillis() ); localRepoDir.mkdirs(); filesToDelete.add( localRepoDir ); } public void tearDown() throws Exception { super.tearDown(); if ( !filesToDelete.isEmpty() ) { for ( Iterator it = filesToDelete.iterator(); it.hasNext(); ) { File file = (File) it.next(); if ( file.exists() ) { if ( file.isDirectory() ) { FileUtils.deleteDirectory( file ); } else { file.delete(); } } } } } public void testShouldInjectOneProfileToStandaloneSuperPom() throws Exception { ProfileManager pm = new DefaultProfileManager( getContainer(), new Properties() ); String profileId = "test-profile"; String key = "test"; String value = "value"; Profile profile = new Profile(); profile.setId( profileId ); profile.addProperty( key, value ); pm.addProfile( profile ); pm.explicitlyActivate( profileId ); MavenProject project = projectBuilder.buildStandaloneSuperProject( getLocalRepository(), pm ); assertEquals( value, project.getProperties().getProperty( key ) ); } public void testShouldInjectProfileWithRepositoryToStandaloneSuperPom() throws Exception { ProfileManager pm = new DefaultProfileManager( getContainer(), new Properties() ); String profileId = "test-profile"; String repoId = "test-repo"; Profile profile = new Profile(); profile.setId( profileId ); Repository repo = new Repository(); repo.setId( repoId ); repo.setUrl( "http://www.google.com" ); profile.addRepository( repo ); pm.addProfile( profile ); pm.explicitlyActivate( profileId ); MavenProject project = projectBuilder.buildStandaloneSuperProject( getLocalRepository(), pm ); List repositories = project.getRepositories(); assertNotNull( repositories ); Repository result = null; for ( Iterator it = repositories.iterator(); it.hasNext(); ) { Repository candidate = (Repository) it.next(); if ( repoId.equals( candidate.getId() ) ) { result = candidate; break; } } assertNotNull( "Profile-injected repository not found in super-POM.", result ); assertEquals( "Profile-injected repository was not first in repo list within super-POM", repoId, ( (Repository) repositories.get( 0 ) ).getId() ); } /** * Check that we can build ok from the middle pom of a (parent,child,grandchild) heirarchy * @throws Exception */ public void testBuildFromMiddlePom() throws Exception { File f1 = getTestFile( "src/test/resources/projects/grandchild-check/child/pom.xml"); File f2 = getTestFile( "src/test/resources/projects/grandchild-check/child/grandchild/pom.xml"); getProject( f1 ); // it's the building of the grandchild project, having already cached the child project // (but not the parent project), which causes the problem. getProject( f2 ); } public void testDuplicatePluginDefinitionsMerged() throws Exception { File f1 = getTestFile( "src/test/resources/projects/duplicate-plugins-merged-pom.xml" ); MavenProject project = getProject( f1 ); assertEquals( 2, ( (Plugin) project.getBuildPlugins().get( 0 ) ).getDependencies().size() ); } public void testBuildDirectoryExpressionInterpolatedWithTranslatedValue() throws Exception { File pom = getTestFile( "src/test/resources/projects/build-path-expression-pom.xml" ); MavenProject project = getProject( pom ); projectBuilder.calculateConcreteState( project, new DefaultProjectBuilderConfiguration() ); Build build = project.getBuild(); assertNotNull( "Project should have a build section containing the test resource.", build ); String sourceDirectory = build.getSourceDirectory(); assertNotNull( "Project build should contain a valid source directory.", sourceDirectory ); List resources = build.getResources(); assertNotNull( "Project should contain a build resource.", resources ); assertEquals( "Project should contain exactly one build resource.", 1, resources.size() ); Resource res = (Resource) resources.get( 0 ); assertEquals( "Project resource should be the same directory as the source directory.", sourceDirectory, res.getDirectory() ); System.out.println( "Interpolated, translated resource directory is: " + res.getDirectory() ); } protected ArtifactRepository getLocalRepository() throws Exception { ArtifactRepositoryLayout repoLayout = (ArtifactRepositoryLayout) lookup( ArtifactRepositoryLayout.ROLE, "legacy" ); ArtifactRepository r = new DefaultArtifactRepository( "local", "file://" + localRepoDir.getAbsolutePath(), repoLayout ); return r; } } maven2-core-2.2.1/maven-project/src/test/java/org/apache/maven/project/MavenProjectTest.java0000644000175000017500000001475311176153707031737 0ustar twernertwernerpackage org.apache.maven.project; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import java.io.File; import java.io.IOException; import java.util.List; import java.util.Map; import org.apache.maven.artifact.DependencyResolutionRequiredException; import org.apache.maven.artifact.versioning.ManagedVersionMap; import org.apache.maven.model.DependencyManagement; import org.apache.maven.model.Model; import org.apache.maven.model.Parent; public class MavenProjectTest extends AbstractMavenProjectTestCase { public void testTestClasspathOrdering() throws DependencyResolutionRequiredException { Model model = new Model(); MavenProject project = new MavenProject( model ); project.getBuild().setOutputDirectory( "main" ); project.getBuild().setTestOutputDirectory( "test" ); List testClasspath = project.getTestClasspathElements(); // test-classes should be before main-classes, see MNG-3118 assertEquals( "test", new File( (String) testClasspath.get( 0 ) ).getName() ); assertEquals( "main", new File( (String) testClasspath.get( 1 ) ).getName() ); } public void testShouldInterpretChildPathAdjustmentBasedOnModulePaths() throws IOException { Model parentModel = new Model(); parentModel.addModule( "../child" ); MavenProject parentProject = new MavenProject( parentModel ); Model childModel = new Model(); childModel.setArtifactId( "artifact" ); MavenProject childProject = new MavenProject( childModel ); File childFile = new File( System.getProperty( "java.io.tmpdir" ), "maven-project-tests" + System.currentTimeMillis() + "/child/pom.xml" ); childProject.setFile( childFile ); String adjustment = parentProject.getModulePathAdjustment( childProject ); assertNotNull( adjustment ); assertEquals( "..", adjustment ); } public void testIdentityProtoInheritance() { Parent parent = new Parent(); parent.setGroupId( "test-group" ); parent.setVersion( "1000" ); parent.setArtifactId( "test-artifact" ); Model model = new Model(); model.setParent( parent ); model.setArtifactId( "real-artifact" ); MavenProject project = new MavenProject( model ); assertEquals( "groupId proto-inheritance failed.", "test-group", project.getGroupId() ); assertEquals( "artifactId is masked.", "real-artifact", project.getArtifactId() ); assertEquals( "version proto-inheritance failed.", "1000", project.getVersion() ); // draw the NPE. project.getId(); } public void testEmptyConstructor() { MavenProject project = new MavenProject(); assertEquals( MavenProject.EMPTY_PROJECT_GROUP_ID + ":" + MavenProject.EMPTY_PROJECT_ARTIFACT_ID + ":jar:" + MavenProject.EMPTY_PROJECT_VERSION, project.getId() ); } public void testClone() throws Exception { File f = getFileForClasspathResource( "canonical-pom.xml" ); MavenProject projectToClone = getProject( f ); MavenProject clonedProject = (MavenProject) projectToClone.clone(); assertEquals( "maven-core", clonedProject.getArtifactId() ); Map clonedMap = clonedProject.getManagedVersionMap(); assertNotNull( "ManagedVersionMap not copied", clonedMap ); assertTrue( "ManagedVersionMap is not empty", clonedMap.isEmpty() ); } public void testCloneWithDependencyManagement() throws Exception { File f = getFileForClasspathResource( "dependencyManagement-pom.xml" ); MavenProject projectToClone = getProjectWithDependencies( f ); DependencyManagement dep = projectToClone.getDependencyManagement(); assertNotNull( "No dependencyManagement", dep ); List list = dep.getDependencies(); assertNotNull( "No dependencies", list ); assertTrue( "Empty dependency list", !list.isEmpty() ); Map map = projectToClone.getManagedVersionMap(); assertNotNull( "No ManagedVersionMap", map ); assertTrue( "ManagedVersionMap is empty", !map.isEmpty() ); MavenProject clonedProject = (MavenProject) projectToClone.clone(); assertEquals( "maven-core", clonedProject.getArtifactId() ); Map clonedMap = clonedProject.getManagedVersionMap(); assertNotNull( "ManagedVersionMap not copied", clonedMap ); assertTrue( "ManagedVersionMap is empty", !clonedMap.isEmpty() ); assertTrue( "Not a ManagedVersionMap", clonedMap instanceof ManagedVersionMap ); assertTrue( "ManagedVersionMap does not contain test key", clonedMap.containsKey( "maven-test:maven-test-b:jar" ) ); } public void testGetModulePathAdjustment() throws IOException { Model moduleModel = new Model(); MavenProject module = new MavenProject( moduleModel ); module.setFile( new File( "module-dir/pom.xml" ) ); Model parentModel = new Model(); parentModel.addModule( "../module-dir" ); MavenProject parent = new MavenProject( parentModel ); parent.setFile( new File( "parent-dir/pom.xml" ) ); String pathAdjustment = parent.getModulePathAdjustment( module ); assertEquals( "..", pathAdjustment ); } public void testCloneWithDistributionManagement() throws Exception { File f = getFileForClasspathResource( "distributionManagement-pom.xml" ); MavenProject projectToClone = getProject( f ); MavenProject clonedProject = (MavenProject) projectToClone.clone(); assertNotNull( "clonedProject - distributionManagement", clonedProject.getDistributionManagementArtifactRepository() ); } } maven2-core-2.2.1/maven-project/src/test/java/org/apache/maven/project/interpolation/0000755000175000017500000000000011250552244030504 5ustar twernertwerner././@LongLink0000000000000000000000000000017200000000000011565 Lustar rootrootmaven2-core-2.2.1/maven-project/src/test/java/org/apache/maven/project/interpolation/RegexBasedModelInterpolatorTest.javamaven2-core-2.2.1/maven-project/src/test/java/org/apache/maven/project/interpolation/RegexBasedModel0000644000175000017500000000315311055044707033426 0ustar twernertwernerpackage org.apache.maven.project.interpolation; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import org.apache.maven.project.path.PathTranslator; /** * @author jdcasey * @version $Id: RegexBasedModelInterpolatorTest.java 689163 2008-08-26 18:21:59Z jdcasey $ */ public class RegexBasedModelInterpolatorTest extends AbstractModelInterpolatorTest { protected ModelInterpolator createInterpolator( PathTranslator translator ) throws Exception { RegexBasedModelInterpolator interpolator = new RegexBasedModelInterpolator( translator ); interpolator.initialize(); return interpolator; } protected ModelInterpolator createInterpolator() throws Exception { RegexBasedModelInterpolator interpolator = new RegexBasedModelInterpolator(); interpolator.initialize(); return interpolator; } } ././@LongLink0000000000000000000000000000016600000000000011570 Lustar rootrootmaven2-core-2.2.1/maven-project/src/test/java/org/apache/maven/project/interpolation/ModelInterpolationEdgeCases.javamaven2-core-2.2.1/maven-project/src/test/java/org/apache/maven/project/interpolation/ModelInterpolat0000644000175000017500000001372211101576551033540 0ustar twernertwernerpackage org.apache.maven.project.interpolation; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import org.apache.maven.model.Build; import org.apache.maven.model.Model; import java.util.HashMap; import java.util.Properties; import junit.framework.TestCase; public class ModelInterpolationEdgeCases extends TestCase { public void testMultiExpressionRecursion() throws Throwable { Test test = new Test() { void run() { Model model = new Model(); Build build = new Build(); model.setBuild( build ); build.setDirectory( "${project.build.sourceDirectory}" ); build.setSourceDirectory( "${project.build.testSourceDirectory}/../main" ); build.setTestSourceDirectory( "${project.build.directory}/test" ); try { interpolate( model ); System.out.println( "Should fail." ); failureMessage = "should fail with expression cycle in build paths."; // fail("should fail with expression cycle in build paths."); } catch ( ModelInterpolationException e ) { // expected } catch ( Throwable e ) { error = e; // throw e; } } }; run( test ); } public void testMultiPrefixRecursion_Synonyms() throws Throwable { Test test = new Test() { void run() { Model model = new Model(); Build build = new Build(); model.setBuild( build ); build.setDirectory( "${project.build.directory}" ); build.setSourceDirectory( "${pom.build.sourceDirectory}" ); build.setTestSourceDirectory( "${build.testSourceDirectory}" ); try { interpolate( model ); System.out.println( "Should fail." ); failureMessage = "should fail with expression synonym recursion."; } catch ( ModelInterpolationException e ) { // expected } catch ( Throwable e ) { error = e; } } }; run( test ); } public void testMultiPrefixSeparation_EnvarPropertyDifference() throws Throwable { Test test = new Test() { void run() { Model model = new Model(); Properties properties = new Properties(); properties.setProperty( "ENVAR", "pomValue" ); properties.setProperty( "prop", "${env.ENVAR}" ); properties.setProperty( "prop2", "${pom.ENVAR}" ); model.setProperties( properties ); try { Model result = interpolate( model ); Properties resultProps = result.getProperties(); assertFalse( "Values should not match!", resultProps.getProperty( "prop" ).equals( resultProps.getProperty( "prop2" ) ) ); } catch ( ModelInterpolationException e ) { error = e; } catch ( Throwable e ) { error = e; } } }; run( test ); } private void run( Test test ) throws Throwable { Thread t = new Thread( new TestRunnable( test ) ); t.setDaemon( true ); t.start(); try { t.join( 5000 ); } catch ( InterruptedException e ) { } if ( t.isAlive() ) { StackTraceElement element = new Throwable().getStackTrace()[1]; fail( "Test: " + element.getMethodName() + " failed to execute in 5 seconds. Looks like it's caught in an infinite loop of some kind." ); } else { test.checkFailure(); } } private Model interpolate( Model model ) throws Throwable { RegexBasedModelInterpolator interpolator = new RegexBasedModelInterpolator(); interpolator.initialize(); return interpolator.interpolate( model, new HashMap(), true ); } private static final class TestRunnable implements Runnable { private Test test; TestRunnable( Test test ) { this.test = test; } public void run() { test.run(); } } private static abstract class Test { String failureMessage; Throwable error; abstract void run(); void checkFailure() throws Throwable { if ( error != null ) { throw error; } else if ( failureMessage != null ) { fail( failureMessage ); } } } } ././@LongLink0000000000000000000000000000017400000000000011567 Lustar rootrootmaven2-core-2.2.1/maven-project/src/test/java/org/apache/maven/project/interpolation/StringSearchModelInterpolatorTest.javamaven2-core-2.2.1/maven-project/src/test/java/org/apache/maven/project/interpolation/StringSearchMod0000644000175000017500000002656511101576551033503 0ustar twernertwernerpackage org.apache.maven.project.interpolation; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import java.io.File; import java.util.ArrayList; import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Properties; import org.apache.maven.model.Model; import org.apache.maven.project.DefaultProjectBuilderConfiguration; import org.apache.maven.project.ProjectBuilderConfiguration; import org.apache.maven.project.path.PathTranslator; /** * @author jdcasey * @version $Id: StringSearchModelInterpolatorTest.java 708543 2008-10-28 11:54:17Z bentmann $ */ public class StringSearchModelInterpolatorTest extends AbstractModelInterpolatorTest { protected ModelInterpolator createInterpolator( PathTranslator translator ) throws Exception { StringSearchModelInterpolator interpolator = new StringSearchModelInterpolator( translator ); interpolator.initialize(); return interpolator; } protected ModelInterpolator createInterpolator() throws Exception { StringSearchModelInterpolator interpolator = new StringSearchModelInterpolator(); interpolator.initialize(); return interpolator; } public void testInterpolateStringArray() throws Exception { Model model = new Model(); Properties p = new Properties(); p.setProperty( "key", "value" ); p.setProperty( "key2", "value2" ); String[] values = { "${key}", "${key2}" }; StringSearchModelInterpolator interpolator = (StringSearchModelInterpolator) createInterpolator(); ProjectBuilderConfiguration config = new DefaultProjectBuilderConfiguration().setExecutionProperties( p ); interpolator.interpolateObject( values, model, new File( "." ), config, true ); assertEquals( "value", values[0] ); assertEquals( "value2", values[1] ); } public void testInterpolateObjectWithStringArrayField() throws Exception { Model model = new Model(); Properties p = new Properties(); p.setProperty( "key", "value" ); p.setProperty( "key2", "value2" ); String[] values = { "${key}", "${key2}" }; ObjectWithStringArrayField obj = new ObjectWithStringArrayField( values ); StringSearchModelInterpolator interpolator = (StringSearchModelInterpolator) createInterpolator(); ProjectBuilderConfiguration config = new DefaultProjectBuilderConfiguration().setExecutionProperties( p ); interpolator.interpolateObject( obj, model, new File( "." ), config, true ); assertEquals( "value", obj.values[0] ); assertEquals( "value2", obj.values[1] ); } public void testInterpolateObjectWithStringListField() throws Exception { Model model = new Model(); Properties p = new Properties(); p.setProperty( "key", "value" ); p.setProperty( "key2", "value2" ); List values = new ArrayList(); values.add( "${key}" ); values.add( "${key2}" ); ObjectWithListField obj = new ObjectWithListField( values ); StringSearchModelInterpolator interpolator = (StringSearchModelInterpolator) createInterpolator(); ProjectBuilderConfiguration config = new DefaultProjectBuilderConfiguration().setExecutionProperties( p ); interpolator.interpolateObject( obj, model, new File( "." ), config, true ); assertEquals( "value", obj.values.get( 0 ) ); assertEquals( "value2", obj.values.get( 1 ) ); } public void testInterpolateObjectWithStringListFieldAndOneLiteralValue() throws Exception { Model model = new Model(); Properties p = new Properties(); p.setProperty( "key", "value" ); p.setProperty( "key2", "value2" ); List values = new ArrayList(); values.add( "key" ); values.add( "${key2}" ); ObjectWithListField obj = new ObjectWithListField( values ); StringSearchModelInterpolator interpolator = (StringSearchModelInterpolator) createInterpolator(); ProjectBuilderConfiguration config = new DefaultProjectBuilderConfiguration().setExecutionProperties( p ); interpolator.interpolateObject( obj, model, new File( "." ), config, true ); assertEquals( "key", obj.values.get( 0 ) ); assertEquals( "value2", obj.values.get( 1 ) ); } public void testInterpolateObjectWithUnmodifiableStringListField() throws Exception { Model model = new Model(); Properties p = new Properties(); p.setProperty( "key", "value" ); p.setProperty( "key2", "value2" ); List values = Collections.unmodifiableList( Collections.singletonList( "${key}" ) ); ObjectWithListField obj = new ObjectWithListField( values ); StringSearchModelInterpolator interpolator = (StringSearchModelInterpolator) createInterpolator(); ProjectBuilderConfiguration config = new DefaultProjectBuilderConfiguration().setExecutionProperties( p ); interpolator.interpolateObject( obj, model, new File( "." ), config, true ); assertEquals( "${key}", obj.values.get( 0 ) ); } public void testInterpolateObjectWithStringArrayListField() throws Exception { Model model = new Model(); Properties p = new Properties(); p.setProperty( "key", "value" ); p.setProperty( "key2", "value2" ); p.setProperty( "key3", "value3" ); p.setProperty( "key4", "value4" ); List values = new ArrayList(); values.add( new String[] { "${key}", "${key2}" } ); values.add( new String[] { "${key3}", "${key4}" } ); ObjectWithListField obj = new ObjectWithListField( values ); StringSearchModelInterpolator interpolator = (StringSearchModelInterpolator) createInterpolator(); ProjectBuilderConfiguration config = new DefaultProjectBuilderConfiguration().setExecutionProperties( p ); interpolator.interpolateObject( obj, model, new File( "." ), config, true ); assertEquals( "value", ( (String[]) obj.values.get( 0 ) )[0] ); assertEquals( "value2", ( (String[]) obj.values.get( 0 ) )[1] ); assertEquals( "value3", ( (String[]) obj.values.get( 1 ) )[0] ); assertEquals( "value4", ( (String[]) obj.values.get( 1 ) )[1] ); } public void testInterpolateObjectWithStringToStringMapField() throws Exception { Model model = new Model(); Properties p = new Properties(); p.setProperty( "key", "value" ); p.setProperty( "key2", "value2" ); Map values = new HashMap(); values.put( "key", "${key}" ); values.put( "key2", "${key2}" ); ObjectWithMapField obj = new ObjectWithMapField( values ); StringSearchModelInterpolator interpolator = (StringSearchModelInterpolator) createInterpolator(); ProjectBuilderConfiguration config = new DefaultProjectBuilderConfiguration().setExecutionProperties( p ); interpolator.interpolateObject( obj, model, new File( "." ), config, true ); assertEquals( "value", obj.values.get( "key" ) ); assertEquals( "value2", obj.values.get( "key2" ) ); } public void testInterpolateObjectWithStringToStringMapFieldAndOneLiteralValue() throws Exception { Model model = new Model(); Properties p = new Properties(); p.setProperty( "key", "value" ); p.setProperty( "key2", "value2" ); Map values = new HashMap(); values.put( "key", "val" ); values.put( "key2", "${key2}" ); ObjectWithMapField obj = new ObjectWithMapField( values ); StringSearchModelInterpolator interpolator = (StringSearchModelInterpolator) createInterpolator(); ProjectBuilderConfiguration config = new DefaultProjectBuilderConfiguration().setExecutionProperties( p ); interpolator.interpolateObject( obj, model, new File( "." ), config, true ); assertEquals( "val", obj.values.get( "key" ) ); assertEquals( "value2", obj.values.get( "key2" ) ); } public void testInterpolateObjectWithUnmodifiableStringToStringMapField() throws Exception { Model model = new Model(); Properties p = new Properties(); p.setProperty( "key", "value" ); p.setProperty( "key2", "value2" ); Map values = Collections.unmodifiableMap( Collections.singletonMap( "key", "${key}" ) ); ObjectWithMapField obj = new ObjectWithMapField( values ); StringSearchModelInterpolator interpolator = (StringSearchModelInterpolator) createInterpolator(); ProjectBuilderConfiguration config = new DefaultProjectBuilderConfiguration().setExecutionProperties( p ); interpolator.interpolateObject( obj, model, new File( "." ), config, true ); assertEquals( "${key}", obj.values.get( "key" ) ); } public void testInterpolateObjectWithStringToStringArrayMapField() throws Exception { Model model = new Model(); Properties p = new Properties(); p.setProperty( "key", "value" ); p.setProperty( "key2", "value2" ); p.setProperty( "key3", "value3" ); p.setProperty( "key4", "value4" ); Map values = new HashMap(); values.put( "key", new String[] { "${key}", "${key2}" } ); values.put( "key2", new String[] { "${key3}", "${key4}" } ); ObjectWithMapField obj = new ObjectWithMapField( values ); StringSearchModelInterpolator interpolator = (StringSearchModelInterpolator) createInterpolator(); ProjectBuilderConfiguration config = new DefaultProjectBuilderConfiguration().setExecutionProperties( p ); interpolator.interpolateObject( obj, model, new File( "." ), config, true ); assertEquals( "value", ( (String[]) obj.values.get( "key" ) )[0] ); assertEquals( "value2", ( (String[]) obj.values.get( "key" ) )[1] ); assertEquals( "value3", ( (String[]) obj.values.get( "key2" ) )[0] ); assertEquals( "value4", ( (String[]) obj.values.get( "key2" ) )[1] ); } private static final class ObjectWithStringArrayField { private final String[] values; public ObjectWithStringArrayField( String[] values ) { this.values = values; } } private static final class ObjectWithListField { private final List values; public ObjectWithListField( List values ) { this.values = values; } } private static final class ObjectWithMapField { private final Map values; public ObjectWithMapField( Map values ) { this.values = values; } } } ././@LongLink0000000000000000000000000000017000000000000011563 Lustar rootrootmaven2-core-2.2.1/maven-project/src/test/java/org/apache/maven/project/interpolation/AbstractModelInterpolatorTest.javamaven2-core-2.2.1/maven-project/src/test/java/org/apache/maven/project/interpolation/AbstractModelIn0000644000175000017500000003621211175345173033455 0ustar twernertwernerpackage org.apache.maven.project.interpolation; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import org.apache.maven.model.Build; import org.apache.maven.model.Dependency; import org.apache.maven.model.Model; import org.apache.maven.model.Organization; import org.apache.maven.model.Repository; import org.apache.maven.model.Resource; import org.apache.maven.model.Scm; import org.apache.maven.project.DefaultProjectBuilderConfiguration; import org.apache.maven.project.path.DefaultPathTranslator; import org.apache.maven.project.path.PathTranslator; import org.codehaus.plexus.personality.plexus.lifecycle.phase.InitializationException; import java.io.File; import java.io.IOException; import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.Collections; import java.util.Date; import java.util.HashMap; import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.Properties; import junit.framework.TestCase; /** * @author jdcasey * @version $Id: AbstractModelInterpolatorTest.java 769023 2009-04-27 15:08:43Z brett $ */ public abstract class AbstractModelInterpolatorTest extends TestCase { private Map context; protected void setUp() throws Exception { super.setUp(); context = new HashMap(); context.put( "basedir", "myBasedir" ); context.put( "project.baseUri", "myBaseUri" ); } public void testDefaultBuildTimestampFormatShouldParseTimeIn24HourFormat() { Calendar cal = Calendar.getInstance(); cal.set( Calendar.HOUR, 12 ); cal.set( Calendar.AM_PM, Calendar.AM ); // just to make sure all the bases are covered... cal.set( Calendar.HOUR_OF_DAY, 0 ); cal.set( Calendar.MINUTE, 16 ); cal.set( Calendar.YEAR, 1976 ); cal.set( Calendar.MONTH, Calendar.NOVEMBER ); cal.set( Calendar.DATE, 11 ); Date firstTestDate = cal.getTime(); cal.set( Calendar.HOUR, 11 ); cal.set( Calendar.AM_PM, Calendar.PM ); // just to make sure all the bases are covered... cal.set( Calendar.HOUR_OF_DAY, 23 ); Date secondTestDate = cal.getTime(); SimpleDateFormat format = new SimpleDateFormat( ModelInterpolator.DEFAULT_BUILD_TIMESTAMP_FORMAT ); assertEquals( "19761111-0016", format.format( firstTestDate ) ); assertEquals( "19761111-2316", format.format( secondTestDate ) ); } public void testShouldNotThrowExceptionOnReferenceToNonExistentValue() throws Exception { Model model = new Model(); Scm scm = new Scm(); scm.setConnection( "${test}/somepath" ); model.setScm( scm ); ModelInterpolator interpolator = createInterpolator(); Model out = interpolator.interpolate( model, context ); assertEquals( "${test}/somepath", out.getScm().getConnection() ); } public void testShouldThrowExceptionOnRecursiveScmConnectionReference() throws Exception { Model model = new Model(); Scm scm = new Scm(); scm.setConnection( "${project.scm.connection}/somepath" ); model.setScm( scm ); try { ModelInterpolator interpolator = createInterpolator(); interpolator.interpolate( model, context ); fail( "The interpolator should not allow self-referencing expressions in POM." ); } catch ( ModelInterpolationException e ) { } } public void testShouldNotThrowExceptionOnReferenceToValueContainingNakedExpression() throws Exception { Model model = new Model(); Scm scm = new Scm(); scm.setConnection( "${test}/somepath" ); model.setScm( scm ); model.addProperty( "test", "test" ); ModelInterpolator interpolator = createInterpolator(); Model out = interpolator.interpolate( model, context ); assertEquals( "test/somepath", out.getScm().getConnection() ); } public void testShouldInterpolateOrganizationNameCorrectly() throws Exception { String orgName = "MyCo"; Model model = new Model(); model.setName( "${pom.organization.name} Tools" ); Organization org = new Organization(); org.setName( orgName ); model.setOrganization( org ); ModelInterpolator interpolator = createInterpolator(); Model out = interpolator.interpolate( model, context ); assertEquals( orgName + " Tools", out.getName() ); } public void testShouldInterpolateDependencyVersionToSetSameAsProjectVersion() throws Exception { Model model = new Model(); model.setVersion( "3.8.1" ); Dependency dep = new Dependency(); dep.setVersion( "${version}" ); model.addDependency( dep ); ModelInterpolator interpolator = createInterpolator(); Model out = interpolator.interpolate( model, context ); assertEquals( "3.8.1", ( (Dependency) out.getDependencies().get( 0 ) ).getVersion() ); } public void testShouldNotInterpolateDependencyVersionWithInvalidReference() throws Exception { Model model = new Model(); model.setVersion( "3.8.1" ); Dependency dep = new Dependency(); dep.setVersion( "${something}" ); model.addDependency( dep ); /* // This is the desired behaviour, however there are too many crappy poms in the repo and an issue with the // timing of executing the interpolation try { new RegexBasedModelInterpolator().interpolate( model, context ); fail( "Should have failed to interpolate with invalid reference" ); } catch ( ModelInterpolationException expected ) { assertTrue( true ); } */ ModelInterpolator interpolator = createInterpolator(); Model out = interpolator.interpolate( model, context ); assertEquals( "${something}", ( (Dependency) out.getDependencies().get( 0 ) ).getVersion() ); } public void testTwoReferences() throws Exception { Model model = new Model(); model.setVersion( "3.8.1" ); model.setArtifactId( "foo" ); Dependency dep = new Dependency(); dep.setVersion( "${artifactId}-${version}" ); model.addDependency( dep ); ModelInterpolator interpolator = createInterpolator(); Model out = interpolator.interpolate( model, context ); assertEquals( "foo-3.8.1", ( (Dependency) out.getDependencies().get( 0 ) ).getVersion() ); } public void testBasedir() throws Exception { Model model = new Model(); model.setVersion( "3.8.1" ); model.setArtifactId( "foo" ); Repository repository = new Repository(); repository.setUrl( "file://localhost/${basedir}/temp-repo" ); model.addRepository( repository ); ModelInterpolator interpolator = createInterpolator(); Model out = interpolator.interpolate( model, context ); assertEquals( "file://localhost/myBasedir/temp-repo", ( (Repository) out.getRepositories().get( 0 ) ).getUrl() ); } public void testBaseUri() throws Exception { Model model = new Model(); model.setVersion( "3.8.1" ); model.setArtifactId( "foo" ); Repository repository = new Repository(); repository.setUrl( "${project.baseUri}/temp-repo" ); model.addRepository( repository ); ModelInterpolator interpolator = createInterpolator(); Model out = interpolator.interpolate( model, context ); assertEquals( "myBaseUri/temp-repo", ( (Repository) out.getRepositories().get( 0 ) ).getUrl() ); } public void testEnvars() throws Exception { Map context = new HashMap(); context.put( "env.HOME", "/path/to/home" ); Model model = new Model(); Properties modelProperties = new Properties(); modelProperties.setProperty( "outputDirectory", "${env.HOME}" ); model.setProperties( modelProperties ); ModelInterpolator interpolator = createInterpolator(); Model out = interpolator.interpolate( model, context ); assertEquals( "/path/to/home", out.getProperties().getProperty( "outputDirectory" ) ); } public void testEnvarExpressionThatEvaluatesToNullReturnsTheLiteralString() throws Exception { Properties envars = new Properties(); Model model = new Model(); Properties modelProperties = new Properties(); modelProperties.setProperty( "outputDirectory", "${env.DOES_NOT_EXIST}" ); model.setProperties( modelProperties ); ModelInterpolator interpolator = createInterpolator(); Model out = interpolator.interpolate( model, context ); assertEquals( out.getProperties().getProperty( "outputDirectory" ), "${env.DOES_NOT_EXIST}" ); } public void testExpressionThatEvaluatesToNullReturnsTheLiteralString() throws Exception { Model model = new Model(); Properties modelProperties = new Properties(); modelProperties.setProperty( "outputDirectory", "${DOES_NOT_EXIST}" ); model.setProperties( modelProperties ); ModelInterpolator interpolator = createInterpolator(); Model out = interpolator.interpolate( model, context ); assertEquals( out.getProperties().getProperty( "outputDirectory" ), "${DOES_NOT_EXIST}" ); } public void testShouldInterpolateSourceDirectoryReferencedFromResourceDirectoryCorrectly() throws Exception { Model model = new Model(); Build build = new Build(); build.setSourceDirectory( "correct" ); Resource res = new Resource(); res.setDirectory( "${project.build.sourceDirectory}" ); build.addResource( res ); Resource res2 = new Resource(); res2.setDirectory( "${pom.build.sourceDirectory}" ); build.addResource( res2 ); Resource res3 = new Resource(); res3.setDirectory( "${build.sourceDirectory}" ); build.addResource( res3 ); model.setBuild( build ); ModelInterpolator interpolator = createInterpolator(); Model out = interpolator.interpolate( model, context ); List outResources = out.getBuild().getResources(); Iterator resIt = outResources.iterator(); assertEquals( build.getSourceDirectory(), ( (Resource) resIt.next() ).getDirectory() ); assertEquals( build.getSourceDirectory(), ( (Resource) resIt.next() ).getDirectory() ); assertEquals( build.getSourceDirectory(), ( (Resource) resIt.next() ).getDirectory() ); } public void testShouldInterpolateUnprefixedBasedirExpression() throws Exception { File basedir = new File( "/test/path" ); Model model = new Model(); Dependency dep = new Dependency(); dep.setSystemPath( "${basedir}/artifact.jar" ); model.addDependency( dep ); ModelInterpolator interpolator = createInterpolator(); Model result = interpolator.interpolate( model, basedir, new DefaultProjectBuilderConfiguration(), true ); List rDeps = result.getDependencies(); assertNotNull( rDeps ); assertEquals( 1, rDeps.size() ); assertEquals( new File( basedir, "artifact.jar" ).getAbsolutePath(), new File( ( (Dependency) rDeps.get( 0 ) ) .getSystemPath() ).getAbsolutePath() ); } public void testTwoLevelRecursiveBasedirAlignedExpression() throws Exception { Model model = new Model(); Build build = new Build(); model.setBuild( build ); build.setDirectory( "${project.basedir}/target" ); build.setOutputDirectory( "${project.build.directory}/classes" ); PathTranslator translator = new DefaultPathTranslator(); ModelInterpolator interpolator = createInterpolator( translator ); File basedir = new File( System.getProperty( "java.io.tmpdir" ), "base" ); String value = interpolator.interpolate( "${project.build.outputDirectory}/foo", model, basedir, new DefaultProjectBuilderConfiguration(), true ); value = value.replace( '/', File.separatorChar ).replace( '\\', File.separatorChar ); String check = new File( basedir, "target/classes/foo" ).getAbsolutePath(); check = check.replace( '/', File.separatorChar ).replace( '\\', File.separatorChar ); assertEquals( check, value ); } protected abstract ModelInterpolator createInterpolator( PathTranslator translator ) throws Exception; protected abstract ModelInterpolator createInterpolator() throws Exception; // public void testPOMExpressionDoesNotUseSystemProperty() // throws Exception // { // Model model = new Model(); // model.setVersion( "1.0" ); // // Properties modelProperties = new Properties(); // modelProperties.setProperty( "version", "prop version" ); // modelProperties.setProperty( "foo.version", "prop foo.version" ); // modelProperties.setProperty( "pom.version", "prop pom.version" ); // modelProperties.setProperty( "project.version", "prop project.version" ); // // model.setProperties( modelProperties ); // // Dependency dep = new Dependency(); // model.addDependency( dep ); // // checkDep( "prop version", "${version}", model ); // checkDep( "1.0", "${pom.version}", model ); // checkDep( "1.0", "${project.version}", model ); // checkDep( "prop foo.version", "${foo.version}", model ); // } // // private void checkDep( String expectedVersion, // String depVersionExpr, // Model model ) // throws Exception // { // ( (Dependency) model.getDependencies().get( 0 ) ).setVersion( depVersionExpr ); // Model out = createInterpolator().interpolate( model, context ); // String result = ( (Dependency) out.getDependencies().get( 0 ) ).getVersion(); // assertEquals( "Expected '" + expectedVersion + "' for version expression '" // + depVersionExpr + "', but was '" + result + "'", expectedVersion, result ); // } } maven2-core-2.2.1/maven-project/src/test/java/org/apache/maven/project/canonical/0000755000175000017500000000000011250552244027544 5ustar twernertwerner././@LongLink0000000000000000000000000000016200000000000011564 Lustar rootrootmaven2-core-2.2.1/maven-project/src/test/java/org/apache/maven/project/canonical/CanonicalProjectBuilderTest.javamaven2-core-2.2.1/maven-project/src/test/java/org/apache/maven/project/canonical/CanonicalProjectBui0000644000175000017500000000706410551365651033363 0ustar twernertwernerpackage org.apache.maven.project.canonical; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import org.apache.maven.model.Plugin; import org.apache.maven.model.PluginExecution; import org.apache.maven.project.AbstractMavenProjectTestCase; import org.apache.maven.project.MavenProject; import org.codehaus.plexus.util.xml.Xpp3Dom; import java.io.File; import java.util.Iterator; import java.util.List; /** * @author Jason van Zyl * @version $Id: CanonicalProjectBuilderTest.java 495147 2007-01-11 07:47:53Z jvanzyl $ */ public class CanonicalProjectBuilderTest extends AbstractMavenProjectTestCase { public void testProjectBuilder() throws Exception { File f = getFileForClasspathResource( "canonical-pom.xml" ); MavenProject project = getProject( f ); // ---------------------------------------------------------------------- // Top-level elements // ---------------------------------------------------------------------- assertEquals( "4.0.0", project.getModelVersion() ); // ---------------------------------------------------------------------- // Plugins // ---------------------------------------------------------------------- List plugins = project.getBuildPlugins(); // Plugin0 [plexus] String key = "org.apache.maven.plugins:maven-plexus-plugin"; Plugin plugin = null; for ( Iterator it = plugins.iterator(); it.hasNext(); ) { Plugin check = (Plugin) it.next(); if ( key.equals( check.getKey() ) ) { plugin = check; break; } } assertNotNull( plugin ); assertEquals( "1.0", plugin.getVersion() ); Xpp3Dom configuration = (Xpp3Dom) plugin.getConfiguration(); assertEquals( "src/conf/plexus.conf", configuration.getChild( "plexusConfiguration" ).getValue() ); assertEquals( "src/conf/plexus.properties", configuration.getChild( "plexusConfigurationPropertiesFile" ).getValue() ); assertEquals( "Continuum", configuration.getChild( "plexusApplicationName" ).getValue() ); // ---------------------------------------------------------------------- // Goal specific configuration // ---------------------------------------------------------------------- List executions = plugin.getExecutions(); PluginExecution execution = (PluginExecution) executions.get( 0 ); String g0 = (String) execution.getGoals().get( 0 ); assertEquals( "plexus:runtime", g0 ); configuration = (Xpp3Dom) execution.getConfiguration(); assertEquals( "ContinuumPro", configuration.getChild( "plexusApplicationName" ).getValue() ); // Plugin1 [antlr] } } maven2-core-2.2.1/maven-project/src/test/java/org/apache/maven/project/validation/0000755000175000017500000000000011250552245027750 5ustar twernertwerner././@LongLink0000000000000000000000000000016100000000000011563 Lustar rootrootmaven2-core-2.2.1/maven-project/src/test/java/org/apache/maven/project/validation/DefaultModelValidatorTest.javamaven2-core-2.2.1/maven-project/src/test/java/org/apache/maven/project/validation/DefaultModelValida0000644000175000017500000001740010705230153033356 0ustar twernertwernerpackage org.apache.maven.project.validation; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import org.apache.maven.model.Model; import org.apache.maven.model.io.xpp3.MavenXpp3Reader; import org.apache.maven.project.AbstractMavenProjectTestCase; import org.codehaus.plexus.util.ReaderFactory; import java.io.Reader; import java.util.List; /** * @author Trygve Laugstøl * @version $Id: DefaultModelValidatorTest.java 585268 2007-10-16 21:43:07Z hboutemy $ */ public class DefaultModelValidatorTest extends AbstractMavenProjectTestCase { private Model model; private ModelValidator validator; public void testMissingModelVersion() throws Exception { ModelValidationResult result = validate( "missing-modelVersion-pom.xml" ); assertEquals( 1, result.getMessageCount() ); assertEquals( "'modelVersion' is missing.", result.getMessage( 0 ) ); } public void testMissingArtifactId() throws Exception { ModelValidationResult result = validate( "missing-artifactId-pom.xml" ); assertEquals( 1, result.getMessageCount() ); assertEquals( "'artifactId' is missing.", result.getMessage( 0 ) ); } public void testMissingGroupId() throws Exception { ModelValidationResult result = validate( "missing-groupId-pom.xml" ); assertEquals( 1, result.getMessageCount() ); assertEquals( "'groupId' is missing.", result.getMessage( 0 ) ); } public void testInvalidIds() throws Exception { ModelValidationResult result = validate( "invalid-ids-pom.xml" ); assertEquals( 2, result.getMessageCount() ); assertEquals( "'groupId' with value 'o/a/m' does not match a valid id pattern.", result.getMessage( 0 ) ); assertEquals( "'artifactId' with value 'm$-do$' does not match a valid id pattern.", result.getMessage( 1 ) ); } public void testMissingType() throws Exception { ModelValidationResult result = validate( "missing-type-pom.xml" ); assertEquals( 1, result.getMessageCount() ); assertEquals( "'packaging' is missing.", result.getMessage( 0 ) ); } public void testMissingVersion() throws Exception { ModelValidationResult result = validate( "missing-version-pom.xml" ); assertEquals( 1, result.getMessageCount() ); assertEquals( "'version' is missing.", result.getMessage( 0 ) ); } public void testInvalidAggregatorPackaging() throws Exception { ModelValidationResult result = validate( "invalid-aggregator-packaging-pom.xml" ); assertEquals( 1, result.getMessageCount() ); assertTrue( result.getMessage( 0 ).indexOf( "Aggregator projects require 'pom' as packaging." ) > -1 ); } public void testMissingDependencyArtifactId() throws Exception { ModelValidationResult result = validate( "missing-dependency-artifactId-pom.xml" ); assertEquals( 1, result.getMessageCount() ); assertTrue( result.getMessage( 0 ).indexOf( "'dependencies.dependency.artifactId' is missing." ) > -1 ); } public void testMissingDependencyGroupId() throws Exception { ModelValidationResult result = validate( "missing-dependency-groupId-pom.xml" ); assertEquals( 1, result.getMessageCount() ); assertTrue( result.getMessage( 0 ).indexOf( "'dependencies.dependency.groupId' is missing." ) > -1 ); } public void testMissingDependencyVersion() throws Exception { ModelValidationResult result = validate( "missing-dependency-version-pom.xml" ); assertEquals( 1, result.getMessageCount() ); assertTrue( result.getMessage( 0 ).indexOf( "'dependencies.dependency.version' is missing" ) > -1 ); } public void testMissingDependencyManagementArtifactId() throws Exception { ModelValidationResult result = validate( "missing-dependency-mgmt-artifactId-pom.xml" ); assertEquals( 1, result.getMessageCount() ); assertTrue( result.getMessage( 0 ).indexOf( "'dependencyManagement.dependencies.dependency.artifactId' is missing." ) > -1 ); } public void testMissingDependencyManagementGroupId() throws Exception { ModelValidationResult result = validate( "missing-dependency-mgmt-groupId-pom.xml" ); assertEquals( 1, result.getMessageCount() ); assertTrue( result.getMessage( 0 ).indexOf( "'dependencyManagement.dependencies.dependency.groupId' is missing." ) > -1 ); } public void testMissingAll() throws Exception { ModelValidationResult result = validate( "missing-1-pom.xml" ); assertEquals( 4, result.getMessageCount() ); List messages = result.getMessages(); assertTrue( messages.contains( "\'modelVersion\' is missing." ) ); assertTrue( messages.contains( "\'groupId\' is missing." ) ); assertTrue( messages.contains( "\'artifactId\' is missing." ) ); assertTrue( messages.contains( "\'version\' is missing." ) ); // type is inherited from the super pom } public void testMissingPluginArtifactId() throws Exception { ModelValidationResult result = validate( "missing-plugin-artifactId-pom.xml" ); assertEquals( 1, result.getMessageCount() ); assertEquals( "'build.plugins.plugin.artifactId' is missing.", result.getMessage( 0 ) ); } public void testMissingRepositoryId() throws Exception { ModelValidationResult result = validate( "missing-repository-id-pom.xml" ); assertEquals( 4, result.getMessageCount() ); assertEquals( "'repositories.repository.id' is missing.", result.getMessage( 0 ) ); assertEquals( "'repositories.repository.url' is missing.", result.getMessage( 1 ) ); assertEquals( "'pluginRepositories.pluginRepository.id' is missing.", result.getMessage( 2 ) ); assertEquals( "'pluginRepositories.pluginRepository.url' is missing.", result.getMessage( 3 ) ); } public void testMissingResourceDirectory() throws Exception { ModelValidationResult result = validate( "missing-resource-directory-pom.xml" ); assertEquals( 2, result.getMessageCount() ); assertEquals( "'build.resources.resource.directory' is missing.", result.getMessage( 0 ) ); assertEquals( "'build.testResources.testResource.directory' is missing.", result.getMessage( 1 ) ); } private ModelValidationResult validate( String testName ) throws Exception { Reader input = ReaderFactory.newXmlReader( getFileForClasspathResource( "validation/" + testName ) ); MavenXpp3Reader reader = new MavenXpp3Reader(); validator = (ModelValidator) lookup( ModelValidator.ROLE ); model = reader.read( input ); ModelValidationResult result = validator.validate( model ); assertNotNull( result ); input.close(); return result; } } maven2-core-2.2.1/maven-project/src/test/java/org/apache/maven/project/path/0000755000175000017500000000000011250552245026552 5ustar twernertwerner././@LongLink0000000000000000000000000000015300000000000011564 Lustar rootrootmaven2-core-2.2.1/maven-project/src/test/java/org/apache/maven/project/path/DefaultPathTranslatorTest.javamaven2-core-2.2.1/maven-project/src/test/java/org/apache/maven/project/path/DefaultPathTranslatorTes0000644000175000017500000000324011101576551033424 0ustar twernertwernerpackage org.apache.maven.project.path; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import java.io.File; import junit.framework.TestCase; public class DefaultPathTranslatorTest extends TestCase { public void testAlignToBasedirWhereBasedirExpressionIsTheCompleteValue() { File basedir = new File( System.getProperty( "java.io.tmpdir" ), "test" ).getAbsoluteFile(); String aligned = new DefaultPathTranslator().alignToBaseDirectory( "${basedir}", basedir ); assertEquals( basedir.getAbsolutePath(), aligned ); } public void testAlignToBasedirWhereBasedirExpressionIsTheValuePrefix() { File basedir = new File( System.getProperty( "java.io.tmpdir" ), "test" ).getAbsoluteFile(); String aligned = new DefaultPathTranslator().alignToBaseDirectory( "${basedir}/dir", basedir ); assertEquals( new File( basedir, "dir" ).getAbsolutePath(), aligned ); } } maven2-core-2.2.1/maven-project/src/test/java/org/apache/maven/project/ModelUtilsTest.java0000644000175000017500000005412111151515456031410 0ustar twernertwernerpackage org.apache.maven.project; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import org.apache.maven.model.Build; import org.apache.maven.model.Dependency; import org.apache.maven.model.Plugin; import org.apache.maven.model.PluginContainer; import org.apache.maven.model.PluginExecution; import org.apache.maven.model.ReportPlugin; import org.apache.maven.model.Reporting; import org.codehaus.plexus.util.xml.Xpp3Dom; import java.util.Collections; import java.util.Iterator; import java.util.List; import java.util.Map; import junit.framework.TestCase; public class ModelUtilsTest extends TestCase { public void testShouldUseMainPluginDependencyVersionOverManagedDepVersion() { Plugin mgtPlugin = createPlugin( "group", "artifact", "1", Collections.EMPTY_MAP ); Dependency mgtDep = createDependency( "g", "a", "2" ); mgtPlugin.addDependency( mgtDep ); Plugin plugin = createPlugin( "group", "artifact", "1", Collections.EMPTY_MAP ); Dependency dep = createDependency( "g", "a", "1" ); plugin.addDependency( dep ); ModelUtils.mergePluginDefinitions( plugin, mgtPlugin, false ); assertEquals( dep.getVersion(), ((Dependency) plugin.getDependencies().get( 0 ) ).getVersion() ); } private Dependency createDependency( String gid, String aid, String ver ) { Dependency dep = new Dependency(); dep.setGroupId( gid ); dep.setArtifactId( aid ); dep.setVersion( ver ); return dep; } public void testShouldNotInheritPluginWithInheritanceSetToFalse() { PluginContainer parent = new PluginContainer(); Plugin parentPlugin = createPlugin( "group", "artifact", "1.0", Collections.EMPTY_MAP ); parentPlugin.setInherited( "false" ); parent.addPlugin( parentPlugin ); PluginContainer child = new PluginContainer(); child.addPlugin( createPlugin( "group3", "artifact3", "1.0", Collections.EMPTY_MAP ) ); ModelUtils.mergePluginLists( child, parent, true ); List results = child.getPlugins(); assertEquals( 1, results.size() ); Plugin result1 = (Plugin) results.get( 0 ); assertEquals( "group3", result1.getGroupId() ); assertEquals( "artifact3", result1.getArtifactId() ); } /** * Test that this is the resulting ordering of plugins after merging: * * Given: * * parent: X -> A -> B -> D -> E * child: Y -> A -> C -> D -> F * * Result: * * X -> Y -> A -> B -> C -> D -> E -> F */ public void testShouldPreserveChildOrderingOfPluginsAfterParentMerge() { PluginContainer parent = new PluginContainer(); parent.addPlugin( createPlugin( "group", "artifact", "1.0", Collections.EMPTY_MAP ) ); parent.addPlugin( createPlugin( "group2", "artifact2", "1.0", Collections.singletonMap( "key", "value" ) ) ); PluginContainer child = new PluginContainer(); child.addPlugin( createPlugin( "group3", "artifact3", "1.0", Collections.EMPTY_MAP ) ); child.addPlugin( createPlugin( "group2", "artifact2", "1.0", Collections.singletonMap( "key2", "value2" ) ) ); ModelUtils.mergePluginLists( child, parent, true ); List results = child.getPlugins(); assertEquals( 3, results.size() ); Plugin result1 = (Plugin) results.get( 0 ); assertEquals( "group", result1.getGroupId() ); assertEquals( "artifact", result1.getArtifactId() ); Plugin result2 = (Plugin) results.get( 1 ); assertEquals( "group3", result2.getGroupId() ); assertEquals( "artifact3", result2.getArtifactId() ); Plugin result3 = (Plugin) results.get( 2 ); assertEquals( "group2", result3.getGroupId() ); assertEquals( "artifact2", result3.getArtifactId() ); Xpp3Dom result3Config = (Xpp3Dom) result3.getConfiguration(); assertNotNull( result3Config ); assertNotNull( result3Config.getChild( "key" ) ); assertNotNull( result3Config.getChild( "key2" ) ); assertEquals( "value", result3Config.getChild( "key" ).getValue() ); assertEquals( "value2", result3Config.getChild( "key2" ).getValue() ); } /** * Test that this is the resulting ordering of reports after merging: * * Given: * * parent: X -> A -> B -> D -> E * child: Y -> A -> C -> D -> F * * Result: * * X -> Y -> A -> B -> C -> D -> E -> F */ public void testShouldPreserveChildOrderingOfReportsAfterParentMerge() { Reporting parent = new Reporting(); parent.addPlugin( createReportPlugin( "group", "artifact", "1.0", Collections.EMPTY_MAP ) ); parent.addPlugin( createReportPlugin( "group2", "artifact2", "1.0", Collections.singletonMap( "key", "value" ) ) ); Reporting child = new Reporting(); child.addPlugin( createReportPlugin( "group3", "artifact3", "1.0", Collections.EMPTY_MAP ) ); child.addPlugin( createReportPlugin( "group2", "artifact2", "1.0", Collections.singletonMap( "key2", "value2" ) ) ); ModelUtils.mergeReportPluginLists( child, parent, true ); List results = child.getPlugins(); assertEquals( 3, results.size() ); ReportPlugin result1 = (ReportPlugin) results.get( 0 ); assertEquals( "group", result1.getGroupId() ); assertEquals( "artifact", result1.getArtifactId() ); ReportPlugin result2 = (ReportPlugin) results.get( 1 ); assertEquals( "group3", result2.getGroupId() ); assertEquals( "artifact3", result2.getArtifactId() ); ReportPlugin result3 = (ReportPlugin) results.get( 2 ); assertEquals( "group2", result3.getGroupId() ); assertEquals( "artifact2", result3.getArtifactId() ); Xpp3Dom result3Config = (Xpp3Dom) result3.getConfiguration(); assertNotNull( result3Config ); assertNotNull( result3Config.getChild( "key" ) ); assertNotNull( result3Config.getChild( "key2" ) ); //assertEquals( "value", result3Config.getChild( "key" ).getValue() ); assertEquals( "value2", result3Config.getChild( "key2" ).getValue() ); } private Xpp3Dom createConfiguration( Map configuration ) { Xpp3Dom config = new Xpp3Dom( "configuration" ); if( configuration != null ) { for ( Iterator it = configuration.entrySet().iterator(); it.hasNext(); ) { Map.Entry entry = (Map.Entry) it.next(); Xpp3Dom param = new Xpp3Dom( String.valueOf( entry.getKey() ) ); param.setValue( String.valueOf( entry.getValue() ) ); config.addChild( param ); } } return config; } private Plugin createPlugin( String groupId, String artifactId, String version, Map configuration ) { Plugin plugin = new Plugin(); plugin.setGroupId( groupId ); plugin.setArtifactId( artifactId ); plugin.setVersion( version ); plugin.setConfiguration( createConfiguration( configuration ) ); return plugin; } private ReportPlugin createReportPlugin( String groupId, String artifactId, String version, Map configuration ) { ReportPlugin plugin = new ReportPlugin(); plugin.setGroupId( groupId ); plugin.setArtifactId( artifactId ); plugin.setVersion( version ); plugin.setConfiguration( createConfiguration( configuration ) ); return plugin; } public void testShouldInheritOnePluginWithExecution() { Plugin parent = new Plugin(); parent.setArtifactId( "testArtifact" ); parent.setGroupId( "testGroup" ); parent.setVersion( "1.0" ); PluginExecution parentExecution = new PluginExecution(); parentExecution.setId( "testExecution" ); parent.addExecution( parentExecution ); Plugin child = new Plugin(); child.setArtifactId( "testArtifact" ); child.setGroupId( "testGroup" ); child.setVersion( "1.0" ); ModelUtils.mergePluginDefinitions( child, parent, false ); assertEquals( 1, child.getExecutions().size() ); } public void testShouldMergeInheritedPluginHavingExecutionWithLocalPlugin() { Plugin parent = new Plugin(); parent.setArtifactId( "testArtifact" ); parent.setGroupId( "testGroup" ); parent.setVersion( "1.0" ); PluginExecution parentExecution = new PluginExecution(); parentExecution.setId( "testExecution" ); parent.addExecution( parentExecution ); Plugin child = new Plugin(); child.setArtifactId( "testArtifact" ); child.setGroupId( "testGroup" ); child.setVersion( "1.0" ); PluginExecution childExecution = new PluginExecution(); childExecution.setId( "testExecution2" ); child.addExecution( childExecution ); ModelUtils.mergePluginDefinitions( child, parent, false ); assertEquals( 2, child.getExecutions().size() ); } public void testShouldMergeOnePluginWithInheritExecutionWithoutDuplicatingPluginInList() { Plugin parent = new Plugin(); parent.setArtifactId( "testArtifact" ); parent.setGroupId( "testGroup" ); parent.setVersion( "1.0" ); PluginExecution parentExecution = new PluginExecution(); parentExecution.setId( "testExecution" ); parent.addExecution( parentExecution ); Build parentContainer = new Build(); parentContainer.addPlugin( parent ); Plugin child = new Plugin(); child.setArtifactId( "testArtifact" ); child.setGroupId( "testGroup" ); child.setVersion( "1.0" ); Build childContainer = new Build(); childContainer.addPlugin( child ); ModelUtils.mergePluginLists( childContainer, parentContainer, true ); List plugins = childContainer.getPlugins(); assertEquals( 1, plugins.size() ); Plugin plugin = (Plugin) plugins.get( 0 ); assertEquals( 1, plugin.getExecutions().size() ); } public void testShouldMergePluginWithDifferentExecutionFromParentWithoutDuplicatingPluginInList() { Plugin parent = new Plugin(); parent.setArtifactId( "testArtifact" ); parent.setGroupId( "testGroup" ); parent.setVersion( "1.0" ); PluginExecution parentExecution = new PluginExecution(); parentExecution.setId( "testExecution" ); parent.addExecution( parentExecution ); Build parentContainer = new Build(); parentContainer.addPlugin( parent ); Plugin child = new Plugin(); child.setArtifactId( "testArtifact" ); child.setGroupId( "testGroup" ); child.setVersion( "1.0" ); PluginExecution childExecution = new PluginExecution(); childExecution.setId( "testExecution2" ); child.addExecution( childExecution ); Build childContainer = new Build(); childContainer.addPlugin( child ); ModelUtils.mergePluginLists( childContainer, parentContainer, true ); List plugins = childContainer.getPlugins(); assertEquals( 1, plugins.size() ); Plugin plugin = (Plugin) plugins.get( 0 ); assertEquals( 2, plugin.getExecutions().size() ); } public void testShouldNOTMergeInheritedPluginHavingInheritEqualFalse() { Plugin parent = new Plugin(); parent.setArtifactId( "testArtifact" ); parent.setGroupId( "testGroup" ); parent.setVersion( "1.0" ); parent.setInherited( "false" ); PluginExecution parentExecution = new PluginExecution(); parentExecution.setId( "testExecution" ); parent.addExecution( parentExecution ); Plugin child = new Plugin(); child.setArtifactId( "testArtifact" ); child.setGroupId( "testGroup" ); child.setVersion( "1.0" ); ModelUtils.mergePluginDefinitions( child, parent, true ); assertEquals( 0, child.getExecutions().size() ); } /** * Verifies MNG-1499: The order of the merged list should be the plugins specified by the parent followed by the * child list. */ public void testShouldKeepOriginalPluginOrdering() { Plugin parentPlugin1 = new Plugin(); parentPlugin1.setArtifactId( "testArtifact" ); parentPlugin1.setGroupId( "zzz" ); // This will put this plugin last in the sorted map parentPlugin1.setVersion( "1.0" ); PluginExecution parentExecution1 = new PluginExecution(); parentExecution1.setId( "testExecution" ); parentPlugin1.addExecution( parentExecution1 ); Plugin parentPlugin2 = new Plugin(); parentPlugin2.setArtifactId( "testArtifact" ); parentPlugin2.setGroupId( "yyy" ); parentPlugin2.setVersion( "1.0" ); PluginExecution parentExecution2 = new PluginExecution(); parentExecution2.setId( "testExecution" ); parentPlugin2.addExecution( parentExecution2 ); PluginContainer parentContainer = new PluginContainer(); parentContainer.addPlugin(parentPlugin1); parentContainer.addPlugin(parentPlugin2); Plugin childPlugin1 = new Plugin(); childPlugin1.setArtifactId( "testArtifact" ); childPlugin1.setGroupId( "bbb" ); childPlugin1.setVersion( "1.0" ); PluginExecution childExecution1 = new PluginExecution(); childExecution1.setId( "testExecution" ); childPlugin1.addExecution( childExecution1 ); Plugin childPlugin2 = new Plugin(); childPlugin2.setArtifactId( "testArtifact" ); childPlugin2.setGroupId( "aaa" ); childPlugin2.setVersion( "1.0" ); PluginExecution childExecution2 = new PluginExecution(); childExecution2.setId( "testExecution" ); childPlugin2.addExecution( childExecution2 ); PluginContainer childContainer = new PluginContainer(); childContainer.addPlugin(childPlugin1); childContainer.addPlugin(childPlugin2); ModelUtils.mergePluginLists(childContainer, parentContainer, true); assertEquals( 4, childContainer.getPlugins().size() ); assertSame(parentPlugin1, childContainer.getPlugins().get(0)); assertSame(parentPlugin2, childContainer.getPlugins().get(1)); assertSame(childPlugin1, childContainer.getPlugins().get(2)); assertSame(childPlugin2, childContainer.getPlugins().get(3)); } /** * Verifies MNG-1499: The ordering of plugin executions should also be in the specified order. */ public void testShouldKeepOriginalPluginExecutionOrdering() { Plugin parent = new Plugin(); parent.setArtifactId( "testArtifact" ); parent.setGroupId( "testGroup" ); parent.setVersion( "1.0" ); PluginExecution parentExecution1 = new PluginExecution(); parentExecution1.setId( "zzz" ); // Will show up last in the sorted map PluginExecution parentExecution2 = new PluginExecution(); parentExecution2.setId( "yyy" ); // Will show up last in the sorted map parent.addExecution( parentExecution1 ); parent.addExecution( parentExecution2 ); // this block verifies MNG-1703 Dependency dep = new Dependency(); dep.setGroupId( "depGroupId" ); dep.setArtifactId( "depArtifactId" ); dep.setVersion( "depVersion" ); parent.setDependencies( Collections.singletonList( dep ) ); Plugin child = new Plugin(); child.setArtifactId( "testArtifact" ); child.setGroupId( "testGroup" ); child.setVersion( "1.0" ); PluginExecution childExecution1 = new PluginExecution(); childExecution1.setId( "bbb" ); PluginExecution childExecution2 = new PluginExecution(); childExecution2.setId( "aaa" ); child.addExecution( childExecution1 ); child.addExecution( childExecution2 ); ModelUtils.mergePluginDefinitions( child, parent, false ); assertEquals( 4, child.getExecutions().size() ); assertSame(parentExecution1, child.getExecutions().get(0)); assertSame(parentExecution2, child.getExecutions().get(1)); assertSame(childExecution1, child.getExecutions().get(2)); assertSame(childExecution2, child.getExecutions().get(3)); // this block prevents MNG-1703 assertEquals( 1, child.getDependencies().size() ); Dependency dep2 = (Dependency) child.getDependencies().get( 0 ); assertEquals( dep.getManagementKey(), dep2.getManagementKey() ); } public void testShouldMergeTwoPluginDependenciesOnMergeDupePluginDefs() { PluginContainer first = new PluginContainer(); Plugin fPlugin = createPlugin( "g", "a", "1", Collections.EMPTY_MAP ); Dependency fDep = new Dependency(); fDep.setGroupId( "group" ); fDep.setArtifactId( "artifact" ); fDep.setVersion( "1" ); first.addPlugin( fPlugin ); fPlugin.addDependency( fDep ); Plugin sPlugin = createPlugin( "g", "a", "1", Collections.EMPTY_MAP ); Dependency sDep = new Dependency(); sDep.setGroupId( "group" ); sDep.setArtifactId( "artifact2" ); sDep.setVersion( "1" ); first.addPlugin( sPlugin ); sPlugin.addDependency( sDep ); ModelUtils.mergeDuplicatePluginDefinitions( first ); assertEquals( 2, ((Plugin)first.getPlugins().get( 0 ) ).getDependencies().size() ); } public void testShouldNotMergePluginExecutionWhenExecInheritedIsFalseAndTreatAsInheritanceIsTrue() { String gid = "group"; String aid = "artifact"; String ver = "1"; PluginContainer parent = new PluginContainer(); Plugin pParent = createPlugin( gid, aid, ver, Collections.EMPTY_MAP ); pParent.setInherited( Boolean.toString( true ) ); PluginExecution eParent = new PluginExecution(); String testId = "test"; eParent.setId( testId ); eParent.addGoal( "run" ); eParent.setPhase( "initialize" ); eParent.setInherited( Boolean.toString( false ) ); pParent.addExecution( eParent ); parent.addPlugin( pParent ); PluginContainer child = new PluginContainer(); Plugin pChild = createPlugin( gid, aid, ver, Collections.EMPTY_MAP ); PluginExecution eChild = new PluginExecution(); eChild.setId( "child-specified" ); eChild.addGoal( "child" ); eChild.setPhase( "compile" ); pChild.addExecution( eChild ); child.addPlugin( pChild ); ModelUtils.mergePluginDefinitions( pChild, pParent, true ); Map executionMap = pChild.getExecutionsAsMap(); assertNull( "test execution should not be inherited from parent.", executionMap.get( testId ) ); } public void testShouldNotMergePluginExecutionWhenPluginInheritedIsFalseAndTreatAsInheritanceIsTrue() { String gid = "group"; String aid = "artifact"; String ver = "1"; PluginContainer parent = new PluginContainer(); Plugin pParent = createPlugin( gid, aid, ver, Collections.EMPTY_MAP ); pParent.setInherited( Boolean.toString( false ) ); PluginExecution eParent = new PluginExecution(); String testId = "test"; eParent.setId( testId ); eParent.addGoal( "run" ); eParent.setPhase( "initialize" ); eParent.setInherited( Boolean.toString( true ) ); pParent.addExecution( eParent ); parent.addPlugin( pParent ); PluginContainer child = new PluginContainer(); Plugin pChild = createPlugin( gid, aid, ver, Collections.EMPTY_MAP ); PluginExecution eChild = new PluginExecution(); eChild.setId( "child-specified" ); eChild.addGoal( "child" ); eChild.setPhase( "compile" ); pChild.addExecution( eChild ); child.addPlugin( pChild ); ModelUtils.mergePluginDefinitions( pChild, pParent, true ); Map executionMap = pChild.getExecutionsAsMap(); assertNull( "test execution should not be inherited from parent.", executionMap.get( testId ) ); } public void testShouldMergePluginExecutionWhenExecInheritedIsTrueAndTreatAsInheritanceIsTrue() { String gid = "group"; String aid = "artifact"; String ver = "1"; PluginContainer parent = new PluginContainer(); Plugin pParent = createPlugin( gid, aid, ver, Collections.EMPTY_MAP ); pParent.setInherited( Boolean.toString( true ) ); PluginExecution eParent = new PluginExecution(); String testId = "test"; eParent.setId( testId ); eParent.addGoal( "run" ); eParent.setPhase( "initialize" ); eParent.setInherited( Boolean.toString( true ) ); pParent.addExecution( eParent ); parent.addPlugin( pParent ); PluginContainer child = new PluginContainer(); Plugin pChild = createPlugin( gid, aid, ver, Collections.EMPTY_MAP ); PluginExecution eChild = new PluginExecution(); eChild.setId( "child-specified" ); eChild.addGoal( "child" ); eChild.setPhase( "compile" ); pChild.addExecution( eChild ); child.addPlugin( pChild ); ModelUtils.mergePluginDefinitions( pChild, pParent, true ); Map executionMap = pChild.getExecutionsAsMap(); assertNotNull( "test execution should be inherited from parent.", executionMap.get( testId ) ); } } ././@LongLink0000000000000000000000000000015600000000000011567 Lustar rootrootmaven2-core-2.2.1/maven-project/src/test/java/org/apache/maven/project/ProjectBaseDirectoryAlignmentTest.javamaven2-core-2.2.1/maven-project/src/test/java/org/apache/maven/project/ProjectBaseDirectoryAlignment0000644000175000017500000000425111030240413033453 0ustar twernertwernerpackage org.apache.maven.project; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import org.apache.maven.model.Build; import org.apache.maven.model.Resource; import java.io.File; public class ProjectBaseDirectoryAlignmentTest extends AbstractMavenProjectTestCase { private String dir = "src/test/resources/projects/base-directory-alignment/"; public void testProjectDirectoryBaseDirectoryAlignment() throws Exception { File f = getTestFile( dir + "project-which-needs-directory-alignment.xml" ); MavenProject project = getProject( f ); projectBuilder.calculateConcreteState( project, new DefaultProjectBuilderConfiguration() ); assertNotNull( "Test project can't be null!", project ); File basedirFile = new File( getBasedir() ); File sourceDirectoryFile = new File( project.getBuild().getSourceDirectory() ); File testSourceDirectoryFile = new File( project.getBuild().getTestSourceDirectory() ); assertEquals( basedirFile.getCanonicalPath(), sourceDirectoryFile.getCanonicalPath().substring( 0, getBasedir().length() ) ); assertEquals( basedirFile.getCanonicalPath(), testSourceDirectoryFile.getCanonicalPath().substring( 0, getBasedir().length() ) ); Build build = project.getBuild(); Resource resource = (Resource) build.getResources().get( 0 ); assertTrue( resource.getDirectory().startsWith( getBasedir() ) ); } } ././@LongLink0000000000000000000000000000014500000000000011565 Lustar rootrootmaven2-core-2.2.1/maven-project/src/test/java/org/apache/maven/project/MavenProjectDynamismTest.javamaven2-core-2.2.1/maven-project/src/test/java/org/apache/maven/project/MavenProjectDynamismTest.java0000644000175000017500000010312011221205616033410 0ustar twernertwernerpackage org.apache.maven.project; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import java.io.File; import java.io.IOException; import java.net.URI; import java.net.URISyntaxException; import java.net.URL; import java.util.Iterator; import java.util.List; import java.util.Map; import org.apache.maven.model.Build; import org.apache.maven.model.Dependency; import org.apache.maven.model.Plugin; import org.apache.maven.model.Resource; import org.apache.maven.project.interpolation.ModelInterpolationException; import org.codehaus.plexus.PlexusTestCase; import org.codehaus.plexus.util.StringUtils; import org.codehaus.plexus.util.xml.Xpp3Dom; import org.codehaus.plexus.util.xml.pull.XmlPullParserException; public class MavenProjectDynamismTest extends PlexusTestCase { private DefaultMavenProjectBuilder projectBuilder; public void setUp() throws Exception { super.setUp(); projectBuilder = (DefaultMavenProjectBuilder) lookup( MavenProjectBuilder.class.getName() ); } public void testBuildSectionGroupIdInterpolation() throws IOException, XmlPullParserException, URISyntaxException, ProjectBuildingException, ModelInterpolationException { MavenProject project = buildProject( "pom-interp.xml" ); projectBuilder.calculateConcreteState( project, new DefaultProjectBuilderConfiguration() ); String basepath = new File( project.getBasedir(), project.getGroupId() ).getAbsolutePath(); Build build = project.getBuild(); assertTrue( build.getSourceDirectory() + " doesn't start with base-path: " + basepath, build.getSourceDirectory().startsWith( basepath ) ); assertTrue( build.getTestSourceDirectory() + " doesn't start with base-path: " + basepath, build.getTestSourceDirectory().startsWith( basepath ) ); // TODO: MNG-3731 // assertTrue( build.getScriptSourceDirectory() + " doesn't start with base-path: " + basepath, // build.getScriptSourceDirectory().startsWith( basepath ) ); List plugins = build.getPlugins(); assertNotNull( plugins ); assertEquals( 1, plugins.size() ); Plugin plugin = (Plugin) plugins.get( 0 ); assertEquals( "my-plugin", plugin.getArtifactId() ); Xpp3Dom conf = (Xpp3Dom) plugin.getConfiguration(); assertNotNull( conf ); Xpp3Dom[] children = conf.getChildren(); assertEquals( 3, children.length ); for ( int i = 0; i < children.length; i++ ) { assertEquals( "Configuration parameter: " + children[i].getName() + " should have a an interpolated POM groupId as its value.", children[i].getValue(), project.getGroupId() ); } project.getProperties().setProperty( "foo", "bar" ); projectBuilder.restoreDynamicState( project, new DefaultProjectBuilderConfiguration() ); String projectGidExpr = "${project.groupId}"; String pomGidExpr = "${pom.groupId}"; String nakedGidExpr = "${groupId}"; build = project.getBuild(); assertTrue( build.getSourceDirectory() + " didn't start with: " + projectGidExpr, build.getSourceDirectory().startsWith( projectGidExpr ) ); assertTrue( build.getTestSourceDirectory() + " didn't start with: " + pomGidExpr, build.getTestSourceDirectory().startsWith( pomGidExpr ) ); assertTrue( build.getScriptSourceDirectory() + " didn't start with: " + nakedGidExpr, build.getScriptSourceDirectory().startsWith( nakedGidExpr ) ); plugins = build.getPlugins(); assertNotNull( plugins ); assertEquals( 1, plugins.size() ); plugin = (Plugin) plugins.get( 0 ); assertEquals( "my-plugin", plugin.getArtifactId() ); conf = (Xpp3Dom) plugin.getConfiguration(); assertNotNull( conf ); children = conf.getChildren(); assertEquals( 3, children.length ); assertEquals( "Configuration parameter: " + children[0].getName() + " should have " + projectGidExpr + " as its value.", children[0].getValue(), projectGidExpr ); assertEquals( "Configuration parameter: " + children[1].getName() + " should have " + pomGidExpr + " as its value.", children[1].getValue(), pomGidExpr ); assertEquals( "Configuration parameter: " + children[2].getName() + " should have " + nakedGidExpr + " as its value.", children[2].getValue(), nakedGidExpr ); } public void testRoundTrip() throws IOException, XmlPullParserException, URISyntaxException, ModelInterpolationException, ProjectBuildingException { MavenProject project = buildProject( "pom.xml" ); ProjectBuilderConfiguration config = new DefaultProjectBuilderConfiguration(); projectBuilder.calculateConcreteState( project, config ); File baseDir = project.getBasedir(); File buildDir = new File( baseDir, "target" ); String basedirExpr = "${pom.basedir}"; String buildDirExpr = "${pom.build.directory}"; assertTrue( project.isConcrete() ); Build build = project.getBuild(); assertEquals( "Concrete source directory should be absolute.", new File( baseDir, "/src/main/java" ).getAbsolutePath(), new File( build.getSourceDirectory() ).getAbsolutePath() ); assertEquals( "Concrete test-source directory should be absolute.", new File( baseDir, "/src/test/java" ).getAbsolutePath(), new File( build.getTestSourceDirectory() ).getAbsolutePath() ); assertEquals( "Concrete script-source directory should be absolute.", new File( baseDir, "/src/main/scripts" ).getAbsolutePath(), new File( build.getScriptSourceDirectory() ).getAbsolutePath() ); List compileSourceRoots = project.getCompileSourceRoots(); assertNotNull( "Concrete compile-source roots should not be null.", compileSourceRoots ); assertEquals( "Concrete compile-source roots should contain one entry.", 1, compileSourceRoots.size() ); assertEquals( "Concrete compile-source roots should contain interpolated source-directory value.", new File( baseDir, "/src/main/java" ).getAbsolutePath(), new File( (String) compileSourceRoots.get( 0 ) ).getAbsolutePath() ); List testCompileSourceRoots = project.getTestCompileSourceRoots(); assertNotNull( "Concrete test-compile-source roots should not be null.", testCompileSourceRoots ); assertEquals( "Concrete test-compile-source roots should contain one entry.", 1, testCompileSourceRoots.size() ); assertEquals( "Concrete test-compile-source roots should contain interpolated test-source-directory value.", new File( baseDir, "/src/test/java" ).getAbsolutePath(), new File( (String) testCompileSourceRoots.get( 0 ) ).getAbsolutePath() ); List scriptSourceRoots = project.getScriptSourceRoots(); assertNotNull( "Concrete script-source roots should not be null.", scriptSourceRoots ); assertEquals( "Concrete script-source roots should contain one entry.", 1, scriptSourceRoots.size() ); assertEquals( "Concrete script-source roots should contain interpolated script-source-directory value.", new File( baseDir, "/src/main/scripts" ).getAbsolutePath(), new File( (String) scriptSourceRoots.get( 0 ) ).getAbsolutePath() ); List resources = build.getResources(); assertNotNull( "Concrete resources should not be null.", resources ); assertEquals( "Concrete resources should contain one entry.", 1, resources.size() ); assertEquals( "Concrete resource should contain absolute path.", new File( buildDir, "generated-resources/plexus" ).getAbsolutePath(), new File( ( (Resource) resources.get( 0 ) ).getDirectory() ).getAbsolutePath() ); List filters = build.getFilters(); assertNotNull( "Concrete filters should not be null.", filters ); assertEquals( "Concrete filters should contain one entry.", 1, filters.size() ); assertEquals( "Concrete filter entry should contain absolute path.", new File( buildDir, "/generated-filters.properties" ).getAbsolutePath(), new File( (String) filters.get( 0 ) ).getAbsolutePath() ); assertEquals( "Concrete output-directory should be absolute.", new File( buildDir, "/classes" ).getAbsolutePath(), new File( build.getOutputDirectory() ).getAbsolutePath() ); assertEquals( "Concrete test-output-directory should be absolute.", new File( buildDir, "/test-classes" ).getAbsolutePath(), new File( build.getTestOutputDirectory() ).getAbsolutePath() ); assertEquals( "Concrete build directory should be absolute.", new File( baseDir, "target" ).getAbsolutePath(), new File( build.getDirectory() ).getAbsolutePath() ); // Next, we have to change something to ensure the project is restored to its dynamic state. project.getProperties().setProperty( "restoreTrigger", "true" ); // -------------------------------------------------------------------- // NOW, RESTORE THE DYNAMIC STATE FOR THE BUILD SECTION AND // ASSOCIATED DIRECTORIES ATTACHED TO THE PROJECT INSTANCE. // -------------------------------------------------------------------- projectBuilder.restoreDynamicState( project, config ); assertFalse( project.isConcrete() ); build = project.getBuild(); assertEquals( "Restored source directory should be expressed in terms of the basedir.\nWas: " + build.getSourceDirectory() + "\nShould be: " + basedirExpr + "/src/main/java\n", basedirExpr + "/src/main/java", build.getSourceDirectory() ); assertEquals( "Restored test-source directory should be expressed in terms of the basedir.", basedirExpr + "/src/test/java", build.getTestSourceDirectory() ); assertEquals( "Restored script-source directory should be expressed in terms of the basedir.", basedirExpr + "/src/main/scripts", build.getScriptSourceDirectory() ); compileSourceRoots = project.getCompileSourceRoots(); assertNotNull( "Restored compile-source roots should not be null.", compileSourceRoots ); assertEquals( "Restored compile-source roots should contain one entry.", 1, compileSourceRoots.size() ); assertEquals( "Restored compile-source roots should contain uninterpolated source-directory value.", "${pom.basedir}/src/main/java", compileSourceRoots.get( 0 ) ); testCompileSourceRoots = project.getTestCompileSourceRoots(); assertNotNull( "Restored test-compile-source roots should not be null.", testCompileSourceRoots ); assertEquals( "Restored test-compile-source roots should contain one entry.", 1, testCompileSourceRoots.size() ); assertEquals( "Restored test-compile-source roots should contain uninterpolated test-source-directory value.", "${pom.basedir}/src/test/java", testCompileSourceRoots.get( 0 ) ); scriptSourceRoots = project.getScriptSourceRoots(); assertNotNull( "Restored script-source roots should not be null.", scriptSourceRoots ); assertEquals( "Restored script-source roots should contain one entry.", 1, scriptSourceRoots.size() ); assertEquals( "Restored script-source roots should contain uninterpolated script-source-directory value.", "${pom.basedir}/src/main/scripts", scriptSourceRoots.get( 0 ) ); resources = build.getResources(); assertNotNull( "Restored resources should not be null.", resources ); assertEquals( "Restored resources should contain one entry.", 1, resources.size() ); assertEquals( "Restored resource should contain uninterpolated reference to build directory.", buildDirExpr + "/generated-resources/plexus", ( (Resource) resources.get( 0 ) ).getDirectory() ); filters = build.getFilters(); assertNotNull( "Restored filters should not be null.", filters ); assertEquals( "Restored filters should contain one entry.", 1, filters.size() ); assertEquals( "Restored filter entry should contain uninterpolated reference to build directory.", buildDirExpr + "/generated-filters.properties", filters.get( 0 ) ); assertEquals( "Restored output-directory should be expressed in terms of the build-directory.", buildDirExpr + "/classes", build.getOutputDirectory() ); assertEquals( "Restored test-output-directory should be expressed in terms of the build-directory.", buildDirExpr + "/test-classes", build.getTestOutputDirectory() ); assertEquals( "Restored build directory should be relative.", "target", build.getDirectory() ); } public void testShouldPreserveAddedResourceInRestoredState() throws IOException, XmlPullParserException, URISyntaxException, ProjectBuildingException, ModelInterpolationException { MavenProject project = buildProject( "pom.xml" ); ProjectBuilderConfiguration config = new DefaultProjectBuilderConfiguration(); projectBuilder.calculateConcreteState( project, config ); Build build = project.getBuild(); Resource r = new Resource(); r.setDirectory( "myDir" ); build.addResource( r ); List resources = build.getResources(); assertNotNull( "Concrete resources should not be null.", resources ); assertEquals( "Concrete resources should contain two entries.", 2, resources.size() ); assertResourcePresent( "concrete resources", new File( build.getDirectory(), "generated-resources/plexus" ).getAbsolutePath(), resources ); assertResourcePresent( "concrete resources", "myDir", resources ); // Next, we have to change something to ensure the project is restored to its dynamic state. project.getProperties().setProperty( "restoreTrigger", "true" ); projectBuilder.restoreDynamicState( project, config ); build = project.getBuild(); resources = build.getResources(); assertNotNull( "Restored resources should not be null.", resources ); assertEquals( "Restored resources should contain two entries.", 2, resources.size() ); assertResourcePresent( "restored resources", "${pom.build.directory}/generated-resources/plexus", resources ); assertResourcePresent( "restored resources", "myDir", resources ); } public void testShouldPreserveAddedFilterInRestoredState() throws IOException, XmlPullParserException, URISyntaxException, ProjectBuildingException, ModelInterpolationException { MavenProject project = buildProject( "pom.xml" ); ProjectBuilderConfiguration config = new DefaultProjectBuilderConfiguration(); projectBuilder.calculateConcreteState( project, config ); Build build = project.getBuild(); build.addFilter( "myDir/filters.properties" ); List filters = build.getFilters(); assertNotNull( "Concrete filters should not be null.", filters ); assertEquals( "Concrete filters should contain two entries.", 2, filters.size() ); assertFilterPresent( "concrete filters", new File( build.getDirectory(), "generated-filters.properties" ).getAbsolutePath(), filters ); assertFilterPresent( "concrete filters", "myDir/filters.properties", filters ); // Next, we have to change something to ensure the project is restored to its dynamic state. project.getProperties().setProperty( "restoreTrigger", "true" ); projectBuilder.restoreDynamicState( project, config ); build = project.getBuild(); filters = build.getFilters(); assertNotNull( "Restored filters should not be null.", filters ); assertEquals( "Restored filters should contain two entries.", 2, filters.size() ); assertFilterPresent( "restored filters", "${pom.build.directory}/generated-filters.properties", filters ); assertFilterPresent( "restored filters", "myDir/filters.properties", filters ); } public void testShouldIncorporateChangedBuildDirectoryViaExpressionsOnNextConcreteCalculation() throws IOException, XmlPullParserException, URISyntaxException, ProjectBuildingException, ModelInterpolationException { MavenProject project = buildProject( "pom.xml" ); ProjectBuilderConfiguration config = new DefaultProjectBuilderConfiguration(); projectBuilder.calculateConcreteState( project, config ); Build build = project.getBuild(); assertEquals( "First concrete build directory should be absolute and point to target dir.", new File( project.getBasedir(), "target" ).getAbsolutePath(), build.getDirectory() ); assertEquals( "First concrete build output-directory should be absolute and point to target/classes dir.", new File( project.getBasedir(), "target/classes" ).getAbsolutePath(), new File( build.getOutputDirectory() ).getAbsolutePath() ); build.setDirectory( "target2" ); assertEquals( "AFTER CHANGING BUILD DIRECTORY, build directory should be relative and point to target2 dir.", "target2", build.getDirectory() ); assertEquals( "AFTER CHANGING BUILD DIRECTORY, build output-directory should be absolute and still point to target/classes dir.", new File( project.getBasedir(), "target/classes" ).getAbsolutePath(), new File( build.getOutputDirectory() ).getAbsolutePath() ); projectBuilder.restoreDynamicState( project, config ); projectBuilder.calculateConcreteState( project, config ); build = project.getBuild(); assertEquals( "Second concrete build directory should be absolute and point to target2 dir.", new File( project.getBasedir(), "target2" ).getAbsolutePath(), new File( build.getDirectory() ).getAbsolutePath() ); assertEquals( "Second concrete build output-directory should be absolute and point to target2/classes dir.", new File( project.getBasedir(), "target2/classes" ).getAbsolutePath(), new File( build.getOutputDirectory() ).getAbsolutePath() ); } public void testShouldPreserveInitialValuesForPropertiesReferencingBuildPaths() throws IOException, XmlPullParserException, URISyntaxException, ProjectBuildingException, ModelInterpolationException { MavenProject project = buildProject( "pom.xml" ); ProjectBuilderConfiguration config = new DefaultProjectBuilderConfiguration(); projectBuilder.calculateConcreteState( project, config ); project.getBuild().setDirectory( "target2" ); String originalValue = project.getProperties().getProperty( "myProperty" ); projectBuilder.restoreDynamicState( project, config ); projectBuilder.calculateConcreteState( project, config ); assertEquals( "After resetting build-directory and going through a recalculation phase for the project, " + "property value for 'myProperty' should STILL be the absolute initial build directory.", originalValue, project.getProperties().getProperty( "myProperty" ) ); } public void testShouldAlignCompileSourceRootsInConcreteState() throws IOException, XmlPullParserException, URISyntaxException, ProjectBuildingException, ModelInterpolationException { MavenProject project = buildProject( "pom-relative.xml" ); ProjectBuilderConfiguration config = new DefaultProjectBuilderConfiguration(); projectBuilder.calculateConcreteState( project, config ); List compileSourceRoots = project.getCompileSourceRoots(); assertNotNull( "First concrete state compile-source roots should not be null.", compileSourceRoots ); assertEquals( "First concrete state should contain one compile-source root.", 1, compileSourceRoots.size() ); assertEquals( "First concrete state should have an absolute path for compile-source root.", new File( project.getBasedir(), "src/main/java" ).getAbsolutePath(), compileSourceRoots.get( 0 ) ); String newSourceRoot = new File( project.getBuild().getDirectory(), "generated-sources/modello" ).getAbsolutePath(); project.addCompileSourceRoot( newSourceRoot ); // Next, we have to change something to ensure the project is restored to its dynamic state. project.getProperties().setProperty( "restoreTrigger", "true" ); projectBuilder.restoreDynamicState( project, config ); compileSourceRoots = project.getCompileSourceRoots(); assertNotNull( "Restored dynamic state compile-source roots should not be null.", compileSourceRoots ); assertEquals( "Restored dynamic state should contain two compile-source roots.", 2, compileSourceRoots.size() ); assertEquals( "Restored dynamic state should have a relative path for original compile-source root.", "src/main/java", compileSourceRoots.get( 0 ) ); assertEquals( "Restored dynamic state should have a relative path for new compile-source root.", "target/generated-sources/modello", compileSourceRoots.get( 1 ) ); projectBuilder.calculateConcreteState( project, config ); compileSourceRoots = project.getCompileSourceRoots(); assertNotNull( "Second concrete state compile-source roots should not be null.", compileSourceRoots ); assertEquals( "Second concrete state should contain two compile-source roots.", 2, compileSourceRoots.size() ); assertEquals( "Second concrete state should have an absolute path for original compile-source root.", new File( project.getBasedir(), "src/main/java" ).getAbsolutePath(), compileSourceRoots.get( 0 ) ); assertEquals( "Second concrete state should have an absolute path for new compile-source root.", newSourceRoot, compileSourceRoots.get( 1 ) ); } public void testShouldMaintainAddedAndExistingPluginEntriesInRoundTrip() throws IOException, XmlPullParserException, URISyntaxException, ProjectBuildingException, ModelInterpolationException { MavenProject project = buildProject( "pom-plugins.xml" ); String firstPlugin = "one:first-maven-plugin"; String secondPlugin = "two:second-maven-plugin"; String thirdPlugin = "three:third-maven-plugin"; project.getBuild().flushPluginMap(); Map pluginMap = project.getBuild().getPluginsAsMap(); assertNotNull( "Before calculating concrete state, project should contain plugin: " + firstPlugin, pluginMap.get( firstPlugin ) ); assertNotNull( "Before calculating concrete state, project should contain plugin: " + secondPlugin, pluginMap.get( secondPlugin ) ); assertNull( "Before calculating concrete state, project should NOT contain plugin: " + thirdPlugin, pluginMap.get( thirdPlugin ) ); ProjectBuilderConfiguration config = new DefaultProjectBuilderConfiguration(); projectBuilder.calculateConcreteState( project, config ); project.getBuild().flushPluginMap(); pluginMap = project.getBuild().getPluginsAsMap(); assertNotNull( "After calculating concrete state, project should contain plugin: " + firstPlugin, pluginMap.get( firstPlugin ) ); assertNotNull( "After calculating concrete state, project should contain plugin: " + secondPlugin, pluginMap.get( secondPlugin ) ); assertNull( "After calculating concrete state, project should NOT contain plugin: " + thirdPlugin, pluginMap.get( thirdPlugin ) ); Plugin third = new Plugin(); third.setGroupId( "three" ); third.setArtifactId( "third-maven-plugin" ); third.setVersion( "3" ); project.addPlugin( third ); project.getBuild().flushPluginMap(); pluginMap = project.getBuild().getPluginsAsMap(); assertNotNull( "After adding third plugin, project should contain plugin: " + firstPlugin, pluginMap.get( firstPlugin ) ); assertNotNull( "After adding third plugin, project should contain plugin: " + secondPlugin, pluginMap.get( secondPlugin ) ); assertNotNull( "After adding third plugin, project should contain plugin: " + thirdPlugin, pluginMap.get( thirdPlugin ) ); projectBuilder.restoreDynamicState( project, config ); project.getBuild().flushPluginMap(); pluginMap = project.getBuild().getPluginsAsMap(); assertNotNull( "After restoring project dynamism, project should contain plugin: " + firstPlugin, pluginMap.get( firstPlugin ) ); assertNotNull( "After restoring project dynamism, project should contain plugin: " + secondPlugin, pluginMap.get( secondPlugin ) ); assertNotNull( "After restoring project dynamism, project should contain plugin: " + thirdPlugin, pluginMap.get( thirdPlugin ) ); } public void testShouldMaintainAddedAndExistingSourceRootsInRoundTrip() throws IOException, XmlPullParserException, URISyntaxException, ProjectBuildingException, ModelInterpolationException { MavenProject project = buildProject( "pom-source-roots.xml" ); File basedir = project.getBasedir(); ProjectBuilderConfiguration config = new DefaultProjectBuilderConfiguration(); projectBuilder.calculateConcreteState( project, config ); assertTrue( "Before adding source roots, project should be concrete", project.isConcrete() ); assertEquals( "Before adding source roots, project should contain one compile source root", 1, project.getCompileSourceRoots().size() ); assertEquals( "First compile source root should be absolute ref to src/main/java", new File( basedir, "src/main/java" ).getAbsolutePath(), project.getCompileSourceRoots().get( 0 ) ); assertEquals( "Before adding source roots, project should contain one test source root", 1, project.getTestCompileSourceRoots().size() ); assertEquals( "First test source root should be absolute ref to src/test/java", new File( basedir, "src/test/java" ).getAbsolutePath(), project.getTestCompileSourceRoots().get( 0 ) ); assertEquals( "Before adding source roots, project should contain one script source root", 1, project.getScriptSourceRoots().size() ); assertEquals( "First script source root should be relative ref to src/main/scripts", "src/main/scripts", project.getScriptSourceRoots().get( 0 ) ); project.addCompileSourceRoot( new File( basedir, "target/generated/src/main/java" ).getAbsolutePath() ); project.addTestCompileSourceRoot( new File( basedir, "target/generated/src/test/java" ).getAbsolutePath() ); project.addScriptSourceRoot( new File( basedir, "target/generated/src/main/scripts" ).getAbsolutePath() ); project.getProperties().setProperty( "trigger-transition", "true" ); projectBuilder.restoreDynamicState( project, config ); projectBuilder.calculateConcreteState( project, config ); assertTrue( "After adding source roots and transitioning, project should be concrete", project.isConcrete() ); assertEquals( "After adding source roots and transitioning, project should contain two compile source roots", 2, project.getCompileSourceRoots().size() ); assertEquals( "First compile source root should be absolute ref to src/main/java", new File( basedir, "src/main/java" ).getAbsolutePath(), project.getCompileSourceRoots().get( 0 ) ); assertEquals( "Second compile source root should be absolute ref to target/generated/src/main/java", new File( basedir, "target/generated/src/main/java" ).getAbsolutePath(), project.getCompileSourceRoots().get( 1 ) ); assertEquals( "After adding source roots and transitioning, project should contain two test source roots", 2, project.getTestCompileSourceRoots().size() ); assertEquals( "First test source root should be absolute ref to src/test/java", new File( basedir, "src/test/java" ).getAbsolutePath(), project.getTestCompileSourceRoots().get( 0 ) ); assertEquals( "Second test source root should be absolute ref to target/generated/src/test/java", new File( basedir, "target/generated/src/test/java" ).getAbsolutePath(), project.getTestCompileSourceRoots().get( 1 ) ); assertEquals( "After adding source roots and transitioning, project should contain two script source roots", 2, project.getScriptSourceRoots().size() ); assertEquals( "First script source root should be relative ref to src/main/scripts", "src/main/scripts", project.getScriptSourceRoots().get( 0 ) ); assertEquals( "Second script source root should be relative ref to target/generated/src/main/scripts", "target/generated/src/main/scripts", project.getScriptSourceRoots().get( 1 ) ); } public void testShouldInterpolatePluginLevelDependency() throws IOException, XmlPullParserException, URISyntaxException, ProjectBuildingException, ModelInterpolationException { MavenProject project = buildProject( "plugin-level-dep.pom.xml" ); Plugin plugin = (Plugin) project.getBuild().getPluginsAsMap().get( "org.apache.maven.plugins:maven-compiler-plugin" ); assertNotNull( "ERROR - compiler plugin config not found!", plugin ); assertTrue( "ERROR - compiler plugin custom dependencies not found!", ( plugin.getDependencies() != null && !plugin.getDependencies().isEmpty() ) ); Dependency dep = (Dependency) plugin.getDependencies().get( 0 ); assertEquals( "custom dependency version should be an INTERPOLATED reference to this project's version.", project.getVersion(), dep.getVersion() ); } // Useful for diagnostics. // private void displayPOM( Model model ) // throws IOException // { // StringWriter writer = new StringWriter(); // new MavenXpp3Writer().write( writer, model ); // // System.out.println( writer.toString() ); // } private void assertResourcePresent( String testLabel, String directory, List resources ) { boolean found = false; if ( resources != null ) { for ( Iterator it = resources.iterator(); it.hasNext(); ) { Resource resource = (Resource) it.next(); if ( new File( directory ).getAbsolutePath().equals( new File( resource.getDirectory() ).getAbsolutePath() ) ) { found = true; break; } } } if ( !found ) { fail( "Missing resource with directory: " + directory + " in " + testLabel ); } } private void assertFilterPresent( String testLabel, String path, List filters ) { boolean found = false; if ( filters != null ) { for ( Iterator it = filters.iterator(); it.hasNext(); ) { String filterPath = (String) it.next(); if ( new File( path ).getAbsolutePath().equals( new File( filterPath ).getAbsolutePath() ) ) { found = true; break; } } } if ( !found ) { fail( "Missing filter with path: " + path + " in " + testLabel ); } } private MavenProject buildProject( String path ) throws IOException, XmlPullParserException, URISyntaxException, ProjectBuildingException { ClassLoader cloader = Thread.currentThread().getContextClassLoader(); URL resource = cloader.getResource( "project-dynamism/" + path ); if ( resource == null ) { fail( "Cannot find classpath resource for POM: " + path ); } String resourcePath = StringUtils.replace( resource.getPath(), "%20", " " ); URI uri = new File( resourcePath ).toURI().normalize(); File pomFile = new File( uri ); pomFile = pomFile.getAbsoluteFile(); MavenProject project = projectBuilder.build( pomFile, new DefaultProjectBuilderConfiguration() ); return project; } } maven2-core-2.2.1/maven-project/src/test/java/org/apache/maven/project/injection/0000755000175000017500000000000011250552244027577 5ustar twernertwerner././@LongLink0000000000000000000000000000016700000000000011571 Lustar rootrootmaven2-core-2.2.1/maven-project/src/test/java/org/apache/maven/project/injection/DefaultModelDefaultsInjectorTest.javamaven2-core-2.2.1/maven-project/src/test/java/org/apache/maven/project/injection/DefaultModelDefault0000644000175000017500000003223410764047110033400 0ustar twernertwernerpackage org.apache.maven.project.injection; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import org.apache.maven.model.Build; import org.apache.maven.model.Dependency; import org.apache.maven.model.DependencyManagement; import org.apache.maven.model.Exclusion; import org.apache.maven.model.Model; import org.apache.maven.model.Plugin; import org.apache.maven.model.PluginManagement; import java.util.List; import java.util.Map; import junit.framework.TestCase; /** * @author jdcasey */ public class DefaultModelDefaultsInjectorTest extends TestCase { public void testShouldConstructWithNoParams() { new DefaultModelDefaultsInjector(); } public void testShouldMergePluginManagementVersionIntoPlugin() { String groupId = "org.apache.maven.plugins"; String artifactId = "maven-test-plugin"; Model model = new Model(); Build build = new Build(); Plugin targetPlugin = new Plugin(); targetPlugin.setGroupId( groupId ); targetPlugin.setArtifactId( artifactId ); build.addPlugin( targetPlugin ); PluginManagement pMgmt = new PluginManagement(); Plugin managedPlugin = new Plugin(); managedPlugin.setGroupId( groupId ); managedPlugin.setArtifactId( artifactId ); managedPlugin.setVersion( "10.0.0" ); pMgmt.addPlugin( managedPlugin ); build.setPluginManagement( pMgmt ); model.setBuild( build ); new DefaultModelDefaultsInjector().injectDefaults( model ); Map pMap = model.getBuild().getPluginsAsMap(); Plugin result = (Plugin) pMap.get( groupId + ":" + artifactId ); assertNotNull( result ); assertEquals( managedPlugin.getVersion(), result.getVersion() ); } public void testShouldKeepPluginVersionOverPluginManagementVersion() { String groupId = "org.apache.maven.plugins"; String artifactId = "maven-test-plugin"; Model model = new Model(); Build build = new Build(); Plugin targetPlugin = new Plugin(); targetPlugin.setGroupId( groupId ); targetPlugin.setArtifactId( artifactId ); targetPlugin.setVersion( "9.0.0" ); build.addPlugin( targetPlugin ); PluginManagement pMgmt = new PluginManagement(); Plugin managedPlugin = new Plugin(); managedPlugin.setGroupId( groupId ); managedPlugin.setArtifactId( artifactId ); managedPlugin.setVersion( "10.0.0" ); pMgmt.addPlugin( managedPlugin ); build.setPluginManagement( pMgmt ); model.setBuild( build ); new DefaultModelDefaultsInjector().injectDefaults( model ); Map pMap = model.getBuild().getPluginsAsMap(); Plugin result = (Plugin) pMap.get( groupId + ":" + artifactId ); assertNotNull( result ); assertEquals( targetPlugin.getVersion(), result.getVersion() ); } public void testShouldMergeManagedDependencyOfTypeEJBToDependencyList() { Model model = new Model(); Dependency managedDep = new Dependency(); managedDep.setGroupId( "group" ); managedDep.setArtifactId( "artifact" ); managedDep.setVersion( "1.0" ); managedDep.setType( "ejb" ); DependencyManagement depMgmt = new DependencyManagement(); depMgmt.addDependency( managedDep ); model.setDependencyManagement( depMgmt ); Dependency dep = new Dependency(); dep.setGroupId( "group" ); dep.setArtifactId( "artifact" ); // looks like groupId:artifactId:type is the minimum for identification, where // type is defaulted to "jar". dep.setType( "ejb" ); model.addDependency( dep ); new DefaultModelDefaultsInjector().injectDefaults( model ); List resultingDeps = model.getDependencies(); assertEquals( 1, resultingDeps.size() ); Dependency result = (Dependency) resultingDeps.get( 0 ); assertEquals( "1.0", result.getVersion() ); } public void testShouldSucceedInMergingDependencyWithDependency() { Model model = new Model(); Dependency dep = new Dependency(); dep.setGroupId( "myGroup" ); dep.setArtifactId( "myArtifact" ); model.addDependency( dep ); Dependency def = new Dependency(); def.setGroupId( dep.getGroupId() ); def.setArtifactId( dep.getArtifactId() ); def.setVersion( "1.0.1" ); def.setScope( "scope" ); DependencyManagement depMgmt = new DependencyManagement(); depMgmt.addDependency( def ); model.setDependencyManagement( depMgmt ); new DefaultModelDefaultsInjector().injectDefaults( model ); List deps = model.getDependencies(); assertEquals( 1, deps.size() ); Dependency result = (Dependency) deps.get( 0 ); assertEquals( def.getVersion(), result.getVersion() ); } public void testShouldMergeDependencyExclusionsFromDefaultsToDependency() { Model model = new Model(); Dependency dep = new Dependency(); dep.setGroupId( "myGroup" ); dep.setArtifactId( "myArtifact" ); model.addDependency( dep ); Dependency def = new Dependency(); def.setGroupId( dep.getGroupId() ); def.setArtifactId( dep.getArtifactId() ); def.setVersion( "1.0.1" ); def.setScope( "scope" ); Exclusion exc = new Exclusion(); exc.setArtifactId( "mydep" ); exc.setGroupId( "mygrp" ); def.addExclusion( exc ); DependencyManagement depMgmt = new DependencyManagement(); depMgmt.addDependency( def ); model.setDependencyManagement( depMgmt ); new DefaultModelDefaultsInjector().injectDefaults( model ); List deps = model.getDependencies(); assertEquals( 1, deps.size() ); Dependency result = (Dependency) deps.get( 0 ); assertEquals( def.getVersion(), result.getVersion() ); List resultExclusions = result.getExclusions(); assertNotNull( resultExclusions ); assertEquals( 1, resultExclusions.size() ); Exclusion resultExclusion = (Exclusion) resultExclusions.get( 0 ); assertEquals( "mydep", resultExclusion.getArtifactId() ); assertEquals( "mygrp", resultExclusion.getGroupId() ); } public void testShouldMergeDefaultUrlAndArtifactWhenDependencyDoesntSupplyVersion() { Model model = new Model(); Dependency dep = new Dependency(); dep.setGroupId( "myGroup" ); dep.setArtifactId( "myArtifact" ); model.addDependency( dep ); Dependency def = new Dependency(); def.setGroupId( dep.getGroupId() ); def.setArtifactId( dep.getArtifactId() ); def.setVersion( "1.0.1" ); DependencyManagement depMgmt = new DependencyManagement(); depMgmt.addDependency( def ); model.setDependencyManagement( depMgmt ); new DefaultModelDefaultsInjector().injectDefaults( model ); List deps = model.getDependencies(); assertEquals( 1, deps.size() ); Dependency result = (Dependency) deps.get( 0 ); assertEquals( def.getVersion(), result.getVersion() ); } public void testShouldNotMergeDefaultUrlOrArtifactWhenDependencySuppliesVersion() { Model model = new Model(); Dependency dep = new Dependency(); dep.setGroupId( "myGroup" ); dep.setArtifactId( "myArtifact" ); dep.setVersion( "1.0.1" ); model.addDependency( dep ); Dependency def = new Dependency(); def.setGroupId( dep.getGroupId() ); def.setArtifactId( dep.getArtifactId() ); DependencyManagement depMgmt = new DependencyManagement(); depMgmt.addDependency( def ); model.setDependencyManagement( depMgmt ); new DefaultModelDefaultsInjector().injectDefaults( model ); List deps = model.getDependencies(); assertEquals( 1, deps.size() ); Dependency result = (Dependency) deps.get( 0 ); assertEquals( dep.getVersion(), result.getVersion() ); } public void testShouldMergeDefaultPropertiesWhenDependencyDoesntSupplyProperties() { Model model = new Model(); Dependency dep = new Dependency(); dep.setGroupId( "myGroup" ); dep.setArtifactId( "myArtifact" ); dep.setVersion( "1.0.1" ); model.addDependency( dep ); Dependency def = new Dependency(); def.setGroupId( dep.getGroupId() ); def.setArtifactId( dep.getArtifactId() ); DependencyManagement depMgmt = new DependencyManagement(); depMgmt.addDependency( def ); model.setDependencyManagement( depMgmt ); new DefaultModelDefaultsInjector().injectDefaults( model ); List deps = model.getDependencies(); assertEquals( 1, deps.size() ); } public void testShouldNotMergeDefaultPropertiesWhenDependencySuppliesProperties() { Model model = new Model(); Dependency dep = new Dependency(); dep.setGroupId( "myGroup" ); dep.setArtifactId( "myArtifact" ); dep.setVersion( "1.0.1" ); model.addDependency( dep ); Dependency def = new Dependency(); def.setGroupId( dep.getGroupId() ); def.setArtifactId( dep.getArtifactId() ); DependencyManagement depMgmt = new DependencyManagement(); depMgmt.addDependency( def ); model.setDependencyManagement( depMgmt ); new DefaultModelDefaultsInjector().injectDefaults( model ); List deps = model.getDependencies(); assertEquals( 1, deps.size() ); } public void testShouldMergeDefaultScopeWhenDependencyDoesntSupplyScope() { Model model = new Model(); Dependency dep = new Dependency(); dep.setGroupId( "myGroup" ); dep.setArtifactId( "myArtifact" ); dep.setVersion( "1.0.1" ); dep.setScope( "scope" ); model.addDependency( dep ); Dependency def = new Dependency(); def.setGroupId( dep.getGroupId() ); def.setArtifactId( dep.getArtifactId() ); DependencyManagement depMgmt = new DependencyManagement(); depMgmt.addDependency( def ); model.setDependencyManagement( depMgmt ); new DefaultModelDefaultsInjector().injectDefaults( model ); List deps = model.getDependencies(); assertEquals( 1, deps.size() ); Dependency result = (Dependency) deps.get( 0 ); assertEquals( "scope", result.getScope() ); } public void testShouldNotMergeDefaultScopeWhenDependencySuppliesScope() { Model model = new Model(); Dependency dep = new Dependency(); dep.setGroupId( "myGroup" ); dep.setArtifactId( "myArtifact" ); dep.setVersion( "1.0.1" ); dep.setScope( "scope" ); model.addDependency( dep ); Dependency def = new Dependency(); def.setGroupId( dep.getGroupId() ); def.setArtifactId( dep.getArtifactId() ); def.setScope( "default" ); DependencyManagement depMgmt = new DependencyManagement(); depMgmt.addDependency( def ); model.setDependencyManagement( depMgmt ); new DefaultModelDefaultsInjector().injectDefaults( model ); List deps = model.getDependencies(); assertEquals( 1, deps.size() ); Dependency result = (Dependency) deps.get( 0 ); assertEquals( "scope", result.getScope() ); } public void testShouldRejectDependencyWhereNoVersionIsFoundAfterDefaultsInjection() { Model model = new Model(); Dependency dep = new Dependency(); dep.setGroupId( "myGroup" ); dep.setArtifactId( "myArtifact" ); model.addDependency( dep ); Dependency def = new Dependency(); def.setGroupId( dep.getGroupId() ); def.setArtifactId( dep.getArtifactId() ); DependencyManagement depMgmt = new DependencyManagement(); depMgmt.addDependency( def ); model.setDependencyManagement( depMgmt ); // try // { new DefaultModelDefaultsInjector().injectDefaults( model ); Dependency dependency = (Dependency) model.getDependencies().get( 0 ); assertNull( "check version is null", dependency.getVersion() ); // fail("Should fail to validate dependency without a version."); // } // catch ( IllegalStateException e ) // { // // should throw when it detects a missing version in the test dependency. // } } } ././@LongLink0000000000000000000000000000015200000000000011563 Lustar rootrootmaven2-core-2.2.1/maven-project/src/test/java/org/apache/maven/project/injection/TestProfileInjector.javamaven2-core-2.2.1/maven-project/src/test/java/org/apache/maven/project/injection/TestProfileInjector0000644000175000017500000000210210772004567033463 0ustar twernertwernerpackage org.apache.maven.project.injection; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import org.apache.maven.model.Model; import org.apache.maven.model.Profile; public class TestProfileInjector implements ProfileInjector { public void inject( Profile profile, Model model ) { // do nothing. } } ././@LongLink0000000000000000000000000000016100000000000011563 Lustar rootrootmaven2-core-2.2.1/maven-project/src/test/java/org/apache/maven/project/injection/DefaultProfileInjectorTest.javamaven2-core-2.2.1/maven-project/src/test/java/org/apache/maven/project/injection/DefaultProfileInjec0000644000175000017500000003155411031262315033402 0ustar twernertwernerpackage org.apache.maven.project.injection; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import java.util.Collections; import java.util.Iterator; import java.util.List; import java.util.Map; import junit.framework.TestCase; import org.apache.maven.model.Build; import org.apache.maven.model.BuildBase; import org.apache.maven.model.Dependency; import org.apache.maven.model.Model; import org.apache.maven.model.Plugin; import org.apache.maven.model.PluginContainer; import org.apache.maven.model.PluginExecution; import org.apache.maven.model.Profile; import org.apache.maven.model.Repository; import org.codehaus.plexus.util.xml.Xpp3Dom; public class DefaultProfileInjectorTest extends TestCase { public void testShouldUseProfilePluginDependencyVersionOverMainPluginDepVersion() { PluginContainer profile = new PluginContainer(); Plugin profilePlugin = createPlugin( "group", "artifact", "1", Collections.EMPTY_MAP ); Dependency profileDep = createDependency( "g", "a", "2" ); profilePlugin.addDependency( profileDep ); profile.addPlugin( profilePlugin ); PluginContainer model = new PluginContainer(); Plugin plugin = createPlugin( "group", "artifact", "1", Collections.EMPTY_MAP ); Dependency dep = createDependency( "g", "a", "1" ); plugin.addDependency( dep ); model.addPlugin( plugin ); new DefaultProfileInjector().injectPlugins( profile, model ); assertEquals( profileDep.getVersion(), ((Dependency) plugin.getDependencies().get( 0 ) ).getVersion() ); } private Dependency createDependency( String gid, String aid, String ver ) { Dependency dep = new Dependency(); dep.setGroupId( gid ); dep.setArtifactId( aid ); dep.setVersion( ver ); return dep; } /** * Test that this is the resulting ordering of plugins after merging: * * Given: * * model: X -> A -> B -> D -> E * profile: Y -> A -> C -> D -> F * * Result: * * X -> Y -> A -> B -> C -> D -> E -> F */ public void testShouldPreserveOrderingOfPluginsAfterProfileMerge() { PluginContainer profile = new PluginContainer(); profile.addPlugin( createPlugin( "group", "artifact", "1.0", Collections.EMPTY_MAP ) ); profile.addPlugin( createPlugin( "group2", "artifact2", "1.0", Collections.singletonMap( "key", "value" ) ) ); PluginContainer model = new PluginContainer(); model.addPlugin( createPlugin( "group3", "artifact3", "1.0", Collections.EMPTY_MAP ) ); model.addPlugin( createPlugin( "group2", "artifact2", "1.0", Collections.singletonMap( "key2", "value2" ) ) ); new DefaultProfileInjector().injectPlugins( profile, model ); List results = model.getPlugins(); assertEquals( 3, results.size() ); Plugin result1 = (Plugin) results.get( 0 ); assertEquals( "group3", result1.getGroupId() ); assertEquals( "artifact3", result1.getArtifactId() ); Plugin result2 = (Plugin) results.get( 1 ); assertEquals( "group", result2.getGroupId() ); assertEquals( "artifact", result2.getArtifactId() ); Plugin result3 = (Plugin) results.get( 2 ); assertEquals( "group2", result3.getGroupId() ); assertEquals( "artifact2", result3.getArtifactId() ); Xpp3Dom result3Config = (Xpp3Dom) result3.getConfiguration(); assertNotNull( result3Config ); assertEquals( "value", result3Config.getChild( "key" ).getValue() ); assertEquals( "value2", result3Config.getChild( "key2" ).getValue() ); } private Plugin createPlugin( String groupId, String artifactId, String version, Map configuration ) { Plugin plugin = new Plugin(); plugin.setGroupId( groupId ); plugin.setArtifactId( artifactId ); plugin.setVersion( version ); Xpp3Dom config = new Xpp3Dom( "configuration" ); if( configuration != null ) { for ( Iterator it = configuration.entrySet().iterator(); it.hasNext(); ) { Map.Entry entry = (Map.Entry) it.next(); Xpp3Dom param = new Xpp3Dom( String.valueOf( entry.getKey() ) ); param.setValue( String.valueOf( entry.getValue() ) ); config.addChild( param ); } } plugin.setConfiguration( config ); return plugin; } public void testProfilePluginConfigurationShouldOverrideCollidingModelPluginConfiguration() { Plugin mPlugin = new Plugin(); mPlugin.setGroupId( "test" ); mPlugin.setArtifactId( "test-artifact" ); mPlugin.setVersion( "1.0-SNAPSHOT" ); Xpp3Dom mConfigChild = new Xpp3Dom( "test" ); mConfigChild.setValue( "value" ); Xpp3Dom mConfigChild2 = new Xpp3Dom( "test2" ); mConfigChild2.setValue( "value2" ); Xpp3Dom mConfig = new Xpp3Dom( "configuration" ); mConfig.addChild( mConfigChild ); mConfig.addChild( mConfigChild2 ); mPlugin.setConfiguration( mConfig ); Build mBuild = new Build(); mBuild.addPlugin( mPlugin ); Model model = new Model(); model.setBuild( mBuild ); Plugin pPlugin = new Plugin(); pPlugin.setGroupId( "test" ); pPlugin.setArtifactId( "test-artifact" ); pPlugin.setVersion( "1.0-SNAPSHOT" ); Xpp3Dom pConfigChild = new Xpp3Dom( "test" ); pConfigChild.setValue( "replacedValue" ); Xpp3Dom pConfig = new Xpp3Dom( "configuration" ); pConfig.addChild( pConfigChild ); pPlugin.setConfiguration( pConfig ); BuildBase pBuild = new BuildBase(); pBuild.addPlugin( pPlugin ); Profile profile = new Profile(); profile.setId( "testId" ); profile.setBuild( pBuild ); new DefaultProfileInjector().inject( profile, model ); Build rBuild = model.getBuild(); Plugin rPlugin = (Plugin) rBuild.getPlugins().get( 0 ); Xpp3Dom rConfig = (Xpp3Dom) rPlugin.getConfiguration(); Xpp3Dom rChild = rConfig.getChild( "test" ); assertEquals( "replacedValue", rChild.getValue() ); Xpp3Dom rChild2 = rConfig.getChild( "test2" ); assertEquals( "value2", rChild2.getValue() ); } public void testModelConfigShouldPersistWhenPluginHasExecConfigs() { Plugin mPlugin = new Plugin(); mPlugin.setGroupId( "test" ); mPlugin.setArtifactId( "test-artifact" ); mPlugin.setVersion( "1.0-SNAPSHOT" ); Xpp3Dom mConfigChild = new Xpp3Dom( "test" ); mConfigChild.setValue( "value" ); Xpp3Dom mConfigChild2 = new Xpp3Dom( "test2" ); mConfigChild2.setValue( "value2" ); Xpp3Dom mConfig = new Xpp3Dom( "configuration" ); mConfig.addChild( mConfigChild ); mConfig.addChild( mConfigChild2 ); mPlugin.setConfiguration( mConfig ); Build mBuild = new Build(); mBuild.addPlugin( mPlugin ); Model model = new Model(); model.setBuild( mBuild ); Plugin pPlugin = new Plugin(); pPlugin.setGroupId( "test" ); pPlugin.setArtifactId( "test-artifact" ); pPlugin.setVersion( "1.0-SNAPSHOT" ); PluginExecution pExec = new PluginExecution(); pExec.setId("profile-injected"); Xpp3Dom pConfigChild = new Xpp3Dom( "test" ); pConfigChild.setValue( "replacedValue" ); Xpp3Dom pConfig = new Xpp3Dom( "configuration" ); pConfig.addChild( pConfigChild ); pExec.setConfiguration( pConfig ); pPlugin.addExecution( pExec ); BuildBase pBuild = new BuildBase(); pBuild.addPlugin( pPlugin ); Profile profile = new Profile(); profile.setId( "testId" ); profile.setBuild( pBuild ); new DefaultProfileInjector().inject( profile, model ); Build rBuild = model.getBuild(); Plugin rPlugin = (Plugin) rBuild.getPlugins().get( 0 ); PluginExecution rExec = (PluginExecution) rPlugin.getExecutionsAsMap().get( "profile-injected" ); assertNotNull( rExec ); Xpp3Dom rExecConfig = (Xpp3Dom) rExec.getConfiguration(); Xpp3Dom rChild = rExecConfig.getChild( "test" ); assertEquals( "replacedValue", rChild.getValue() ); Xpp3Dom rConfig = (Xpp3Dom) rPlugin.getConfiguration(); assertNotNull( rConfig ); Xpp3Dom rChild2 = rConfig.getChild( "test2" ); assertEquals( "value2", rChild2.getValue() ); } public void testProfileRepositoryShouldOverrideModelRepository() { Repository mRepository = new Repository(); mRepository.setId( "testId" ); mRepository.setName( "Test repository" ); mRepository.setUrl( "http://www.google.com" ); Model model = new Model(); model.addRepository( mRepository ); Repository pRepository = new Repository(); pRepository.setId( "testId" ); pRepository.setName( "Test repository" ); pRepository.setUrl( "http://www.yahoo.com" ); Profile profile = new Profile(); profile.setId( "testId" ); profile.addRepository( pRepository ); new DefaultProfileInjector().inject( profile, model ); Repository rRepository = (Repository) model.getRepositories().get( 0 ); assertEquals( "http://www.yahoo.com", rRepository.getUrl() ); } public void testShouldPreserveModelModulesWhenProfileHasNone() { Model model = new Model(); model.addModule( "module1" ); Profile profile = new Profile(); profile.setId( "testId" ); new DefaultProfileInjector().inject( profile, model ); List rModules = model.getModules(); assertEquals( 1, rModules.size() ); assertEquals( "module1", rModules.get( 0 ) ); } // NOTE: The execution-id's are important, because they are NOT in // alphabetical order. The trunk version of Maven currently injects // profiles into a TreeMap, then calls map.values(), which puts the // executions in alphabetical order...the WRONG order. public void testShouldPreserveOrderingOfProfileInjectedPluginExecutions() { Plugin profilePlugin = new Plugin(); profilePlugin.setGroupId( "group" ); profilePlugin.setArtifactId( "artifact" ); profilePlugin.setVersion( "version" ); PluginExecution exec1 = new PluginExecution(); exec1.setId( "z" ); profilePlugin.addExecution( exec1 ); PluginExecution exec2 = new PluginExecution(); exec2.setId( "y" ); profilePlugin.addExecution( exec2 ); BuildBase buildBase = new BuildBase(); buildBase.addPlugin( profilePlugin ); Profile profile = new Profile(); profile.setBuild( buildBase ); Plugin modelPlugin = new Plugin(); modelPlugin.setGroupId( "group" ); modelPlugin.setArtifactId( "artifact" ); modelPlugin.setVersion( "version" ); PluginExecution exec3 = new PluginExecution(); exec3.setId( "w" ); modelPlugin.addExecution( exec3 ); PluginExecution exec4 = new PluginExecution(); exec4.setId( "x" ); modelPlugin.addExecution( exec4 ); Build build = new Build(); build.addPlugin( modelPlugin ); Model model = new Model(); model.setBuild( build ); new DefaultProfileInjector().inject( profile, model ); List plugins = model.getBuild().getPlugins(); assertNotNull( plugins ); assertEquals( 1, plugins.size() ); Plugin plugin = (Plugin) plugins.get( 0 ); List executions = plugin.getExecutions(); assertNotNull( executions ); assertEquals( 4, executions.size() ); Iterator it = executions.iterator(); PluginExecution e = (PluginExecution) it.next(); assertEquals( "w", e.getId() ); e = (PluginExecution) it.next(); assertEquals( "x", e.getId() ); e = (PluginExecution) it.next(); assertEquals( "z", e.getId() ); e = (PluginExecution) it.next(); assertEquals( "y", e.getId() ); } } maven2-core-2.2.1/maven-project/src/test/java/org/apache/maven/project/ProjectSorterTest.java0000644000175000017500000004340011174102426032124 0ustar twernertwernerpackage org.apache.maven.project; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import junit.framework.TestCase; import org.apache.maven.model.Build; import org.apache.maven.model.Dependency; import org.apache.maven.model.Extension; import org.apache.maven.model.Model; import org.apache.maven.model.Plugin; import org.apache.maven.model.PluginManagement; import org.codehaus.plexus.util.dag.CycleDetectedException; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.List; /** * Test sorting projects by dependencies. * * @author Brett Porter * @version $Id: ProjectSorterTest.java 767940 2009-04-23 15:11:18Z jdcasey $ */ public class ProjectSorterTest extends TestCase { public void testBasicSingleProject() throws CycleDetectedException, DuplicateProjectException, MissingProjectException { MavenProject project = createProject( "group", "artifactA", "1.0" ); List projects = new ProjectSorter( Collections.singletonList( project ) ).getSortedProjects(); assertEquals( "Wrong number of projects: " + projects, 1, projects.size() ); assertEquals( "Didn't match project", project, projects.get( 0 ) ); } public void testBasicMultiProject() throws CycleDetectedException, DuplicateProjectException, MissingProjectException { MavenProject projectA = createProject( "group", "artifactA", "1.0" ); MavenProject projectB = createProject( "group", "artifactB", "1.0" ); MavenProject projectC = createProject( "group", "artifactC", "1.0" ); projectA.getDependencies().add( createDependency( projectB ) ); projectB.getDependencies().add( createDependency( projectC ) ); List projects = Arrays.asList( new Object[] { projectA, projectB, projectC } ); projects = new ProjectSorter( projects ).getSortedProjects(); assertEquals( "Wrong number of projects: " + projects, 3, projects.size() ); assertEquals( "Didn't match project", projectC, projects.get( 0 ) ); assertEquals( "Didn't match project", projectB, projects.get( 1 ) ); assertEquals( "Didn't match project", projectA, projects.get( 2 ) ); } public void testResumeFrom() throws CycleDetectedException, DuplicateProjectException, MissingProjectException { MavenProject projectA = createProject( "group", "artifactA", "1.0" ); MavenProject projectB = createProject( "group", "artifactB", "1.0" ); MavenProject projectC = createProject( "group", "artifactC", "1.0" ); projectA.getDependencies().add( createDependency( projectB ) ); projectB.getDependencies().add( createDependency( projectC ) ); List projects = Arrays.asList( new Object[] { projectA, projectB, projectC } ); projects = new ProjectSorter( projects, null, "group:artifactB", false, false ).getSortedProjects(); assertEquals( "Wrong number of projects: " + projects, 2, projects.size() ); assertEquals( "Didn't match project", projectB, projects.get( 0 ) ); assertEquals( "Didn't match project", projectA, projects.get( 1 ) ); } public void testSelectedProjects() throws CycleDetectedException, DuplicateProjectException, MissingProjectException { MavenProject projectA = createProject( "group", "artifactA", "1.0" ); MavenProject projectB = createProject( "group", "artifactB", "1.0" ); MavenProject projectC = createProject( "group", "artifactC", "1.0" ); projectA.getDependencies().add( createDependency( projectB ) ); projectB.getDependencies().add( createDependency( projectC ) ); List projects = Arrays.asList( new Object[] { projectA, projectB, projectC } ); List selectedProjects = Arrays.asList( new Object[] { "group:artifactB" } ); projects = new ProjectSorter( projects, selectedProjects, null, false, false ).getSortedProjects(); assertEquals( "Wrong number of projects: " + projects, 1, projects.size() ); assertEquals( "Didn't match project", projectB, projects.get( 0 ) ); } public void testMake() throws CycleDetectedException, DuplicateProjectException, MissingProjectException { MavenProject projectA = createProject( "group", "artifactA", "1.0" ); MavenProject projectB = createProject( "group", "artifactB", "1.0" ); MavenProject projectC = createProject( "group", "artifactC", "1.0" ); projectA.getDependencies().add( createDependency( projectB ) ); projectB.getDependencies().add( createDependency( projectC ) ); List projects = Arrays.asList( new Object[] { projectA, projectB, projectC } ); List selectedProjects = Arrays.asList( new Object[] { "group:artifactB" } ); projects = new ProjectSorter( projects, selectedProjects, null, true/* make */, false ).getSortedProjects(); assertEquals( "Wrong number of projects: " + projects, 2, projects.size() ); assertEquals( "Didn't match project", projectC, projects.get( 0 ) ); assertEquals( "Didn't match project", projectB, projects.get( 1 ) ); } public void testMakeDependents() throws CycleDetectedException, DuplicateProjectException, MissingProjectException { MavenProject projectA = createProject( "group", "artifactA", "1.0" ); MavenProject projectB = createProject( "group", "artifactB", "1.0" ); MavenProject projectC = createProject( "group", "artifactC", "1.0" ); projectA.getDependencies().add( createDependency( projectB ) ); projectB.getDependencies().add( createDependency( projectC ) ); List projects = Arrays.asList( new Object[] { projectA, projectB, projectC } ); List selectedProjects = Arrays.asList( new Object[] { "group:artifactB" } ); projects = new ProjectSorter( projects, selectedProjects, null, false/* make */, true/* makeDependents */).getSortedProjects(); assertEquals( "Wrong number of projects: " + projects, 2, projects.size() ); assertEquals( "Didn't match project", projectB, projects.get( 0 ) ); assertEquals( "Didn't match project", projectA, projects.get( 1 ) ); } public void testMakeBoth() throws CycleDetectedException, DuplicateProjectException, MissingProjectException { MavenProject projectA = createProject( "group", "artifactA", "1.0" ); MavenProject projectB = createProject( "group", "artifactB", "1.0" ); MavenProject projectC = createProject( "group", "artifactC", "1.0" ); MavenProject projectD = createProject( "group", "artifactD", "1.0" ); MavenProject projectE = createProject( "group", "artifactE", "1.0" ); projectA.getDependencies().add( createDependency( projectB ) ); projectB.getDependencies().add( createDependency( projectC ) ); projectD.getDependencies().add( createDependency( projectE ) ); projectE.getDependencies().add( createDependency( projectB ) ); List projects = Arrays.asList( new Object[] { projectA, projectB, projectC, projectD, projectE } ); List selectedProjects = Arrays.asList( new Object[] { "group:artifactE" } ); projects = new ProjectSorter( projects, selectedProjects, null, true/* make */, true/* makeDependents */).getSortedProjects(); assertEquals( "Wrong number of projects: " + projects, 4, projects.size() ); assertEquals( "Didn't match project", projectC, projects.get( 0 ) ); assertEquals( "Didn't match project", projectB, projects.get( 1 ) ); assertEquals( "Didn't match project", projectE, projects.get( 2 ) ); assertEquals( "Didn't match project", projectD, projects.get( 3 ) ); } public void testShouldNotFailWhenPluginDepReferencesCurrentProject() throws CycleDetectedException, DuplicateProjectException, MissingProjectException { MavenProject project = createProject( "group", "artifact", "1.0" ); Model model = project.getModel(); Build build = model.getBuild(); if ( build == null ) { build = new Build(); model.setBuild( build ); } Plugin plugin = new Plugin(); plugin.setArtifactId( "other-artifact" ); plugin.setGroupId( "other.group" ); plugin.setVersion( "1.0" ); Dependency dep = new Dependency(); dep.setGroupId( "group" ); dep.setArtifactId( "artifact" ); dep.setVersion( "1.0" ); plugin.addDependency( dep ); build.addPlugin( plugin ); new ProjectSorter( Collections.singletonList( project ) ); } public void testShouldNotFailWhenManagedPluginDepReferencesCurrentProject() throws CycleDetectedException, DuplicateProjectException, MissingProjectException { MavenProject project = createProject( "group", "artifact", "1.0" ); Model model = project.getModel(); Build build = model.getBuild(); if ( build == null ) { build = new Build(); model.setBuild( build ); } PluginManagement pMgmt = new PluginManagement(); Plugin plugin = new Plugin(); plugin.setArtifactId( "other-artifact" ); plugin.setGroupId( "other.group" ); plugin.setVersion( "1.0" ); Dependency dep = new Dependency(); dep.setGroupId( "group" ); dep.setArtifactId( "artifact" ); dep.setVersion( "1.0" ); plugin.addDependency( dep ); pMgmt.addPlugin( plugin ); build.setPluginManagement( pMgmt ); new ProjectSorter( Collections.singletonList( project ) ); } public void testShouldNotFailWhenProjectReferencesNonExistentProject() throws CycleDetectedException, DuplicateProjectException, MissingProjectException { MavenProject project = createProject( "group", "artifact", "1.0" ); Model model = project.getModel(); Build build = model.getBuild(); if ( build == null ) { build = new Build(); model.setBuild( build ); } Extension extension = new Extension(); extension.setArtifactId( "other-artifact" ); extension.setGroupId( "other.group" ); extension.setVersion( "1.0" ); build.addExtension( extension ); new ProjectSorter( Collections.singletonList( project ) ); } public void testMatchingArtifactIdsDifferentGroupIds() throws CycleDetectedException, DuplicateProjectException, MissingProjectException { List projects = new ArrayList(); MavenProject project1 = createProject( "groupId1", "artifactId", "1.0" ); projects.add( project1 ); MavenProject project2 = createProject( "groupId2", "artifactId", "1.0" ); projects.add( project2 ); project1.getDependencies().add( createDependency( project2 ) ); projects = new ProjectSorter( projects ).getSortedProjects(); assertEquals( project2, projects.get( 0 ) ); assertEquals( project1, projects.get( 1 ) ); } public void testMatchingGroupIdsDifferentArtifactIds() throws CycleDetectedException, DuplicateProjectException, MissingProjectException { List projects = new ArrayList(); MavenProject project1 = createProject( "groupId", "artifactId1", "1.0" ); projects.add( project1 ); MavenProject project2 = createProject( "groupId", "artifactId2", "1.0" ); projects.add( project2 ); project1.getDependencies().add( createDependency( project2 ) ); projects = new ProjectSorter( projects ).getSortedProjects(); assertEquals( project2, projects.get( 0 ) ); assertEquals( project1, projects.get( 1 ) ); } public void testMatchingIdsAndVersions() throws CycleDetectedException, MissingProjectException { List projects = new ArrayList(); MavenProject project1 = createProject( "groupId", "artifactId", "1.0" ); projects.add( project1 ); MavenProject project2 = createProject( "groupId", "artifactId", "1.0" ); projects.add( project2 ); try { projects = new ProjectSorter( projects ).getSortedProjects(); fail( "Duplicate projects should fail" ); } catch ( DuplicateProjectException e ) { // expected assertTrue( true ); } } public void testMatchingIdsAndDifferentVersions() throws CycleDetectedException, MissingProjectException { List projects = new ArrayList(); MavenProject project1 = createProject( "groupId", "artifactId", "1.0" ); projects.add( project1 ); MavenProject project2 = createProject( "groupId", "artifactId", "2.0" ); projects.add( project2 ); try { projects = new ProjectSorter( projects ).getSortedProjects(); fail( "Duplicate projects should fail" ); } catch ( DuplicateProjectException e ) { // expected assertTrue( true ); } } public void testPluginDependenciesInfluenceSorting() throws Exception { List projects = new ArrayList(); MavenProject parentProject = createProject( "groupId", "parent", "1.0" ); projects.add( parentProject ); MavenProject declaringProject = createProject( "groupId", "declarer", "1.0" ); declaringProject.setParent( parentProject ); projects.add( declaringProject ); MavenProject pluginLevelDepProject = createProject( "groupId", "plugin-level-dep", "1.0" ); pluginLevelDepProject.setParent( parentProject ); projects.add( pluginLevelDepProject ); MavenProject pluginProject = createProject( "groupId", "plugin", "1.0" ); pluginProject.setParent( parentProject ); projects.add( pluginProject ); Plugin plugin = new Plugin(); plugin.setGroupId( pluginProject.getGroupId() ); plugin.setArtifactId( pluginProject.getArtifactId() ); plugin.setVersion( pluginProject.getVersion() ); plugin.addDependency( createDependency( pluginLevelDepProject ) ); Model model = declaringProject.getModel(); Build build = model.getBuild(); if ( build == null ) { build = new Build(); model.setBuild( build ); } build.addPlugin( plugin ); projects = new ProjectSorter( projects ).getSortedProjects(); assertEquals( parentProject, projects.get( 0 ) ); // the order of these two is non-deterministic, based on when they're added to the reactor. assertTrue( projects.contains( pluginProject ) ); assertTrue( projects.contains( pluginLevelDepProject ) ); // the declaring project MUST be listed after the plugin and its plugin-level dep, though. assertEquals( declaringProject, projects.get( 3 ) ); } public void testPluginDependenciesInfluenceSorting_DeclarationInParent() throws Exception { List projects = new ArrayList(); MavenProject parentProject = createProject( "groupId", "parent-declarer", "1.0" ); projects.add( parentProject ); MavenProject pluginProject = createProject( "groupId", "plugin", "1.0" ); pluginProject.setParent( parentProject ); projects.add( pluginProject ); MavenProject pluginLevelDepProject = createProject( "groupId", "plugin-level-dep", "1.0" ); pluginLevelDepProject.setParent( parentProject ); projects.add( pluginLevelDepProject ); Plugin plugin = new Plugin(); plugin.setGroupId( pluginProject.getGroupId() ); plugin.setArtifactId( pluginProject.getArtifactId() ); plugin.setVersion( pluginProject.getVersion() ); plugin.addDependency( createDependency( pluginLevelDepProject ) ); Model model = parentProject.getModel(); Build build = model.getBuild(); if ( build == null ) { build = new Build(); model.setBuild( build ); } build.addPlugin( plugin ); projects = new ProjectSorter( projects ).getSortedProjects(); System.out.println( projects ); assertEquals( parentProject, projects.get( 0 ) ); // the order of these two is non-deterministic, based on when they're added to the reactor. assertTrue( projects.contains( pluginProject ) ); assertTrue( projects.contains( pluginLevelDepProject ) ); } private Dependency createDependency( MavenProject project ) { Dependency depdendency = new Dependency(); depdendency.setArtifactId( project.getArtifactId() ); depdendency.setGroupId( project.getGroupId() ); depdendency.setVersion( project.getVersion() ); return depdendency; } private static MavenProject createProject( String groupId, String artifactId, String version ) { Model model = new Model(); model.setGroupId( groupId ); model.setArtifactId( artifactId ); model.setVersion( version ); return new MavenProject( model ); } } ././@LongLink0000000000000000000000000000015100000000000011562 Lustar rootrootmaven2-core-2.2.1/maven-project/src/test/java/org/apache/maven/project/AbstractMavenProjectTestCase.javamaven2-core-2.2.1/maven-project/src/test/java/org/apache/maven/project/AbstractMavenProjectTestCase.0000644000175000017500000001115210772571326033345 0ustar twernertwernerpackage org.apache.maven.project; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.artifact.repository.DefaultArtifactRepository; import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout; import org.apache.maven.profiles.DefaultProfileManager; import org.apache.maven.project.validation.ModelValidationResult; import org.codehaus.plexus.PlexusTestCase; import java.io.File; import java.io.FileNotFoundException; import java.net.URISyntaxException; import java.net.URI; import java.net.URL; /** * @author Jason van Zyl * @version $Id: AbstractMavenProjectTestCase.java 641671 2008-03-27 01:05:26Z jdcasey $ */ public abstract class AbstractMavenProjectTestCase extends PlexusTestCase { protected MavenProjectBuilder projectBuilder; protected void setUp() throws Exception { super.setUp(); if ( getContainer().hasComponent( MavenProjectBuilder.ROLE, "test" ) ) { projectBuilder = (MavenProjectBuilder) lookup( MavenProjectBuilder.ROLE, "test" ); } else { // default over to the main project builder... projectBuilder = (MavenProjectBuilder) lookup( MavenProjectBuilder.ROLE ); } } // ---------------------------------------------------------------------- // Local repository // ---------------------------------------------------------------------- protected File getLocalRepositoryPath() throws FileNotFoundException, URISyntaxException { File markerFile = getFileForClasspathResource( "local-repo/marker.txt" ); return markerFile.getAbsoluteFile().getParentFile(); } protected File getFileForClasspathResource( String resource ) throws FileNotFoundException, URISyntaxException { ClassLoader cloader = Thread.currentThread().getContextClassLoader(); URL resourceUrl = cloader.getResource( resource ); if ( resourceUrl == null ) { throw new FileNotFoundException( "Unable to find: " + resource ); } return new File( new URI( resourceUrl.toString() ) ); } protected ArtifactRepository getLocalRepository() throws Exception { ArtifactRepositoryLayout repoLayout = (ArtifactRepositoryLayout) lookup( ArtifactRepositoryLayout.ROLE, "legacy" ); ArtifactRepository r = new DefaultArtifactRepository( "local", "file://" + getLocalRepositoryPath().getAbsolutePath(), repoLayout ); return r; } // ---------------------------------------------------------------------- // Project building // ---------------------------------------------------------------------- protected MavenProject getProjectWithDependencies( File pom ) throws Exception { try { return projectBuilder.buildWithDependencies( pom, getLocalRepository(), null ); } catch ( Exception e ) { if ( e instanceof InvalidProjectModelException ) { ModelValidationResult validationResult = ((InvalidProjectModelException)e).getValidationResult(); String message = "In: " + pom + "(" + ((ProjectBuildingException) e).getProjectId() + ")\n\n" + validationResult.render( " " ); System.out.println( message ); fail( message ); } throw e; } } protected MavenProject getProject( File pom ) throws Exception { return projectBuilder.build( pom, getLocalRepository(), new DefaultProfileManager( getContainer() ) ); } } maven2-core-2.2.1/maven-project/src/test/java/org/apache/maven/project/imports/0000755000175000017500000000000011250552245027313 5ustar twernertwernermaven2-core-2.2.1/maven-project/src/test/java/org/apache/maven/project/imports/t01/0000755000175000017500000000000011250552245027717 5ustar twernertwerner././@LongLink0000000000000000000000000000015300000000000011564 Lustar rootrootmaven2-core-2.2.1/maven-project/src/test/java/org/apache/maven/project/imports/t01/ProjectImportsTest.javamaven2-core-2.2.1/maven-project/src/test/java/org/apache/maven/project/imports/t01/ProjectImportsTes0000644000175000017500000001356410772571326033324 0ustar twernertwernerpackage org.apache.maven.project.imports.t01; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import org.apache.maven.artifact.Artifact; import org.apache.maven.project.MavenProject; import org.apache.maven.project.imports.AbstractProjectImportsTestCase; import java.io.File; import java.util.Map; /** * Verifies managed dependencies are imported into other projects correctly. * * @version $Id: ProjectImportsTest.java 641671 2008-03-27 01:05:26Z jdcasey $ */ public class ProjectImportsTest extends AbstractProjectImportsTestCase { // ---------------------------------------------------------------------- // // p1 inherits from p0 // p0 inhertis from super model // // or we can show it graphically as: // // p1 ---> p0 --> super model // // ---------------------------------------------------------------------- public void testDependencyManagementImportsVersions() throws Exception { File localRepo = getLocalRepositoryPath(); File pom0 = new File( localRepo, "p0/pom.xml" ); File pom0Basedir = pom0.getParentFile(); System.out.println("basedir " + pom0Basedir.getAbsolutePath()); File pom1 = new File( pom0Basedir, "p1/pom.xml" ); File pom2 = new File( pom0Basedir, "p2/pom.xml" ); File pom3 = new File( pom0Basedir, "p3/pom.xml" ); File pom4 = new File( pom0Basedir, "p4/pom.xml" ); getProjectWithDependencies( pom0 ); // load the child project, which inherits from p0... // MavenProject project0 = getProjectWithDependencies( pom0 ); MavenProject project1 = getProjectWithDependencies( pom1 ); assertEquals( pom0Basedir, project1.getParent().getBasedir() ); Map map = project1.getArtifactMap(); assertNotNull("No artifacts", map); assertTrue("No Artifacts", map.size() > 0); assertTrue("Set size should be 2, is " + map.size(), map.size() == 2); Artifact a = (Artifact) map.get("maven-test:maven-test-a"); Artifact b = (Artifact) map.get("maven-test:maven-test-b"); assertTrue("Incorrect version for " + a.getDependencyConflictId(), a.getVersion().equals("1.0")); assertTrue("Incorrect version for " + b.getDependencyConflictId(), b.getVersion().equals("1.0")); // load the child project, which inherits from p0... // MavenProject project0 = getProjectWithDependencies( pom0 ); MavenProject project2 = getProjectWithDependencies( pom2 ); map = project2.getArtifactMap(); assertNotNull("No artifacts", map); assertTrue("No Artifacts", map.size() > 0); assertTrue("Set size should be 3, is " + map.size(), map.size() == 3); a = (Artifact) map.get("maven-test:maven-test-a"); b = (Artifact) map.get("maven-test:maven-test-b"); Artifact c = (Artifact) map.get("maven-test:maven-test-c"); assertTrue("Incorrect version for " + a.getDependencyConflictId(), a.getVersion().equals("1.0")); assertTrue("Incorrect version for " + b.getDependencyConflictId(), b.getVersion().equals("1.0")); assertTrue("Incorrect version for " + c.getDependencyConflictId(), c.getVersion().equals("1.0")); // load the child project, which inherits from p0... // MavenProject project0 = getProjectWithDependencies( pom0 ); MavenProject project3 = getProjectWithDependencies( pom3 ); map = project3.getArtifactMap(); assertNotNull("No artifacts", map); assertTrue("No Artifacts", map.size() > 0); assertTrue("Set size should be 3, is " + map.size(), map.size() == 3); a = (Artifact) map.get("maven-test:maven-test-a"); c = (Artifact) map.get("maven-test:maven-test-c"); Artifact d = (Artifact) map.get("maven-test:maven-test-d"); assertTrue("Incorrect version for " + a.getDependencyConflictId(), a.getVersion().equals("1.1")); assertTrue("Incorrect version for " + c.getDependencyConflictId(), c.getVersion().equals("1.1")); assertTrue("Incorrect version for " + d.getDependencyConflictId(), d.getVersion().equals("1.0")); // load the child project, which inherits from p0... // MavenProject project0 = getProjectWithDependencies( pom0 ); MavenProject project4 = getProjectWithDependencies( pom4 ); map = project4.getArtifactMap(); assertNotNull("No artifacts", map); assertTrue("No Artifacts", map.size() > 0); assertTrue("Set size should be 4, is " + map.size(), map.size() == 4); a = (Artifact) map.get("maven-test:maven-test-a"); b = (Artifact) map.get("maven-test:maven-test-b"); c = (Artifact) map.get("maven-test:maven-test-c"); d = (Artifact) map.get("maven-test:maven-test-d"); assertTrue("Incorrect version for " + a.getDependencyConflictId(), a.getVersion().equals("1.0")); assertTrue("Incorrect version for " + b.getDependencyConflictId(), b.getVersion().equals("1.1")); assertTrue("Incorrect version for " + c.getDependencyConflictId(), c.getVersion().equals("1.0")); assertTrue("Incorrect version for " + d.getDependencyConflictId(), d.getVersion().equals("1.0")); } }././@LongLink0000000000000000000000000000016300000000000011565 Lustar rootrootmaven2-core-2.2.1/maven-project/src/test/java/org/apache/maven/project/imports/AbstractProjectImportsTestCase.javamaven2-core-2.2.1/maven-project/src/test/java/org/apache/maven/project/imports/AbstractProjectImport0000644000175000017500000000353110772004567033534 0ustar twernertwernerpackage org.apache.maven.project.imports; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import org.apache.maven.project.AbstractMavenProjectTestCase; import java.io.File; /** * @author Jason van Zyl * @version $Id: AbstractProjectImportsTestCase.java 640549 2008-03-24 20:05:11Z bentmann $ */ public abstract class AbstractProjectImportsTestCase extends AbstractMavenProjectTestCase { protected String getTestSeries() { String className = getClass().getPackage().getName(); return className.substring( className.lastIndexOf( "." ) + 1 ); } protected File projectFile( String name ) { return new File( getLocalRepositoryPath(), "/maven/poms/" + name + "-1.0.pom" ); } // ---------------------------------------------------------------------- // The local repository for this category of tests // ---------------------------------------------------------------------- protected File getLocalRepositoryPath() { return getTestFile( "src/test/resources/imports-repo/" + getTestSeries() ); } } maven2-core-2.2.1/maven-project/src/test/java/org/apache/maven/project/ProjectClasspathTest.java0000644000175000017500000001341010551365651032577 0ustar twernertwernerpackage org.apache.maven.project; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import org.apache.maven.artifact.Artifact; import java.io.File; import java.util.Iterator; /** * @todo relocate to maven-artifact in entirety */ public class ProjectClasspathTest extends AbstractMavenProjectTestCase { private String dir = "projects/scope/"; public void testProjectClasspath() throws Exception { File f = getFileForClasspathResource( dir + "project-with-scoped-dependencies.xml" ); // assertEquals( TestArtifactResolver.class, getContainer().lookup( ArtifactResolver.ROLE ).getClass() ); TestProjectBuilder builder = (TestProjectBuilder) getContainer().lookup( MavenProjectBuilder.ROLE, "test" ); TestArtifactResolver testArtifactResolver = (TestArtifactResolver) getContainer().lookup( TestArtifactResolver.class.getName() ); builder.setArtifactResolver( testArtifactResolver ); builder.setArtifactMetadataSource( testArtifactResolver.source() ); MavenProject project = getProjectWithDependencies( f ); Artifact artifact; assertNotNull( "Test project can't be null!", project ); checkArtifactIdScope( project, "provided", "provided" ); checkArtifactIdScope( project, "test", "test" ); checkArtifactIdScope( project, "compile", "compile" ); checkArtifactIdScope( project, "runtime", "runtime" ); checkArtifactIdScope( project, "default", "compile" ); // check all transitive deps of a test dependency are test, except test and provided which is skipped artifact = getArtifact( project, "maven-test-test", "scope-provided" ); assertNull( "Check no provided dependencies are transitive", artifact ); artifact = getArtifact( project, "maven-test-test", "scope-test" ); assertNull( "Check no test dependencies are transitive", artifact ); artifact = getArtifact( project, "maven-test-test", "scope-compile" ); assertEquals( "Check scope", "test", artifact.getScope() ); artifact = getArtifact( project, "maven-test-test", "scope-default" ); assertEquals( "Check scope", "test", artifact.getScope() ); artifact = getArtifact( project, "maven-test-test", "scope-runtime" ); assertEquals( "Check scope", "test", artifact.getScope() ); // check all transitive deps of a provided dependency are provided scope, except for test checkGroupIdScope( project, "provided", "maven-test-provided" ); artifact = getArtifact( project, "maven-test-provided", "scope-runtime" ); assertEquals( "Check scope", "provided", artifact.getScope() ); // check all transitive deps of a runtime dependency are runtime scope, except for test checkGroupIdScope( project, "runtime", "maven-test-runtime" ); artifact = getArtifact( project, "maven-test-runtime", "scope-runtime" ); assertEquals( "Check scope", "runtime", artifact.getScope() ); // check all transitive deps of a compile dependency are compile scope, except for runtime and test checkGroupIdScope( project, "compile", "maven-test-compile" ); artifact = getArtifact( project, "maven-test-compile", "scope-runtime" ); assertEquals( "Check scope", "runtime", artifact.getScope() ); // check all transitive deps of a default dependency are compile scope, except for runtime and test checkGroupIdScope( project, "compile", "maven-test-default" ); artifact = getArtifact( project, "maven-test-default", "scope-runtime" ); assertEquals( "Check scope", "runtime", artifact.getScope() ); } private void checkGroupIdScope( MavenProject project, String scopeValue, String groupId ) { Artifact artifact; artifact = getArtifact( project, groupId, "scope-compile" ); assertEquals( "Check scope", scopeValue, artifact.getScope() ); artifact = getArtifact( project, groupId, "scope-test" ); assertNull( "Check test dependency is not transitive", artifact ); artifact = getArtifact( project, groupId, "scope-provided" ); assertNull( "Check provided dependency is not transitive", artifact ); artifact = getArtifact( project, groupId, "scope-default" ); assertEquals( "Check scope", scopeValue, artifact.getScope() ); } private void checkArtifactIdScope( MavenProject project, String scope, String scopeValue ) { String artifactId = "scope-" + scope; Artifact artifact = getArtifact( project, "maven-test", artifactId ); assertEquals( "Check scope", scopeValue, artifact.getScope() ); } private Artifact getArtifact( MavenProject project, String groupId, String artifactId ) { for ( Iterator i = project.getArtifacts().iterator(); i.hasNext(); ) { Artifact a = (Artifact) i.next(); if ( artifactId.equals( a.getArtifactId() ) && a.getGroupId().equals( groupId ) ) { return a; } } return null; } } maven2-core-2.2.1/maven-project/src/test/java/org/apache/maven/project/artifact/0000755000175000017500000000000011250552245027413 5ustar twernertwerner././@LongLink0000000000000000000000000000015500000000000011566 Lustar rootrootmaven2-core-2.2.1/maven-project/src/test/java/org/apache/maven/project/artifact/MavenMetadataSourceTest.javamaven2-core-2.2.1/maven-project/src/test/java/org/apache/maven/project/artifact/MavenMetadataSourceT0000644000175000017500000001443510772004567033370 0ustar twernertwernerpackage org.apache.maven.project.artifact; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.ArtifactUtils; import org.apache.maven.artifact.factory.ArtifactFactory; import org.apache.maven.artifact.resolver.filter.ArtifactFilter; import org.apache.maven.artifact.resolver.filter.ScopeArtifactFilter; import org.apache.maven.model.Dependency; import org.apache.maven.model.DependencyManagement; import org.apache.maven.model.Exclusion; import org.apache.maven.model.Model; import org.apache.maven.project.MavenProject; import org.apache.maven.project.injection.ModelDefaultsInjector; import org.codehaus.plexus.PlexusTestCase; import java.util.ArrayList; import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.Set; public class MavenMetadataSourceTest extends PlexusTestCase { public void testShouldNotCarryExclusionsOverFromDependencyToDependency() throws Exception { Dependency dep1 = new Dependency(); dep1.setGroupId( "test" ); dep1.setArtifactId( "test-artifact" ); dep1.setVersion( "1" ); dep1.setType( "jar" ); Exclusion exc = new Exclusion(); exc.setGroupId( "test" ); exc.setArtifactId( "test-artifact3" ); dep1.addExclusion( exc ); Dependency dep2 = new Dependency(); dep2.setGroupId( "test" ); dep2.setArtifactId( "test-artifact2" ); dep2.setVersion( "1" ); dep2.setType( "jar" ); List deps = new ArrayList(); deps.add( dep1 ); deps.add( dep2 ); ArtifactFactory factory = ( ArtifactFactory ) lookup( ArtifactFactory.ROLE ); ArtifactFilter dependencyFilter = new ScopeArtifactFilter( Artifact.SCOPE_COMPILE ); MavenProject project = new MavenProject( new Model() ); Set result = MavenMetadataSource.createArtifacts( factory, deps, null, dependencyFilter, project ); for ( Iterator it = result.iterator(); it.hasNext(); ) { Artifact artifact = ( Artifact ) it.next(); if ( "test-artifact2".equals( artifact.getArtifactId() ) ) { ArtifactFilter filter = artifact.getDependencyFilter(); assertSame( dependencyFilter, filter ); } } } public void testShouldUseCompileScopeIfDependencyScopeEmpty() throws Exception { String groupId = "org.apache.maven"; String artifactId = "maven-model"; Dependency dep = new Dependency(); dep.setGroupId( groupId ); dep.setArtifactId( artifactId ); dep.setVersion( "2.0-alpha-3" ); Model model = new Model(); model.addDependency( dep ); MavenProject project = new MavenProject( model ); ArtifactFactory factory = (ArtifactFactory) lookup( ArtifactFactory.ROLE ); project.setArtifacts( project.createArtifacts( factory, null, null ) ); String key = ArtifactUtils.versionlessKey( groupId, artifactId ); Map artifactMap = project.getArtifactMap(); assertNotNull( "artifact-map should not be null.", artifactMap ); assertEquals( "artifact-map should contain 1 element.", 1, artifactMap.size() ); Artifact artifact = (Artifact) artifactMap.get( key ); assertNotNull( "dependency artifact not found in map.", artifact ); assertEquals( "dependency artifact has wrong scope.", Artifact.SCOPE_COMPILE, artifact.getScope() ); //check for back-propagation of default scope. assertEquals( "default scope NOT back-propagated to dependency.", Artifact.SCOPE_COMPILE, dep.getScope() ); } public void testShouldUseInjectedTestScopeFromDependencyManagement() throws Exception { String groupId = "org.apache.maven"; String artifactId = "maven-model"; Dependency dep = new Dependency(); dep.setGroupId( groupId ); dep.setArtifactId( artifactId ); dep.setVersion( "2.0-alpha-3" ); Model model = new Model(); model.addDependency( dep ); Dependency mgd = new Dependency(); mgd.setGroupId( groupId ); mgd.setArtifactId( artifactId ); mgd.setScope( Artifact.SCOPE_TEST ); DependencyManagement depMgmt = new DependencyManagement(); depMgmt.addDependency( mgd ); model.setDependencyManagement( depMgmt ); MavenProject project = new MavenProject( model ); ModelDefaultsInjector injector = (ModelDefaultsInjector) lookup( ModelDefaultsInjector.ROLE ); injector.injectDefaults( model ); ArtifactFactory factory = (ArtifactFactory) lookup( ArtifactFactory.ROLE ); project.setArtifacts( project.createArtifacts( factory, null, null ) ); String key = ArtifactUtils.versionlessKey( groupId, artifactId ); Map artifactMap = project.getArtifactMap(); assertNotNull( "artifact-map should not be null.", artifactMap ); assertEquals( "artifact-map should contain 1 element.", 1, artifactMap.size() ); Artifact artifact = (Artifact) artifactMap.get( key ); assertNotNull( "dependency artifact not found in map.", artifact ); assertEquals( "dependency artifact has wrong scope.", Artifact.SCOPE_TEST, artifact.getScope() ); //check for back-propagation of default scope. assertEquals( "default scope NOT back-propagated to dependency.", Artifact.SCOPE_TEST, dep.getScope() ); } } maven2-core-2.2.1/maven-project/src/test/java/org/apache/maven/project/TestProjectBuilder.java0000644000175000017500000000243110772004567032245 0ustar twernertwernerpackage org.apache.maven.project; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import org.apache.maven.artifact.metadata.ArtifactMetadataSource; import org.apache.maven.artifact.resolver.ArtifactResolver; public class TestProjectBuilder extends DefaultMavenProjectBuilder { public void setArtifactResolver( ArtifactResolver resolver ) { artifactResolver = resolver; } public void setArtifactMetadataSource( ArtifactMetadataSource metadataSource ) { artifactMetadataSource = metadataSource; } } maven2-core-2.2.1/maven-project/src/test/java/org/apache/maven/project/inheritance/0000755000175000017500000000000011250552245030107 5ustar twernertwernermaven2-core-2.2.1/maven-project/src/test/java/org/apache/maven/project/inheritance/t01/0000755000175000017500000000000011250552244030512 5ustar twernertwerner././@LongLink0000000000000000000000000000016300000000000011565 Lustar rootrootmaven2-core-2.2.1/maven-project/src/test/java/org/apache/maven/project/inheritance/t01/ProjectInheritanceTest.javamaven2-core-2.2.1/maven-project/src/test/java/org/apache/maven/project/inheritance/t01/ProjectInheri0000644000175000017500000000701310551365651033212 0ustar twernertwernerpackage org.apache.maven.project.inheritance.t01; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import org.apache.maven.project.MavenProject; import org.apache.maven.project.inheritance.AbstractProjectInheritanceTestCase; /** * A test which demonstrates maven's recursive inheritance where * we are testing to make sure that elements stated in a model are * not clobbered by the same elements elsewhere in the lineage. * * @author Jason van Zyl * @version $Id: ProjectInheritanceTest.java 495147 2007-01-11 07:47:53Z jvanzyl $ */ public class ProjectInheritanceTest extends AbstractProjectInheritanceTestCase { // ---------------------------------------------------------------------- // // p4 inherits from p3 // p3 inherits from p2 // p2 inherits from p1 // p1 inherits from p0 // p0 inhertis from super model // // or we can show it graphically as: // // p4 ---> p3 ---> p2 ---> p1 ---> p0 --> super model // // ---------------------------------------------------------------------- public void testProjectInheritance() throws Exception { // ---------------------------------------------------------------------- // Check p0 value for org name // ---------------------------------------------------------------------- MavenProject p0 = getProject( projectFile( "p0" ) ); assertEquals( "p0-org", p0.getOrganization().getName() ); // ---------------------------------------------------------------------- // Check p1 value for org name // ---------------------------------------------------------------------- MavenProject p1 = getProject( projectFile( "p1" ) ); assertEquals( "p1-org", p1.getOrganization().getName() ); // ---------------------------------------------------------------------- // Check p2 value for org name // ---------------------------------------------------------------------- MavenProject p2 = getProject( projectFile( "p2" ) ); assertEquals( "p2-org", p2.getOrganization().getName() ); // ---------------------------------------------------------------------- // Check p2 value for org name // ---------------------------------------------------------------------- MavenProject p3 = getProject( projectFile( "p3" ) ); assertEquals( "p3-org", p3.getOrganization().getName() ); // ---------------------------------------------------------------------- // Check p4 value for org name // ---------------------------------------------------------------------- MavenProject p4 = getProject( projectFile( "p4" ) ); assertEquals( "p4-org", p4.getOrganization().getName() ); } } maven2-core-2.2.1/maven-project/src/test/java/org/apache/maven/project/inheritance/t11/0000755000175000017500000000000011250552244030513 5ustar twernertwerner././@LongLink0000000000000000000000000000016300000000000011565 Lustar rootrootmaven2-core-2.2.1/maven-project/src/test/java/org/apache/maven/project/inheritance/t11/ProjectInheritanceTest.javamaven2-core-2.2.1/maven-project/src/test/java/org/apache/maven/project/inheritance/t11/ProjectInheri0000644000175000017500000000562310772004567033221 0ustar twernertwernerpackage org.apache.maven.project.inheritance.t11; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import java.io.File; import java.util.Collection; import java.util.List; import java.util.Map; import java.util.Iterator; import org.apache.maven.model.Build; import org.apache.maven.model.MailingList; import org.apache.maven.model.Plugin; import org.apache.maven.model.PluginExecution; import org.apache.maven.model.Dependency; import org.apache.maven.project.MavenProject; import org.apache.maven.project.inheritance.AbstractProjectInheritanceTestCase; import org.apache.maven.artifact.Artifact; import org.codehaus.plexus.util.xml.Xpp3Dom; import org.codehaus.plexus.logging.LoggerManager; import org.codehaus.plexus.logging.Logger; /** * Verifies scope of root project is preserved regardless of parent depenedency management. See * {@link http://jira.codehaus.org/browse/MNG-2919} * * @author Patrick Schneider * @version $Id: ProjectInheritanceTest.java 640549 2008-03-24 20:05:11Z bentmann $ */ public class ProjectInheritanceTest extends AbstractProjectInheritanceTestCase { // ---------------------------------------------------------------------- // // p1 inherits from p0 // p0 inhertis from super model // // or we can show it graphically as: // // p1 ---> p0 --> super model // // ---------------------------------------------------------------------- public void testDependencyManagementOverridesTransitiveDependencyVersion() throws Exception { File localRepo = getLocalRepositoryPath(); File pom0 = new File( localRepo, "p0/pom.xml" ); File pom0Basedir = pom0.getParentFile(); File pom1 = new File( pom0Basedir, "p1/pom.xml" ); // load the child project, which inherits from p0... // MavenProject project0 = getProjectWithDependencies( pom0 ); MavenProject project1 = getProjectWithDependencies( pom1 ); assertEquals( pom0Basedir, project1.getParent().getBasedir() ); assertNull( "dependencyManagement has overwritten the scope of a child project", project1.getArtifact().getScope() ); } }maven2-core-2.2.1/maven-project/src/test/java/org/apache/maven/project/inheritance/t02/0000755000175000017500000000000011250552244030513 5ustar twernertwerner././@LongLink0000000000000000000000000000016300000000000011565 Lustar rootrootmaven2-core-2.2.1/maven-project/src/test/java/org/apache/maven/project/inheritance/t02/ProjectInheritanceTest.javamaven2-core-2.2.1/maven-project/src/test/java/org/apache/maven/project/inheritance/t02/ProjectInheri0000644000175000017500000001516010772004567033216 0ustar twernertwernerpackage org.apache.maven.project.inheritance.t02; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import java.io.File; import java.util.ArrayList; import java.util.HashMap; import java.util.Iterator; import java.util.List; import java.util.Map; import org.apache.maven.model.Build; import org.apache.maven.model.MailingList; import org.apache.maven.model.Plugin; import org.apache.maven.project.MavenProject; import org.apache.maven.project.inheritance.AbstractProjectInheritanceTestCase; /** * A test which demonstrates maven's recursive inheritance where * a distinct value is taken from each parent contributing to the * the final model of the project being assembled. There is no * overriding going on amongst the models being used in this test: * each model in the lineage is providing a value that is not present * anywhere else in the lineage. We are just making sure that values * down in the lineage are bubbling up where they should. * * @author Jason van Zyl * @version $Id: ProjectInheritanceTest.java 640549 2008-03-24 20:05:11Z bentmann $ */ public class ProjectInheritanceTest extends AbstractProjectInheritanceTestCase { // ---------------------------------------------------------------------- // // p4 inherits from p3 // p3 inherits from p2 // p2 inherits from p1 // p1 inherits from p0 // p0 inhertis from super model // // or we can show it graphically as: // // p4 ---> p3 ---> p2 ---> p1 ---> p0 --> super model // // ---------------------------------------------------------------------- public void testProjectInheritance() throws Exception { File localRepo = getLocalRepositoryPath(); System.out.println( "Local repository is at: " + localRepo.getAbsolutePath() ); File pom0 = new File( localRepo, "p0/pom.xml" ); File pom1 = new File( pom0.getParentFile(), "p1/pom.xml" ); File pom2 = new File( pom1.getParentFile(), "p2/pom.xml" ); File pom3 = new File( pom2.getParentFile(), "p3/pom.xml" ); File pom4 = new File( pom3.getParentFile(), "p4/pom.xml" ); File pom5 = new File( pom4.getParentFile(), "p5/pom.xml" ); System.out.println( "Location of project-4's POM: " + pom4.getPath() ); // load everything... MavenProject project0 = getProject( pom0 ); MavenProject project1 = getProject( pom1 ); MavenProject project2 = getProject( pom2 ); MavenProject project3 = getProject( pom3 ); MavenProject project4 = getProject( pom4 ); MavenProject project5 = getProject( pom5 ); assertEquals( "p4", project4.getName() ); // ---------------------------------------------------------------------- // Value inherited from p3 // ---------------------------------------------------------------------- assertEquals( "2000", project4.getInceptionYear() ); // ---------------------------------------------------------------------- // Value taken from p2 // ---------------------------------------------------------------------- assertEquals( "mailing-list", ( (MailingList) project4.getMailingLists().get( 0 ) ).getName() ); // ---------------------------------------------------------------------- // Value taken from p1 // ---------------------------------------------------------------------- assertEquals( "scm-url/p2/p3/p4", project4.getScm().getUrl() ); // ---------------------------------------------------------------------- // Value taken from p4 // ---------------------------------------------------------------------- assertEquals( "Codehaus", project4.getOrganization().getName() ); // ---------------------------------------------------------------------- // Value taken from super model // ---------------------------------------------------------------------- assertEquals( "4.0.0", project4.getModelVersion() ); Build build = project4.getBuild(); List plugins = build.getPlugins(); Map validPluginCounts = new HashMap(); String testPluginArtifactId = "maven-compiler-plugin"; // this is the plugin we're looking for. validPluginCounts.put( testPluginArtifactId, new Integer( 0 ) ); // these are injected if -DperformRelease=true validPluginCounts.put( "maven-deploy-plugin", new Integer( 0 ) ); validPluginCounts.put( "maven-javadoc-plugin", new Integer( 0 ) ); validPluginCounts.put( "maven-source-plugin", new Integer( 0 ) ); Plugin testPlugin = null; for ( Iterator it = plugins.iterator(); it.hasNext(); ) { Plugin plugin = (Plugin) it.next(); String pluginArtifactId = plugin.getArtifactId(); if ( !validPluginCounts.containsKey( pluginArtifactId ) ) { fail( "Illegal plugin found: " + pluginArtifactId ); } else { if ( pluginArtifactId.equals( testPluginArtifactId ) ) { testPlugin = plugin; } Integer count = (Integer) validPluginCounts.get( pluginArtifactId ); if ( count.intValue() > 0 ) { fail( "Multiple copies of plugin: " + pluginArtifactId + " found in POM." ); } else { count = new Integer( count.intValue() + 1 ); validPluginCounts.put( pluginArtifactId, count ); } } } List executions = testPlugin.getExecutions(); assertEquals( 1, executions.size() ); } } maven2-core-2.2.1/maven-project/src/test/java/org/apache/maven/project/inheritance/t10/0000755000175000017500000000000011250552244030512 5ustar twernertwerner././@LongLink0000000000000000000000000000016300000000000011565 Lustar rootrootmaven2-core-2.2.1/maven-project/src/test/java/org/apache/maven/project/inheritance/t10/ProjectInheritanceTest.javamaven2-core-2.2.1/maven-project/src/test/java/org/apache/maven/project/inheritance/t10/ProjectInheri0000644000175000017500000000770510772004567033223 0ustar twernertwernerpackage org.apache.maven.project.inheritance.t10; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import java.io.File; import java.util.Collection; import java.util.List; import java.util.Map; import java.util.Iterator; import org.apache.maven.model.Build; import org.apache.maven.model.MailingList; import org.apache.maven.model.Plugin; import org.apache.maven.model.PluginExecution; import org.apache.maven.model.Dependency; import org.apache.maven.project.MavenProject; import org.apache.maven.project.inheritance.AbstractProjectInheritanceTestCase; import org.apache.maven.artifact.Artifact; import org.codehaus.plexus.util.xml.Xpp3Dom; import org.codehaus.plexus.logging.LoggerManager; import org.codehaus.plexus.logging.Logger; /** * Verifies scope inheritence of direct and transitive dependencies. * * Should show three behaviors: * * 1. dependencyManagement should override the scope of transitive dependencies. * 2. Direct dependencies should override the scope of dependencyManagement. * 3. Direct dependencies should inherit scope from dependencyManagement when * they do not explicitly state a scope. * * @author Patrick Schneider * @version $Id: ProjectInheritanceTest.java 640549 2008-03-24 20:05:11Z bentmann $ */ public class ProjectInheritanceTest extends AbstractProjectInheritanceTestCase { // ---------------------------------------------------------------------- // // p1 inherits from p0 // p0 inhertis from super model // // or we can show it graphically as: // // p1 ---> p0 --> super model // // ---------------------------------------------------------------------- public void testDependencyManagementOverridesTransitiveDependencyVersion() throws Exception { File localRepo = getLocalRepositoryPath(); File pom0 = new File( localRepo, "p0/pom.xml" ); File pom0Basedir = pom0.getParentFile(); File pom1 = new File( pom0Basedir, "p1/pom.xml" ); // load the child project, which inherits from p0... MavenProject project0 = getProjectWithDependencies( pom0 ); MavenProject project1 = getProjectWithDependencies( pom1 ); assertEquals( pom0Basedir, project1.getParent().getBasedir() ); System.out.println("Project " + project1.getId() + " " + project1); Map map = project1.getArtifactMap(); assertNotNull("No artifacts", map); assertTrue("No Artifacts", map.size() > 0); assertTrue("Set size should be 3, is " + map.size(), map.size() == 3); Artifact a = (Artifact) map.get("maven-test:maven-test-a"); Artifact b = (Artifact) map.get("maven-test:maven-test-b"); Artifact c = (Artifact) map.get("maven-test:maven-test-c"); // inherited from depMgmt assertTrue("Incorrect scope for " + a.getDependencyConflictId(), a.getScope().equals("test")); // transitive dep, overridden b depMgmt assertTrue("Incorrect scope for " + b.getDependencyConflictId(), b.getScope().equals("runtime")); // direct dep, overrides depMgmt assertTrue("Incorrect scope for " + c.getDependencyConflictId(), c.getScope().equals("runtime")); } }maven2-core-2.2.1/maven-project/src/test/java/org/apache/maven/project/inheritance/t08/0000755000175000017500000000000011250552245030522 5ustar twernertwerner././@LongLink0000000000000000000000000000016300000000000011565 Lustar rootrootmaven2-core-2.2.1/maven-project/src/test/java/org/apache/maven/project/inheritance/t08/ProjectInheritanceTest.javamaven2-core-2.2.1/maven-project/src/test/java/org/apache/maven/project/inheritance/t08/ProjectInheri0000644000175000017500000000571210772004567033226 0ustar twernertwernerpackage org.apache.maven.project.inheritance.t08; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import java.io.File; import java.util.Set; import java.util.Iterator; import org.apache.maven.project.MavenProject; import org.apache.maven.project.inheritance.AbstractProjectInheritanceTestCase; import org.apache.maven.artifact.Artifact; /** * A test which demonstrates maven's dependency management * * @author Ralph Goers * @version $Id: ProjectInheritanceTest.java 640549 2008-03-24 20:05:11Z bentmann $ */ public class ProjectInheritanceTest extends AbstractProjectInheritanceTestCase { // ---------------------------------------------------------------------- // // p1 inherits from p0 // p0 inhertis from super model // // or we can show it graphically as: // // p1 ---> p0 --> super model // // ---------------------------------------------------------------------- public void testDependencyManagement() throws Exception { File localRepo = getLocalRepositoryPath(); File pom0 = new File( localRepo, "p0/pom.xml" ); File pom0Basedir = pom0.getParentFile(); File pom1 = new File( pom0Basedir, "p1/pom.xml" ); // load everything... MavenProject project0 = getProjectWithDependencies( pom0 ); MavenProject project1 = getProjectWithDependencies( pom1 ); assertEquals( pom0Basedir, project1.getParent().getBasedir() ); System.out.println("Project " + project1.getId() + " " + project1); Set set = project1.getArtifacts(); assertNotNull("No artifacts", set); assertTrue("No Artifacts", set.size() > 0); Iterator iter = set.iterator(); assertTrue("Set size should be 4, is " + set.size(), set.size() == 4); while (iter.hasNext()) { Artifact artifact = (Artifact)iter.next(); System.out.println("Artifact: " + artifact.getDependencyConflictId() + " " + artifact.getVersion() + " Optional=" + (artifact.isOptional() ? "true" : "false")); assertTrue("Incorrect version for " + artifact.getDependencyConflictId(), artifact.getVersion().equals("1.0")); } } } ././@LongLink0000000000000000000000000000017300000000000011566 Lustar rootrootmaven2-core-2.2.1/maven-project/src/test/java/org/apache/maven/project/inheritance/AbstractProjectInheritanceTestCase.javamaven2-core-2.2.1/maven-project/src/test/java/org/apache/maven/project/inheritance/AbstractProjectIn0000644000175000017500000000355010551365651033424 0ustar twernertwernerpackage org.apache.maven.project.inheritance; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import org.apache.maven.project.AbstractMavenProjectTestCase; import java.io.File; /** * @author Jason van Zyl * @version $Id: AbstractProjectInheritanceTestCase.java 495147 2007-01-11 07:47:53Z jvanzyl $ */ public abstract class AbstractProjectInheritanceTestCase extends AbstractMavenProjectTestCase { protected String getTestSeries() { String className = getClass().getPackage().getName(); return className.substring( className.lastIndexOf( "." ) + 1 ); } protected File projectFile( String name ) { return new File( getLocalRepositoryPath(), "/maven/poms/" + name + "-1.0.pom" ); } // ---------------------------------------------------------------------- // The local repository for this category of tests // ---------------------------------------------------------------------- protected File getLocalRepositoryPath() { return getTestFile( "src/test/resources/inheritance-repo/" + getTestSeries() ); } } maven2-core-2.2.1/maven-project/src/test/java/org/apache/maven/project/inheritance/t03/0000755000175000017500000000000011250552244030514 5ustar twernertwerner././@LongLink0000000000000000000000000000016300000000000011565 Lustar rootrootmaven2-core-2.2.1/maven-project/src/test/java/org/apache/maven/project/inheritance/t03/ProjectInheritanceTest.javamaven2-core-2.2.1/maven-project/src/test/java/org/apache/maven/project/inheritance/t03/ProjectInheri0000644000175000017500000000535210772004567033221 0ustar twernertwernerpackage org.apache.maven.project.inheritance.t03; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import java.io.File; import java.util.List; import org.apache.maven.model.Build; import org.apache.maven.model.MailingList; import org.apache.maven.model.Plugin; import org.apache.maven.model.PluginExecution; import org.apache.maven.project.MavenProject; import org.apache.maven.project.inheritance.AbstractProjectInheritanceTestCase; import org.codehaus.plexus.util.xml.Xpp3Dom; /** * A test which demonstrates maven's recursive inheritance where * a distinct value is taken from each parent contributing to the * the final model of the project being assembled. There is no * overriding going on amongst the models being used in this test: * each model in the lineage is providing a value that is not present * anywhere else in the lineage. We are just making sure that values * down in the lineage are bubbling up where they should. * * @author Jason van Zyl * @version $Id: ProjectInheritanceTest.java 640549 2008-03-24 20:05:11Z bentmann $ */ public class ProjectInheritanceTest extends AbstractProjectInheritanceTestCase { // ---------------------------------------------------------------------- // // p1 inherits from p0 // p0 inhertis from super model // // or we can show it graphically as: // // p1 ---> p0 --> super model // // ---------------------------------------------------------------------- public void testProjectInheritance() throws Exception { File localRepo = getLocalRepositoryPath(); File pom0 = new File( localRepo, "p0/pom.xml" ); File pom0Basedir = pom0.getParentFile(); File pom1 = new File( pom0Basedir, "p1/pom.xml" ); // load everything... MavenProject project0 = getProject( pom0 ); MavenProject project1 = getProject( pom1 ); assertEquals( pom0Basedir, project1.getParent().getBasedir() ); } } maven2-core-2.2.1/maven-project/src/test/java/org/apache/maven/project/inheritance/t13/0000755000175000017500000000000011250552245030516 5ustar twernertwerner././@LongLink0000000000000000000000000000016300000000000011565 Lustar rootrootmaven2-core-2.2.1/maven-project/src/test/java/org/apache/maven/project/inheritance/t13/ProjectInheritanceTest.javamaven2-core-2.2.1/maven-project/src/test/java/org/apache/maven/project/inheritance/t13/ProjectInheri0000644000175000017500000001020011101576551033200 0ustar twernertwernerpackage org.apache.maven.project.inheritance.t13; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.artifact.repository.DefaultArtifactRepository; import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout; import org.apache.maven.model.Dependency; import org.apache.maven.project.MavenProject; import org.apache.maven.project.inheritance.AbstractProjectInheritanceTestCase; import java.io.File; import java.util.List; /** * Verifies that plugin execution sections in the parent POM that have * inherit == false are not inherited to the child POM. */ public class ProjectInheritanceTest extends AbstractProjectInheritanceTestCase { protected ArtifactRepository getLocalRepository() throws Exception { ArtifactRepositoryLayout repoLayout = (ArtifactRepositoryLayout) lookup( ArtifactRepositoryLayout.ROLE, "default" ); ArtifactRepository r = new DefaultArtifactRepository( "local", "file://" + getLocalRepositoryPath().getAbsolutePath() + "/repo", repoLayout ); return r; } // ---------------------------------------------------------------------- // // p1 inherits from p0 // p0 inherits from super model // // or we can show it graphically as: // // p1 ---> p0 --> super model // // ---------------------------------------------------------------------- public void testChildDependenciesAddedAheadOfParentDependencies() throws Exception { File localRepo = getLocalRepositoryPath(); File pom0 = new File( localRepo, "p0/pom.xml" ); File pom0Basedir = pom0.getParentFile(); File pom1 = new File( pom0Basedir, "p1/pom.xml" ); getProjectWithDependencies( pom0 ); MavenProject project1 = getProjectWithDependencies( pom1 ); List dependencies = project1.getDependencies(); assertNotNull( "Must contain dependencies.", dependencies ); assertEquals( "Must contain 2 dependencies.", 2, dependencies.size() ); Dependency dep1 = (Dependency) dependencies.get( 0 ); assertEquals( "Child dependency should be listed first.", "test-from-child", dep1.getArtifactId() ); assertEquals( "Child dependency should have version '1'.", "1", dep1.getVersion() ); Dependency dep2 = (Dependency) dependencies.get( 1 ); assertEquals( "Parent dependency should be listed last.", "test-from-parent", dep2.getArtifactId() ); List compileArtifacts = project1.getCompileArtifacts(); assertNotNull( "Must contain compile-scoped artifacts.", compileArtifacts ); assertEquals( "Must contain 2 compile-scoped artifacts.", 2, compileArtifacts.size() ); Artifact artifact1 = (Artifact) compileArtifacts.get( 0 ); assertEquals( "Child dependency should be listed first in compile-scoped artifacts list.", "test-from-child", artifact1.getArtifactId() ); Artifact artifact2 = (Artifact) compileArtifacts.get( 1 ); assertEquals( "Parent dependency should be listed last in compile-scoped artifacts list.", "test-from-parent", artifact2.getArtifactId() ); } }maven2-core-2.2.1/maven-project/src/test/java/org/apache/maven/project/inheritance/t09/0000755000175000017500000000000011250552245030523 5ustar twernertwerner././@LongLink0000000000000000000000000000016300000000000011565 Lustar rootrootmaven2-core-2.2.1/maven-project/src/test/java/org/apache/maven/project/inheritance/t09/ProjectInheritanceTest.javamaven2-core-2.2.1/maven-project/src/test/java/org/apache/maven/project/inheritance/t09/ProjectInheri0000644000175000017500000001260310772004567033224 0ustar twernertwernerpackage org.apache.maven.project.inheritance.t09; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import java.io.File; import java.util.Collection; import java.util.List; import java.util.Map; import java.util.Iterator; import org.apache.maven.model.Build; import org.apache.maven.model.MailingList; import org.apache.maven.model.Plugin; import org.apache.maven.model.PluginExecution; import org.apache.maven.model.Dependency; import org.apache.maven.project.MavenProject; import org.apache.maven.project.inheritance.AbstractProjectInheritanceTestCase; import org.apache.maven.artifact.Artifact; import org.codehaus.plexus.util.xml.Xpp3Dom; import org.codehaus.plexus.logging.LoggerManager; import org.codehaus.plexus.logging.Logger; /** * Verifies exclusions listed in dependencyManagement are valid for * transitive dependencies. * * @author Patrick Schneider * @version $Id: ProjectInheritanceTest.java 640549 2008-03-24 20:05:11Z bentmann $ */ public class ProjectInheritanceTest extends AbstractProjectInheritanceTestCase { // ---------------------------------------------------------------------- // // p1 inherits from p0 // p0 inhertis from super model // // or we can show it graphically as: // // p1 ---> p0 --> super model // // ---------------------------------------------------------------------- /** * How the test project is set up: * * 1. dependencyManagement lists dependencies on a & b, * with an exclusion on c in b. * 2. the child project lists a dependency on project a only * 3. a depends on b (which is transitive to the child project), * and b depends on c. * * We should see that the resulting size of collected artifacts is two: * a & b only. */ public void testDependencyManagementExclusionsExcludeTransitively() throws Exception { File localRepo = getLocalRepositoryPath(); File pom0 = new File( localRepo, "p0/pom.xml" ); File pom0Basedir = pom0.getParentFile(); File pom1 = new File( pom0Basedir, "p1/pom.xml" ); // load the child project, which inherits from p0... MavenProject project0 = getProjectWithDependencies( pom0 ); MavenProject project1 = getProjectWithDependencies( pom1 ); assertEquals( pom0Basedir, project1.getParent().getBasedir() ); System.out.println("Project " + project1.getId() + " " + project1); Map map = project1.getArtifactMap(); assertNotNull("No artifacts", map); assertTrue("No Artifacts", map.size() > 0); assertTrue("Set size should be 2, is " + map.size(), map.size() == 2); assertTrue("maven-test-a is not in the project", map.containsKey( "maven-test:maven-test-a" )); assertTrue("maven-test-b is not in the project", map.containsKey( "maven-test:maven-test-b" )); } /** * Setup exactly the same as the above test, except that the child project * now depends upon d, which has a transitive dependency on c. Even though * we did list an exclusion on c, it was only from within the context of * project b. We will pick up project c in this case because no * restrictions were placed on d. This demonstrates that a, b, c, & d will * all be collected. * * @throws Exception */ public void testDependencyManagementExclusionDoesNotOverrideGloballyForTransitives() throws Exception { File localRepo = getLocalRepositoryPath(); File pom0 = new File( localRepo, "p0/pom.xml" ); File pom0Basedir = pom0.getParentFile(); File pom2 = new File( pom0Basedir, "p2/pom.xml" ); // load the child project, which inherits from p0... MavenProject project0 = getProjectWithDependencies( pom0 ); MavenProject project2 = getProjectWithDependencies( pom2 ); assertEquals( pom0Basedir, project2.getParent().getBasedir() ); System.out.println( "Project " + project2.getId() + " " + project2 ); Map map = project2.getArtifactMap(); assertNotNull( "No artifacts", map ); assertTrue( "No Artifacts", map.size() > 0 ); assertTrue( "Set size should be 4, is " + map.size(), map.size() == 4 ); assertTrue( "maven-test-a is not in the project", map.containsKey( "maven-test:maven-test-a" ) ); assertTrue( "maven-test-b is not in the project", map.containsKey( "maven-test:maven-test-b" ) ); assertTrue( "maven-test-c is not in the project", map.containsKey( "maven-test:maven-test-c" ) ); assertTrue( "maven-test-d is not in the project", map.containsKey( "maven-test:maven-test-d" ) ); } }maven2-core-2.2.1/maven-project/src/test/java/org/apache/maven/project/inheritance/t06/0000755000175000017500000000000011250552245030520 5ustar twernertwerner././@LongLink0000000000000000000000000000016300000000000011565 Lustar rootrootmaven2-core-2.2.1/maven-project/src/test/java/org/apache/maven/project/inheritance/t06/ProjectInheritanceTest.javamaven2-core-2.2.1/maven-project/src/test/java/org/apache/maven/project/inheritance/t06/ProjectInheri0000644000175000017500000000570210772004567033223 0ustar twernertwernerpackage org.apache.maven.project.inheritance.t06; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import java.io.File; import java.util.Set; import java.util.Iterator; import org.apache.maven.project.MavenProject; import org.apache.maven.project.inheritance.AbstractProjectInheritanceTestCase; import org.apache.maven.artifact.Artifact; /** * A test which demonstrates maven's dependency management * * @author Ralph Goers * @version $Id: ProjectInheritanceTest.java 640549 2008-03-24 20:05:11Z bentmann $ */ public class ProjectInheritanceTest extends AbstractProjectInheritanceTestCase { // ---------------------------------------------------------------------- // // p1 inherits from p0 // p0 inhertis from super model // // or we can show it graphically as: // // p1 ---> p0 --> super model // // ---------------------------------------------------------------------- public void testDependencyManagement() throws Exception { File localRepo = getLocalRepositoryPath(); File pom0 = new File( localRepo, "p0/pom.xml" ); File pom0Basedir = pom0.getParentFile(); File pom1 = new File( pom0Basedir, "p1/pom.xml" ); // load everything... MavenProject project0 = getProjectWithDependencies( pom0 ); MavenProject project1 = getProjectWithDependencies( pom1 ); assertEquals( pom0Basedir, project1.getParent().getBasedir() ); System.out.println("Project " + project1.getId() + " " + project1); Set set = project1.getArtifacts(); assertNotNull("No artifacts", set); assertTrue("No Artifacts", set.size() > 0); Iterator iter = set.iterator(); assertTrue("Set size should be 4, is " + set.size(), set.size() == 4); while (iter.hasNext()) { Artifact artifact = (Artifact)iter.next(); System.out.println("Artifact: " + artifact.getDependencyConflictId() + " " + artifact.getVersion() + " Optional=" + (artifact.isOptional() ? "true" : "false")); assertTrue("Incorrect version for " + artifact.getDependencyConflictId(), artifact.getVersion().equals("1.0")); } } } ././@LongLink0000000000000000000000000000017500000000000011570 Lustar rootrootmaven2-core-2.2.1/maven-project/src/test/java/org/apache/maven/project/inheritance/DefaultModelInheritanceAssemblerTest.javamaven2-core-2.2.1/maven-project/src/test/java/org/apache/maven/project/inheritance/DefaultModelInher0000644000175000017500000012326511151504752033376 0ustar twernertwernerpackage org.apache.maven.project.inheritance; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import org.apache.maven.model.Build; import org.apache.maven.model.Dependency; import org.apache.maven.model.DependencyManagement; import org.apache.maven.model.DeploymentRepository; import org.apache.maven.model.DistributionManagement; import org.apache.maven.model.Model; import org.apache.maven.model.Parent; import org.apache.maven.model.Plugin; import org.apache.maven.model.PluginExecution; import org.apache.maven.model.Relocation; import org.apache.maven.model.ReportPlugin; import org.apache.maven.model.ReportSet; import org.apache.maven.model.Reporting; import org.apache.maven.model.Repository; import org.apache.maven.model.RepositoryBase; import org.apache.maven.model.Resource; import org.apache.maven.model.Scm; import org.apache.maven.model.Site; import java.util.ArrayList; import java.util.Collections; import java.util.Iterator; import java.util.List; import java.util.Map; import junit.framework.TestCase; /** * @author jdcasey */ public class DefaultModelInheritanceAssemblerTest extends TestCase { private ModelInheritanceAssembler assembler = new DefaultModelInheritanceAssembler(); public void testShouldAdjustChildUrlBasedOnParentAndModulePathInSiblingDir() { Model parent = makeBaseModel( "parent" ); parent.setUrl( "http://www.google.com/parent" ); Model child = makeBaseModel( "child" ); // TODO: this is probably what we should be appending... // child.setUrl( "/child.dir" ); parent.addModule( "../child" ); assembler.assembleModelInheritance( child, parent, ".." ); String resultingUrl = child.getUrl(); System.out.println( resultingUrl ); assertEquals( "http://www.google.com/child", resultingUrl ); } public void testShouldAdjustPathsThreeLevelsDeepAncestryInRepoAndNonStandardModulePaths() { Model top = makeBaseModel( "top" ); top.setUrl( "http://www.google.com/top" ); Model middle = makeBaseModel( "middle" ); top.addModule( "../middle" ); Model bottom = makeBaseModel( "bottom" ); middle.addModule( "../bottom" ); assembler.assembleModelInheritance( middle, top, ".." ); assembler.assembleModelInheritance( bottom, middle, ".." ); String resultingUrl = bottom.getUrl(); System.out.println( resultingUrl ); assertEquals( "http://www.google.com/bottom", resultingUrl ); } public void testShouldMergeSuccessiveDependencyManagementSectionsOverThreeLevels() { Model top = makeBaseModel( "top" ); DependencyManagement topMgmt = new DependencyManagement(); topMgmt.addDependency( makeDep( "top-dep" ) ); top.setDependencyManagement( topMgmt ); Model mid = makeBaseModel( "mid" ); DependencyManagement midMgmt = new DependencyManagement(); midMgmt.addDependency( makeDep( "mid-dep" ) ); mid.setDependencyManagement( midMgmt ); Model bottom = makeBaseModel( "bottom" ); DependencyManagement bottomMgmt = new DependencyManagement(); bottomMgmt.addDependency( makeDep( "bottom-dep" ) ); bottom.setDependencyManagement( bottomMgmt ); assembler.assembleModelInheritance( mid, top ); assembler.assembleModelInheritance( bottom, mid ); DependencyManagement result = bottom.getDependencyManagement(); List resultDeps = result.getDependencies(); assertEquals( 3, resultDeps.size() ); } public void testShouldMergeDependencyManagementSectionsFromTopTwoLevelsToBottomLevel() { Model top = makeBaseModel( "top" ); DependencyManagement topMgmt = new DependencyManagement(); topMgmt.addDependency( makeDep( "top-dep" ) ); top.setDependencyManagement( topMgmt ); Model mid = makeBaseModel( "mid" ); DependencyManagement midMgmt = new DependencyManagement(); midMgmt.addDependency( makeDep( "mid-dep" ) ); mid.setDependencyManagement( midMgmt ); Model bottom = makeBaseModel( "bottom" ); assembler.assembleModelInheritance( mid, top ); assembler.assembleModelInheritance( bottom, mid ); DependencyManagement result = bottom.getDependencyManagement(); List resultDeps = result.getDependencies(); assertEquals( 2, resultDeps.size() ); } private Dependency makeDep( String artifactId ) { Dependency dep = new Dependency(); dep.setGroupId( "maven" ); dep.setArtifactId( artifactId ); dep.setVersion( "1.0" ); return dep; } public void testShouldAppendChildPathAdjustmentWithNoChildPartAndNoParentPart() { String parentPath = ""; String childPath = null; String pathAdjustment = "../file-management"; String result = ( (DefaultModelInheritanceAssembler) assembler ).appendPath( parentPath, childPath, pathAdjustment, true ); System.out.println( "Resulting path is: \'" + result + "\'" ); assertEquals( "Append with path adjustment failed.", "/file-management", result ); } public void testShouldAppendChildPathAdjustmentWithNoChildPart() { String parentPath = "http://maven.apache.org/shared/maven-shared-parent"; String childPath = null; String pathAdjustment = "../file-management"; String result = ( (DefaultModelInheritanceAssembler) assembler ).appendPath( parentPath, childPath, pathAdjustment, true ); System.out.println( "Resulting path is: \'" + result + "\'" ); assertEquals( "Append with path adjustment failed.", "http://maven.apache.org/shared/file-management", result ); } public void testShouldAppendPathWithChildPathAdjustment() { String parentPath = "http://maven.apache.org/shared/maven-shared-parent"; String childPath = "file-management"; String pathAdjustment = ".."; String result = ( (DefaultModelInheritanceAssembler) assembler ).appendPath( parentPath, childPath, pathAdjustment, true ); System.out.println( "Resulting path is: \'" + result + "\'" ); assertEquals( "Append with path adjustment failed.", "http://maven.apache.org/shared/file-management", result ); } public void testAppendPathUNC() { String parentPath = "file:////host/shared/maven-shared-parent"; String childPath = "file-management"; String pathAdjustment = null; String result = ( (DefaultModelInheritanceAssembler) assembler ).appendPath( parentPath, childPath, pathAdjustment, true ); assertEquals( "file:////host/shared/maven-shared-parent/file-management", result ); } public void testDistributionManagementInheritance() { Model parent = makeBaseModel( "parent" ); Model child = makeBaseModel( "child" ); DistributionManagement distributionManagement = new DistributionManagement(); distributionManagement.setDownloadUrl( "downloadUrl" ); distributionManagement.setRelocation( new Relocation() ); distributionManagement.setStatus( "deployed" ); DeploymentRepository repository = new DeploymentRepository(); repository.setId( "apache.releases" ); repository.setUrl( "scp://minotaur.apache.org/www/www.apache.org/dist/java-repository" ); repository.setName( "name" ); repository.setLayout( "legacy" ); distributionManagement.setRepository( repository ); DeploymentRepository snapshotRepository = new DeploymentRepository(); snapshotRepository.setId( "apache.snapshots" ); snapshotRepository.setUrl( "scp://minotaur.apache.org/www/cvs.apache.org/repository" ); snapshotRepository.setName( "name" ); snapshotRepository.setLayout( "legacy" ); snapshotRepository.setUniqueVersion( false ); distributionManagement.setSnapshotRepository( snapshotRepository ); Site site = new Site(); site.setId( "apache.website" ); site.setUrl( "scp://minotaur.apache.org/www/maven.apache.org/" ); site.setName( "name3" ); distributionManagement.setSite( site ); parent.setDistributionManagement( distributionManagement ); assembler.assembleModelInheritance( child, parent ); DistributionManagement childDistMgmt = child.getDistributionManagement(); assertNotNull( "Check distMgmt inherited", childDistMgmt ); assertNull( "Check status NOT inherited", childDistMgmt.getStatus() ); assertNull( "Check relocation NOT inherited", childDistMgmt.getRelocation() ); assertEquals( "Check downloadUrl inherited", distributionManagement.getDownloadUrl(), childDistMgmt.getDownloadUrl() ); Site childSite = childDistMgmt.getSite(); assertNotNull( "Check site inherited", childSite ); assertEquals( "Check id matches", site.getId(), childSite.getId() ); assertEquals( "Check name matches", site.getName(), childSite.getName() ); assertEquals( "Check url matches with appended path", site.getUrl() + "child", childSite.getUrl() ); assertRepositoryBase( childDistMgmt.getRepository(), repository ); assertRepositoryBase( childDistMgmt.getSnapshotRepository(), snapshotRepository ); assertEquals( "Check uniqueVersion is inherited", snapshotRepository.isUniqueVersion(), childDistMgmt.getSnapshotRepository().isUniqueVersion() ); } private static void assertRepositoryBase( RepositoryBase childRepository, RepositoryBase repository ) { assertNotNull( "Check repository inherited", childRepository ); assertEquals( "Check id matches", repository.getId(), childRepository.getId() ); assertEquals( "Check name matches", repository.getName(), childRepository.getName() ); assertEquals( "Check url matches", repository.getUrl(), childRepository.getUrl() ); assertEquals( "Check layout matches", repository.getLayout(), childRepository.getLayout() ); } public void testShouldOverrideUnitTestExcludesOnly() { Model parent = new Model(); parent.setGroupId( "test" ); parent.setArtifactId( "test" ); parent.setVersion( "0.0" ); Build parentBuild = new Build(); parentBuild.setSourceDirectory( "src/main/java" ); parentBuild.setTestSourceDirectory( "src/test/java" ); Resource parentResource = new Resource(); parentResource.setDirectory( "src/main/resources" ); parentBuild.addResource( parentResource ); Resource parentUTResource = new Resource(); parentUTResource.setDirectory( "src/test/resources" ); parentBuild.addTestResource( parentUTResource ); parent.setBuild( parentBuild ); Model child = new Model(); Parent parentElement = new Parent(); parentElement.setArtifactId( parent.getArtifactId() ); parentElement.setGroupId( parent.getGroupId() ); parentElement.setVersion( parent.getVersion() ); child.setParent( parentElement ); child.setPackaging( "plugin" ); Build childBuild = new Build(); child.setBuild( childBuild ); assembler.assembleModelInheritance( child, parent ); assertEquals( "source directory should be from parent", "src/main/java", child.getBuild().getSourceDirectory() ); assertEquals( "unit test source directory should be from parent", "src/test/java", child.getBuild().getTestSourceDirectory() ); // TODO: test inheritence/super pom? // List childExcludesTest = child.getBuild().getUnitTest().getExcludes(); // // assertTrue( "unit test excludes should have **/*AspectTest.java", childExcludesTest // .contains( "**/*AspectTest.java" ) ); // assertTrue( "unit test excludes should have **/*Abstract*.java", childExcludesTest // .contains( "**/*Abstract*.java" ) ); // List resources = child.getBuild().getResources(); assertEquals( "build resources inherited from parent should be of size 1", 1, resources.size() ); assertEquals( "first resource should have dir == src/main/resources", "src/main/resources", ( (Resource) resources.get( 0 ) ).getDirectory() ); List utResources = child.getBuild().getTestResources(); assertEquals( "UT resources inherited from parent should be of size 1", 1, utResources.size() ); assertEquals( "first UT resource should have dir == src/test/resources", "src/test/resources", ( (Resource) utResources.get( 0 ) ).getDirectory() ); assertEquals( "plugin", child.getPackaging() ); assertEquals( "jar", parent.getPackaging() ); } /** *
     * root
     *   |--artifact1
     *   |         |
     *   |         |--artifact1-1
     *   |
     *   |--artifact2 (in another directory called a2 so it has it's own scm section)
     *             |
     *             |--artifact2-1
     * 
*/ public void testScmInheritance() throws Exception { // Make the models Model root = makeScmModel( "root", "scm:foo:/scm-root", "scm:foo:/scm-dev-root", null ); Model artifact1 = makeScmModel( "artifact1" ); Model artifact1_1 = makeScmModel( "artifact1-1" ); Model artifact2 = makeScmModel( "artifact2", "scm:foo:/scm-root/yay-artifact2", "scm:foo:/scm-dev-root/yay-artifact2", null ); Model artifact2_1 = makeScmModel( "artifact2-1" ); // Assemble assembler.assembleModelInheritance( artifact1, root ); assembler.assembleModelInheritance( artifact1_1, artifact1 ); assembler.assembleModelInheritance( artifact2, root ); assembler.assembleModelInheritance( artifact2_1, artifact2 ); // --- -- - assertConnection( "scm:foo:/scm-root/artifact1", "scm:foo:/scm-dev-root/artifact1", artifact1 ); assertConnection( "scm:foo:/scm-root/artifact1/artifact1-1", "scm:foo:/scm-dev-root/artifact1/artifact1-1", artifact1_1 ); assertConnection( "scm:foo:/scm-root/yay-artifact2", "scm:foo:/scm-dev-root/yay-artifact2", artifact2 ); assertConnection( "scm:foo:/scm-root/yay-artifact2/artifact2-1", "scm:foo:/scm-dev-root/yay-artifact2/artifact2-1", artifact2_1 ); } public void testScmInheritanceWhereParentHasConnectionAndTheChildDoesnt() { Model parent = makeScmModel( "parent", "scm:foo:bar:/scm-root", null, null ); Model child = makeScmModel( "child" ); assembler.assembleModelInheritance( child, parent ); assertScm( "scm:foo:bar:/scm-root/child", null, null, child.getScm() ); } public void testScmInheritanceWhereParentHasConnectionAndTheChildDoes() { Model parent = makeScmModel( "parent", "scm:foo:bar:/scm-root", null, null ); Model child = makeScmModel( "child", "scm:foo:bar:/another-root", null, null ); assembler.assembleModelInheritance( child, parent ); assertScm( "scm:foo:bar:/another-root", null, null, child.getScm() ); } public void testScmInheritanceWhereParentHasDeveloperConnectionAndTheChildDoesnt() { Model parent = makeScmModel( "parent", null, "scm:foo:bar:/scm-dev-root", null ); Model child = makeScmModel( "child" ); assembler.assembleModelInheritance( child, parent ); assertScm( null, "scm:foo:bar:/scm-dev-root/child", null, child.getScm() ); } public void testScmInheritanceWhereParentHasDeveloperConnectionAndTheChildDoes() { Model parent = makeScmModel( "parent", null, "scm:foo:bar:/scm-dev-root", null ); Model child = makeScmModel( "child", null, "scm:foo:bar:/another-dev-root", null ); assembler.assembleModelInheritance( child, parent ); assertScm( null, "scm:foo:bar:/another-dev-root", null, child.getScm() ); } public void testScmInheritanceWhereParentHasUrlAndTheChildDoesnt() { Model parent = makeScmModel( "parent", null, null, "http://foo/bar" ); Model child = makeScmModel( "child" ); assembler.assembleModelInheritance( child, parent ); assertScm( null, null, "http://foo/bar/child", child.getScm() ); } public void testScmInheritanceWhereParentHasUrlAndTheChildDoes() { Model parent = makeScmModel( "parent", null, null, "http://foo/bar/" ); Model child = makeScmModel( "child", null, null, "http://bar/foo/" ); assembler.assembleModelInheritance( child, parent ); assertScm( null, null, "http://bar/foo/", child.getScm() ); } public void testRepositoryInheritenceWhereParentHasRepositoryAndTheChildDoesnt() { Model parent = makeRepositoryModel( "parent", "central", "http://repo1.maven.org/maven/" ); List repos = new ArrayList( parent.getRepositories() ); Model child = makeBaseModel( "child" ); assembler.assembleModelInheritance( child, parent ); // TODO: a lot easier if modello generated equals() :) assertRepositories( repos, child.getRepositories() ); } public void testRepositoryInheritenceWhereParentHasRepositoryAndTheChildHasDifferent() { Model parent = makeRepositoryModel( "parent", "central", "http://repo1.maven.org/maven/" ); List repos = new ArrayList( parent.getRepositories() ); Model child = makeRepositoryModel( "child", "workplace", "http://repository.mycompany.com/maven/" ); repos.addAll( child.getRepositories() ); assembler.assembleModelInheritance( child, parent ); // TODO: a lot easier if modello generated equals() :) assertRepositories( repos, child.getRepositories() ); } public void testRepositoryInheritenceWhereParentHasRepositoryAndTheChildHasSameId() { Model parent = makeRepositoryModel( "parent", "central", "http://repo1.maven.org/maven/" ); Model child = makeRepositoryModel( "child", "central", "http://repo2.maven.org/maven/" ); // We want to get the child repository here. List repos = new ArrayList( child.getRepositories() ); assembler.assembleModelInheritance( child, parent ); // TODO: a lot easier if modello generated equals() :) assertRepositories( repos, child.getRepositories() ); } public void testPluginInheritanceWhereParentPluginWithoutInheritFlagAndChildHasNoPlugins() { Model parent = makeBaseModel( "parent" ); Model child = makeBaseModel( "child" ); Plugin parentPlugin = new Plugin(); parentPlugin.setArtifactId( "maven-testInheritance-plugin" ); parentPlugin.setGroupId( "org.apache.maven.plugins" ); parentPlugin.setVersion( "1.0" ); List parentPlugins = Collections.singletonList( parentPlugin ); Build parentBuild = new Build(); parentBuild.setPlugins( parentPlugins ); parent.setBuild( parentBuild ); assembler.assembleModelInheritance( child, parent ); assertPlugins( parentPlugins, child ); } public void testPluginInheritanceWhereParentPluginWithTrueInheritFlagAndChildHasNoPlugins() { Model parent = makeBaseModel( "parent" ); Model child = makeBaseModel( "child" ); Plugin parentPlugin = new Plugin(); parentPlugin.setArtifactId( "maven-testInheritance2-plugin" ); parentPlugin.setGroupId( "org.apache.maven.plugins" ); parentPlugin.setVersion( "1.0" ); parentPlugin.setInherited( "true" ); List parentPlugins = Collections.singletonList( parentPlugin ); Build parentBuild = new Build(); parentBuild.setPlugins( parentPlugins ); parent.setBuild( parentBuild ); assembler.assembleModelInheritance( child, parent ); assertPlugins( parentPlugins, child ); } public void testPluginInheritanceWhereParentPluginWithFalseInheritFlagAndChildHasNoPlugins() { Model parent = makeBaseModel( "parent" ); Model child = makeBaseModel( "child" ); Plugin parentPlugin = new Plugin(); parentPlugin.setArtifactId( "maven-testInheritance3-plugin" ); parentPlugin.setGroupId( "org.apache.maven.plugins" ); parentPlugin.setVersion( "1.0" ); parentPlugin.setInherited( "false" ); List parentPlugins = Collections.singletonList( parentPlugin ); Build parentBuild = new Build(); parentBuild.setPlugins( parentPlugins ); parent.setBuild( parentBuild ); assembler.assembleModelInheritance( child, parent ); assertPlugins( new ArrayList(), child ); } private void assertPlugins( List expectedPlugins, Model child ) { Build childBuild = child.getBuild(); if ( ( expectedPlugins != null ) && !expectedPlugins.isEmpty() ) { assertNotNull( childBuild ); Map childPluginsMap = childBuild.getPluginsAsMap(); if ( childPluginsMap != null ) { assertEquals( expectedPlugins.size(), childPluginsMap.size() ); for ( Iterator it = expectedPlugins.iterator(); it.hasNext(); ) { Plugin expectedPlugin = (Plugin) it.next(); Plugin childPlugin = (Plugin) childPluginsMap.get( expectedPlugin.getKey() ); assertPluginsEqual( expectedPlugin, childPlugin ); } } else { fail( "child plugins collection is null, but expectations map is not." ); } } else { assertTrue( ( childBuild == null ) || ( childBuild.getPlugins() == null ) || childBuild.getPlugins().isEmpty() ); } } private void assertPluginsEqual( Plugin reference, Plugin test ) { assertEquals( "Plugin keys don't match", reference.getKey(), test.getKey() ); assertEquals( "Plugin configurations don't match", reference.getConfiguration(), test.getConfiguration() ); List referenceExecutions = reference.getExecutions(); Map testExecutionsMap = test.getExecutionsAsMap(); if ( ( referenceExecutions != null ) && !referenceExecutions.isEmpty() ) { assertTrue( "Missing goals specification", ( ( testExecutionsMap != null ) && !testExecutionsMap.isEmpty() ) ); for ( Iterator it = referenceExecutions.iterator(); it.hasNext(); ) { PluginExecution referenceExecution = (PluginExecution) it.next(); PluginExecution testExecution = (PluginExecution) testExecutionsMap.get( referenceExecution.getId() ); assertNotNull( "Goal from reference not found in test", testExecution ); assertEquals( "Goal IDs don't match", referenceExecution.getId(), testExecution.getId() ); assertEquals( "Goal configurations don't match", referenceExecution.getConfiguration(), testExecution.getConfiguration() ); assertEquals( "Goal lists don't match", referenceExecution.getGoals(), testExecution.getGoals() ); } } else { assertTrue( "Unexpected goals specification", ( ( testExecutionsMap == null ) || testExecutionsMap.isEmpty() ) ); } } public void testReportingExcludeDefaultsInheritance() { // parent and child have no reporting section Model parent = makeBaseModel( "parent" ); Model child = makeBaseModel( "child" ); assembler.assembleModelInheritance( child, parent ); assertNull( child.getReporting() ); // parent is default, and child has no reporting section parent = makeBaseModel( "parent" ); parent.setReporting( new Reporting() ); child = makeBaseModel( "child" ); assembler.assembleModelInheritance( child, parent ); assertFalse( child.getReporting().isExcludeDefaults() ); // parent is false, and child has no reporting section parent = makeBaseModel( "parent" ); parent.setReporting( createReportingWithExcludeDefaults( false ) ); child = makeBaseModel( "child" ); assembler.assembleModelInheritance( child, parent ); assertFalse( child.getReporting().isExcludeDefaults() ); // parent is true, and child has no reporting section parent = makeBaseModel( "parent" ); parent.setReporting( createReportingWithExcludeDefaults( true ) ); child = makeBaseModel( "child" ); assembler.assembleModelInheritance( child, parent ); assertTrue( child.getReporting().isExcludeDefaults() ); // parent has no reporting section, child is false parent = makeBaseModel( "parent" ); child = makeBaseModel( "child" ); child.setReporting( createReportingWithExcludeDefaults( false ) ); assembler.assembleModelInheritance( child, parent ); assertFalse( child.getReporting().isExcludeDefaults() ); // parent is default, and child is false parent = makeBaseModel( "parent" ); parent.setReporting( new Reporting() ); child = makeBaseModel( "child" ); child.setReporting( createReportingWithExcludeDefaults( false ) ); assembler.assembleModelInheritance( child, parent ); assertFalse( child.getReporting().isExcludeDefaults() ); // parent is false, and child is false parent = makeBaseModel( "parent" ); parent.setReporting( createReportingWithExcludeDefaults( false ) ); child = makeBaseModel( "child" ); child.setReporting( createReportingWithExcludeDefaults( false ) ); assembler.assembleModelInheritance( child, parent ); assertFalse( child.getReporting().isExcludeDefaults() ); // parent is true, and child is false parent = makeBaseModel( "parent" ); parent.setReporting( createReportingWithExcludeDefaults( true ) ); child = makeBaseModel( "child" ); child.setReporting( createReportingWithExcludeDefaults( false ) ); assembler.assembleModelInheritance( child, parent ); assertFalse( child.getReporting().isExcludeDefaults() ); // parent has no reporting section, child is true parent = makeBaseModel( "parent" ); child = makeBaseModel( "child" ); child.setReporting( createReportingWithExcludeDefaults( true ) ); assembler.assembleModelInheritance( child, parent ); assertTrue( child.getReporting().isExcludeDefaults() ); // parent is default, and child is true parent = makeBaseModel( "parent" ); parent.setReporting( new Reporting() ); child = makeBaseModel( "child" ); child.setReporting( createReportingWithExcludeDefaults( true ) ); assembler.assembleModelInheritance( child, parent ); assertTrue( child.getReporting().isExcludeDefaults() ); // parent is false, and child is true parent = makeBaseModel( "parent" ); parent.setReporting( createReportingWithExcludeDefaults( false ) ); child = makeBaseModel( "child" ); child.setReporting( createReportingWithExcludeDefaults( true ) ); assembler.assembleModelInheritance( child, parent ); assertTrue( child.getReporting().isExcludeDefaults() ); // parent is true, and child is true parent = makeBaseModel( "parent" ); parent.setReporting( createReportingWithExcludeDefaults( true ) ); child = makeBaseModel( "child" ); child.setReporting( createReportingWithExcludeDefaults( true ) ); assembler.assembleModelInheritance( child, parent ); assertTrue( child.getReporting().isExcludeDefaults() ); // parent has no reporting section, child is default parent = makeBaseModel( "parent" ); child = makeBaseModel( "child" ); child.setReporting( new Reporting() ); assembler.assembleModelInheritance( child, parent ); assertFalse( child.getReporting().isExcludeDefaults() ); // parent is default, and child is default parent = makeBaseModel( "parent" ); parent.setReporting( new Reporting() ); child = makeBaseModel( "child" ); child.setReporting( new Reporting() ); assembler.assembleModelInheritance( child, parent ); assertFalse( child.getReporting().isExcludeDefaults() ); // parent is false, and child is default parent = makeBaseModel( "parent" ); parent.setReporting( createReportingWithExcludeDefaults( false ) ); child = makeBaseModel( "child" ); child.setReporting( new Reporting() ); assembler.assembleModelInheritance( child, parent ); assertFalse( child.getReporting().isExcludeDefaults() ); // parent is true, and child is default parent = makeBaseModel( "parent" ); parent.setReporting( createReportingWithExcludeDefaults( true ) ); child = makeBaseModel( "child" ); child.setReporting( new Reporting() ); assembler.assembleModelInheritance( child, parent ); assertTrue( child.getReporting().isExcludeDefaults() ); } private Reporting createReportingWithExcludeDefaults( boolean excludeDefaults ) { Reporting reporting = new Reporting(); reporting.setExcludeDefaults( excludeDefaults ); return reporting; } public void testReportInheritanceWhereParentReportWithoutInheritFlagAndChildHasNoReports() { Model parent = makeBaseModel( "parent" ); Model child = makeBaseModel( "child" ); ReportPlugin parentReport = new ReportPlugin(); parentReport.setArtifactId( "maven-testInheritance-report-plugin" ); parentReport.setGroupId( "org.apache.maven.plugins" ); parentReport.setVersion( "1.0" ); List parentPlugins = Collections.singletonList( parentReport ); Reporting parentBuild = new Reporting(); parentBuild.setPlugins( parentPlugins ); parent.setReporting( parentBuild ); assembler.assembleModelInheritance( child, parent ); assertReports( parentPlugins, child ); } public void testReportInheritanceWhereParentReportWithTrueInheritFlagAndChildHasNoReports() { Model parent = makeBaseModel( "parent" ); Model child = makeBaseModel( "child" ); ReportPlugin parentPlugin = new ReportPlugin(); parentPlugin.setArtifactId( "maven-testInheritance2-report-plugin" ); parentPlugin.setGroupId( "org.apache.maven.plugins" ); parentPlugin.setVersion( "1.0" ); parentPlugin.setInherited( "true" ); List parentPlugins = Collections.singletonList( parentPlugin ); Reporting parentBuild = new Reporting(); parentBuild.setPlugins( parentPlugins ); parent.setReporting( parentBuild ); assembler.assembleModelInheritance( child, parent ); assertReports( parentPlugins, child ); } public void testReportInheritanceWhereParentReportWithFalseInheritFlagAndChildHasNoReports() { Model parent = makeBaseModel( "parent" ); Model child = makeBaseModel( "child" ); ReportPlugin parentPlugin = new ReportPlugin(); parentPlugin.setArtifactId( "maven-testInheritance3-report-plugin" ); parentPlugin.setGroupId( "org.apache.maven.plugins" ); parentPlugin.setVersion( "1.0" ); parentPlugin.setInherited( "false" ); List parentPlugins = Collections.singletonList( parentPlugin ); Reporting parentBuild = new Reporting(); parentBuild.setPlugins( parentPlugins ); parent.setReporting( parentBuild ); assembler.assembleModelInheritance( child, parent ); assertReports( new ArrayList(), child ); } public void testPluginExecInheritanceWhereExecInheritedSetToFalse() { String testId = "test"; String gid = "group"; String aid = "artifact"; String ver = "1"; Model child = makeBaseModel( "child" ); Plugin pChild = new Plugin(); pChild.setGroupId( gid ); pChild.setArtifactId( aid ); pChild.setVersion( ver ); PluginExecution eChild = new PluginExecution(); eChild.setId( "normal" ); eChild.addGoal( "run" ); pChild.addExecution( eChild ); Build bChild = new Build(); bChild.addPlugin( pChild ); child.setBuild( bChild ); Model parent = makeBaseModel( "parent" ); Plugin pParent = new Plugin(); pParent.setGroupId( gid ); pParent.setArtifactId( aid ); pParent.setVersion( ver ); pParent.setInherited( Boolean.toString( true ) ); PluginExecution eParent = new PluginExecution(); eParent.setId( testId ); eParent.addGoal( "test" ); eParent.setInherited( Boolean.toString( false ) ); pParent.addExecution( eParent ); Build bParent = new Build(); bParent.addPlugin( pParent ); parent.setBuild( bParent ); assembler.assembleModelInheritance( child, parent ); Map pluginMap = bChild.getPluginsAsMap(); assertNotNull( pluginMap ); Plugin plugin = (Plugin) pluginMap.get( gid + ":" + aid ); assertNotNull( plugin ); Map executionMap = plugin.getExecutionsAsMap(); assertNotNull( executionMap ); assertNull( "test execution with inherited == false should NOT be inherited to child model.", executionMap.get( testId ) ); } public void testPluginExecInheritanceWhereExecInheritedSetToFalseAndPluginInheritedNotSet() { String testId = "test"; String gid = "group"; String aid = "artifact"; String ver = "1"; Model child = makeBaseModel( "child" ); Plugin pChild = new Plugin(); pChild.setGroupId( gid ); pChild.setArtifactId( aid ); pChild.setVersion( ver ); PluginExecution eChild = new PluginExecution(); eChild.setId( "normal" ); eChild.addGoal( "run" ); pChild.addExecution( eChild ); Build bChild = new Build(); bChild.addPlugin( pChild ); child.setBuild( bChild ); Model parent = makeBaseModel( "parent" ); Plugin pParent = new Plugin(); pParent.setGroupId( gid ); pParent.setArtifactId( aid ); pParent.setVersion( ver ); PluginExecution eParent = new PluginExecution(); eParent.setId( testId ); eParent.addGoal( "test" ); eParent.setInherited( Boolean.toString( false ) ); pParent.addExecution( eParent ); Build bParent = new Build(); bParent.addPlugin( pParent ); parent.setBuild( bParent ); assembler.assembleModelInheritance( child, parent ); Map pluginMap = bChild.getPluginsAsMap(); assertNotNull( pluginMap ); Plugin plugin = (Plugin) pluginMap.get( gid + ":" + aid ); assertNotNull( plugin ); Map executionMap = plugin.getExecutionsAsMap(); assertNotNull( executionMap ); assertNull( "test execution with inherited == false should NOT be inherited to child model.", executionMap.get( testId ) ); } private void assertReports( List expectedPlugins, Model child ) { Reporting childBuild = child.getReporting(); if ( ( expectedPlugins != null ) && !expectedPlugins.isEmpty() ) { assertNotNull( childBuild ); Map childPluginsMap = childBuild.getReportPluginsAsMap(); if ( childPluginsMap != null ) { assertEquals( expectedPlugins.size(), childPluginsMap.size() ); for ( Iterator it = expectedPlugins.iterator(); it.hasNext(); ) { ReportPlugin expectedPlugin = (ReportPlugin) it.next(); ReportPlugin childPlugin = (ReportPlugin) childPluginsMap.get( expectedPlugin.getKey() ); assertReportsEqual( expectedPlugin, childPlugin ); } } else { fail( "child plugins collection is null, but expectations map is not." ); } } else { assertTrue( ( childBuild == null ) || ( childBuild.getPlugins() == null ) || childBuild.getPlugins().isEmpty() ); } } private void assertReportsEqual( ReportPlugin reference, ReportPlugin test ) { assertEquals( "Plugin keys don't match", reference.getKey(), test.getKey() ); assertEquals( "Plugin configurations don't match", reference.getConfiguration(), test.getConfiguration() ); List referenceReportSets = reference.getReportSets(); Map testReportSetsMap = test.getReportSetsAsMap(); if ( ( referenceReportSets != null ) && !referenceReportSets.isEmpty() ) { assertTrue( "Missing goals specification", ( ( testReportSetsMap != null ) && !testReportSetsMap.isEmpty() ) ); for ( Iterator it = referenceReportSets.iterator(); it.hasNext(); ) { ReportSet referenceReportSet = (ReportSet) it.next(); ReportSet testReportSet = (ReportSet) testReportSetsMap.get( referenceReportSet.getId() ); assertNotNull( "Goal from reference not found in test", testReportSet ); assertEquals( "Goal IDs don't match", referenceReportSet.getId(), testReportSet.getId() ); assertEquals( "Goal configurations don't match", referenceReportSet.getConfiguration(), testReportSet.getConfiguration() ); assertEquals( "Reports don't match", referenceReportSet.getReports(), testReportSet.getReports() ); } } else { assertTrue( "Unexpected goals specification", ( ( testReportSetsMap == null ) || testReportSetsMap.isEmpty() ) ); } } // ---------------------------------------------------------------------- // // ---------------------------------------------------------------------- private void assertConnection( String expectedConnection, String expectedDeveloperConnection, Model model ) { String connection = model.getScm().getConnection(); assertNotNull( connection ); assertEquals( expectedConnection, connection ); String developerConnection = model.getScm().getDeveloperConnection(); assertNotNull( developerConnection ); assertEquals( expectedDeveloperConnection, developerConnection ); } public void assertScm( String connection, String developerConnection, String url, Scm scm ) { assertNotNull( scm ); assertEquals( connection, scm.getConnection() ); assertEquals( developerConnection, scm.getDeveloperConnection() ); assertEquals( url, scm.getUrl() ); } private static Model makeScmModel( String artifactId ) { return makeScmModel( artifactId, null, null, null ); } private static Model makeScmModel( String artifactId, String connection, String developerConnection, String url ) { Model model = makeBaseModel( artifactId ); if ( ( connection != null ) || ( developerConnection != null ) || ( url != null ) ) { Scm scm = new Scm(); scm.setConnection( connection ); scm.setDeveloperConnection( developerConnection ); scm.setUrl( url ); model.setScm( scm ); } return model; } private static Model makeBaseModel( String artifactId ) { Model model = new Model(); model.setModelVersion( "4.0.0" ); model.setGroupId( "maven" ); model.setArtifactId( artifactId ); model.setVersion( "1.0" ); return model; } private static Model makeRepositoryModel( String artifactId, String id, String url ) { Model model = makeBaseModel( artifactId ); Repository repository = makeRepository( id, url ); model.setRepositories( new ArrayList( Collections.singletonList( repository ) ) ); return model; } private static Repository makeRepository( String id, String url ) { Repository repository = new Repository(); repository.setId( id ); repository.setUrl( url ); return repository; } private void assertRepositories( List expected, List actual ) { assertEquals( "Repository list sizes don't match", expected.size(), actual.size() ); for ( Iterator i = expected.iterator(); i.hasNext(); ) { Repository expectedRepository = (Repository) i.next(); boolean found = false; for ( Iterator j = actual.iterator(); j.hasNext() && !found; ) { Repository actualRepository = (Repository) j.next(); if ( actualRepository.getId().equals( expectedRepository.getId() ) ) { assertEquals( "Repository URLs don't match", expectedRepository.getUrl(), actualRepository.getUrl() ); found = true; } } assertTrue( "Repository with ID " + expectedRepository.getId() + " not found", found ); } } } maven2-core-2.2.1/maven-project/src/test/java/org/apache/maven/project/inheritance/t05/0000755000175000017500000000000011250552245030517 5ustar twernertwerner././@LongLink0000000000000000000000000000016300000000000011565 Lustar rootrootmaven2-core-2.2.1/maven-project/src/test/java/org/apache/maven/project/inheritance/t05/ProjectInheritanceTest.javamaven2-core-2.2.1/maven-project/src/test/java/org/apache/maven/project/inheritance/t05/ProjectInheri0000644000175000017500000000542410772004567033223 0ustar twernertwernerpackage org.apache.maven.project.inheritance.t05; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import java.io.File; import java.util.Set; import java.util.Iterator; import org.apache.maven.project.MavenProject; import org.apache.maven.project.inheritance.AbstractProjectInheritanceTestCase; import org.apache.maven.artifact.Artifact; /** * A test which demonstrates maven's dependency management * * @author Ralph Goers * @version $Id: ProjectInheritanceTest.java 640549 2008-03-24 20:05:11Z bentmann $ */ public class ProjectInheritanceTest extends AbstractProjectInheritanceTestCase { // ---------------------------------------------------------------------- // // p1 inherits from p0 // p0 inhertis from super model // // or we can show it graphically as: // // p1 ---> p0 --> super model // // ---------------------------------------------------------------------- public void testDependencyManagement() throws Exception { File localRepo = getLocalRepositoryPath(); File pom0 = new File( localRepo, "p0/pom.xml" ); File pom0Basedir = pom0.getParentFile(); File pom1 = new File( pom0Basedir, "p1/pom.xml" ); // load everything... MavenProject project0 = getProjectWithDependencies( pom0 ); MavenProject project1 = getProjectWithDependencies( pom1 ); assertEquals( pom0Basedir, project1.getParent().getBasedir() ); Set set = project1.getArtifacts(); assertNotNull("No artifacts", set); assertTrue("No Artifacts", set.size() > 0); Iterator iter = set.iterator(); while (iter.hasNext()) { Artifact artifact = (Artifact)iter.next(); System.out.println("Artifact: " + artifact.getDependencyConflictId() + " " + artifact.getVersion() + " Scope: " + artifact.getScope()); assertTrue("Incorrect version for " + artifact.getDependencyConflictId(), artifact.getVersion().equals("1.0")); } } } maven2-core-2.2.1/maven-project/src/test/java/org/apache/maven/project/inheritance/t00/0000755000175000017500000000000011250552244030511 5ustar twernertwerner././@LongLink0000000000000000000000000000016300000000000011565 Lustar rootrootmaven2-core-2.2.1/maven-project/src/test/java/org/apache/maven/project/inheritance/t00/ProjectInheritanceTest.javamaven2-core-2.2.1/maven-project/src/test/java/org/apache/maven/project/inheritance/t00/ProjectInheri0000644000175000017500000000723310551365651033215 0ustar twernertwernerpackage org.apache.maven.project.inheritance.t00; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import org.apache.maven.model.MailingList; import org.apache.maven.project.MavenProject; import org.apache.maven.project.inheritance.AbstractProjectInheritanceTestCase; /** * A test which demonstrates maven's recursive inheritance where * a distinct value is taken from each parent contributing to the * the final model of the project being assembled. There is no * overriding going on amongst the models being used in this test: * each model in the lineage is providing a value that is not present * anywhere else in the lineage. We are just making sure that values * down in the lineage are bubbling up where they should. * * @author Jason van Zyl * @version $Id: ProjectInheritanceTest.java 495147 2007-01-11 07:47:53Z jvanzyl $ */ public class ProjectInheritanceTest extends AbstractProjectInheritanceTestCase { // ---------------------------------------------------------------------- // // p4 inherits from p3 // p3 inherits from p2 // p2 inherits from p1 // p1 inherits from p0 // p0 inhertis from super model // // or we can show it graphically as: // // p4 ---> p3 ---> p2 ---> p1 ---> p0 --> super model // // ---------------------------------------------------------------------- public void testProjectInheritance() throws Exception { MavenProject p4 = getProject( projectFile( "p4" ) ); assertEquals( "p4", p4.getName() ); // ---------------------------------------------------------------------- // Value inherited from p3 // ---------------------------------------------------------------------- assertEquals( "2000", p4.getInceptionYear() ); // ---------------------------------------------------------------------- // Value taken from p2 // ---------------------------------------------------------------------- assertEquals( "mailing-list", ( (MailingList) p4.getMailingLists().get( 0 ) ).getName() ); // ---------------------------------------------------------------------- // Value taken from p1 // ---------------------------------------------------------------------- assertEquals( "scm-url/p2/p3/p4", p4.getScm().getUrl() ); // ---------------------------------------------------------------------- // Value taken from p4 // ---------------------------------------------------------------------- assertEquals( "Codehaus", p4.getOrganization().getName() ); // ---------------------------------------------------------------------- // Value taken from super model // ---------------------------------------------------------------------- assertEquals( "4.0.0", p4.getModelVersion() ); assertEquals( "4.0.0", p4.getModelVersion() ); } } maven2-core-2.2.1/maven-project/src/test/java/org/apache/maven/project/inheritance/t04/0000755000175000017500000000000011250552245030516 5ustar twernertwerner././@LongLink0000000000000000000000000000016300000000000011565 Lustar rootrootmaven2-core-2.2.1/maven-project/src/test/java/org/apache/maven/project/inheritance/t04/ProjectInheritanceTest.javamaven2-core-2.2.1/maven-project/src/test/java/org/apache/maven/project/inheritance/t04/ProjectInheri0000644000175000017500000000637610772004567033231 0ustar twernertwernerpackage org.apache.maven.project.inheritance.t04; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import java.io.File; import java.util.Set; import java.util.Iterator; import org.apache.maven.project.MavenProject; import org.apache.maven.project.inheritance.AbstractProjectInheritanceTestCase; import org.apache.maven.artifact.Artifact; /** * Verifies the version of a dependency listed in a parent's * dependencyManagement section is chosen over another version of the same * dependency, listed transitively. * * @author Patrick Schneider * @version $Id: ProjectInheritanceTest.java 640549 2008-03-24 20:05:11Z bentmann $ */ public class ProjectInheritanceTest extends AbstractProjectInheritanceTestCase { // ---------------------------------------------------------------------- // // p1 inherits from p0 // p0 inhertis from super model // // or we can show it graphically as: // // p1 ---> p0 --> super model // // p1 has a depMgmt section that specifies versions 1.0 of jars "a" & "b" // jar "a" has a transitive dependency on 2.0 of jar "b", but maven should // prefer to use version 1.0. // // ---------------------------------------------------------------------- public void testDependencyManagementOverridesTransitiveDependencyVersion() throws Exception { File localRepo = getLocalRepositoryPath(); File pom0 = new File( localRepo, "p0/pom.xml" ); File pom0Basedir = pom0.getParentFile(); File pom1 = new File( pom0Basedir, "p1/pom.xml" ); // load the child project, which inherits from p0... MavenProject project0 = getProjectWithDependencies( pom0 ); MavenProject project1 = getProjectWithDependencies( pom1 ); assertEquals( pom0Basedir, project1.getParent().getBasedir() ); Set set = project1.getArtifacts(); assertNotNull("No artifacts", set); assertTrue("No Artifacts", set.size() > 0); assertTrue("Set size should be 3, is " + set.size(), set.size() == 3); Iterator iter = set.iterator(); while (iter.hasNext()) { Artifact artifact = (Artifact)iter.next(); System.out.println("Artifact: " + artifact.getDependencyConflictId() + " " + artifact.getVersion() + " Optional=" + (artifact.isOptional() ? "true" : "false")); assertTrue("Incorrect version for " + artifact.getDependencyConflictId(), artifact.getVersion().equals("1.0")); } } }maven2-core-2.2.1/maven-project/src/test/java/org/apache/maven/project/inheritance/t12/0000755000175000017500000000000011250552244030514 5ustar twernertwerner././@LongLink0000000000000000000000000000016300000000000011565 Lustar rootrootmaven2-core-2.2.1/maven-project/src/test/java/org/apache/maven/project/inheritance/t12/ProjectInheritanceTest.javamaven2-core-2.2.1/maven-project/src/test/java/org/apache/maven/project/inheritance/t12/ProjectInheri0000644000175000017500000000463210772004567033221 0ustar twernertwernerpackage org.apache.maven.project.inheritance.t12; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import org.apache.maven.model.Plugin; import org.apache.maven.project.MavenProject; import org.apache.maven.project.inheritance.AbstractProjectInheritanceTestCase; import java.io.File; import java.util.Map; /** * Verifies that plugin execution sections in the parent POM that have * inherit == false are not inherited to the child POM. */ public class ProjectInheritanceTest extends AbstractProjectInheritanceTestCase { // ---------------------------------------------------------------------- // // p1 inherits from p0 // p0 inherits from super model // // or we can show it graphically as: // // p1 ---> p0 --> super model // // ---------------------------------------------------------------------- public void testFalsePluginExecutionInheritValue() throws Exception { File localRepo = getLocalRepositoryPath(); File pom0 = new File( localRepo, "p0/pom.xml" ); File pom0Basedir = pom0.getParentFile(); File pom1 = new File( pom0Basedir, "p1/pom.xml" ); getProjectWithDependencies( pom0 ); MavenProject project1 = getProjectWithDependencies( pom1 ); Map pluginMap = project1.getBuild().getPluginsAsMap(); Plugin compilerPlugin = (Plugin) pluginMap.get( "org.apache.maven.plugins:maven-compiler-plugin" ); assertNotNull( compilerPlugin ); Map executionMap = compilerPlugin.getExecutionsAsMap(); assertNull( "Plugin execution: \'test\' should NOT exist in the compiler plugin specification for the child project!", executionMap.get( "test" ) ); } }maven2-core-2.2.1/maven-project/src/test/java/org/apache/maven/project/inheritance/t07/0000755000175000017500000000000011250552245030521 5ustar twernertwerner././@LongLink0000000000000000000000000000016300000000000011565 Lustar rootrootmaven2-core-2.2.1/maven-project/src/test/java/org/apache/maven/project/inheritance/t07/ProjectInheritanceTest.javamaven2-core-2.2.1/maven-project/src/test/java/org/apache/maven/project/inheritance/t07/ProjectInheri0000644000175000017500000000661710772004567033232 0ustar twernertwernerpackage org.apache.maven.project.inheritance.t07; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import java.io.File; import java.util.List; import java.util.Set; import java.util.Iterator; import org.apache.maven.model.Build; import org.apache.maven.model.MailingList; import org.apache.maven.model.Plugin; import org.apache.maven.model.PluginExecution; import org.apache.maven.model.Dependency; import org.apache.maven.project.MavenProject; import org.apache.maven.project.inheritance.AbstractProjectInheritanceTestCase; import org.apache.maven.artifact.Artifact; import org.codehaus.plexus.util.xml.Xpp3Dom; import org.codehaus.plexus.logging.LoggerManager; import org.codehaus.plexus.logging.Logger; /** * A test which demonstrates maven's dependency management * * @author Jason van Zyl * @version $Id: ProjectInheritanceTest.java 640549 2008-03-24 20:05:11Z bentmann $ */ public class ProjectInheritanceTest extends AbstractProjectInheritanceTestCase { // ---------------------------------------------------------------------- // // p1 inherits from p0 // p0 inhertis from super model // // or we can show it graphically as: // // p1 ---> p0 --> super model // // ---------------------------------------------------------------------- public void testDependencyManagement() throws Exception { File localRepo = getLocalRepositoryPath(); File pom0 = new File( localRepo, "p0/pom.xml" ); File pom0Basedir = pom0.getParentFile(); File pom1 = new File( pom0Basedir, "p1/pom.xml" ); // load everything... MavenProject project0 = getProjectWithDependencies( pom0 ); MavenProject project1 = getProjectWithDependencies( pom1 ); assertEquals( pom0Basedir, project1.getParent().getBasedir() ); System.out.println("Project " + project1.getId() + " " + project1); Set set = project1.getArtifacts(); assertNotNull("No artifacts", set); assertTrue("No Artifacts", set.size() > 0); Iterator iter = set.iterator(); assertTrue("Set size should be 3, is " + set.size(), set.size() == 3); while (iter.hasNext()) { Artifact artifact = (Artifact)iter.next(); assertFalse("", artifact.getArtifactId().equals("maven-test-d")); System.out.println("Artifact: " + artifact.getDependencyConflictId() + " " + artifact.getVersion() + " Optional=" + (artifact.isOptional() ? "true" : "false")); assertTrue("Incorrect version for " + artifact.getDependencyConflictId(), artifact.getVersion().equals("1.0")); } } } maven2-core-2.2.1/maven-project/src/test/java/org/apache/maven/project/TestArtifactResolver.java0000644000175000017500000002215611035020441032573 0ustar twernertwernerpackage org.apache.maven.project; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.InvalidRepositoryException; import org.apache.maven.artifact.factory.ArtifactFactory; import org.apache.maven.artifact.metadata.ArtifactMetadataRetrievalException; import org.apache.maven.artifact.metadata.ArtifactMetadataSource; import org.apache.maven.artifact.metadata.ResolutionGroup; import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.artifact.repository.ArtifactRepositoryFactory; import org.apache.maven.artifact.resolver.ArtifactNotFoundException; import org.apache.maven.artifact.resolver.ArtifactResolutionException; import org.apache.maven.artifact.resolver.ArtifactResolutionResult; import org.apache.maven.artifact.resolver.DefaultArtifactResolver; import org.apache.maven.artifact.resolver.filter.ArtifactFilter; import org.apache.maven.artifact.versioning.InvalidVersionSpecificationException; import org.apache.maven.artifact.versioning.VersionRange; import org.apache.maven.model.Dependency; import org.apache.maven.model.Model; import org.apache.maven.model.io.xpp3.MavenXpp3Reader; import org.codehaus.plexus.PlexusConstants; import org.codehaus.plexus.PlexusContainer; import org.codehaus.plexus.context.Context; import org.codehaus.plexus.context.ContextException; import org.codehaus.plexus.personality.plexus.lifecycle.phase.Contextualizable; import org.codehaus.plexus.util.IOUtil; import org.codehaus.plexus.util.StringUtils; import org.codehaus.plexus.util.xml.pull.XmlPullParserException; import java.io.File; import java.io.IOException; import java.io.InputStreamReader; import java.util.HashSet; import java.util.Iterator; import java.util.List; import java.util.Set; public class TestArtifactResolver extends DefaultArtifactResolver implements Contextualizable { public static final String ROLE = TestArtifactResolver.class.getName(); private ArtifactRepositoryFactory repositoryFactory; private PlexusContainer container; static class Source implements ArtifactMetadataSource { private ArtifactFactory artifactFactory; private final ArtifactRepositoryFactory repositoryFactory; private final PlexusContainer container; public Source( ArtifactFactory artifactFactory, ArtifactRepositoryFactory repositoryFactory, PlexusContainer container ) { this.artifactFactory = artifactFactory; this.repositoryFactory = repositoryFactory; this.container = container; } public ResolutionGroup retrieve( Artifact artifact, ArtifactRepository localRepository, List remoteRepositories ) throws ArtifactMetadataRetrievalException { Model model = null; InputStreamReader r = null; try { String scope = artifact.getArtifactId().substring( "scope-".length() ); if ( "maven-test".equals( artifact.getGroupId() ) ) { String name = "/projects/scope/transitive-" + scope + "-dep.xml"; r = new InputStreamReader( getClass().getResourceAsStream( name ) ); MavenXpp3Reader reader = new MavenXpp3Reader(); model = reader.read( r ); } else { model = new Model(); } model.setGroupId( artifact.getGroupId() ); model.setArtifactId( artifact.getArtifactId() ); } catch ( IOException e ) { throw new ArtifactMetadataRetrievalException( e ); } catch ( XmlPullParserException e ) { throw new ArtifactMetadataRetrievalException( e ); } finally { IOUtil.close( r ); } Set artifacts; try { artifacts = createArtifacts( model.getDependencies(), artifact.getScope() ); } catch ( InvalidVersionSpecificationException e ) { throw new ArtifactMetadataRetrievalException( e ); } List artifactRepositories; try { artifactRepositories = ProjectUtils.buildArtifactRepositories( model.getRepositories(), repositoryFactory, container ); } catch ( InvalidRepositoryException e ) { throw new ArtifactMetadataRetrievalException( e ); } return new ResolutionGroup( artifact, artifacts, artifactRepositories ); } public List retrieveAvailableVersions( Artifact artifact, ArtifactRepository localRepository, List remoteRepositories ) { throw new UnsupportedOperationException( "Cannot get available versions in this test case" ); } protected Set createArtifacts( List dependencies, String inheritedScope ) throws InvalidVersionSpecificationException { Set projectArtifacts = new HashSet(); for ( Iterator i = dependencies.iterator(); i.hasNext(); ) { Dependency d = (Dependency) i.next(); String scope = d.getScope(); if ( StringUtils.isEmpty( scope ) ) { scope = Artifact.SCOPE_COMPILE; d.setScope( scope ); } VersionRange versionRange = VersionRange.createFromVersionSpec( d.getVersion() ); Artifact artifact = artifactFactory.createDependencyArtifact( d.getGroupId(), d.getArtifactId(), versionRange, d.getType(), d.getClassifier(), scope, inheritedScope ); if ( artifact != null ) { projectArtifacts.add( artifact ); } } return projectArtifacts; } public Artifact retrieveRelocatedArtifact( Artifact artifact, ArtifactRepository localRepository, List remoteRepositories ) throws ArtifactMetadataRetrievalException { return artifact; } } public Source source() { return new Source( artifactFactory, repositoryFactory, container ); } /** * @noinspection RefusedBequest */ public void resolve( Artifact artifact, List remoteRepositories, ArtifactRepository localRepository ) throws ArtifactResolutionException { artifact.setFile( new File( "dummy" ) ); } public ArtifactResolutionResult resolveTransitively( Set artifacts, Artifact originatingArtifact, ArtifactRepository localRepository, List remoteRepositories, ArtifactMetadataSource source, ArtifactFilter filter ) throws ArtifactResolutionException, ArtifactNotFoundException { return super.resolveTransitively( artifacts, originatingArtifact, localRepository, remoteRepositories, new Source( artifactFactory, repositoryFactory, container ), filter ); } public ArtifactResolutionResult resolveTransitively( Set artifacts, Artifact originatingArtifact, List remoteRepositories, ArtifactRepository localRepository, ArtifactMetadataSource source ) throws ArtifactResolutionException, ArtifactNotFoundException { return super.resolveTransitively( artifacts, originatingArtifact, remoteRepositories, localRepository, new Source( artifactFactory, repositoryFactory, container ) ); } public void contextualize( Context context ) throws ContextException { container = (PlexusContainer) context.get( PlexusConstants.PLEXUS_KEY ); } }maven2-core-2.2.1/maven-project/src/main/0000755000175000017500000000000011250552246020057 5ustar twernertwernermaven2-core-2.2.1/maven-project/src/main/resources/0000755000175000017500000000000011250552246022071 5ustar twernertwernermaven2-core-2.2.1/maven-project/src/main/resources/org/0000755000175000017500000000000011250552246022660 5ustar twernertwernermaven2-core-2.2.1/maven-project/src/main/resources/org/apache/0000755000175000017500000000000011250552246024101 5ustar twernertwernermaven2-core-2.2.1/maven-project/src/main/resources/org/apache/maven/0000755000175000017500000000000011250552246025207 5ustar twernertwernermaven2-core-2.2.1/maven-project/src/main/resources/org/apache/maven/project/0000755000175000017500000000000011250552246026655 5ustar twernertwernermaven2-core-2.2.1/maven-project/src/main/resources/org/apache/maven/project/pom-4.0.0.xml0000644000175000017500000001500511122105061030613 0ustar twernertwerner 4.0.0 Maven Default Project central Maven Repository Switchboard default http://repo1.maven.org/maven2 false central Maven Plugin Repository http://repo1.maven.org/maven2 default false never ${project.basedir}/target ${project.build.directory}/classes ${project.artifactId}-${project.version} ${project.build.directory}/test-classes ${project.basedir}/src/main/java src/main/scripts ${project.basedir}/src/test/java ${project.basedir}/src/main/resources ${project.basedir}/src/test/resources maven-antrun-plugin 1.3 maven-assembly-plugin 2.2-beta-2 maven-clean-plugin 2.2 maven-compiler-plugin 2.0.2 maven-dependency-plugin 2.0 maven-deploy-plugin 2.4 maven-ear-plugin 2.3.1 maven-ejb-plugin 2.1 maven-install-plugin 2.2 maven-jar-plugin 2.2 maven-javadoc-plugin 2.5 maven-plugin-plugin 2.4.3 maven-rar-plugin 2.2 maven-release-plugin 2.0-beta-8 maven-resources-plugin 2.3 maven-site-plugin 2.0-beta-7 maven-source-plugin 2.0.4 maven-surefire-plugin 2.4.3 maven-war-plugin 2.1-alpha-2 ${project.build.directory}/site release-profile performRelease true true org.apache.maven.plugins maven-source-plugin attach-sources jar true org.apache.maven.plugins maven-javadoc-plugin attach-javadocs jar true org.apache.maven.plugins maven-deploy-plugin true maven2-core-2.2.1/maven-project/src/main/resources/META-INF/0000755000175000017500000000000011250552246023231 5ustar twernertwernermaven2-core-2.2.1/maven-project/src/main/resources/META-INF/plexus/0000755000175000017500000000000011250552246024551 5ustar twernertwernermaven2-core-2.2.1/maven-project/src/main/resources/META-INF/plexus/components.xml0000644000175000017500000001570611221205616027463 0ustar twernertwerner org.apache.maven.project.artifact.ProjectArtifactFactory maven-project org.apache.maven.project.artifact.ProjectArtifactFactory org.apache.maven.artifact.handler.manager.ArtifactHandlerManager org.apache.maven.project.MavenProjectHelper org.apache.maven.project.DefaultMavenProjectHelper org.apache.maven.artifact.handler.manager.ArtifactHandlerManager org.apache.maven.project.interpolation.ModelInterpolator org.apache.maven.project.interpolation.StringSearchModelInterpolator org.apache.maven.project.path.PathTranslator org.apache.maven.project.injection.ModelDefaultsInjector org.apache.maven.project.injection.DefaultModelDefaultsInjector org.apache.maven.project.injection.ProfileInjector org.apache.maven.project.injection.DefaultProfileInjector org.apache.maven.project.MavenProjectBuilder org.apache.maven.project.DefaultMavenProjectBuilder org.apache.maven.profiles.MavenProfilesBuilder org.apache.maven.project.injection.ProfileInjector org.apache.maven.project.injection.ModelDefaultsInjector org.apache.maven.project.interpolation.ModelInterpolator org.apache.maven.project.inheritance.ModelInheritanceAssembler org.apache.maven.project.validation.ModelValidator org.apache.maven.project.path.PathTranslator org.apache.maven.project.artifact.ProjectArtifactFactory maven-project org.apache.maven.artifact.resolver.ArtifactResolver org.apache.maven.artifact.repository.ArtifactRepositoryFactory org.apache.maven.artifact.manager.WagonManager org.apache.maven.profiles.activation.ProfileActivator always-on org.apache.maven.profiles.activation.AlwaysOnProfileActivator org.apache.maven.profiles.activation.ProfileActivator jdk-prefix org.apache.maven.profiles.activation.JdkPrefixProfileActivator org.apache.maven.profiles.activation.ProfileActivator system-property org.apache.maven.profiles.activation.SystemPropertyProfileActivator org.apache.maven.profiles.activation.ProfileActivator os org.apache.maven.profiles.activation.OperatingSystemProfileActivator org.apache.maven.profiles.activation.ProfileActivator file org.apache.maven.profiles.activation.FileProfileActivator org.apache.maven.project.inheritance.ModelInheritanceAssembler org.apache.maven.project.inheritance.DefaultModelInheritanceAssembler org.apache.maven.project.validation.ModelValidator org.apache.maven.project.validation.DefaultModelValidator org.apache.maven.project.path.PathTranslator org.apache.maven.project.path.DefaultPathTranslator org.apache.maven.artifact.metadata.ArtifactMetadataSource maven org.apache.maven.project.artifact.MavenMetadataSource org.apache.maven.project.MavenProjectBuilder org.apache.maven.artifact.factory.ArtifactFactory org.apache.maven.artifact.repository.metadata.RepositoryMetadataManager maven2-core-2.2.1/maven-project/src/main/java/0000755000175000017500000000000011250552245020777 5ustar twernertwernermaven2-core-2.2.1/maven-project/src/main/java/org/0000755000175000017500000000000011250552245021566 5ustar twernertwernermaven2-core-2.2.1/maven-project/src/main/java/org/apache/0000755000175000017500000000000011250552245023007 5ustar twernertwernermaven2-core-2.2.1/maven-project/src/main/java/org/apache/maven/0000755000175000017500000000000011250552245024115 5ustar twernertwernermaven2-core-2.2.1/maven-project/src/main/java/org/apache/maven/profiles/0000755000175000017500000000000011250552245025740 5ustar twernertwernermaven2-core-2.2.1/maven-project/src/main/java/org/apache/maven/profiles/ProfileManager.java0000644000175000017500000000333210773027063031503 0ustar twernertwernerpackage org.apache.maven.profiles; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import org.apache.maven.model.Profile; import org.apache.maven.profiles.activation.ProfileActivationException; import org.apache.maven.settings.Settings; import java.util.List; import java.util.Map; import java.util.Properties; public interface ProfileManager { void addProfile( Profile profile ); void explicitlyActivate( String profileId ); void explicitlyActivate( List profileIds ); void explicitlyDeactivate( String profileId ); void explicitlyDeactivate( List profileIds ); void activateAsDefault( String profileId ); List getActiveProfiles() throws ProfileActivationException; void addProfiles( List profiles ); Map getProfilesById(); List getExplicitlyActivatedIds(); List getExplicitlyDeactivatedIds(); List getIdsActivatedByDefault(); void loadSettingsProfiles( Settings settings ); Properties getRequestProperties(); }maven2-core-2.2.1/maven-project/src/main/java/org/apache/maven/profiles/activation/0000755000175000017500000000000011250552245030101 5ustar twernertwerner././@LongLink0000000000000000000000000000015500000000000011566 Lustar rootrootmaven2-core-2.2.1/maven-project/src/main/java/org/apache/maven/profiles/activation/FileProfileActivator.javamaven2-core-2.2.1/maven-project/src/main/java/org/apache/maven/profiles/activation/FileProfileActiva0000644000175000017500000000737711035430171033364 0ustar twernertwernerpackage org.apache.maven.profiles.activation; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import java.io.IOException; import org.apache.maven.model.Activation; import org.apache.maven.model.ActivationFile; import org.apache.maven.model.Profile; import org.codehaus.plexus.interpolation.EnvarBasedValueSource; import org.codehaus.plexus.interpolation.InterpolationException; import org.codehaus.plexus.interpolation.MapBasedValueSource; import org.codehaus.plexus.interpolation.RegexBasedInterpolator; import org.codehaus.plexus.logging.LogEnabled; import org.codehaus.plexus.logging.Logger; import org.codehaus.plexus.util.FileUtils; import org.codehaus.plexus.util.StringUtils; public class FileProfileActivator extends DetectedProfileActivator implements LogEnabled { private Logger logger; protected boolean canDetectActivation( Profile profile ) { return profile.getActivation() != null && profile.getActivation().getFile() != null; } public boolean isActive( Profile profile ) { Activation activation = profile.getActivation(); ActivationFile actFile = activation.getFile(); if ( actFile != null ) { // check if the file exists, if it does then the profile will be active String fileString = actFile.getExists(); RegexBasedInterpolator interpolator = new RegexBasedInterpolator(); try { interpolator.addValueSource( new EnvarBasedValueSource() ); } catch ( IOException e ) { // ignored } interpolator.addValueSource( new MapBasedValueSource( System.getProperties() ) ); try { if ( StringUtils.isNotEmpty( fileString ) ) { fileString = StringUtils.replace( interpolator.interpolate( fileString, "" ), "\\", "/" ); return FileUtils.fileExists( fileString ); } // check if the file is missing, if it is then the profile will be active fileString = actFile.getMissing(); if ( StringUtils.isNotEmpty( fileString ) ) { fileString = StringUtils.replace( interpolator.interpolate( fileString, "" ), "\\", "/" ); return !FileUtils.fileExists( fileString ); } } catch ( InterpolationException e ) { if ( logger.isDebugEnabled() ) { logger.debug( "Failed to interpolate missing file location for profile activator: " + fileString, e ); } else { logger.warn( "Failed to interpolate missing file location for profile activator: " + fileString + ". Run in debug mode (-X) for more information." ); } } } return false; } public void enableLogging( Logger logger ) { this.logger = logger; } } ././@LongLink0000000000000000000000000000016100000000000011563 Lustar rootrootmaven2-core-2.2.1/maven-project/src/main/java/org/apache/maven/profiles/activation/DetectedProfileActivator.javamaven2-core-2.2.1/maven-project/src/main/java/org/apache/maven/profiles/activation/DetectedProfileAc0000644000175000017500000000222310772004567033340 0ustar twernertwernerpackage org.apache.maven.profiles.activation; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import org.apache.maven.model.Profile; public abstract class DetectedProfileActivator implements ProfileActivator { public boolean canDetermineActivation( Profile profile ) { return canDetectActivation( profile ); } protected abstract boolean canDetectActivation( Profile profile ); } ././@LongLink0000000000000000000000000000015100000000000011562 Lustar rootrootmaven2-core-2.2.1/maven-project/src/main/java/org/apache/maven/profiles/activation/ProfileActivator.javamaven2-core-2.2.1/maven-project/src/main/java/org/apache/maven/profiles/activation/ProfileActivator.0000644000175000017500000000216211140213732033351 0ustar twernertwernerpackage org.apache.maven.profiles.activation; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import org.apache.maven.model.Profile; public interface ProfileActivator { static final String ROLE = ProfileActivator.class.getName(); boolean canDetermineActivation( Profile profile ); boolean isActive( Profile profile ) throws ProfileActivationException; } ././@LongLink0000000000000000000000000000016200000000000011564 Lustar rootrootmaven2-core-2.2.1/maven-project/src/main/java/org/apache/maven/profiles/activation/JdkPrefixProfileActivator.javamaven2-core-2.2.1/maven-project/src/main/java/org/apache/maven/profiles/activation/JdkPrefixProfileA0000644000175000017500000000642411142322117033333 0ustar twernertwernerpackage org.apache.maven.profiles.activation; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import org.apache.maven.artifact.versioning.DefaultArtifactVersion; import org.apache.maven.artifact.versioning.InvalidVersionSpecificationException; import org.apache.maven.artifact.versioning.VersionRange; import org.apache.maven.model.Activation; import org.apache.maven.model.Profile; import org.codehaus.plexus.util.StringUtils; public class JdkPrefixProfileActivator extends DetectedProfileActivator { private static final String JDK_VERSION = System.getProperty( "java.version" ); public boolean isActive( Profile profile ) throws ProfileActivationException { Activation activation = profile.getActivation(); String jdk = activation.getJdk(); // null case is covered by canDetermineActivation(), so we can do a straight startsWith() here. if ( jdk.startsWith( "[" ) || jdk.startsWith( "(" ) ) { try { if ( matchJdkVersionRange( jdk ) ) { return true; } else { return false; } } catch ( InvalidVersionSpecificationException e ) { throw new ProfileActivationException( "Invalid JDK version in profile '" + profile.getId() + "': " + e.getMessage() ); } } boolean reverse = false; if ( jdk.startsWith( "!" ) ) { reverse = true; jdk = jdk.substring( 1 ); } if ( getJdkVersion().startsWith( jdk ) ) { return !reverse; } else { return reverse; } } private boolean matchJdkVersionRange( String jdk ) throws InvalidVersionSpecificationException { VersionRange jdkVersionRange = VersionRange.createFromVersionSpec( convertJdkToMavenVersion( jdk ) ); DefaultArtifactVersion jdkVersion = new DefaultArtifactVersion( convertJdkToMavenVersion( getJdkVersion() ) ); return jdkVersionRange.containsVersion( jdkVersion ); } private String convertJdkToMavenVersion( String jdk ) { return jdk.replaceAll( "_", "-" ); } protected String getJdkVersion() { return JDK_VERSION; } protected boolean canDetectActivation( Profile profile ) { return profile.getActivation() != null && StringUtils.isNotEmpty( profile.getActivation().getJdk() ); } } ././@LongLink0000000000000000000000000000016700000000000011571 Lustar rootrootmaven2-core-2.2.1/maven-project/src/main/java/org/apache/maven/profiles/activation/SystemPropertyProfileActivator.javamaven2-core-2.2.1/maven-project/src/main/java/org/apache/maven/profiles/activation/SystemPropertyPro0000644000175000017500000000707211140213732033535 0ustar twernertwernerpackage org.apache.maven.profiles.activation; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import java.util.Properties; import org.apache.maven.model.Activation; import org.apache.maven.model.ActivationProperty; import org.apache.maven.model.Profile; import org.codehaus.plexus.context.Context; import org.codehaus.plexus.context.ContextException; import org.codehaus.plexus.personality.plexus.lifecycle.phase.Contextualizable; import org.codehaus.plexus.util.StringUtils; public class SystemPropertyProfileActivator extends DetectedProfileActivator implements Contextualizable { private Properties properties; public void contextualize(Context context) throws ContextException { properties = (Properties)context.get("SystemProperties"); } protected boolean canDetectActivation( Profile profile ) { return profile.getActivation() != null && profile.getActivation().getProperty() != null; } public boolean isActive( Profile profile ) throws ProfileActivationException { Activation activation = profile.getActivation(); ActivationProperty property = activation.getProperty(); if ( property != null ) { String name = property.getName(); boolean reverseName = false; if ( name == null ) { throw new ProfileActivationException( "The property name is required to activate the profile '" + profile.getId() + "'" ); } if ( name.startsWith("!") ) { reverseName = true; name = name.substring( 1 ); } String sysValue = properties.getProperty( name ); String propValue = property.getValue(); if ( StringUtils.isNotEmpty( propValue ) ) { boolean reverseValue = false; if ( propValue.startsWith( "!" ) ) { reverseValue = true; propValue = propValue.substring( 1 ); } // we have a value, so it has to match the system value... boolean result = propValue.equals( sysValue ); if ( reverseValue ) { return !result; } else { return result; } } else { boolean result = StringUtils.isNotEmpty( sysValue ); if ( reverseName ) { return !result; } else { return result; } } } return false; } } ././@LongLink0000000000000000000000000000016300000000000011565 Lustar rootrootmaven2-core-2.2.1/maven-project/src/main/java/org/apache/maven/profiles/activation/ProfileActivationException.javamaven2-core-2.2.1/maven-project/src/main/java/org/apache/maven/profiles/activation/ProfileActivation0000644000175000017500000000216010772004567033454 0ustar twernertwernerpackage org.apache.maven.profiles.activation; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ public class ProfileActivationException extends Exception { public ProfileActivationException( String message, Throwable cause ) { super( message, cause ); } public ProfileActivationException( String message ) { super( message ); } } ././@LongLink0000000000000000000000000000017000000000000011563 Lustar rootrootmaven2-core-2.2.1/maven-project/src/main/java/org/apache/maven/profiles/activation/OperatingSystemProfileActivator.javamaven2-core-2.2.1/maven-project/src/main/java/org/apache/maven/profiles/activation/OperatingSystemPr0000644000175000017500000000774010772004567033502 0ustar twernertwernerpackage org.apache.maven.profiles.activation; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import org.apache.maven.model.Activation; import org.apache.maven.model.ActivationOS; import org.apache.maven.model.Profile; import org.codehaus.plexus.util.Os; public class OperatingSystemProfileActivator implements ProfileActivator { public boolean canDetermineActivation( Profile profile ) { Activation activation = profile.getActivation(); return activation != null && activation.getOs() != null; } public boolean isActive( Profile profile ) { Activation activation = profile.getActivation(); ActivationOS os = activation.getOs(); boolean result = ensureAtLeastOneNonNull( os ); if ( result && os.getFamily() != null ) { result = determineFamilyMatch( os.getFamily() ); } if ( result && os.getName() != null ) { result = determineNameMatch( os.getName() ); } if ( result && os.getArch() != null ) { result = determineArchMatch( os.getArch() ); } if ( result && os.getVersion() != null ) { result = determineVersionMatch( os.getVersion() ); } return result; } private boolean ensureAtLeastOneNonNull( ActivationOS os ) { return os.getArch() != null || os.getFamily() != null || os.getName() != null || os.getVersion() != null; } private boolean determineVersionMatch( String version ) { String test = version; boolean reverse = false; if ( test.startsWith( "!" ) ) { reverse = true; test = test.substring( 1 ); } boolean result = Os.isVersion( test ); if ( reverse ) { return !result; } else { return result; } } private boolean determineArchMatch( String arch ) { String test = arch; boolean reverse = false; if ( test.startsWith( "!" ) ) { reverse = true; test = test.substring( 1 ); } boolean result = Os.isArch( test ); if ( reverse ) { return !result; } else { return result; } } private boolean determineNameMatch( String name ) { String test = name; boolean reverse = false; if ( test.startsWith( "!" ) ) { reverse = true; test = test.substring( 1 ); } boolean result = Os.isName( test ); if ( reverse ) { return !result; } else { return result; } } private boolean determineFamilyMatch( String family ) { String test = family; boolean reverse = false; if ( test.startsWith( "!" ) ) { reverse = true; test = test.substring( 1 ); } boolean result = Os.isFamily( test ); if ( reverse ) { return !result; } else { return result; } } } ././@LongLink0000000000000000000000000000016100000000000011563 Lustar rootrootmaven2-core-2.2.1/maven-project/src/main/java/org/apache/maven/profiles/activation/AlwaysOnProfileActivator.javamaven2-core-2.2.1/maven-project/src/main/java/org/apache/maven/profiles/activation/AlwaysOnProfileAc0000644000175000017500000000240110772004567033352 0ustar twernertwernerpackage org.apache.maven.profiles.activation; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import org.apache.maven.model.Profile; import org.apache.maven.profiles.AlwaysOnActivation; public class AlwaysOnProfileActivator implements ProfileActivator { public boolean canDetermineActivation( Profile profile ) { return profile.getActivation() != null && profile.getActivation() instanceof AlwaysOnActivation; } public boolean isActive( Profile profile ) { return true; } } maven2-core-2.2.1/maven-project/src/main/java/org/apache/maven/profiles/DefaultProfileManager.java0000644000175000017500000002517511013117066033010 0ustar twernertwernerpackage org.apache.maven.profiles; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import org.apache.maven.model.Activation; import org.apache.maven.model.Profile; import org.apache.maven.profiles.activation.ProfileActivationException; import org.apache.maven.profiles.activation.ProfileActivator; import org.apache.maven.settings.Settings; import org.apache.maven.settings.SettingsUtils; import org.codehaus.plexus.PlexusContainer; import org.codehaus.plexus.component.repository.exception.ComponentLifecycleException; import org.codehaus.plexus.component.repository.exception.ComponentLookupException; import java.util.ArrayList; import java.util.Iterator; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; import java.util.Properties; import java.util.Map.Entry; public class DefaultProfileManager implements ProfileManager { private PlexusContainer container; private List activatedIds = new ArrayList(); private List deactivatedIds = new ArrayList(); private List defaultIds = new ArrayList(); private Map profilesById = new LinkedHashMap(); private Properties requestProperties; /** * @deprecated without passing in the system properties, the SystemPropertiesProfileActivator will not work correctly * in embedded envirnments. */ public DefaultProfileManager( PlexusContainer container ) { this( container, (Settings)null); } /** * the properties passed to the profile manager are the props that * are passed to maven, possibly containing profile activator properties * */ public DefaultProfileManager( PlexusContainer container, Properties props ) { this( container, (Settings)null, props ); } /** * @deprecated without passing in the system properties, the SystemPropertiesProfileActivator will not work correctly * in embedded envirnments. */ public DefaultProfileManager( PlexusContainer container, Settings settings ) { this.container = container; loadSettingsProfiles( settings ); } /** * the properties passed to the profile manager are the props that * are passed to maven, possibly containing profile activator properties * */ public DefaultProfileManager( PlexusContainer container, Settings settings, Properties props ) { this.container = container; loadSettingsProfiles( settings ); if ( props != null ) { requestProperties = props; } } public Properties getRequestProperties() { return requestProperties; } public Map getProfilesById() { return profilesById; } /* (non-Javadoc) * @see org.apache.maven.profiles.ProfileManager#addProfile(org.apache.maven.model.Profile) */ public void addProfile( Profile profile ) { String profileId = profile.getId(); Profile existing = (Profile) profilesById.get( profileId ); if ( existing != null ) { container.getLogger().warn( "Overriding profile: \'" + profileId + "\' (source: " + existing.getSource() + ") with new instance from source: " + profile.getSource() ); } profilesById.put( profile.getId(), profile ); Activation activation = profile.getActivation(); if ( activation != null && activation.isActiveByDefault() ) { activateAsDefault( profileId ); } } /* (non-Javadoc) * @see org.apache.maven.profiles.ProfileManager#explicitlyActivate(java.lang.String) */ public void explicitlyActivate( String profileId ) { if ( !activatedIds.contains( profileId ) ) { container.getLogger().debug( "Profile with id: \'" + profileId + "\' has been explicitly activated." ); activatedIds.add( profileId ); } } /* (non-Javadoc) * @see org.apache.maven.profiles.ProfileManager#explicitlyActivate(java.util.List) */ public void explicitlyActivate( List profileIds ) { for ( Iterator it = profileIds.iterator(); it.hasNext(); ) { String profileId = (String) it.next(); explicitlyActivate( profileId ); } } /* (non-Javadoc) * @see org.apache.maven.profiles.ProfileManager#explicitlyDeactivate(java.lang.String) */ public void explicitlyDeactivate( String profileId ) { if ( !deactivatedIds.contains( profileId ) ) { container.getLogger().debug( "Profile with id: \'" + profileId + "\' has been explicitly deactivated." ); deactivatedIds.add( profileId ); } } /* (non-Javadoc) * @see org.apache.maven.profiles.ProfileManager#explicitlyDeactivate(java.util.List) */ public void explicitlyDeactivate( List profileIds ) { for ( Iterator it = profileIds.iterator(); it.hasNext(); ) { String profileId = (String) it.next(); explicitlyDeactivate( profileId ); } } /* (non-Javadoc) * @see org.apache.maven.profiles.ProfileManager#getActiveProfiles() */ public List getActiveProfiles() throws ProfileActivationException { List activeFromPom = new ArrayList(); List activeExternal = new ArrayList(); for ( Iterator it = profilesById.entrySet().iterator(); it.hasNext(); ) { Map.Entry entry = (Entry) it.next(); String profileId = (String) entry.getKey(); Profile profile = (Profile) entry.getValue(); boolean shouldAdd = false; if ( activatedIds.contains( profileId ) ) { shouldAdd = true; } else if ( isActive( profile ) ) { shouldAdd = true; } if ( !deactivatedIds.contains( profileId ) && shouldAdd ) { if ( "pom".equals( profile.getSource() ) ) { activeFromPom.add( profile ); } else { activeExternal.add( profile ); } } } if ( activeFromPom.isEmpty() ) { for ( Iterator it = defaultIds.iterator(); it.hasNext(); ) { String profileId = (String) it.next(); if ( deactivatedIds.contains( profileId ) ) { continue; } Profile profile = (Profile) profilesById.get( profileId ); activeFromPom.add( profile ); } } List allActive = new ArrayList( activeFromPom.size() + activeExternal.size() ); allActive.addAll( activeExternal ); allActive.addAll( activeFromPom ); return allActive; } private boolean isActive( Profile profile ) throws ProfileActivationException { List activators = null; Properties systemProperties = new Properties( System.getProperties() ); if ( requestProperties != null ) { systemProperties.putAll( requestProperties ); } container.addContextValue("SystemProperties", systemProperties); try { activators = container.lookupList( ProfileActivator.ROLE ); for ( Iterator activatorIterator = activators.iterator(); activatorIterator.hasNext(); ) { ProfileActivator activator = (ProfileActivator) activatorIterator.next(); if ( activator.canDetermineActivation( profile ) ) { if ( activator.isActive( profile ) ) { return true; } } } return false; } catch ( ComponentLookupException e ) { throw new ProfileActivationException( "Cannot retrieve list of profile activators.", e ); } finally { container.getContext().put("SystemProperties", null); if ( activators != null ) { try { container.releaseAll( activators ); } catch ( ComponentLifecycleException e ) { container.getLogger().debug( "Error releasing profile activators - ignoring.", e ); } } } } /* (non-Javadoc) * @see org.apache.maven.profiles.ProfileManager#addProfiles(java.util.List) */ public void addProfiles( List profiles ) { for ( Iterator it = profiles.iterator(); it.hasNext(); ) { Profile profile = (Profile) it.next(); addProfile( profile ); } } public void activateAsDefault( String profileId ) { if ( !defaultIds.contains( profileId ) ) { defaultIds.add( profileId ); } } public List getExplicitlyActivatedIds() { return activatedIds; } public List getExplicitlyDeactivatedIds() { return deactivatedIds; } public List getIdsActivatedByDefault() { return defaultIds; } public void loadSettingsProfiles( Settings settings ) { if ( settings == null ) { return; } List settingsProfiles = settings.getProfiles(); List settingsActiveProfileIds = settings.getActiveProfiles(); explicitlyActivate( settingsActiveProfileIds ); if ( settingsProfiles != null && !settingsProfiles.isEmpty() ) { for ( Iterator it = settings.getProfiles().iterator(); it.hasNext(); ) { org.apache.maven.settings.Profile rawProfile = (org.apache.maven.settings.Profile) it.next(); Profile profile = SettingsUtils.convertFromSettingsProfile( rawProfile ); addProfile( profile ); } } } } maven2-core-2.2.1/maven-project/src/main/java/org/apache/maven/project/0000755000175000017500000000000011250552246025564 5ustar twernertwernermaven2-core-2.2.1/maven-project/src/main/java/org/apache/maven/project/ModelUtils.java0000644000175000017500000014240111151515456030514 0ustar twernertwernerpackage org.apache.maven.project; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import java.util.ArrayList; import java.util.Enumeration; import java.util.Iterator; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; import java.util.Properties; import java.util.TreeMap; import org.apache.maven.model.Activation; import org.apache.maven.model.ActivationFile; import org.apache.maven.model.ActivationOS; import org.apache.maven.model.ActivationProperty; import org.apache.maven.model.Build; import org.apache.maven.model.BuildBase; import org.apache.maven.model.CiManagement; import org.apache.maven.model.Contributor; import org.apache.maven.model.Dependency; import org.apache.maven.model.DependencyManagement; import org.apache.maven.model.DeploymentRepository; import org.apache.maven.model.Developer; import org.apache.maven.model.DistributionManagement; import org.apache.maven.model.Exclusion; import org.apache.maven.model.Extension; import org.apache.maven.model.IssueManagement; import org.apache.maven.model.License; import org.apache.maven.model.MailingList; import org.apache.maven.model.Model; import org.apache.maven.model.ModelBase; import org.apache.maven.model.Notifier; import org.apache.maven.model.Organization; import org.apache.maven.model.Parent; import org.apache.maven.model.Plugin; import org.apache.maven.model.PluginContainer; import org.apache.maven.model.PluginExecution; import org.apache.maven.model.PluginManagement; import org.apache.maven.model.Prerequisites; import org.apache.maven.model.Profile; import org.apache.maven.model.Relocation; import org.apache.maven.model.ReportPlugin; import org.apache.maven.model.ReportSet; import org.apache.maven.model.Reporting; import org.apache.maven.model.Repository; import org.apache.maven.model.RepositoryBase; import org.apache.maven.model.RepositoryPolicy; import org.apache.maven.model.Resource; import org.apache.maven.model.Scm; import org.apache.maven.model.Site; import org.codehaus.plexus.util.xml.Xpp3Dom; public final class ModelUtils { private static final ModelPartCloner DEPENDENCY_CLONER = new ModelPartCloner() { public Object cloneModelPart( Object src ) { return ModelUtils.cloneDependency( (Dependency) src ); } }; private static final ModelPartCloner PLUGIN_CLONER = new ModelPartCloner() { public Object cloneModelPart( Object src ) { return ModelUtils.clonePlugin( (Plugin) src ); } }; private static final ModelPartCloner EXTENSION_CLONER = new ModelPartCloner() { public Object cloneModelPart( Object src ) { return ModelUtils.cloneExtension( (Extension) src ); } }; private static final ModelPartCloner RESOURCE_CLONER = new ModelPartCloner() { public Object cloneModelPart( Object src ) { return ModelUtils.cloneResource( (Resource) src ); } }; private static final ModelPartCloner NOTIFIER_CLONER = new ModelPartCloner() { public Object cloneModelPart( Object src ) { return ModelUtils.cloneNotifier( (Notifier) src ); } }; private static final ModelPartCloner CONTRIBUTOR_CLONER = new ModelPartCloner() { public Object cloneModelPart( Object src ) { return ModelUtils.cloneContributor( (Contributor) src ); } }; private static final ModelPartCloner DEVELOPER_CLONER = new ModelPartCloner() { public Object cloneModelPart( Object src ) { return ModelUtils.cloneDeveloper( (Developer) src ); } }; private static final ModelPartCloner LICENSE_CLONER = new ModelPartCloner() { public Object cloneModelPart( Object src ) { return ModelUtils.cloneLicense( (License) src ); } }; private static final ModelPartCloner MAILING_LIST_CLONER = new ModelPartCloner() { public Object cloneModelPart( Object src ) { return ModelUtils.cloneMailingList( (MailingList) src ); } }; private static final ModelPartCloner REPOSITORY_CLONER = new ModelPartCloner() { public Object cloneModelPart( Object src ) { return ModelUtils.cloneRepository( (Repository) src ); } }; private static final ModelPartCloner PROFILE_CLONER = new ModelPartCloner() { public Object cloneModelPart( Object src ) { return ModelUtils.cloneProfile( (Profile) src ); } }; private static final ModelPartCloner REPORT_PLUGIN_CLONER = new ModelPartCloner() { public Object cloneModelPart( Object src ) { return ModelUtils.cloneReportPlugin( (ReportPlugin) src ); } }; private static final ModelPartCloner REPORT_SET_CLONER = new ModelPartCloner() { public Object cloneModelPart( Object src ) { return ModelUtils.cloneReportSet( (ReportSet) src ); } }; private static final ModelPartCloner DEPENDENCY_EXCLUSION_CLONER = new ModelPartCloner() { public Object cloneModelPart( Object src ) { return ModelUtils.cloneExclusion( (Exclusion) src ); } }; private static final ModelPartCloner PLUGIN_EXECUTION_CLONER = new ModelPartCloner() { public Object cloneModelPart( Object src ) { return ModelUtils.clonePluginExecution( (PluginExecution) src ); } }; /** * Given this plugin list: * * A1 -> B -> C -> A2 -> D * * Rearrange it to this: * * A(A1 + A2) -> B -> C -> D * * In cases of overlapping definitions, A1 is overridden by A2 * */ public static void mergeDuplicatePluginDefinitions( PluginContainer pluginContainer ) { if ( pluginContainer == null ) { return; } List originalPlugins = pluginContainer.getPlugins(); if ( ( originalPlugins == null ) || originalPlugins.isEmpty() ) { return; } List normalized = new ArrayList( originalPlugins.size() ); for ( Iterator it = originalPlugins.iterator(); it.hasNext(); ) { Plugin currentPlugin = (Plugin) it.next(); if ( normalized.contains( currentPlugin ) ) { int idx = normalized.indexOf( currentPlugin ); Plugin firstPlugin = (Plugin) normalized.get( idx ); // MNG-3719: merge currentPlugin with firstPlugin as parent, // then use updated currentPlugin as new parent mergePluginDefinitions( currentPlugin, firstPlugin, false ); normalized.set(idx, currentPlugin); } else { normalized.add( currentPlugin ); } } pluginContainer.setPlugins( normalized ); } public static ReportSet cloneReportSet( ReportSet src ) { if ( src == null ) { return null; } ReportSet result = new ReportSet(); result.setConfiguration( cloneConfiguration( src.getConfiguration() ) ); result.setId( src.getId() ); result.setInherited( src.getInherited() ); result.setReports( cloneListOfStrings( src.getReports() ) ); return result; } public static ReportPlugin cloneReportPlugin( ReportPlugin src ) { if ( src == null ) { return null; } ReportPlugin result = new ReportPlugin(); result.setArtifactId( src.getArtifactId() ); result.setConfiguration( cloneConfiguration( src.getConfiguration() ) ); result.setGroupId( src.getGroupId() ); result.setInherited( src.getInherited() ); result.setReportSets( cloneList( src.getReportSets(), REPORT_SET_CLONER ) ); result.setVersion( src.getVersion() ); return result; } public static Profile cloneProfile( Profile src ) { if ( src == null ) { return null; } Profile result = new Profile(); cloneModelBaseFields( src, result ); result.setActivation( cloneActivation( src.getActivation() ) ); BuildBase resultBuild = null; if ( src.getBuild() != null ) { resultBuild = new BuildBase(); cloneBuildBaseFields( src.getBuild(), resultBuild ); } result.setBuild( resultBuild ); result.setId( src.getId() ); result.setSource( src.getSource() ); return result; } private static void cloneModelBaseFields( ModelBase src, ModelBase result ) { result.setDependencies( cloneList( src.getDependencies(), DEPENDENCY_CLONER ) ); result.setDependencyManagement( cloneDependencyManagement( src.getDependencyManagement() ) ); result.setDistributionManagement( cloneDistributionManagement( src.getDistributionManagement() ) ); result.setModules( cloneListOfStrings( src.getModules() ) ); result.setPluginRepositories( cloneList( src.getPluginRepositories(), REPOSITORY_CLONER ) ); result.setProperties( cloneProperties( src.getProperties() ) ); result.setReporting( cloneReporting( src.getReporting() ) ); result.setRepositories( cloneList( src.getRepositories(), REPOSITORY_CLONER ) ); } public static Reporting cloneReporting( Reporting src ) { if ( src == null ) { return null; } Reporting result = new Reporting(); result.setExcludeDefaults( src.isExcludeDefaults() ); result.setOutputDirectory( src.getOutputDirectory() ); result.setPlugins( cloneList( src.getPlugins(), REPORT_PLUGIN_CLONER ) ); return result; } public static Activation cloneActivation( Activation src ) { if ( src == null ) { return null; } Activation result = new Activation(); result.setActiveByDefault( src.isActiveByDefault() ); result.setFile( cloneActivationFile( src.getFile() ) ); result.setJdk( src.getJdk() ); result.setOs( cloneActivationOs( src.getOs() ) ); result.setProperty( cloneActivationProperty( src.getProperty() ) ); return result; } public static ActivationProperty cloneActivationProperty( ActivationProperty src ) { if ( src == null ) { return null; } ActivationProperty result = new ActivationProperty(); result.setName( src.getName() ); result.setValue( src.getValue() ); return result; } public static ActivationOS cloneActivationOs( ActivationOS src ) { if ( src == null ) { return null; } ActivationOS result = new ActivationOS(); result.setArch( src.getArch() ); result.setFamily( src.getFamily() ); result.setName( src.getName() ); result.setVersion( src.getVersion() ); return result; } public static ActivationFile cloneActivationFile( ActivationFile src ) { if ( src == null ) { return null; } ActivationFile result = new ActivationFile(); result.setExists( src.getExists() ); result.setMissing( src.getMissing() ); return result; } public static Repository cloneRepository( Repository src ) { if ( src == null ) { return null; } Repository result = new Repository(); result.setReleases( cloneRepositoryPolicy( src.getReleases() ) ); result.setSnapshots( cloneRepositoryPolicy( src.getSnapshots() ) ); cloneRepositoryBaseFields( src, result ); return result; } public static RepositoryPolicy cloneRepositoryPolicy( RepositoryPolicy src ) { if ( src == null ) { return null; } RepositoryPolicy result = new RepositoryPolicy(); result.setChecksumPolicy( src.getChecksumPolicy() ); result.setEnabled( src.isEnabled() ); result.setUpdatePolicy( src.getUpdatePolicy() ); return result; } public static MailingList cloneMailingList( MailingList src ) { if ( src == null ) { return null; } MailingList result = new MailingList(); result.setArchive( src.getArchive() ); result.setName( src.getName() ); result.setOtherArchives( src.getOtherArchives() ); result.setPost( src.getPost() ); result.setSubscribe( src.getSubscribe() ); result.setUnsubscribe( src.getUnsubscribe() ); return result; } /** * This should be the resulting ordering of plugins after merging: * * Given: * * parent: X -> A -> B -> D -> E * child: Y -> A -> C -> D -> F * * Result: * * X -> Y -> A -> B -> C -> D -> E -> F */ public static void mergePluginLists( PluginContainer child, PluginContainer parent, boolean handleAsInheritance ) { if ( ( child == null ) || ( parent == null ) ) { // nothing to do. return; } List parentPlugins = parent.getPlugins(); if ( ( parentPlugins != null ) && !parentPlugins.isEmpty() ) { parentPlugins = new ArrayList( parentPlugins ); // If we're processing this merge as an inheritance, we have to build up a list of // plugins that were considered for inheritance. if ( handleAsInheritance ) { for ( Iterator it = parentPlugins.iterator(); it.hasNext(); ) { Plugin plugin = (Plugin) it.next(); String inherited = plugin.getInherited(); if ( ( inherited != null ) && !Boolean.valueOf( inherited ).booleanValue() ) { it.remove(); } } } List assembledPlugins = new ArrayList(); Map childPlugins = child.getPluginsAsMap(); for ( Iterator it = parentPlugins.iterator(); it.hasNext(); ) { Plugin parentPlugin = (Plugin) it.next(); String parentInherited = parentPlugin.getInherited(); // only merge plugin definition from the parent if at least one // of these is true: // 1. we're not processing the plugins in an inheritance-based merge // 2. the parent's flag is not set // 3. the parent's flag is set to true if ( !handleAsInheritance || ( parentInherited == null ) || Boolean.valueOf( parentInherited ).booleanValue() ) { Plugin childPlugin = (Plugin) childPlugins.get( parentPlugin.getKey() ); if ( ( childPlugin != null ) && !assembledPlugins.contains( childPlugin ) ) { Plugin assembledPlugin = childPlugin; mergePluginDefinitions( childPlugin, parentPlugin, handleAsInheritance ); // fix for MNG-2221 (assembly cache was not being populated for later reference): assembledPlugins.add( assembledPlugin ); } // if we're processing this as an inheritance-based merge, and // the parent's flag is not set, then we need to // clear the inherited flag in the merge result. if ( handleAsInheritance && ( parentInherited == null ) ) { parentPlugin.unsetInheritanceApplied(); } } // very important to use the parentPlugins List, rather than parentContainer.getPlugins() // since this list is a local one, and may have been modified during processing. List results = ModelUtils.orderAfterMerge( assembledPlugins, parentPlugins, child.getPlugins() ); child.setPlugins( results ); child.flushPluginMap(); } } } public static List orderAfterMerge( List merged, List highPrioritySource, List lowPrioritySource ) { List results = new ArrayList(); if ( !merged.isEmpty() ) { results.addAll( merged ); } List missingFromResults = new ArrayList(); List sources = new ArrayList(); sources.add( highPrioritySource ); sources.add( lowPrioritySource ); for ( Iterator sourceIterator = sources.iterator(); sourceIterator.hasNext(); ) { List source = (List) sourceIterator.next(); for ( Iterator it = source.iterator(); it.hasNext(); ) { Object item = it.next(); if ( results.contains( item ) ) { if ( !missingFromResults.isEmpty() ) { int idx = results.indexOf( item ); if ( idx < 0 ) { idx = 0; } results.addAll( idx, missingFromResults ); missingFromResults.clear(); } } else { missingFromResults.add( item ); } } if ( !missingFromResults.isEmpty() ) { results.addAll( missingFromResults ); missingFromResults.clear(); } } return results; } /** * Merge the list of reporting plugins from parent pom and child pom * TODO it's pretty much a copy of {@link #mergePluginLists(PluginContainer, PluginContainer, boolean)} * * @param child * @param parent * @param handleAsInheritance */ public static void mergeReportPluginLists( Reporting child, Reporting parent, boolean handleAsInheritance ) { if ( ( child == null ) || ( parent == null ) ) { // nothing to do. return; } List parentPlugins = parent.getPlugins(); if ( ( parentPlugins != null ) && !parentPlugins.isEmpty() ) { parentPlugins = new ArrayList( parentPlugins ); // If we're processing this merge as an inheritance, we have to build up a list of // plugins that were considered for inheritance. if ( handleAsInheritance ) { for ( Iterator it = parentPlugins.iterator(); it.hasNext(); ) { ReportPlugin plugin = (ReportPlugin) it.next(); String inherited = plugin.getInherited(); if ( ( inherited != null ) && !Boolean.valueOf( inherited ).booleanValue() ) { it.remove(); } } } List assembledPlugins = new ArrayList(); Map childPlugins = child.getReportPluginsAsMap(); for ( Iterator it = parentPlugins.iterator(); it.hasNext(); ) { ReportPlugin parentPlugin = (ReportPlugin) it.next(); String parentInherited = parentPlugin.getInherited(); // only merge plugin definition from the parent if at least one // of these is true: // 1. we're not processing the plugins in an inheritance-based merge // 2. the parent's flag is not set // 3. the parent's flag is set to true if ( !handleAsInheritance || ( parentInherited == null ) || Boolean.valueOf( parentInherited ).booleanValue() ) { ReportPlugin childPlugin = (ReportPlugin) childPlugins.get( parentPlugin.getKey() ); if ( ( childPlugin != null ) && !assembledPlugins.contains( childPlugin ) ) { ReportPlugin assembledPlugin = childPlugin; mergeReportPluginDefinitions( childPlugin, parentPlugin, handleAsInheritance ); // fix for MNG-2221 (assembly cache was not being populated for later reference): assembledPlugins.add( assembledPlugin ); } // if we're processing this as an inheritance-based merge, and // the parent's flag is not set, then we need to // clear the inherited flag in the merge result. if ( handleAsInheritance && ( parentInherited == null ) ) { parentPlugin.unsetInheritanceApplied(); } } // very important to use the parentPlugins List, rather than parentContainer.getPlugins() // since this list is a local one, and may have been modified during processing. List results = ModelUtils.orderAfterMerge( assembledPlugins, parentPlugins, child.getPlugins() ); child.setPlugins( results ); child.flushReportPluginMap(); } } } public static void mergePluginDefinitions( Plugin child, Plugin parent, boolean handleAsInheritance ) { if ( ( child == null ) || ( parent == null ) ) { // nothing to do. return; } if ( parent.isExtensions() ) { child.setExtensions( true ); } if ( ( child.getVersion() == null ) && ( parent.getVersion() != null ) ) { child.setVersion( parent.getVersion() ); } Xpp3Dom childConfiguration = (Xpp3Dom) child.getConfiguration(); Xpp3Dom parentConfiguration = (Xpp3Dom) parent.getConfiguration(); childConfiguration = Xpp3Dom.mergeXpp3Dom( childConfiguration, parentConfiguration ); child.setConfiguration( childConfiguration ); child.setDependencies( mergeDependencyList( child.getDependencies(), parent.getDependencies() ) ); // from here to the end of the method is dealing with merging of the section. String parentInherited = parent.getInherited(); boolean parentIsInherited = ( parentInherited == null ) || Boolean.valueOf( parentInherited ).booleanValue(); List parentExecutions = parent.getExecutions(); if ( ( parentExecutions != null ) && !parentExecutions.isEmpty() ) { List mergedExecutions = new ArrayList(); Map assembledExecutions = new TreeMap(); Map childExecutions = child.getExecutionsAsMap(); for ( Iterator it = parentExecutions.iterator(); it.hasNext(); ) { PluginExecution parentExecution = (PluginExecution) it.next(); String inherited = parentExecution.getInherited(); boolean parentExecInherited = parentIsInherited && ( ( inherited == null ) || Boolean.valueOf( inherited ).booleanValue() ); if ( !handleAsInheritance || parentExecInherited ) { PluginExecution assembled = parentExecution; PluginExecution childExecution = (PluginExecution) childExecutions.get( parentExecution.getId() ); if ( childExecution != null ) { mergePluginExecutionDefinitions( childExecution, parentExecution ); assembled = childExecution; } else if ( handleAsInheritance && ( parentInherited == null ) ) { parentExecution.unsetInheritanceApplied(); } assembledExecutions.put( assembled.getId(), assembled ); mergedExecutions.add(assembled); } } for ( Iterator it = child.getExecutions().iterator(); it.hasNext(); ) { PluginExecution childExecution = (PluginExecution)it.next(); if ( !assembledExecutions.containsKey( childExecution.getId() ) ) { mergedExecutions.add(childExecution); } } child.setExecutions(mergedExecutions); child.flushExecutionMap(); } } public static void mergeReportPluginDefinitions( ReportPlugin child, ReportPlugin parent, boolean handleAsInheritance ) { if ( ( child == null ) || ( parent == null ) ) { // nothing to do. return; } if ( ( child.getVersion() == null ) && ( parent.getVersion() != null ) ) { child.setVersion( parent.getVersion() ); } String parentInherited = parent.getInherited(); boolean parentIsInherited = ( parentInherited == null ) || Boolean.valueOf( parentInherited ).booleanValue(); // merge configuration just like with build plugins if ( parentIsInherited ) { Xpp3Dom childConfiguration = (Xpp3Dom) child.getConfiguration(); Xpp3Dom parentConfiguration = (Xpp3Dom) parent.getConfiguration(); childConfiguration = Xpp3Dom.mergeXpp3Dom( childConfiguration, parentConfiguration ); child.setConfiguration( childConfiguration ); } // from here to the end of the method is dealing with merging of the section. List parentReportSets = parent.getReportSets(); if ( ( parentReportSets != null ) && !parentReportSets.isEmpty() ) { Map assembledReportSets = new TreeMap(); Map childReportSets = child.getReportSetsAsMap(); for ( Iterator it = parentReportSets.iterator(); it.hasNext(); ) { ReportSet parentReportSet = (ReportSet) it.next(); if ( !handleAsInheritance || parentIsInherited ) { ReportSet assembledReportSet = parentReportSet; ReportSet childReportSet = (ReportSet) childReportSets.get( parentReportSet.getId() ); if ( childReportSet != null ) { mergeReportSetDefinitions( childReportSet, parentReportSet ); assembledReportSet = childReportSet; } else if ( handleAsInheritance && ( parentInherited == null ) ) { parentReportSet.unsetInheritanceApplied(); } assembledReportSets.put( assembledReportSet.getId(), assembledReportSet ); } } for ( Iterator it = childReportSets.entrySet().iterator(); it.hasNext(); ) { Map.Entry entry = (Map.Entry) it.next(); String id = (String) entry.getKey(); if ( !assembledReportSets.containsKey( id ) ) { assembledReportSets.put( id, entry.getValue() ); } } child.setReportSets( new ArrayList( assembledReportSets.values() ) ); child.flushReportSetMap(); } } private static void mergePluginExecutionDefinitions( PluginExecution child, PluginExecution parent ) { if ( child.getPhase() == null ) { child.setPhase( parent.getPhase() ); } List parentGoals = parent.getGoals(); List childGoals = child.getGoals(); List goals = new ArrayList(); if ( ( childGoals != null ) && !childGoals.isEmpty() ) { goals.addAll( childGoals ); } if ( parentGoals != null ) { for ( Iterator goalIterator = parentGoals.iterator(); goalIterator.hasNext(); ) { String goal = (String) goalIterator.next(); if ( !goals.contains( goal ) ) { goals.add( goal ); } } } child.setGoals( goals ); Xpp3Dom childConfiguration = (Xpp3Dom) child.getConfiguration(); Xpp3Dom parentConfiguration = (Xpp3Dom) parent.getConfiguration(); childConfiguration = Xpp3Dom.mergeXpp3Dom( childConfiguration, parentConfiguration ); child.setConfiguration( childConfiguration ); } private static void mergeReportSetDefinitions( ReportSet child, ReportSet parent ) { List parentReports = parent.getReports(); List childReports = child.getReports(); List reports = new ArrayList(); if ( ( childReports != null ) && !childReports.isEmpty() ) { reports.addAll( childReports ); } if ( parentReports != null ) { for ( Iterator i = parentReports.iterator(); i.hasNext(); ) { String report = (String) i.next(); if ( !reports.contains( report ) ) { reports.add( report ); } } } child.setReports( reports ); Xpp3Dom childConfiguration = (Xpp3Dom) child.getConfiguration(); Xpp3Dom parentConfiguration = (Xpp3Dom) parent.getConfiguration(); childConfiguration = Xpp3Dom.mergeXpp3Dom( childConfiguration, parentConfiguration ); child.setConfiguration( childConfiguration ); } public static Model cloneModel( Model src ) { if ( src == null ) { return null; } Model result = new Model(); cloneModelBaseFields( src, result ); result.setArtifactId( src.getArtifactId() ); result.setBuild( cloneBuild( src.getBuild() ) ); result.setCiManagement( cloneCiManagement( src.getCiManagement() ) ); result.setContributors( cloneList( src.getContributors(), CONTRIBUTOR_CLONER ) ); result.setDescription( src.getDescription() ); result.setDevelopers( cloneList( src.getDevelopers(), DEVELOPER_CLONER ) ); result.setGroupId( src.getGroupId() ); result.setInceptionYear( src.getInceptionYear() ); result.setIssueManagement( cloneIssueManagement( src.getIssueManagement() ) ); result.setLicenses( cloneList( src.getLicenses(), LICENSE_CLONER ) ); result.setMailingLists( cloneList( src.getMailingLists(), MAILING_LIST_CLONER ) ); result.setModelVersion( src.getModelVersion() ); result.setName( src.getName() ); result.setOrganization( cloneOrganization( src.getOrganization() ) ); result.setPackaging( src.getPackaging() ); result.setParent( cloneParent( src.getParent() ) ); result.setPrerequisites( clonePrerequisites( src.getPrerequisites() ) ); result.setProfiles( cloneList( src.getProfiles(), PROFILE_CLONER ) ); result.setScm( cloneScm( src.getScm() ) ); result.setUrl( src.getUrl() ); result.setVersion( src.getVersion() ); return result; } public static Scm cloneScm( Scm src ) { if ( src == null ) { return null; } Scm result = new Scm(); result.setConnection( src.getConnection() ); result.setDeveloperConnection( src.getDeveloperConnection() ); result.setTag( src.getTag() ); result.setUrl( src.getUrl() ); return result; } public static Prerequisites clonePrerequisites( Prerequisites src ) { if ( src == null ) { return null; } Prerequisites result = new Prerequisites(); result.setMaven( src.getMaven() ); return result; } public static Organization cloneOrganization( Organization src ) { if ( src == null ) { return null; } Organization result = new Organization(); result.setName( src.getName() ); result.setUrl( src.getUrl() ); return result; } public static License cloneLicense( License src ) { if ( src == null ) { return null; } License result = new License(); result.setComments( src.getComments() ); result.setDistribution( src.getDistribution() ); result.setName( src.getName() ); result.setUrl( src.getUrl() ); return result; } public static IssueManagement cloneIssueManagement( IssueManagement src ) { if ( src == null ) { return null; } IssueManagement result = new IssueManagement(); result.setSystem( src.getSystem() ); result.setUrl( src.getUrl() ); return result; } public static DistributionManagement cloneDistributionManagement( DistributionManagement src ) { if ( src == null ) { return null; } DistributionManagement result = new DistributionManagement(); result.setDownloadUrl( src.getDownloadUrl() ); result.setRelocation( cloneRelocation( src.getRelocation() ) ); result.setRepository( cloneDeploymentRepository( src.getRepository() ) ); result.setSite( cloneSite( src.getSite() ) ); result.setSnapshotRepository( cloneDeploymentRepository( src.getSnapshotRepository() ) ); result.setStatus( src.getStatus() ); return result; } public static Site cloneSite( Site src ) { if ( src == null ) { return null; } Site result = new Site(); result.setId( src.getId() ); result.setName( src.getName() ); result.setUrl( src.getUrl() ); return result; } public static DeploymentRepository cloneDeploymentRepository( DeploymentRepository src ) { if ( src == null ) { return null; } DeploymentRepository result = new DeploymentRepository(); result.setUniqueVersion( src.isUniqueVersion() ); cloneRepositoryBaseFields( src, result ); return result; } private static void cloneRepositoryBaseFields( RepositoryBase src, RepositoryBase result ) { result.setId( src.getId() ); result.setLayout( src.getLayout() ); result.setName( src.getName() ); result.setUrl( src.getUrl() ); } public static Relocation cloneRelocation( Relocation src ) { if ( src == null ) { return null; } Relocation result = new Relocation(); result.setArtifactId( src.getArtifactId() ); result.setGroupId( src.getGroupId() ); result.setMessage( src.getMessage() ); result.setVersion( src.getVersion() ); return result; } public static DependencyManagement cloneDependencyManagement( DependencyManagement src ) { if ( src == null ) { return null; } DependencyManagement result = new DependencyManagement(); result.setDependencies( cloneList( src.getDependencies(), DEPENDENCY_CLONER ) ); return result; } private static List cloneList( List src, ModelPartCloner cloner ) { List result = null; if ( src != null ) { result = new ArrayList( src.size() ); for ( Iterator it = src.iterator(); it.hasNext(); ) { result.add( cloner.cloneModelPart( (Object) it.next() ) ); } } return result; } public static Contributor cloneContributor( Contributor src ) { if ( src == null ) { return null; } Contributor result = new Contributor(); cloneContributorFields( src, result ); return result; } public static Developer cloneDeveloper( Developer src ) { if ( src == null ) { return null; } Developer result = new Developer(); result.setId( src.getId() ); cloneContributorFields( src, result ); return result; } private static void cloneContributorFields( Contributor src, Contributor result ) { result.setEmail( src.getEmail() ); result.setName( src.getName() ); result.setOrganization( src.getOrganization() ); result.setOrganizationUrl( src.getOrganizationUrl() ); result.setProperties( cloneProperties( src.getProperties() ) ); result.setRoles( cloneListOfStrings( src.getRoles() ) ); result.setTimezone( src.getTimezone() ); result.setUrl( src.getUrl() ); } public static CiManagement cloneCiManagement( CiManagement src ) { if ( src == null ) { return null; } CiManagement result = new CiManagement(); List notifiers = null; if ( src.getNotifiers() != null ) { notifiers = new ArrayList( src.getNotifiers().size() ); for ( Iterator it = src.getNotifiers().iterator(); it.hasNext(); ) { notifiers.add( cloneNotifier( (Notifier) it.next() ) ); } } result.setNotifiers( cloneList( src.getNotifiers(), NOTIFIER_CLONER ) ); result.setSystem( src.getSystem() ); result.setUrl( src.getUrl() ); return result; } public static Notifier cloneNotifier( Notifier src ) { if ( src == null ) { return null; } Notifier result = new Notifier(); result.setAddress( src.getAddress() ); result.setConfiguration( cloneProperties( src.getConfiguration() ) ); result.setSendOnError( src.isSendOnError() ); result.setSendOnFailure( result.isSendOnFailure() ); result.setSendOnSuccess( result.isSendOnSuccess() ); result.setSendOnWarning( result.isSendOnWarning() ); return result; } public static Properties cloneProperties( Properties src ) { if ( src == null ) { return null; } Properties result = new Properties(); for( Enumeration e = src.propertyNames(); e.hasMoreElements(); ) { String key = (String) e.nextElement(); result.setProperty( key, src.getProperty( key ) ); } return result; } public static Build cloneBuild( Build src ) { if ( src == null ) { return null; } Build result = new Build(); cloneBuildBaseFields( src, result ); result.setExtensions( cloneList( src.getExtensions(), EXTENSION_CLONER ) ); result.setOutputDirectory( src.getOutputDirectory() ); result.setScriptSourceDirectory( src.getScriptSourceDirectory() ); result.setSourceDirectory( src.getSourceDirectory() ); result.setTestOutputDirectory( src.getTestOutputDirectory() ); result.setTestSourceDirectory( src.getTestSourceDirectory() ); return result; } public static void cloneBuildBaseFields( BuildBase src, BuildBase result ) { result.setDefaultGoal( src.getDefaultGoal() ); result.setDirectory( src.getDirectory() ); result.setFilters( cloneListOfStrings( src.getFilters() ) ); result.setFinalName( src.getFinalName() ); result.setPluginManagement( clonePluginManagement( src.getPluginManagement() ) ); result.setPlugins( cloneList( src.getPlugins(), PLUGIN_CLONER ) ); result.setResources( cloneList( src.getResources(), RESOURCE_CLONER ) ); result.setTestResources( cloneList( src.getTestResources(), RESOURCE_CLONER ) ); } public static PluginManagement clonePluginManagement( PluginManagement src ) { PluginManagement pMgmt = null; if ( src != null ) { pMgmt = new PluginManagement(); pMgmt.setPlugins( cloneList( src.getPlugins(), PLUGIN_CLONER ) ); } return pMgmt; } public static Resource cloneResource( Resource src ) { Resource result = null; if ( src != null ) { result = new Resource(); result.setDirectory( src.getDirectory() ); result.setExcludes( cloneListOfStrings( src.getExcludes() ) ); result.setFiltering( src.isFiltering() ); result.setIncludes( cloneListOfStrings( src.getIncludes() ) ); result.setMergeId( src.getMergeId() ); result.setTargetPath( src.getTargetPath() ); } return result; } public static Plugin clonePlugin( Plugin src ) { Plugin result = null; if ( src != null ) { result = new Plugin(); result.setArtifactId( src.getArtifactId() ); result.setConfiguration( cloneConfiguration( src.getConfiguration() ) ); result.setDependencies( cloneList( src.getDependencies(), DEPENDENCY_CLONER ) ); result.setExecutions( cloneList( src.getExecutions(), PLUGIN_EXECUTION_CLONER ) ); result.setExtensions( src.isExtensions() ); result.setGroupId( src.getGroupId() ); result.setInherited( src.getInherited() ); result.setVersion( src.getVersion() ); } return result; } public static PluginExecution clonePluginExecution( PluginExecution src ) { PluginExecution result = null; if ( src != null ) { result = new PluginExecution(); result.setId( src.getId() ); result.setGoals( cloneListOfStrings( src.getGoals() ) ); result.setConfiguration( cloneConfiguration( src.getConfiguration() ) ); result.setInherited( src.getInherited() ); result.setPhase( src.getPhase() ); } return result; } // FIXME: We need something better than this for configurations! public static Object cloneConfiguration( Object configuration ) { if ( configuration == null ) { return null; } return new Xpp3Dom( (Xpp3Dom) configuration ); } public static Dependency cloneDependency( Dependency src ) { Dependency result = null; if ( src != null ) { result = new Dependency(); result.setArtifactId( src.getArtifactId() ); result.setClassifier( src.getClassifier() ); result.setExclusions( cloneList( src.getExclusions(), DEPENDENCY_EXCLUSION_CLONER ) ); result.setGroupId( src.getGroupId() ); result.setOptional( src.isOptional() ); result.setScope( src.getScope() ); result.setSystemPath( src.getSystemPath() ); result.setType( src.getType() ); result.setVersion( src.getVersion() ); } return result; } public static Exclusion cloneExclusion( Exclusion src ) { Exclusion result = null; if ( src != null ) { result = new Exclusion(); result.setArtifactId( src.getArtifactId() ); result.setGroupId( src.getGroupId() ); } return result; } public static List cloneListOfStrings( List src ) { List result = null; if ( src != null ) { result = new ArrayList( src.size() ); for ( Iterator it = src.iterator(); it.hasNext(); ) { String item = (String) it.next(); result.add( item ); } } return result; } public static Extension cloneExtension( Extension src ) { Extension rExt = new Extension(); rExt.setArtifactId( src.getArtifactId() ); rExt.setGroupId( src.getGroupId() ); rExt.setVersion( src.getVersion() ); return rExt; } public static Exclusion cloneDependencyExclusion( Exclusion src ) { if ( src == null ) { return null; } Exclusion result = new Exclusion(); result.setArtifactId( src.getArtifactId() ); result.setGroupId( src.getGroupId() ); return result; } public static Parent cloneParent( Parent src ) { if ( src == null ) { return null; } Parent result = new Parent(); result.setArtifactId( src.getArtifactId() ); result.setGroupId( src.getGroupId() ); result.setRelativePath( src.getRelativePath() ); result.setVersion( src.getVersion() ); return result; } public static List mergeRepositoryLists( List dominant, List recessive ) { List repositories = new ArrayList(); for ( Iterator it = dominant.iterator(); it.hasNext(); ) { Repository repository = (Repository) it.next(); repositories.add( repository ); } for ( Iterator it = recessive.iterator(); it.hasNext(); ) { Repository repository = (Repository) it.next(); if ( !repositories.contains( repository ) ) { repositories.add( repository ); } } return repositories; } public static void mergeExtensionLists( Build childBuild, Build parentBuild ) { Map extMap = new LinkedHashMap(); List ext = childBuild.getExtensions(); if ( ext != null ) { for ( Iterator it = ext.iterator(); it.hasNext(); ) { Extension extension = (Extension) it.next(); extMap.put( extension.getKey(), extension ); } } ext = parentBuild.getExtensions(); if ( ext != null ) { for ( Iterator it = ext.iterator(); it.hasNext(); ) { Extension extension = (Extension) it.next(); if ( !extMap.containsKey( extension.getKey() ) ) { extMap.put( extension.getKey(), extension ); } } } childBuild.setExtensions( new ArrayList( extMap.values() ) ); } public static void mergeResourceLists( List childResources, List parentResources ) { for ( Iterator i = parentResources.iterator(); i.hasNext(); ) { Resource r = (Resource) i.next(); if ( !childResources.contains( r ) ) { childResources.add( r ); } } } public static void mergeFilterLists( List childFilters, List parentFilters ) { for ( Iterator i = parentFilters.iterator(); i.hasNext(); ) { String f = (String) i.next(); if ( !childFilters.contains( f ) ) { childFilters.add( f ); } } } public static List mergeDependencyList( List child, List parent ) { Map depsMap = new LinkedHashMap(); if ( child != null ) { for ( Iterator it = child.iterator(); it.hasNext(); ) { Dependency dependency = (Dependency) it.next(); depsMap.put( dependency.getManagementKey(), dependency ); } } if ( parent != null ) { for ( Iterator it = parent.iterator(); it.hasNext(); ) { Dependency dependency = (Dependency) it.next(); if ( !depsMap.containsKey( dependency.getManagementKey() ) ) { depsMap.put( dependency.getManagementKey(), dependency ); } } } return new ArrayList( depsMap.values() ); } public static interface ModelPartCloner { Object cloneModelPart( Object src ); } } ././@LongLink0000000000000000000000000000014600000000000011566 Lustar rootrootmaven2-core-2.2.1/maven-project/src/main/java/org/apache/maven/project/DefaultMavenProjectHelper.javamaven2-core-2.2.1/maven-project/src/main/java/org/apache/maven/project/DefaultMavenProjectHelper.jav0000644000175000017500000000715510772611323033340 0ustar twernertwernerpackage org.apache.maven.project; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.handler.ArtifactHandler; import org.apache.maven.artifact.handler.manager.ArtifactHandlerManager; import org.apache.maven.model.Resource; import org.apache.maven.project.artifact.AttachedArtifact; import java.io.File; import java.util.List; public class DefaultMavenProjectHelper implements MavenProjectHelper { private ArtifactHandlerManager artifactHandlerManager; public void attachArtifact( MavenProject project, String artifactType, String artifactClassifier, File artifactFile ) { String type = artifactType; ArtifactHandler handler = null; if ( type != null ) { handler = artifactHandlerManager.getArtifactHandler( artifactType ); } if ( handler == null ) { handler = artifactHandlerManager.getArtifactHandler( "jar" ); } Artifact artifact = new AttachedArtifact( project.getArtifact(), artifactType, artifactClassifier, handler ); artifact.setFile( artifactFile ); artifact.setResolved( true ); project.addAttachedArtifact( artifact ); } public void attachArtifact( MavenProject project, String artifactType, File artifactFile ) { ArtifactHandler handler = artifactHandlerManager.getArtifactHandler( artifactType ); Artifact artifact = new AttachedArtifact( project.getArtifact(), artifactType, handler ); artifact.setFile( artifactFile ); artifact.setResolved( true ); project.addAttachedArtifact( artifact ); } public void attachArtifact( MavenProject project, File artifactFile, String artifactClassifier ) { Artifact projectArtifact = project.getArtifact(); Artifact artifact = new AttachedArtifact( projectArtifact, projectArtifact.getType(), artifactClassifier, projectArtifact.getArtifactHandler() ); artifact.setFile( artifactFile ); artifact.setResolved( true ); project.addAttachedArtifact( artifact ); } public void addResource( MavenProject project, String resourceDirectory, List includes, List excludes ) { Resource resource = new Resource(); resource.setDirectory( resourceDirectory ); resource.setIncludes( includes ); resource.setExcludes( excludes ); project.addResource( resource ); } public void addTestResource( MavenProject project, String resourceDirectory, List includes, List excludes ) { Resource resource = new Resource(); resource.setDirectory( resourceDirectory ); resource.setIncludes( includes ); resource.setExcludes( excludes ); project.addTestResource( resource ); } } maven2-core-2.2.1/maven-project/src/main/java/org/apache/maven/project/interpolation/0000755000175000017500000000000011250552246030453 5ustar twernertwerner././@LongLink0000000000000000000000000000016600000000000011570 Lustar rootrootmaven2-core-2.2.1/maven-project/src/main/java/org/apache/maven/project/interpolation/RegexBasedModelInterpolator.javamaven2-core-2.2.1/maven-project/src/main/java/org/apache/maven/project/interpolation/RegexBasedModel0000644000175000017500000000355111055044707033375 0ustar twernertwernerpackage org.apache.maven.project.interpolation; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import java.io.IOException; import java.util.Properties; import org.apache.maven.project.path.PathTranslator; import org.codehaus.plexus.interpolation.Interpolator; import org.codehaus.plexus.interpolation.RegexBasedInterpolator; /** * Use a regular expression search to find and resolve expressions within the POM. * * @author jdcasey Created on Feb 3, 2005 * @version $Id: RegexBasedModelInterpolator.java 689163 2008-08-26 18:21:59Z jdcasey $ * @todo Consolidate this logic with the PluginParameterExpressionEvaluator, minus deprecations/bans. */ public class RegexBasedModelInterpolator extends AbstractStringBasedModelInterpolator { public RegexBasedModelInterpolator() throws IOException { } public RegexBasedModelInterpolator( PathTranslator pathTranslator ) { super( pathTranslator ); } public RegexBasedModelInterpolator( Properties envars ) { } protected Interpolator createInterpolator() { return new RegexBasedInterpolator( true ); } } ././@LongLink0000000000000000000000000000017700000000000011572 Lustar rootrootmaven2-core-2.2.1/maven-project/src/main/java/org/apache/maven/project/interpolation/AbstractStringBasedModelInterpolator.javamaven2-core-2.2.1/maven-project/src/main/java/org/apache/maven/project/interpolation/AbstractStringB0000644000175000017500000003701011173447153033437 0ustar twernertwernerpackage org.apache.maven.project.interpolation; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import org.apache.maven.model.Model; import org.apache.maven.model.io.xpp3.MavenXpp3Reader; import org.apache.maven.model.io.xpp3.MavenXpp3Writer; import org.apache.maven.project.DefaultProjectBuilderConfiguration; import org.apache.maven.project.ProjectBuilderConfiguration; import org.apache.maven.project.path.PathTranslator; import org.codehaus.plexus.interpolation.AbstractValueSource; import org.codehaus.plexus.interpolation.InterpolationException; import org.codehaus.plexus.interpolation.InterpolationPostProcessor; import org.codehaus.plexus.interpolation.Interpolator; import org.codehaus.plexus.interpolation.MapBasedValueSource; import org.codehaus.plexus.interpolation.ObjectBasedValueSource; import org.codehaus.plexus.interpolation.PrefixAwareRecursionInterceptor; import org.codehaus.plexus.interpolation.PrefixedObjectValueSource; import org.codehaus.plexus.interpolation.PrefixedValueSourceWrapper; import org.codehaus.plexus.interpolation.RecursionInterceptor; import org.codehaus.plexus.interpolation.ValueSource; import org.codehaus.plexus.logging.AbstractLogEnabled; import org.codehaus.plexus.logging.Logger; import org.codehaus.plexus.personality.plexus.lifecycle.phase.Initializable; import org.codehaus.plexus.personality.plexus.lifecycle.phase.InitializationException; import org.codehaus.plexus.util.xml.pull.XmlPullParserException; import java.io.File; import java.io.IOException; import java.io.StringReader; import java.io.StringWriter; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.List; import java.util.Map; import java.util.Properties; /** * Use a regular expression search to find and resolve expressions within the POM. * * @author jdcasey Created on Feb 3, 2005 * @version $Id: AbstractStringBasedModelInterpolator.java 767323 2009-04-21 22:53:31Z jdcasey $ * @todo Consolidate this logic with the PluginParameterExpressionEvaluator, minus deprecations/bans. */ public abstract class AbstractStringBasedModelInterpolator extends AbstractLogEnabled implements ModelInterpolator, Initializable { private static final List PROJECT_PREFIXES = Arrays.asList( new String[]{ "pom.", "project." } ); private static final List TRANSLATED_PATH_EXPRESSIONS; static { List translatedPrefixes = new ArrayList(); // MNG-1927, MNG-2124, MNG-3355: // If the build section is present and the project directory is non-null, we should make // sure interpolation of the directories below uses translated paths. // Afterward, we'll double back and translate any paths that weren't covered during interpolation via the // code below... translatedPrefixes.add( "build.directory" ); translatedPrefixes.add( "build.outputDirectory" ); translatedPrefixes.add( "build.testOutputDirectory" ); translatedPrefixes.add( "build.sourceDirectory" ); translatedPrefixes.add( "build.testSourceDirectory" ); translatedPrefixes.add( "build.scriptSourceDirectory" ); translatedPrefixes.add( "reporting.outputDirectory" ); TRANSLATED_PATH_EXPRESSIONS = translatedPrefixes; } private PathTranslator pathTranslator; private Interpolator interpolator; private RecursionInterceptor recursionInterceptor; // for testing. protected AbstractStringBasedModelInterpolator( PathTranslator pathTranslator ) { this.pathTranslator = pathTranslator; } /** * @todo: Remove the throws clause. * @throws IOException This exception is not thrown any more, and needs to be removed. */ protected AbstractStringBasedModelInterpolator() { } public Model interpolate( Model model, Map context ) throws ModelInterpolationException { return interpolate( model, context, true ); } /** * Serialize the inbound Model instance to a StringWriter, perform the regex replacement to resolve * POM expressions, then re-parse into the resolved Model instance. *
* NOTE: This will result in a different instance of Model being returned!!! * * @param model The inbound Model instance, to serialize and reference for expression resolution * @param context The other context map to be used during resolution * @return The resolved instance of the inbound Model. This is a different instance! * * @deprecated Use {@link ModelInterpolator#interpolate(Model, File, ProjectBuilderConfiguration, boolean)} instead. */ public Model interpolate( Model model, Map context, boolean strict ) throws ModelInterpolationException { Properties props = new Properties(); props.putAll( context ); return interpolate( model, null, new DefaultProjectBuilderConfiguration().setExecutionProperties( props ), true ); } public Model interpolate( Model model, File projectDir, ProjectBuilderConfiguration config, boolean debugEnabled ) throws ModelInterpolationException { StringWriter sWriter = new StringWriter( 1024 ); MavenXpp3Writer writer = new MavenXpp3Writer(); try { writer.write( sWriter, model ); } catch ( IOException e ) { throw new ModelInterpolationException( "Cannot serialize project model for interpolation.", e ); } String serializedModel = sWriter.toString(); serializedModel = interpolate( serializedModel, model, projectDir, config, debugEnabled ); StringReader sReader = new StringReader( serializedModel ); MavenXpp3Reader modelReader = new MavenXpp3Reader(); try { model = modelReader.read( sReader ); } catch ( IOException e ) { throw new ModelInterpolationException( "Cannot read project model from interpolating filter of serialized version.", e ); } catch ( XmlPullParserException e ) { throw new ModelInterpolationException( "Cannot read project model from interpolating filter of serialized version.", e ); } return model; } /** * Interpolates all expressions in the src parameter. *

* The algorithm used for each expression is: *

    *
  • If it starts with either "pom." or "project.", the expression is evaluated against the model.
  • *
  • If the value is null, get the value from the context.
  • *
  • If the value is null, but the context contains the expression, don't replace the expression string * with the value, and continue to find other expressions.
  • *
  • If the value is null, get it from the model properties.
  • *
  • * @param overrideContext * @param outputDebugMessages */ public String interpolate( String src, Model model, final File projectDir, ProjectBuilderConfiguration config, boolean debug ) throws ModelInterpolationException { try { List valueSources = createValueSources( model, projectDir, config ); List postProcessors = createPostProcessors( model, projectDir, config ); return interpolateInternal( src, valueSources, postProcessors, debug ); } finally { interpolator.clearAnswers(); } } protected List createValueSources( final Model model, final File projectDir, final ProjectBuilderConfiguration config ) { String timestampFormat = DEFAULT_BUILD_TIMESTAMP_FORMAT; Properties modelProperties = model.getProperties(); if ( modelProperties != null ) { timestampFormat = modelProperties.getProperty( BUILD_TIMESTAMP_FORMAT_PROPERTY, timestampFormat ); } ValueSource modelValueSource1 = new PrefixedObjectValueSource( PROJECT_PREFIXES, model, false ); ValueSource modelValueSource2 = new ObjectBasedValueSource( model ); ValueSource basedirValueSource = new PrefixedValueSourceWrapper( new AbstractValueSource( false ){ public Object getValue( String expression ) { if ( projectDir != null && "basedir".equals( expression ) ) { return projectDir.getAbsolutePath(); } return null; } }, PROJECT_PREFIXES, true ); ValueSource baseUriValueSource = new PrefixedValueSourceWrapper( new AbstractValueSource( false ){ public Object getValue( String expression ) { if ( projectDir != null && "baseUri".equals( expression ) ) { return projectDir.getAbsoluteFile().toURI().toString(); } return null; } }, PROJECT_PREFIXES, false ); List valueSources = new ArrayList( 9 ); // NOTE: Order counts here! valueSources.add( basedirValueSource ); valueSources.add( baseUriValueSource ); valueSources.add( new BuildTimestampValueSource( config.getBuildStartTime(), timestampFormat ) ); valueSources.add( modelValueSource1 ); valueSources.add( new MapBasedValueSource( config.getUserProperties() ) ); valueSources.add( new MapBasedValueSource( modelProperties ) ); valueSources.add( new MapBasedValueSource( config.getExecutionProperties() ) ); valueSources.add( new AbstractValueSource( false ) { public Object getValue( String expression ) { return config.getExecutionProperties().getProperty( "env." + expression ); } } ); valueSources.add( modelValueSource2 ); return valueSources; } protected List createPostProcessors( final Model model, final File projectDir, final ProjectBuilderConfiguration config ) { return Collections.singletonList( (InterpolationPostProcessor) new PathTranslatingPostProcessor( PROJECT_PREFIXES, TRANSLATED_PATH_EXPRESSIONS, projectDir, pathTranslator ) ); } @SuppressWarnings("unchecked") protected String interpolateInternal( String src, List valueSources, List postProcessors, boolean debug ) throws ModelInterpolationException { if ( src.indexOf( "${" ) < 0 ) { return src; } Logger logger = getLogger(); String result = src; synchronized( this ) { for ( ValueSource vs : valueSources ) { interpolator.addValueSource( vs ); } for ( InterpolationPostProcessor postProcessor : postProcessors ) { interpolator.addPostProcessor( postProcessor ); } try { try { result = interpolator.interpolate( result, recursionInterceptor ); } catch( InterpolationException e ) { throw new ModelInterpolationException( e.getMessage(), e ); } if ( debug ) { List feedback = (List) interpolator.getFeedback(); if ( feedback != null && !feedback.isEmpty() ) { logger.debug( "Maven encountered the following problems during initial POM interpolation:" ); Object last = null; for ( Object next : feedback ) { if ( next instanceof Throwable ) { if ( last == null ) { logger.debug( "", ( (Throwable) next ) ); } else { logger.debug( String.valueOf( last ), ( (Throwable) next ) ); } } else { if ( last != null ) { logger.debug( String.valueOf( last ) ); } last = next; } } if ( last != null ) { logger.debug( String.valueOf( last ) ); } } } interpolator.clearFeedback(); } finally { for ( ValueSource vs : valueSources ) { interpolator.removeValuesSource( vs ); } for ( InterpolationPostProcessor postProcessor : postProcessors ) { interpolator.removePostProcessor( postProcessor ); } } } return result; } protected RecursionInterceptor getRecursionInterceptor() { return recursionInterceptor; } protected void setRecursionInterceptor( RecursionInterceptor recursionInterceptor ) { this.recursionInterceptor = recursionInterceptor; } protected abstract Interpolator createInterpolator(); public void initialize() throws InitializationException { interpolator = createInterpolator(); recursionInterceptor = new PrefixAwareRecursionInterceptor( PROJECT_PREFIXES ); } protected final Interpolator getInterpolator() { return interpolator; } } ././@LongLink0000000000000000000000000000016600000000000011570 Lustar rootrootmaven2-core-2.2.1/maven-project/src/main/java/org/apache/maven/project/interpolation/ModelInterpolationException.javamaven2-core-2.2.1/maven-project/src/main/java/org/apache/maven/project/interpolation/ModelInterpolat0000644000175000017500000000376311173447153033515 0ustar twernertwernerpackage org.apache.maven.project.interpolation; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ /** * @author jdcasey *

    * Created on Feb 2, 2005 */ @SuppressWarnings("serial") public class ModelInterpolationException extends Exception { private String expression; private String originalMessage; public ModelInterpolationException( String message ) { super( message ); } public ModelInterpolationException( String message, Throwable cause ) { super( message, cause ); } public ModelInterpolationException( String expression, String message, Throwable cause ) { super( "The POM expression: " + expression + " could not be evaluated. Reason: " + message, cause ); this.expression = expression; this.originalMessage = message; } public ModelInterpolationException( String expression, String message ) { super( "The POM expression: " + expression + " could not be evaluated. Reason: " + message ); this.expression = expression; this.originalMessage = message; } public String getExpression() { return expression; } public String getOriginalMessage() { return originalMessage; } }././@LongLink0000000000000000000000000000017000000000000011563 Lustar rootrootmaven2-core-2.2.1/maven-project/src/main/java/org/apache/maven/project/interpolation/StringSearchModelInterpolator.javamaven2-core-2.2.1/maven-project/src/main/java/org/apache/maven/project/interpolation/StringSearchMod0000644000175000017500000004230611211010405033416 0ustar twernertwernerpackage org.apache.maven.project.interpolation; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import org.apache.maven.model.Model; import org.apache.maven.project.ProjectBuilderConfiguration; import org.apache.maven.project.path.PathTranslator; import org.codehaus.plexus.interpolation.InterpolationPostProcessor; import org.codehaus.plexus.interpolation.Interpolator; import org.codehaus.plexus.interpolation.StringSearchInterpolator; import org.codehaus.plexus.interpolation.ValueSource; import org.codehaus.plexus.logging.Logger; import java.io.File; import java.lang.reflect.Array; import java.lang.reflect.Field; import java.security.AccessController; import java.security.PrivilegedAction; import java.util.ArrayList; import java.util.Collection; import java.util.LinkedList; import java.util.List; import java.util.Map; import java.util.WeakHashMap; public class StringSearchModelInterpolator extends AbstractStringBasedModelInterpolator { private static final Map, Field[]> fieldsByClass = new WeakHashMap, Field[]>(); private static final Map, Boolean> fieldIsPrimitiveByClass = new WeakHashMap, Boolean>(); public StringSearchModelInterpolator() { } public StringSearchModelInterpolator( PathTranslator pathTranslator ) { super( pathTranslator ); } public Model interpolate( Model model, File projectDir, ProjectBuilderConfiguration config, boolean debugEnabled ) throws ModelInterpolationException { interpolateObject( model, model, projectDir, config, debugEnabled ); return model; } protected void interpolateObject( Object obj, Model model, File projectDir, ProjectBuilderConfiguration config, boolean debugEnabled ) throws ModelInterpolationException { try { List valueSources = createValueSources( model, projectDir, config ); List postProcessors = createPostProcessors( model, projectDir, config ); InterpolateObjectAction action = new InterpolateObjectAction( obj, valueSources, postProcessors, debugEnabled, this, getLogger() ); ModelInterpolationException error = (ModelInterpolationException) AccessController.doPrivileged( action ); if ( error != null ) { throw error; } } finally { getInterpolator().clearAnswers(); } } protected Interpolator createInterpolator() { StringSearchInterpolator interpolator = new StringSearchInterpolator(); interpolator.setCacheAnswers( true ); return interpolator; } private static final class InterpolateObjectAction implements PrivilegedAction { private final boolean debugEnabled; private final LinkedList interpolationTargets; private final StringSearchModelInterpolator modelInterpolator; private final Logger logger; private final List valueSources; private final List postProcessors; public InterpolateObjectAction( Object target, List valueSources, List postProcessors, boolean debugEnabled, StringSearchModelInterpolator modelInterpolator, Logger logger ) { this.valueSources = valueSources; this.postProcessors = postProcessors; this.debugEnabled = debugEnabled; this.interpolationTargets = new LinkedList(); interpolationTargets.add( target ); this.modelInterpolator = modelInterpolator; this.logger = logger; } public ModelInterpolationException run() { while( !interpolationTargets.isEmpty() ) { Object obj = interpolationTargets.removeFirst(); try { traverseObjectWithParents( obj.getClass(), obj ); } catch ( ModelInterpolationException e ) { return e; } } return null; } @SuppressWarnings("unchecked") private void traverseObjectWithParents( Class cls, Object target ) throws ModelInterpolationException { if ( cls == null ) { return; } if ( cls.isArray() ) { evaluateArray( target ); } else if ( isQualifiedForInterpolation( cls ) ) { Field[] fields = (Field[]) fieldsByClass.get( cls ); if ( fields == null ) { fields = cls.getDeclaredFields(); fieldsByClass.put( cls, fields ); } for ( int i = 0; i < fields.length; i++ ) { Class type = fields[i].getType(); if ( isQualifiedForInterpolation( fields[i], type ) ) { boolean isAccessible = fields[i].isAccessible(); fields[i].setAccessible( true ); try { try { if ( String.class == type ) { String value = (String) fields[i].get( target ); if ( value != null ) { String interpolated = modelInterpolator.interpolateInternal( value, valueSources, postProcessors, debugEnabled ); if ( !interpolated.equals( value ) ) { fields[i].set( target, interpolated ); } } } else if ( Collection.class.isAssignableFrom( type ) ) { Collection c = (Collection) fields[i].get( target ); if ( c != null && !c.isEmpty() ) { List originalValues = new ArrayList( c ); try { c.clear(); } catch( UnsupportedOperationException e ) { if ( debugEnabled && logger != null ) { logger.debug( "Skipping interpolation of field: " + fields[i] + " in: " + cls.getName() + "; it is an unmodifiable collection." ); } continue; } for ( Object value : originalValues ) { if ( value != null ) { if( String.class == value.getClass() ) { String interpolated = modelInterpolator.interpolateInternal( (String) value, valueSources, postProcessors, debugEnabled ); if ( !interpolated.equals( value ) ) { c.add( interpolated ); } else { c.add( value ); } } else { c.add( value ); if ( value.getClass().isArray() ) { evaluateArray( value ); } else { interpolationTargets.add( value ); } } } else { // add the null back in...not sure what else to do... c.add( value ); } } } } else if ( Map.class.isAssignableFrom( type ) ) { Map m = (Map) fields[i].get( target ); if ( m != null && !m.isEmpty() ) { for ( Map.Entry entry : m.entrySet() ) { Object value = entry.getValue(); if ( value != null ) { if( String.class == value.getClass() ) { String interpolated = modelInterpolator.interpolateInternal( (String) value, valueSources, postProcessors, debugEnabled ); if ( !interpolated.equals( value ) ) { try { entry.setValue( interpolated ); } catch( UnsupportedOperationException e ) { if ( debugEnabled && logger != null ) { logger.debug( "Skipping interpolation of field: " + fields[i] + " (key: " + entry.getKey() + ") in: " + cls.getName() + "; it is an unmodifiable collection." ); } continue; } } } else { if ( value.getClass().isArray() ) { evaluateArray( value ); } else { interpolationTargets.add( value ); } } } } } } else { Object value = fields[i].get( target ); if ( value != null ) { if ( fields[i].getType().isArray() ) { evaluateArray( value ); } else { interpolationTargets.add( value ); } } } } catch ( IllegalArgumentException e ) { throw new ModelInterpolationException( "Failed to interpolate field: " + fields[i] + " on class: " + cls.getName(), e ); } catch ( IllegalAccessException e ) { throw new ModelInterpolationException( "Failed to interpolate field: " + fields[i] + " on class: " + cls.getName(), e ); } } finally { fields[i].setAccessible( isAccessible ); } } } traverseObjectWithParents( cls.getSuperclass(), target ); } } private boolean isQualifiedForInterpolation( Class cls ) { return !cls.getPackage().getName().startsWith( "java" ); } private boolean isQualifiedForInterpolation( Field field, Class fieldType ) { if ( !fieldIsPrimitiveByClass.containsKey( fieldType ) ) { fieldIsPrimitiveByClass.put( fieldType, Boolean.valueOf( fieldType.isPrimitive() ) ); } if ( ((Boolean) fieldIsPrimitiveByClass.get( fieldType )).booleanValue() ) { return false; } // if ( fieldType.isPrimitive() ) // { // return false; // } if ( "parent".equals( field.getName() ) ) { return false; } return true; } private void evaluateArray( Object target ) throws ModelInterpolationException { int len = Array.getLength( target ); for( int i = 0; i < len; i++ ) { Object value = Array.get( target, i ); if ( value != null ) { if ( String.class == value.getClass() ) { String interpolated = modelInterpolator.interpolateInternal( (String) value, valueSources, postProcessors, debugEnabled ); if ( !interpolated.equals( value ) ) { Array.set( target, i, interpolated ); } } else { interpolationTargets.add( value ); } } } } } } ././@LongLink0000000000000000000000000000015400000000000011565 Lustar rootrootmaven2-core-2.2.1/maven-project/src/main/java/org/apache/maven/project/interpolation/ModelInterpolator.javamaven2-core-2.2.1/maven-project/src/main/java/org/apache/maven/project/interpolation/ModelInterpolat0000644000175000017500000000440011173447153033502 0ustar twernertwernerpackage org.apache.maven.project.interpolation; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import org.apache.maven.model.Model; import org.apache.maven.project.ProjectBuilderConfiguration; import java.io.File; import java.util.Map; /** * @author jdcasey *

    * Created on Feb 2, 2005 */ public interface ModelInterpolator { String DEFAULT_BUILD_TIMESTAMP_FORMAT = "yyyyMMdd-HHmm"; String BUILD_TIMESTAMP_FORMAT_PROPERTY = "maven.build.timestamp.format"; String ROLE = ModelInterpolator.class.getName(); /** * @deprecated Use {@link ModelInterpolator#interpolate(Model, File, ProjectBuilderConfiguration, boolean)} instead. */ Model interpolate( Model project, Map context ) throws ModelInterpolationException; /** * @deprecated Use {@link ModelInterpolator#interpolate(Model, File, ProjectBuilderConfiguration, boolean)} instead. */ Model interpolate( Model model, Map context, boolean strict ) throws ModelInterpolationException; Model interpolate( Model model, File projectDir, ProjectBuilderConfiguration config, boolean debugEnabled ) throws ModelInterpolationException; String interpolate( String src, Model model, File projectDir, ProjectBuilderConfiguration config, boolean debugEnabled ) throws ModelInterpolationException; }././@LongLink0000000000000000000000000000016700000000000011571 Lustar rootrootmaven2-core-2.2.1/maven-project/src/main/java/org/apache/maven/project/interpolation/PathTranslatingPostProcessor.javamaven2-core-2.2.1/maven-project/src/main/java/org/apache/maven/project/interpolation/PathTranslating0000644000175000017500000000434011173447153033506 0ustar twernertwernerpackage org.apache.maven.project.interpolation; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import org.apache.maven.project.path.PathTranslator; import org.codehaus.plexus.interpolation.InterpolationPostProcessor; import org.codehaus.plexus.interpolation.util.ValueSourceUtils; import java.io.File; import java.util.List; /** * * @version $Id: PathTranslatingPostProcessor.java 767323 2009-04-21 22:53:31Z jdcasey $ */ public class PathTranslatingPostProcessor implements InterpolationPostProcessor { private final List unprefixedPathKeys; private final File projectDir; private final PathTranslator pathTranslator; private final List expressionPrefixes; public PathTranslatingPostProcessor( List expressionPrefixes, List unprefixedPathKeys, File projectDir, PathTranslator pathTranslator ) { this.expressionPrefixes = expressionPrefixes; this.unprefixedPathKeys = unprefixedPathKeys; this.projectDir = projectDir; this.pathTranslator = pathTranslator; } public Object execute( String expression, Object value ) { expression = ValueSourceUtils.trimPrefix( expression, expressionPrefixes, true ); if ( projectDir != null && value != null && unprefixedPathKeys.contains( expression ) ) { return pathTranslator.alignToBaseDirectory( String.valueOf( value ), projectDir ); } return value; } } ././@LongLink0000000000000000000000000000016400000000000011566 Lustar rootrootmaven2-core-2.2.1/maven-project/src/main/java/org/apache/maven/project/interpolation/BuildTimestampValueSource.javamaven2-core-2.2.1/maven-project/src/main/java/org/apache/maven/project/interpolation/BuildTimestampV0000644000175000017500000000350411101576551033451 0ustar twernertwernerpackage org.apache.maven.project.interpolation; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import java.text.SimpleDateFormat; import java.util.Date; import org.codehaus.plexus.interpolation.AbstractValueSource; /** * * @version $Id: BuildTimestampValueSource.java 708543 2008-10-28 11:54:17Z bentmann $ */ public class BuildTimestampValueSource extends AbstractValueSource { private final Date startTime; private final String format; private String formattedDate; public BuildTimestampValueSource( Date startTime, String format ) { super( false ); this.startTime = startTime; this.format = format; } public Object getValue( String expression ) { if ( "build.timestamp".equals( expression ) || "maven.build.timestamp".equals( expression ) ) { if ( formattedDate == null && startTime != null ) { formattedDate = new SimpleDateFormat( format ).format( startTime ); } return formattedDate; } return null; } } ././@LongLink0000000000000000000000000000014500000000000011565 Lustar rootrootmaven2-core-2.2.1/maven-project/src/main/java/org/apache/maven/project/ProjectBuildingException.javamaven2-core-2.2.1/maven-project/src/main/java/org/apache/maven/project/ProjectBuildingException.java0000644000175000017500000000310710630102701033357 0ustar twernertwernerpackage org.apache.maven.project; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ /** * @author Jason van Zyl * @version $Id: ProjectBuildingException.java 543605 2007-06-01 20:46:57Z jvanzyl $ */ public class ProjectBuildingException extends Exception { private final String projectId; public ProjectBuildingException( String projectId, String message ) { super( message ); this.projectId = projectId; } public ProjectBuildingException( String projectId, String message, Throwable cause ) { super( message, cause ); this.projectId = projectId; } public String getProjectId() { return projectId; } public String getMessage() { return super.getMessage() + " for project " + this.projectId; } } maven2-core-2.2.1/maven-project/src/main/java/org/apache/maven/project/ProjectUtils.java0000644000175000017500000001422211015636072031056 0ustar twernertwernerpackage org.apache.maven.project; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import org.apache.maven.artifact.InvalidRepositoryException; import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.artifact.repository.ArtifactRepositoryFactory; import org.apache.maven.artifact.repository.ArtifactRepositoryPolicy; import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout; import org.apache.maven.model.DeploymentRepository; import org.apache.maven.model.Repository; import org.apache.maven.model.RepositoryBase; import org.apache.maven.model.RepositoryPolicy; import org.codehaus.plexus.PlexusContainer; import org.codehaus.plexus.component.repository.exception.ComponentLookupException; import java.util.ArrayList; import java.util.Iterator; import java.util.List; public final class ProjectUtils { private ProjectUtils() { } public static List buildArtifactRepositories( List repositories, ArtifactRepositoryFactory artifactRepositoryFactory, PlexusContainer container ) throws InvalidRepositoryException { List repos = new ArrayList(); for ( Iterator i = repositories.iterator(); i.hasNext(); ) { Repository mavenRepo = (Repository) i.next(); ArtifactRepository artifactRepo = buildArtifactRepository( mavenRepo, artifactRepositoryFactory, container ); if ( !repos.contains( artifactRepo ) ) { repos.add( artifactRepo ); } } return repos; } public static ArtifactRepository buildDeploymentArtifactRepository( DeploymentRepository repo, ArtifactRepositoryFactory artifactRepositoryFactory, PlexusContainer container ) throws InvalidRepositoryException { if ( repo != null ) { String id = repo.getId(); String url = repo.getUrl(); // TODO: make this a map inside the factory instead, so no lookup needed ArtifactRepositoryLayout layout = getRepositoryLayout( repo, container ); return artifactRepositoryFactory.createDeploymentArtifactRepository( id, url, layout, repo.isUniqueVersion() ); } else { return null; } } public static ArtifactRepository buildArtifactRepository( Repository repo, ArtifactRepositoryFactory artifactRepositoryFactory, PlexusContainer container ) throws InvalidRepositoryException { if ( repo != null ) { String id = repo.getId(); String url = repo.getUrl(); if ( id == null || id.trim().length() < 1 ) { throw new InvalidRepositoryException( "Repository ID must not be empty (URL is: " + url + ").", new IllegalArgumentException( "repository.id" ) ); } if ( url == null || url.trim().length() < 1 ) { throw new InvalidRepositoryException( "Repository URL must not be empty (ID is: " + id + ").", new IllegalArgumentException( "repository.url" ) ); } // TODO: make this a map inside the factory instead, so no lookup needed ArtifactRepositoryLayout layout = getRepositoryLayout( repo, container ); ArtifactRepositoryPolicy snapshots = buildArtifactRepositoryPolicy( repo.getSnapshots() ); ArtifactRepositoryPolicy releases = buildArtifactRepositoryPolicy( repo.getReleases() ); return artifactRepositoryFactory.createArtifactRepository( id, url, layout, snapshots, releases ); } else { return null; } } private static ArtifactRepositoryPolicy buildArtifactRepositoryPolicy( RepositoryPolicy policy ) { boolean enabled = true; String updatePolicy = null; String checksumPolicy = null; if ( policy != null ) { enabled = policy.isEnabled(); if ( policy.getUpdatePolicy() != null ) { updatePolicy = policy.getUpdatePolicy(); } if ( policy.getChecksumPolicy() != null ) { checksumPolicy = policy.getChecksumPolicy(); } } return new ArtifactRepositoryPolicy( enabled, updatePolicy, checksumPolicy ); } private static ArtifactRepositoryLayout getRepositoryLayout( RepositoryBase mavenRepo, PlexusContainer container ) throws InvalidRepositoryException { String layout = mavenRepo.getLayout(); ArtifactRepositoryLayout repositoryLayout; try { repositoryLayout = (ArtifactRepositoryLayout) container.lookup( ArtifactRepositoryLayout.ROLE, layout ); } catch ( ComponentLookupException e ) { throw new InvalidRepositoryException( "Cannot find layout implementation corresponding to: \'" + layout + "\' for remote repository with id: \'" + mavenRepo.getId() + "\'.", e ); } return repositoryLayout; } } maven2-core-2.2.1/maven-project/src/main/java/org/apache/maven/project/MavenProject.java0000644000175000017500000017566411221204753031042 0ustar twernertwernerpackage org.apache.maven.project; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import java.io.File; import java.io.IOException; import java.io.Writer; import java.util.ArrayList; import java.util.Collections; import java.util.Enumeration; import java.util.HashMap; import java.util.Iterator; import java.util.LinkedHashSet; import java.util.List; import java.util.Map; import java.util.Properties; import java.util.Set; import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.ArtifactUtils; import org.apache.maven.artifact.DependencyResolutionRequiredException; import org.apache.maven.artifact.versioning.ManagedVersionMap; import org.apache.maven.artifact.factory.ArtifactFactory; import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.artifact.resolver.filter.ArtifactFilter; import org.apache.maven.model.Build; import org.apache.maven.model.CiManagement; import org.apache.maven.model.Contributor; import org.apache.maven.model.Dependency; import org.apache.maven.model.DependencyManagement; import org.apache.maven.model.Developer; import org.apache.maven.model.DistributionManagement; import org.apache.maven.model.IssueManagement; import org.apache.maven.model.License; import org.apache.maven.model.MailingList; import org.apache.maven.model.Model; import org.apache.maven.model.Organization; import org.apache.maven.model.Plugin; import org.apache.maven.model.PluginExecution; import org.apache.maven.model.PluginManagement; import org.apache.maven.model.Prerequisites; import org.apache.maven.model.ReportPlugin; import org.apache.maven.model.ReportSet; import org.apache.maven.model.Reporting; import org.apache.maven.model.Resource; import org.apache.maven.model.Scm; import org.apache.maven.model.io.xpp3.MavenXpp3Writer; import org.apache.maven.project.artifact.ActiveProjectArtifact; import org.apache.maven.project.artifact.InvalidDependencyVersionException; import org.apache.maven.project.artifact.MavenMetadataSource; import org.codehaus.plexus.logging.Logger; import org.codehaus.plexus.util.xml.Xpp3Dom; /** * The concern of the project is provide runtime values based on the model.

    * The values in the model remain untouched but during the process of building a * project notions like inheritance and interpolation can be added. This allows * to have an entity which is useful in a runtime while preserving the model so * that it can be marshalled and unmarshalled without being tainted by runtime * requirements.

    We need to leave the model intact because we don't want * the following: *

      *
    1. We don't want interpolated values being written back into the model. *
    2. We don't want inherited values being written back into the model. *
    */ public class MavenProject implements Cloneable { public static final String EMPTY_PROJECT_GROUP_ID = "unknown"; public static final String EMPTY_PROJECT_ARTIFACT_ID = "empty-project"; public static final String EMPTY_PROJECT_VERSION = "0"; private Model model; private MavenProject parent; private File file; private Set artifacts; private Artifact parentArtifact; private Set pluginArtifacts; private List remoteArtifactRepositories; private List collectedProjects = Collections.EMPTY_LIST; private List attachedArtifacts; private MavenProject executionProject; private List compileSourceRoots = new ArrayList(); private List testCompileSourceRoots = new ArrayList(); private List scriptSourceRoots = new ArrayList(); private List pluginArtifactRepositories; private ArtifactRepository releaseArtifactRepository; private ArtifactRepository snapshotArtifactRepository; private List activeProfiles = new ArrayList(); private Set dependencyArtifacts; private Artifact artifact; // calculated. private Map artifactMap; private Model originalModel; private Map pluginArtifactMap; private Set reportArtifacts; private Map reportArtifactMap; private Set extensionArtifacts; private Map extensionArtifactMap; private Map managedVersionMap; private Map projectReferences = new HashMap(); private boolean executionRoot; private Map moduleAdjustments; private File basedir; private Logger logger; private ProjectBuilderConfiguration projectBuilderConfiguration; public MavenProject() { Model model = new Model(); model.setGroupId( EMPTY_PROJECT_GROUP_ID ); model.setArtifactId( EMPTY_PROJECT_ARTIFACT_ID ); model.setVersion( EMPTY_PROJECT_VERSION ); this.setModel( model ); } public MavenProject( Model model ) { this.setModel( model ); } public MavenProject( Model model, Logger logger ) { this.setModel( model ); this.setLogger( logger ); } /** * @deprecated use {@link #clone()} so subclasses can provide a copy of the same class */ public MavenProject( MavenProject project ) { deepCopy( project ); } private final void deepCopy(MavenProject project){ // disown the parent // copy fields setFile( project.getFile() ); // don't need a deep copy, they don't get modified or added/removed to/from - but make them unmodifiable to be // sure! if ( project.getDependencyArtifacts() != null ) { setDependencyArtifacts( Collections.unmodifiableSet( project.getDependencyArtifacts() ) ); } if ( project.getArtifacts() != null ) { setArtifacts( Collections.unmodifiableSet( project.getArtifacts() ) ); } if ( project.getPluginArtifacts() != null ) { setPluginArtifacts( Collections.unmodifiableSet( project.getPluginArtifacts() ) ); } if ( project.getReportArtifacts() != null ) { setReportArtifacts( Collections.unmodifiableSet( project.getReportArtifacts() ) ); } if ( project.getExtensionArtifacts() != null ) { setExtensionArtifacts( Collections.unmodifiableSet( project.getExtensionArtifacts() ) ); } setParentArtifact( ( project.getParentArtifact() ) ); if ( project.getRemoteArtifactRepositories() != null ) { setRemoteArtifactRepositories( Collections.unmodifiableList( project.getRemoteArtifactRepositories() ) ); } if ( project.getPluginArtifactRepositories() != null ) { setPluginArtifactRepositories( ( Collections.unmodifiableList( project.getPluginArtifactRepositories() ) ) ); } if ( project.getCollectedProjects() != null ) { setCollectedProjects( ( Collections.unmodifiableList( project.getCollectedProjects() ) ) ); } if ( project.getActiveProfiles() != null ) { setActiveProfiles( ( Collections.unmodifiableList( project.getActiveProfiles() ) ) ); } if ( project.getAttachedArtifacts() != null ) { // clone properties modifyable by plugins in a forked lifecycle setAttachedArtifacts( new ArrayList( project.getAttachedArtifacts() ) ); } if ( project.getCompileSourceRoots() != null ) { // clone source roots setCompileSourceRoots( ( new ArrayList( project.getCompileSourceRoots() ) ) ); } if ( project.getTestCompileSourceRoots() != null ) { setTestCompileSourceRoots( ( new ArrayList( project.getTestCompileSourceRoots() ) ) ); } if ( project.getScriptSourceRoots() != null ) { setScriptSourceRoots( ( new ArrayList( project.getScriptSourceRoots() ) ) ); } setModel( ( ModelUtils.cloneModel( project.getModel() ) ) ); if ( project.getOriginalModel() != null ) { setOriginalModel( ( ModelUtils.cloneModel( project.getOriginalModel() ) ) ); } setExecutionRoot( project.isExecutionRoot() ); if ( project.getArtifact() != null ) { setArtifact( ArtifactUtils.copyArtifact( project.getArtifact() ) ); } if ( project.getManagedVersionMap() != null ) { setManagedVersionMap( new ManagedVersionMap( project.getManagedVersionMap() ) ); } if ( project.getReleaseArtifactRepository() != null ) { setReleaseArtifactRepository( project.getReleaseArtifactRepository() ); } if ( project.getSnapshotArtifactRepository() != null ) { setSnapshotArtifactRepository( project.getSnapshotArtifactRepository() ); } if ( project.isConcrete() ) { setDynamicBuild( ModelUtils.cloneBuild( project.getDynamicBuild() ) ); setOriginalInterpolatedBuild( ModelUtils.cloneBuild( project.getOriginalInterpolatedBuild() ) ); List dynamicRoots = project.getDynamicCompileSourceRoots(); if ( dynamicRoots != null ) { setDynamicCompileSourceRoots( new ArrayList( dynamicRoots ) ); setOriginalInterpolatedCompileSourceRoots( new ArrayList( project.getOriginalInterpolatedCompileSourceRoots() ) ); } dynamicRoots = project.getDynamicTestCompileSourceRoots(); if ( dynamicRoots != null ) { setDynamicTestCompileSourceRoots( new ArrayList( dynamicRoots ) ); setOriginalInterpolatedTestCompileSourceRoots( new ArrayList( project.getOriginalInterpolatedTestCompileSourceRoots() ) ); } dynamicRoots = project.getDynamicScriptSourceRoots(); if ( dynamicRoots != null ) { setDynamicScriptSourceRoots( new ArrayList( dynamicRoots ) ); setOriginalInterpolatedScriptSourceRoots( new ArrayList( project.getOriginalInterpolatedScriptSourceRoots() ) ); } } preservedProperties = project.preservedProperties; preservedBasedir = project.preservedBasedir; setConcrete( project.isConcrete() ); } public String getModulePathAdjustment( MavenProject moduleProject ) throws IOException { // FIXME: This is hacky. What if module directory doesn't match artifactid, and parent // is coming from the repository?? // FIXME: If there is a hierarchy of three projects, with the url specified at the top, // and the top two projects are referenced from copies that are in the repository, the // middle-level POM doesn't have a File associated with it (or the file's directory is // of an unexpected name), and module path adjustments fail. String module = moduleProject.getArtifactId(); File moduleFile = moduleProject.getFile(); if ( moduleFile != null ) { File moduleDir = moduleFile.getCanonicalFile().getParentFile(); module = moduleDir.getName(); } if ( moduleAdjustments == null ) { moduleAdjustments = new HashMap(); List modules = getModules(); if ( modules != null ) { for ( Iterator it = modules.iterator(); it.hasNext(); ) { String modulePath = (String) it.next(); String moduleName = modulePath; if ( moduleName.endsWith( "/" ) || moduleName.endsWith( "\\" ) ) { moduleName = moduleName.substring( 0, moduleName.length() - 1 ); } int lastSlash = moduleName.lastIndexOf( '/' ); if ( lastSlash < 0 ) { lastSlash = moduleName.lastIndexOf( '\\' ); } String adjustment = null; if ( lastSlash > -1 ) { moduleName = moduleName.substring( lastSlash + 1 ); adjustment = modulePath.substring( 0, lastSlash ); } moduleAdjustments.put( moduleName, adjustment ); } } } return (String) moduleAdjustments.get( module ); } // ---------------------------------------------------------------------- // Accessors // ---------------------------------------------------------------------- public Artifact getArtifact() { return artifact; } public void setArtifact( Artifact artifact ) { this.artifact = artifact; } //@todo I would like to get rid of this. jvz. public Model getModel() { return model; } public MavenProject getParent() { return parent; } public void setParent( MavenProject parent ) { this.parent = parent; } public void setRemoteArtifactRepositories( List remoteArtifactRepositories ) { this.remoteArtifactRepositories = remoteArtifactRepositories; } public List getRemoteArtifactRepositories() { return remoteArtifactRepositories; } public boolean hasParent() { return getParent() != null; } public File getFile() { return file; } public void setFile( File file ) { if ( file == null ) { return; } if ( basedir == null ) { basedir = file.getParentFile(); } this.file = file; } public void setBasedir( File basedir ) { this.basedir = basedir; } public File getBasedir() { return basedir; } public void setDependencies( List dependencies ) { getModel().setDependencies( dependencies ); } public List getDependencies() { return getModel().getDependencies(); } public DependencyManagement getDependencyManagement() { return getModel().getDependencyManagement(); } // ---------------------------------------------------------------------- // Test and compile sourceroots. // ---------------------------------------------------------------------- public void addCompileSourceRoot( String path ) { if ( path != null ) { path = path.trim(); if ( path.length() != 0 ) { if ( !getCompileSourceRoots().contains( path ) ) { getCompileSourceRoots().add( path ); } } } } public void addScriptSourceRoot( String path ) { if ( path != null ) { path = path.trim(); if ( path.length() != 0 ) { if ( !getScriptSourceRoots().contains( path ) ) { getScriptSourceRoots().add( path ); } } } } public void addTestCompileSourceRoot( String path ) { if ( path != null ) { path = path.trim(); if ( path.length() != 0 ) { if ( !getTestCompileSourceRoots().contains( path ) ) { getTestCompileSourceRoots().add( path ); } } } } public List getCompileSourceRoots() { return compileSourceRoots; } public List getScriptSourceRoots() { return scriptSourceRoots; } public List getTestCompileSourceRoots() { return testCompileSourceRoots; } public List getCompileClasspathElements() throws DependencyResolutionRequiredException { List list = new ArrayList( getArtifacts().size() ); list.add( getBuild().getOutputDirectory() ); for ( Iterator i = getArtifacts().iterator(); i.hasNext(); ) { Artifact a = (Artifact) i.next(); if ( a.getArtifactHandler().isAddedToClasspath() ) { // TODO: let the scope handler deal with this if ( Artifact.SCOPE_COMPILE.equals( a.getScope() ) || Artifact.SCOPE_PROVIDED.equals( a.getScope() ) || Artifact.SCOPE_SYSTEM.equals( a.getScope() ) ) { addArtifactPath( a, list ); } } } return list; } public List getCompileArtifacts() { List list = new ArrayList( getArtifacts().size() ); for ( Iterator i = getArtifacts().iterator(); i.hasNext(); ) { Artifact a = (Artifact) i.next(); // TODO: classpath check doesn't belong here - that's the other method if ( a.getArtifactHandler().isAddedToClasspath() ) { // TODO: let the scope handler deal with this if ( Artifact.SCOPE_COMPILE.equals( a.getScope() ) || Artifact.SCOPE_PROVIDED.equals( a.getScope() ) || Artifact.SCOPE_SYSTEM.equals( a.getScope() ) ) { list.add( a ); } } } return list; } public List getCompileDependencies() { Set artifacts = getArtifacts(); if ( artifacts == null || artifacts.isEmpty() ) { return Collections.EMPTY_LIST; } List list = new ArrayList( artifacts.size() ); for ( Iterator i = getArtifacts().iterator(); i.hasNext(); ) { Artifact a = (Artifact) i.next(); // TODO: let the scope handler deal with this if ( Artifact.SCOPE_COMPILE.equals( a.getScope() ) || Artifact.SCOPE_PROVIDED.equals( a.getScope() ) || Artifact.SCOPE_SYSTEM.equals( a.getScope() ) ) { Dependency dependency = new Dependency(); dependency.setArtifactId( a.getArtifactId() ); dependency.setGroupId( a.getGroupId() ); dependency.setVersion( a.getVersion() ); dependency.setScope( a.getScope() ); dependency.setType( a.getType() ); dependency.setClassifier( a.getClassifier() ); list.add( dependency ); } } return list; } public List getTestClasspathElements() throws DependencyResolutionRequiredException { List list = new ArrayList( getArtifacts().size() + 1 ); list.add( getBuild().getTestOutputDirectory() ); list.add( getBuild().getOutputDirectory() ); for ( Iterator i = getArtifacts().iterator(); i.hasNext(); ) { Artifact a = (Artifact) i.next(); if ( a.getArtifactHandler().isAddedToClasspath() ) { // TODO: let the scope handler deal with this // NOTE: [jc] scope == 'test' is the widest possible scope, so we don't really need to perform // this check... // if ( Artifact.SCOPE_TEST.equals( a.getScope() ) || Artifact.SCOPE_COMPILE.equals( a.getScope() ) || // Artifact.SCOPE_RUNTIME.equals( a.getScope() ) ) // { // } File file = a.getFile(); if ( file == null ) { throw new DependencyResolutionRequiredException( a ); } list.add( file.getPath() ); } } return list; } public List getTestArtifacts() { List list = new ArrayList( getArtifacts().size() ); for ( Iterator i = getArtifacts().iterator(); i.hasNext(); ) { Artifact a = (Artifact) i.next(); // TODO: classpath check doesn't belong here - that's the other method if ( a.getArtifactHandler().isAddedToClasspath() ) { // TODO: let the scope handler deal with this // NOTE: [jc] scope == 'test' is the widest possible scope, so we don't really need to perform // this check... // if ( Artifact.SCOPE_TEST.equals( a.getScope() ) || Artifact.SCOPE_COMPILE.equals( a.getScope() ) || // Artifact.SCOPE_RUNTIME.equals( a.getScope() ) ) // { // list.add( a ); // } list.add( a ); } } return list; } public List getTestDependencies() { Set artifacts = getArtifacts(); if ( artifacts == null || artifacts.isEmpty() ) { return Collections.EMPTY_LIST; } List list = new ArrayList( artifacts.size() ); for ( Iterator i = getArtifacts().iterator(); i.hasNext(); ) { Artifact a = (Artifact) i.next(); // TODO: let the scope handler deal with this // NOTE: [jc] scope == 'test' is the widest possible scope, so we don't really need to perform // this check... // if ( Artifact.SCOPE_TEST.equals( a.getScope() ) || Artifact.SCOPE_COMPILE.equals( a.getScope() ) || // Artifact.SCOPE_RUNTIME.equals( a.getScope() ) ) // { // } Dependency dependency = new Dependency(); dependency.setArtifactId( a.getArtifactId() ); dependency.setGroupId( a.getGroupId() ); dependency.setVersion( a.getVersion() ); dependency.setScope( a.getScope() ); dependency.setType( a.getType() ); dependency.setClassifier( a.getClassifier() ); list.add( dependency ); } return list; } public List getRuntimeClasspathElements() throws DependencyResolutionRequiredException { List list = new ArrayList( getArtifacts().size() + 1 ); list.add( getBuild().getOutputDirectory() ); for ( Iterator i = getArtifacts().iterator(); i.hasNext(); ) { Artifact a = (Artifact) i.next(); if ( a.getArtifactHandler().isAddedToClasspath() ) { // TODO: let the scope handler deal with this if ( Artifact.SCOPE_COMPILE.equals( a.getScope() ) || Artifact.SCOPE_RUNTIME.equals( a.getScope() ) ) { File file = a.getFile(); if ( file == null ) { throw new DependencyResolutionRequiredException( a ); } list.add( file.getPath() ); } } } return list; } public List getRuntimeArtifacts() { List list = new ArrayList( getArtifacts().size() ); for ( Iterator i = getArtifacts().iterator(); i.hasNext(); ) { Artifact a = (Artifact) i.next(); // TODO: classpath check doesn't belong here - that's the other method if ( a.getArtifactHandler().isAddedToClasspath() ) { // TODO: let the scope handler deal with this if ( Artifact.SCOPE_COMPILE.equals( a.getScope() ) || Artifact.SCOPE_RUNTIME.equals( a.getScope() ) ) { list.add( a ); } } } return list; } public List getRuntimeDependencies() { Set artifacts = getArtifacts(); if ( artifacts == null || artifacts.isEmpty() ) { return Collections.EMPTY_LIST; } List list = new ArrayList( artifacts.size() ); for ( Iterator i = artifacts.iterator(); i.hasNext(); ) { Artifact a = (Artifact) i.next(); // TODO: let the scope handler deal with this if ( Artifact.SCOPE_COMPILE.equals( a.getScope() ) || Artifact.SCOPE_RUNTIME.equals( a.getScope() ) ) { Dependency dependency = new Dependency(); dependency.setArtifactId( a.getArtifactId() ); dependency.setGroupId( a.getGroupId() ); dependency.setVersion( a.getVersion() ); dependency.setScope( a.getScope() ); dependency.setType( a.getType() ); dependency.setClassifier( a.getClassifier() ); list.add( dependency ); } } return list; } public List getSystemClasspathElements() throws DependencyResolutionRequiredException { List list = new ArrayList( getArtifacts().size() ); list.add( getBuild().getOutputDirectory() ); for ( Iterator i = getArtifacts().iterator(); i.hasNext(); ) { Artifact a = (Artifact) i.next(); if ( a.getArtifactHandler().isAddedToClasspath() ) { // TODO: let the scope handler deal with this if ( Artifact.SCOPE_SYSTEM.equals( a.getScope() ) ) { addArtifactPath( a, list ); } } } return list; } public List getSystemArtifacts() { List list = new ArrayList( getArtifacts().size() ); for ( Iterator i = getArtifacts().iterator(); i.hasNext(); ) { Artifact a = (Artifact) i.next(); // TODO: classpath check doesn't belong here - that's the other method if ( a.getArtifactHandler().isAddedToClasspath() ) { // TODO: let the scope handler deal with this if ( Artifact.SCOPE_SYSTEM.equals( a.getScope() ) ) { list.add( a ); } } } return list; } public List getSystemDependencies() { Set artifacts = getArtifacts(); if ( artifacts == null || artifacts.isEmpty() ) { return Collections.EMPTY_LIST; } List list = new ArrayList( artifacts.size() ); for ( Iterator i = getArtifacts().iterator(); i.hasNext(); ) { Artifact a = (Artifact) i.next(); // TODO: let the scope handler deal with this if ( Artifact.SCOPE_SYSTEM.equals( a.getScope() ) ) { Dependency dependency = new Dependency(); dependency.setArtifactId( a.getArtifactId() ); dependency.setGroupId( a.getGroupId() ); dependency.setVersion( a.getVersion() ); dependency.setScope( a.getScope() ); dependency.setType( a.getType() ); dependency.setClassifier( a.getClassifier() ); list.add( dependency ); } } return list; } // ---------------------------------------------------------------------- // Delegate to the model // ---------------------------------------------------------------------- public void setModelVersion( String pomVersion ) { getModel().setModelVersion( pomVersion ); } public String getModelVersion() { return getModel().getModelVersion(); } public String getId() { return getModel().getId(); } public void setGroupId( String groupId ) { getModel().setGroupId( groupId ); } public String getGroupId() { String groupId = getModel().getGroupId(); if ( ( groupId == null ) && ( getModel().getParent() != null ) ) { groupId = getModel().getParent().getGroupId(); } return groupId; } public void setArtifactId( String artifactId ) { getModel().setArtifactId( artifactId ); } public String getArtifactId() { return getModel().getArtifactId(); } public void setName( String name ) { getModel().setName( name ); } public String getName() { // TODO: this should not be allowed to be null. if ( getModel().getName() != null ) { return getModel().getName(); } else { return "Unnamed - " + getId(); } } public void setVersion( String version ) { getModel().setVersion( version ); } public String getVersion() { String version = getModel().getVersion(); if ( ( version == null ) && ( getModel().getParent() != null ) ) { version = getModel().getParent().getVersion(); } return version; } public String getPackaging() { return getModel().getPackaging(); } public void setPackaging( String packaging ) { getModel().setPackaging( packaging ); } public void setInceptionYear( String inceptionYear ) { getModel().setInceptionYear( inceptionYear ); } public String getInceptionYear() { return getModel().getInceptionYear(); } public void setUrl( String url ) { getModel().setUrl( url ); } public String getUrl() { return getModel().getUrl(); } public Prerequisites getPrerequisites() { return getModel().getPrerequisites(); } public void setIssueManagement( IssueManagement issueManagement ) { getModel().setIssueManagement( issueManagement ); } public CiManagement getCiManagement() { return getModel().getCiManagement(); } public void setCiManagement( CiManagement ciManagement ) { getModel().setCiManagement( ciManagement ); } public IssueManagement getIssueManagement() { return getModel().getIssueManagement(); } public void setDistributionManagement( DistributionManagement distributionManagement ) { getModel().setDistributionManagement( distributionManagement ); } public DistributionManagement getDistributionManagement() { return getModel().getDistributionManagement(); } public void setDescription( String description ) { getModel().setDescription( description ); } public String getDescription() { return getModel().getDescription(); } public void setOrganization( Organization organization ) { getModel().setOrganization( organization ); } public Organization getOrganization() { return getModel().getOrganization(); } public void setScm( Scm scm ) { getModel().setScm( scm ); } public Scm getScm() { return getModel().getScm(); } public void setMailingLists( List mailingLists ) { getModel().setMailingLists( mailingLists ); } public List getMailingLists() { return getModel().getMailingLists(); } public void addMailingList( MailingList mailingList ) { getModel().addMailingList( mailingList ); } public void setDevelopers( List developers ) { getModel().setDevelopers( developers ); } public List getDevelopers() { return getModel().getDevelopers(); } public void addDeveloper( Developer developer ) { getModel().addDeveloper( developer ); } public void setContributors( List contributors ) { getModel().setContributors( contributors ); } public List getContributors() { return getModel().getContributors(); } public void addContributor( Contributor contributor ) { getModel().addContributor( contributor ); } public void setBuild( Build build ) { getModel().setBuild( build ); } public Build getBuild() { return getModelBuild(); } public List getResources() { return getBuild().getResources(); } public List getTestResources() { return getBuild().getTestResources(); } public void addResource( Resource resource ) { getBuild().addResource( resource ); } public void addTestResource( Resource testResource ) { getBuild().addTestResource( testResource ); } public void setReporting( Reporting reporting ) { getModel().setReporting( reporting ); } public Reporting getReporting() { return getModel().getReporting(); } public void setLicenses( List licenses ) { getModel().setLicenses( licenses ); } public List getLicenses() { return getModel().getLicenses(); } public void addLicense( License license ) { getModel().addLicense( license ); } public void setArtifacts( Set artifacts ) { this.artifacts = artifacts; // flush the calculated artifactMap this.artifactMap = null; } /** * All dependencies that this project has, including transitive ones. * Contents are lazily populated, so depending on what phases have run dependencies in some scopes won't be included. * eg. if only compile phase has run, dependencies with scope test won't be included. * @return {@link Set} < {@link Artifact} > * @see #getDependencyArtifacts() to get only direct dependencies */ public Set getArtifacts() { return artifacts == null ? Collections.EMPTY_SET : artifacts; } public Map getArtifactMap() { if ( artifactMap == null ) { artifactMap = ArtifactUtils.artifactMapByVersionlessId( getArtifacts() ); } return artifactMap; } public void setPluginArtifacts( Set pluginArtifacts ) { this.pluginArtifacts = pluginArtifacts; this.pluginArtifactMap = null; } public Set getPluginArtifacts() { return pluginArtifacts; } public Map getPluginArtifactMap() { if ( pluginArtifactMap == null ) { pluginArtifactMap = ArtifactUtils.artifactMapByVersionlessId( getPluginArtifacts() ); } return pluginArtifactMap; } public void setReportArtifacts( Set reportArtifacts ) { this.reportArtifacts = reportArtifacts; this.reportArtifactMap = null; } public Set getReportArtifacts() { return reportArtifacts; } public Map getReportArtifactMap() { if ( reportArtifactMap == null ) { reportArtifactMap = ArtifactUtils.artifactMapByVersionlessId( getReportArtifacts() ); } return reportArtifactMap; } public void setExtensionArtifacts( Set extensionArtifacts ) { this.extensionArtifacts = extensionArtifacts; this.extensionArtifactMap = null; } public Set getExtensionArtifacts() { return this.extensionArtifacts; } public Map getExtensionArtifactMap() { if ( extensionArtifactMap == null ) { extensionArtifactMap = ArtifactUtils.artifactMapByVersionlessId( getExtensionArtifacts() ); } return extensionArtifactMap; } public void setParentArtifact( Artifact parentArtifact ) { this.parentArtifact = parentArtifact; } public Artifact getParentArtifact() { return parentArtifact; } public List getRepositories() { return getModel().getRepositories(); } // ---------------------------------------------------------------------- // Plugins // ---------------------------------------------------------------------- public List getReportPlugins() { if ( getModel().getReporting() == null ) { return null; } return getModel().getReporting().getPlugins(); } public List getBuildPlugins() { if ( getModel().getBuild() == null ) { return null; } return getModel().getBuild().getPlugins(); } public List getModules() { return getModel().getModules(); } public PluginManagement getPluginManagement() { PluginManagement pluginMgmt = null; Build build = getModel().getBuild(); if ( build != null ) { pluginMgmt = build.getPluginManagement(); } return pluginMgmt; } private Build getModelBuild() { Build build = getModel().getBuild(); if ( build == null ) { build = new Build(); getModel().setBuild( build ); } return build; } public void addPlugin( Plugin plugin ) { Build build = getModelBuild(); if ( !build.getPluginsAsMap().containsKey( plugin.getKey() ) ) { injectPluginManagementInfo( plugin ); build.addPlugin( plugin ); build.flushPluginMap(); } } public void injectPluginManagementInfo( Plugin plugin ) { PluginManagement pm = getModelBuild().getPluginManagement(); if ( pm != null ) { Map pmByKey = pm.getPluginsAsMap(); String pluginKey = plugin.getKey(); if ( pmByKey != null && pmByKey.containsKey( pluginKey ) ) { Plugin pmPlugin = (Plugin) pmByKey.get( pluginKey ); ModelUtils.mergePluginDefinitions( plugin, pmPlugin, false ); } } } public List getCollectedProjects() { return collectedProjects; } public void setCollectedProjects( List collectedProjects ) { this.collectedProjects = collectedProjects; } public void setPluginArtifactRepositories( List pluginArtifactRepositories ) { this.pluginArtifactRepositories = pluginArtifactRepositories; } /** * @return a list of ArtifactRepository objects constructed * from the Repository objects returned by getPluginRepositories. */ public List getPluginArtifactRepositories() { return pluginArtifactRepositories; } public ArtifactRepository getDistributionManagementArtifactRepository() { return getArtifact().isSnapshot() && ( getSnapshotArtifactRepository() != null ) ? getSnapshotArtifactRepository() : getReleaseArtifactRepository(); } public List getPluginRepositories() { return getModel().getPluginRepositories(); } public void setActiveProfiles( List activeProfiles ) { this.activeProfiles.addAll( activeProfiles ); } public List getActiveProfiles() { return activeProfiles; } public void addAttachedArtifact( Artifact artifact ) { getAttachedArtifacts().add( artifact ); } public List getAttachedArtifacts() { if ( attachedArtifacts == null ) { attachedArtifacts = new ArrayList(); } return attachedArtifacts; } public Xpp3Dom getGoalConfiguration( String pluginGroupId, String pluginArtifactId, String executionId, String goalId ) { Xpp3Dom dom = null; // ---------------------------------------------------------------------- // I would like to be able to lookup the Mojo object using a key but // we have a limitation in modello that will be remedied shortly. So // for now I have to iterate through and see what we have. // ---------------------------------------------------------------------- if ( getBuildPlugins() != null ) { for ( Iterator iterator = getBuildPlugins().iterator(); iterator.hasNext(); ) { Plugin plugin = (Plugin) iterator.next(); if ( pluginGroupId.equals( plugin.getGroupId() ) && pluginArtifactId.equals( plugin.getArtifactId() ) ) { dom = (Xpp3Dom) plugin.getConfiguration(); if ( executionId != null ) { PluginExecution execution = (PluginExecution) plugin.getExecutionsAsMap().get( executionId ); if ( execution != null ) { Xpp3Dom executionConfiguration = (Xpp3Dom) execution.getConfiguration(); if ( executionConfiguration != null ) { Xpp3Dom newDom = new Xpp3Dom( executionConfiguration ); dom = Xpp3Dom.mergeXpp3Dom( newDom, dom ); } } } break; } } } // PluginManagement pluginManagement = getBuild().getPluginManagement(); // if ( pluginManagement != null && pluginManagement.getPlugins() != null ) // { // for ( Iterator iterator = pluginManagement.getPlugins().iterator(); iterator.hasNext(); ) // { // Plugin plugin = (Plugin) iterator.next(); // // if ( pluginGroupId.equals( plugin.getGroupId() ) && pluginArtifactId.equals( plugin.getArtifactId() ) ) // { // Xpp3Dom managedDom = (Xpp3Dom) plugin.getConfiguration(); // // if ( executionId != null ) // { // PluginExecution execution = (PluginExecution) plugin.getExecutionsAsMap().get( executionId ); // if ( execution != null ) // { // Xpp3Dom executionConfiguration = (Xpp3Dom) execution.getConfiguration(); // if ( executionConfiguration != null ) // { // Xpp3Dom newDom = new Xpp3Dom( executionConfiguration ); // managedDom = Xpp3Dom.mergeXpp3Dom( newDom, dom ); // } // } // } // // dom = Xpp3Dom.mergeXpp3Dom( dom, managedDom ); // break; // } // } // } if ( dom != null ) { // make a copy so the original in the POM doesn't get messed with dom = new Xpp3Dom( dom ); } return dom; } public Xpp3Dom getReportConfiguration( String pluginGroupId, String pluginArtifactId, String reportSetId ) { Xpp3Dom dom = null; // ---------------------------------------------------------------------- // I would like to be able to lookup the Mojo object using a key but // we have a limitation in modello that will be remedied shortly. So // for now I have to iterate through and see what we have. // ---------------------------------------------------------------------- if ( getReportPlugins() != null ) { for ( Iterator iterator = getReportPlugins().iterator(); iterator.hasNext(); ) { ReportPlugin plugin = (ReportPlugin) iterator.next(); if ( pluginGroupId.equals( plugin.getGroupId() ) && pluginArtifactId.equals( plugin.getArtifactId() ) ) { dom = (Xpp3Dom) plugin.getConfiguration(); if ( reportSetId != null ) { ReportSet reportSet = (ReportSet) plugin.getReportSetsAsMap().get( reportSetId ); if ( reportSet != null ) { Xpp3Dom executionConfiguration = (Xpp3Dom) reportSet.getConfiguration(); if ( executionConfiguration != null ) { Xpp3Dom newDom = new Xpp3Dom( executionConfiguration ); dom = Xpp3Dom.mergeXpp3Dom( newDom, dom ); } } } break; } } } if ( dom != null ) { // make a copy so the original in the POM doesn't get messed with dom = new Xpp3Dom( dom ); } return dom; } public MavenProject getExecutionProject() { return executionProject; } public void setExecutionProject( MavenProject executionProject ) { this.executionProject = executionProject; } public void writeModel( Writer writer ) throws IOException { MavenXpp3Writer pomWriter = new MavenXpp3Writer(); pomWriter.write( writer, getModel() ); } public void writeOriginalModel( Writer writer ) throws IOException { MavenXpp3Writer pomWriter = new MavenXpp3Writer(); pomWriter.write( writer, getOriginalModel() ); } /** * Direct dependencies that this project has. * @return {@link Set} < {@link Artifact} > * @see #getArtifacts() to get all transitive dependencies */ public Set getDependencyArtifacts() { return dependencyArtifacts; } public void setDependencyArtifacts( Set dependencyArtifacts ) { this.dependencyArtifacts = dependencyArtifacts; } public void setReleaseArtifactRepository( ArtifactRepository releaseArtifactRepository ) { this.releaseArtifactRepository = releaseArtifactRepository; } public void setSnapshotArtifactRepository( ArtifactRepository snapshotArtifactRepository ) { this.snapshotArtifactRepository = snapshotArtifactRepository; } public void setOriginalModel( Model originalModel ) { this.originalModel = originalModel; } public Model getOriginalModel() { return originalModel; } public void setManagedVersionMap( Map map ) { this.managedVersionMap = map; } public Map getManagedVersionMap() { return this.managedVersionMap; } public boolean equals( Object other ) { if ( other == this ) { return true; } else if ( !( other instanceof MavenProject ) ) { return false; } else { MavenProject otherProject = (MavenProject) other; return getId().equals( otherProject.getId() ); } } public int hashCode() { return getId().hashCode(); } public List getBuildExtensions() { Build build = getBuild(); if ( build == null || build.getExtensions() == null ) { return Collections.EMPTY_LIST; } else { return build.getExtensions(); } } /** * @todo the lazy initialisation of this makes me uneasy. * @return {@link Set} < {@link Artifact} > */ public Set createArtifacts( ArtifactFactory artifactFactory, String inheritedScope, ArtifactFilter dependencyFilter ) throws InvalidDependencyVersionException { return MavenMetadataSource.createArtifacts( artifactFactory, getDependencies(), inheritedScope, dependencyFilter, this ); } public void addProjectReference( MavenProject project ) { projectReferences.put( getProjectReferenceId( project.getGroupId(), project.getArtifactId(), project.getVersion() ), project ); } public static String getProjectReferenceId( String groupId, String artifactId, String version ) { return groupId + ":" + artifactId + ":" + version; } /** * @deprecated Use MavenProjectHelper.attachArtifact(..) instead. */ public void attachArtifact( String type, String classifier, File file ) { } public Properties getProperties() { return getModel().getProperties(); } public List getFilters() { return getBuild().getFilters(); } public Map getProjectReferences() { return projectReferences; } public boolean isExecutionRoot() { return executionRoot; } public void setExecutionRoot( boolean executionRoot ) { this.executionRoot = executionRoot; } public String getDefaultGoal() { return getBuild() != null ? getBuild().getDefaultGoal() : null; } protected void setModel( Model model ) { this.model = model; } protected void setAttachedArtifacts( List attachedArtifacts ) { this.attachedArtifacts = attachedArtifacts; } protected void setCompileSourceRoots( List compileSourceRoots ) { this.compileSourceRoots = compileSourceRoots; } protected void setTestCompileSourceRoots( List testCompileSourceRoots ) { this.testCompileSourceRoots = testCompileSourceRoots; } protected void setScriptSourceRoots( List scriptSourceRoots ) { this.scriptSourceRoots = scriptSourceRoots; } protected ArtifactRepository getReleaseArtifactRepository() { return releaseArtifactRepository; } protected ArtifactRepository getSnapshotArtifactRepository() { return snapshotArtifactRepository; } public void resolveActiveArtifacts() { Set depArtifacts = getDependencyArtifacts(); if ( depArtifacts == null ) { return; } Set updated = new LinkedHashSet( depArtifacts.size() ); int updatedCount = 0; for ( Iterator it = depArtifacts.iterator(); it.hasNext(); ) { Artifact depArtifact = (Artifact) it.next(); Artifact replaced = replaceWithActiveArtifact( depArtifact ); if ( depArtifact != replaced ) { updatedCount++; } updated.add( replaced ); } if ( updatedCount > 0 ) { setDependencyArtifacts( updated ); } } public Artifact replaceWithActiveArtifact( Artifact pluginArtifact ) { if ( getProjectReferences() != null && !getProjectReferences().isEmpty() ) { String refId = getProjectReferenceId( pluginArtifact.getGroupId(), pluginArtifact.getArtifactId(), pluginArtifact.getVersion() ); MavenProject ref = (MavenProject) getProjectReferences().get( refId ); if ( ref != null ) { if ( ref.getArtifact() != null && ref.getArtifact().getDependencyConflictId().equals( pluginArtifact.getDependencyConflictId() ) ) { // if the project artifact doesn't exist, don't use it. We haven't built that far. if ( ref.getArtifact().getFile() != null && ref.getArtifact().getFile().exists() ) { // FIXME: Why aren't we using project.getArtifact() for the second parameter here?? Artifact resultArtifact = new ActiveProjectArtifact( ref, pluginArtifact ); return resultArtifact; } else { logMissingSiblingProjectArtifact( pluginArtifact ); } } Artifact attached = findMatchingArtifact( ref.getAttachedArtifacts(), pluginArtifact ); if ( attached != null ) { if ( attached.getFile() != null && attached.getFile().exists() ) { Artifact resultArtifact = ArtifactUtils.copyArtifact( attached ); resultArtifact.setScope( pluginArtifact.getScope() ); return resultArtifact; } else { logMissingSiblingProjectArtifact( pluginArtifact ); } } } } return pluginArtifact; } /** * Tries to resolve the specified artifact from the given collection of attached project artifacts. * * @param artifacts The attached artifacts, may be null. * @param requestedArtifact The artifact to resolve, must not be null. * @return The matching artifact or null if not found. */ private Artifact findMatchingArtifact( List artifacts, Artifact requestedArtifact ) { if ( artifacts != null && !artifacts.isEmpty() ) { // first try matching by dependency conflict id String requestedId = requestedArtifact.getDependencyConflictId(); for ( Iterator it = artifacts.iterator(); it.hasNext(); ) { Artifact artifact = (Artifact) it.next(); if ( requestedId.equals( artifact.getDependencyConflictId() ) ) { return artifact; } } // next try matching by repository conflict id requestedId = getRepositoryConflictId( requestedArtifact ); for ( Iterator it = artifacts.iterator(); it.hasNext(); ) { Artifact artifact = (Artifact) it.next(); if ( requestedId.equals( getRepositoryConflictId( artifact ) ) ) { return artifact; } } } return null; } /** * Gets the repository conflict id of the specified artifact. Unlike the dependency conflict id, the repository * conflict id uses the artifact file extension instead of the artifact type. Hence, the repository conflict id more * closely reflects the identity of artifacts as perceived by a repository. * * @param artifact The artifact, must not be null. * @return The repository conflict id, never null. */ private String getRepositoryConflictId( Artifact artifact ) { StringBuffer buffer = new StringBuffer( 128 ); buffer.append( artifact.getGroupId() ); buffer.append( ':' ).append( artifact.getArtifactId() ); if ( artifact.getArtifactHandler() != null ) { buffer.append( ':' ).append( artifact.getArtifactHandler().getExtension() ); } else { buffer.append( ':' ).append( artifact.getType() ); } if ( artifact.hasClassifier() ) { buffer.append( ':' ).append( artifact.getClassifier() ); } return buffer.toString(); } private void logMissingSiblingProjectArtifact( Artifact artifact ) { if ( logger == null || !logger.isDebugEnabled() ) { return; } if ( logger.isDebugEnabled() ) { StringBuffer message = new StringBuffer(); message.append( "WARNING: A dependency of the current project (or of one the plugins used in its build) was found in the reactor, " ); message.append( "\nbut had not been built at the time it was requested. It will be resolved from the repository instead." ); message.append( "\n\nCurrent Project: " ).append( getName() ); message.append( "\nRequested Dependency: " ).append( artifact.getId() ); message.append( "\n\nNOTE: You may need to run this build to the 'compile' lifecycle phase, or farther, in order to build the dependency artifact." ); message.append( "\n" ); logger.debug( message.toString() ); } else { logger.warn( "Requested project artifact: " + artifact.getId() + " is not available at this time. Resolving externally." ); } } private void addArtifactPath(Artifact a, List list) throws DependencyResolutionRequiredException { File file = a.getFile(); if ( file == null ) { throw new DependencyResolutionRequiredException( a ); } list.add( file.getPath() ); } /** * Default toString */ public String toString() { StringBuffer sb = new StringBuffer(30); sb.append( "MavenProject: " ); sb.append( this.getGroupId() ); sb.append( ":" ); sb.append( this.getArtifactId() ); sb.append( ":" ); sb.append( this.getVersion() ); sb.append( " @ " ); try { sb.append( this.getFile().getPath() ); } catch (NullPointerException e) { //don't log it. } return sb.toString(); } /** * @throws CloneNotSupportedException * @since 2.0.9 */ public Object clone() throws CloneNotSupportedException { MavenProject clone = (MavenProject) super.clone(); clone.deepCopy( this ); return clone; } // ---------------------------------------------------------------------------- // CODE BELOW IS USED TO PRESERVE DYNAMISM IN THE BUILD SECTION OF THE POM. // ---------------------------------------------------------------------------- private Build dynamicBuild; private Build originalInterpolatedBuild; private List dynamicCompileSourceRoots; private List originalInterpolatedCompileSourceRoots; private List dynamicTestCompileSourceRoots; private List originalInterpolatedTestCompileSourceRoots; private List dynamicScriptSourceRoots; private List originalInterpolatedScriptSourceRoots; private boolean isConcrete = false; public boolean isConcrete() { return isConcrete; } public void setConcrete( boolean concrete ) { isConcrete = concrete; } public Build getDynamicBuild() { return dynamicBuild; } public Build getOriginalInterpolatedBuild() { return originalInterpolatedBuild; } public List getDynamicCompileSourceRoots() { return dynamicCompileSourceRoots; } public List getOriginalInterpolatedCompileSourceRoots() { return originalInterpolatedCompileSourceRoots; } public List getDynamicTestCompileSourceRoots() { return dynamicTestCompileSourceRoots; } public List getOriginalInterpolatedTestCompileSourceRoots() { return originalInterpolatedTestCompileSourceRoots; } public List getDynamicScriptSourceRoots() { return dynamicScriptSourceRoots; } public List getOriginalInterpolatedScriptSourceRoots() { return originalInterpolatedScriptSourceRoots; } public void clearRestorableRoots() { dynamicCompileSourceRoots = null; dynamicTestCompileSourceRoots = null; dynamicScriptSourceRoots = null; originalInterpolatedCompileSourceRoots = null; originalInterpolatedScriptSourceRoots = null; originalInterpolatedTestCompileSourceRoots = null; } public void clearRestorableBuild() { dynamicBuild = null; originalInterpolatedBuild = null; } public void preserveCompileSourceRoots( List originalInterpolatedCompileSourceRoots ) { dynamicCompileSourceRoots = getCompileSourceRoots(); this.originalInterpolatedCompileSourceRoots = originalInterpolatedCompileSourceRoots; } public void preserveTestCompileSourceRoots( List originalInterpolatedTestCompileSourceRoots ) { dynamicTestCompileSourceRoots = getTestCompileSourceRoots(); this.originalInterpolatedTestCompileSourceRoots = originalInterpolatedTestCompileSourceRoots; } public void preserveScriptSourceRoots( List originalInterpolatedScriptSourceRoots ) { dynamicScriptSourceRoots = getScriptSourceRoots(); this.originalInterpolatedScriptSourceRoots = originalInterpolatedScriptSourceRoots; } public void preserveBuild( Build originalInterpolatedBuild ) { dynamicBuild = getBuild(); this.originalInterpolatedBuild = originalInterpolatedBuild; this.originalInterpolatedBuild.setPluginManagement( null ); this.originalInterpolatedBuild.setPlugins( null ); } protected void setDynamicBuild( Build dynamicBuild ) { this.dynamicBuild = dynamicBuild; } protected void setOriginalInterpolatedBuild( Build originalInterpolatedBuild ) { this.originalInterpolatedBuild = originalInterpolatedBuild; } protected void setDynamicCompileSourceRoots( List dynamicCompileSourceRoots ) { this.dynamicCompileSourceRoots = dynamicCompileSourceRoots; } protected void setOriginalInterpolatedCompileSourceRoots( List originalInterpolatedCompileSourceRoots ) { this.originalInterpolatedCompileSourceRoots = originalInterpolatedCompileSourceRoots; } protected void setDynamicTestCompileSourceRoots( List dynamicTestCompileSourceRoots ) { this.dynamicTestCompileSourceRoots = dynamicTestCompileSourceRoots; } protected void setOriginalInterpolatedTestCompileSourceRoots( List originalInterpolatedTestCompileSourceRoots ) { this.originalInterpolatedTestCompileSourceRoots = originalInterpolatedTestCompileSourceRoots; } protected void setDynamicScriptSourceRoots( List dynamicScriptSourceRoots ) { this.dynamicScriptSourceRoots = dynamicScriptSourceRoots; } protected void setOriginalInterpolatedScriptSourceRoots( List originalInterpolatedScriptSourceRoots ) { this.originalInterpolatedScriptSourceRoots = originalInterpolatedScriptSourceRoots; } private Properties preservedProperties; public Properties getPreservedProperties() { return preservedProperties; } public void preserveProperties() { Properties p = getProperties(); if ( p != null ) { preservedProperties = new Properties(); for( Enumeration e = p.propertyNames(); e.hasMoreElements(); ) { String key = (String) e.nextElement(); preservedProperties.setProperty( key, p.getProperty( key ) ); } } } private File preservedBasedir; public File getPreservedBasedir() { return preservedBasedir; } public void preserveBasedir() { this.preservedBasedir = getBasedir(); } public void setLogger( Logger logger ) { this.logger = logger; } /** * Retrieve the {@link ProjectBuilderConfiguration} instance used to construct this MavenProject instance. */ public ProjectBuilderConfiguration getProjectBuilderConfiguration() { return projectBuilderConfiguration; } /** * Set the {@link ProjectBuilderConfiguration} instance used to construct this MavenProject instance. * @param projectBuilderConfiguration */ public void setProjectBuilderConfiguration( ProjectBuilderConfiguration projectBuilderConfiguration ) { this.projectBuilderConfiguration = projectBuilderConfiguration; } } maven2-core-2.2.1/maven-project/src/main/java/org/apache/maven/project/MavenProjectBuilder.java0000644000175000017500000002065211055044707032341 0ustar twernertwernerpackage org.apache.maven.project; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.artifact.resolver.ArtifactNotFoundException; import org.apache.maven.artifact.resolver.ArtifactResolutionException; import org.apache.maven.profiles.ProfileManager; import org.apache.maven.project.interpolation.ModelInterpolationException; import org.apache.maven.wagon.events.TransferListener; import java.io.File; import java.util.List; public interface MavenProjectBuilder { String ROLE = MavenProjectBuilder.class.getName(); String STANDALONE_SUPERPOM_GROUPID = "org.apache.maven"; String STANDALONE_SUPERPOM_ARTIFACTID = "super-pom"; String STANDALONE_SUPERPOM_VERSION = "2.0"; MavenProject build( File project, ArtifactRepository localRepository, ProfileManager globalProfileManager ) throws ProjectBuildingException; MavenProject build( File project, ArtifactRepository localRepository, ProfileManager globalProfileManager, boolean checkDistributionManagementStatus ) throws ProjectBuildingException; // ---------------------------------------------------------------------- // These methods are used by the MavenEmbedder // ---------------------------------------------------------------------- MavenProject buildWithDependencies( File project, ArtifactRepository localRepository, ProfileManager globalProfileManager, TransferListener transferListener ) throws ProjectBuildingException, ArtifactResolutionException, ArtifactNotFoundException; MavenProject buildWithDependencies( File project, ArtifactRepository localRepository, ProfileManager globalProfileManager ) throws ProjectBuildingException, ArtifactResolutionException, ArtifactNotFoundException; // ---------------------------------------------------------------------- // // ---------------------------------------------------------------------- /** * Build the artifact from the local repository, resolving it if necessary. * * @param artifact the artifact description * @param localRepository the local repository * @param remoteArtifactRepositories the remote repository list * @return the built project * @throws ProjectBuildingException */ MavenProject buildFromRepository( Artifact artifact, List remoteArtifactRepositories, ArtifactRepository localRepository ) throws ProjectBuildingException; /** * Build the artifact from the local repository, resolving it if necessary. * * @param artifact the artifact description * @param localRepository the local repository * @param remoteArtifactRepositories the remote repository list * @param allowStubModel return a stub if the POM is not found * @return the built project * @throws ProjectBuildingException */ MavenProject buildFromRepository( Artifact artifact, List remoteArtifactRepositories, ArtifactRepository localRepository, boolean allowStubModel ) throws ProjectBuildingException; /** * @deprecated Use {@link MavenProjectBuilder#buildStandaloneSuperProject(ProjectBuilderConfiguration)} instead. */ MavenProject buildStandaloneSuperProject( ArtifactRepository localRepository ) throws ProjectBuildingException; /** * need to pass a profilemanager with correct context (eg. with execution properties) * @deprecated Use {@link MavenProjectBuilder#buildStandaloneSuperProject(ProjectBuilderConfiguration)} instead. */ MavenProject buildStandaloneSuperProject( ArtifactRepository localRepository, ProfileManager profileManager ) throws ProjectBuildingException; MavenProject buildStandaloneSuperProject( ProjectBuilderConfiguration config ) throws ProjectBuildingException; MavenProject build( File pom, ProjectBuilderConfiguration config ) throws ProjectBuildingException; MavenProject build( File pom, ProjectBuilderConfiguration config, boolean checkDistributionManagementStatus ) throws ProjectBuildingException; // ---------------------------------------------------------------------------- // API BELOW IS USED TO PRESERVE DYNAMISM IN THE BUILD SECTION OF THE POM. // ---------------------------------------------------------------------------- /** * Variant of {@link MavenProjectBuilder#calculateConcreteState(MavenProject, ProjectBuilderConfiguration, boolean)} * which assumes that project references should be processed. This is provided for performance reasons, for cases * where you know all projects in the reactor will be processed, making traversal of project references unnecessary. */ void calculateConcreteState( MavenProject project, ProjectBuilderConfiguration config ) throws ModelInterpolationException; /** * Up to this point, the build section of the POM remains uninterpolated except for the artifact coordinates * it contains. This method will interpolate the build section and associated project-instance data * structures. Along with the {@link MavenProjectBuilder#restoreDynamicState(MavenProject, ProjectBuilderConfiguration, boolean)} * method, this method allows expressions in these areas of the POM and project instance to * be reevaluated in the event that a mojo changes one the build-path values, or a project property. *

    * This method will process the following: *
      *
    1. the specified project's parent project (if not null)
    2. *
    3. specified project
    4. *
    5. its execution project (if not null)
    6. *
    7. any project references (iff processReferences == true)
    8. *
    */ void calculateConcreteState( MavenProject project, ProjectBuilderConfiguration config, boolean processReferences ) throws ModelInterpolationException; // /** // * Variant of {@link MavenProjectBuilder#restoreDynamicState(MavenProject, ProjectBuilderConfiguration, boolean)} // * which assumes that project references should be processed. This is provided for performance reasons, for cases // * where you know all projects in the reactor will be processed, making traversal of project references unnecessary. // */ // void restoreDynamicState( MavenProject project, ProjectBuilderConfiguration config ) // throws ModelInterpolationException; // // /** // * In the event that a mojo execution has changed one or more build paths, or changed the project properties, // * this method can restore the build section of the POM to its uninterpolated form, to allow reevaluation of // * any expressions that may depend on this changed information. This method will short-circuit if the project // * is not in a concrete state (see {@link MavenProjectBuilder#calculateConcreteState(MavenProject, ProjectBuilderConfiguration, boolean)} // * or if the properties and build paths of the project remain unchanged. // *

    // * This method will process the following: // *
      // *
    1. the specified project's parent project (if not null)
    2. // *
    3. specified project
    4. // *
    5. its execution project (if not null)
    6. // *
    7. any project references (iff processReferences == true)
    8. // *
    // */ // void restoreDynamicState( MavenProject project, ProjectBuilderConfiguration config, boolean processReferences ) // throws ModelInterpolationException; } ././@LongLink0000000000000000000000000000015700000000000011570 Lustar rootrootmaven2-core-2.2.1/maven-project/src/main/java/org/apache/maven/project/DefaultProjectBuilderConfiguration.javamaven2-core-2.2.1/maven-project/src/main/java/org/apache/maven/project/DefaultProjectBuilderConfigur0000644000175000017500000000400411101576551033424 0ustar twernertwernerpackage org.apache.maven.project; import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.profiles.ProfileManager; import java.util.Date; import java.util.Properties; public class DefaultProjectBuilderConfiguration implements ProjectBuilderConfiguration { private ProfileManager globalProfileManager; private ArtifactRepository localRepository; private Properties userProperties; private Properties executionProperties = System.getProperties(); private Date buildStartTime; public DefaultProjectBuilderConfiguration() { } public ProjectBuilderConfiguration setGlobalProfileManager( ProfileManager globalProfileManager ) { this.globalProfileManager = globalProfileManager; return this; } public ProfileManager getGlobalProfileManager() { return globalProfileManager; } public ProjectBuilderConfiguration setLocalRepository( ArtifactRepository localRepository ) { this.localRepository = localRepository; return this; } public ArtifactRepository getLocalRepository() { return localRepository; } public ProjectBuilderConfiguration setUserProperties( Properties userProperties ) { this.userProperties = userProperties; return this; } public Properties getUserProperties() { if ( userProperties == null ) { userProperties = new Properties(); } return userProperties; } public Properties getExecutionProperties() { return executionProperties; } public ProjectBuilderConfiguration setExecutionProperties( Properties executionProperties ) { this.executionProperties = executionProperties; return this; } public Date getBuildStartTime() { return buildStartTime; } public ProjectBuilderConfiguration setBuildStartTime( Date buildStartTime ) { this.buildStartTime = buildStartTime; return this; } } maven2-core-2.2.1/maven-project/src/main/java/org/apache/maven/project/overlay/0000755000175000017500000000000011250552245027244 5ustar twernertwernermaven2-core-2.2.1/maven-project/src/main/java/org/apache/maven/project/overlay/BuildOverlay.java0000644000175000017500000001423110772004567032520 0ustar twernertwernerpackage org.apache.maven.project.overlay; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import org.apache.maven.model.Build; import org.apache.maven.model.Extension; import org.apache.maven.model.Plugin; import org.apache.maven.model.PluginManagement; import org.apache.maven.model.Resource; import java.util.ArrayList; import java.util.List; import java.util.Map; /** * @todo why delegate? this is asking for trouble when there are additions. */ public class BuildOverlay extends Build { private final Build build; private List resources; private List testResources; public BuildOverlay( Build build ) { if ( build == null ) { this.build = new Build(); this.resources = new ArrayList(); this.testResources = new ArrayList(); } else { this.build = build; this.resources = new ArrayList( build.getResources() ); this.testResources = new ArrayList( build.getTestResources() ); } } public void addExtension( Extension extension ) { build.addExtension( extension ); } public void addPlugin( Plugin plugin ) { build.addPlugin( plugin ); } public void addResource( Resource resource ) { resources.add( resource ); } public void addTestResource( Resource resource ) { testResources.add( resource ); } public boolean equals( Object obj ) { return build.equals( obj ); } public void flushPluginMap() { build.flushPluginMap(); } public String getDefaultGoal() { return build.getDefaultGoal(); } public String getDirectory() { return build.getDirectory(); } public List getExtensions() { return build.getExtensions(); } public String getFinalName() { return build.getFinalName(); } public String getOutputDirectory() { return build.getOutputDirectory(); } public PluginManagement getPluginManagement() { return build.getPluginManagement(); } public List getPlugins() { return build.getPlugins(); } public Map getPluginsAsMap() { return build.getPluginsAsMap(); } public List getResources() { return resources; } public String getScriptSourceDirectory() { return build.getScriptSourceDirectory(); } public String getSourceDirectory() { return build.getSourceDirectory(); } public String getTestOutputDirectory() { return build.getTestOutputDirectory(); } public List getTestResources() { return testResources; } public String getTestSourceDirectory() { return build.getTestSourceDirectory(); } public int hashCode() { return build.hashCode(); } public void removeExtension( Extension extension ) { build.removeExtension( extension ); } public void removePlugin( Plugin plugin ) { build.removePlugin( plugin ); } public void removeResource( Resource resource ) { resources.remove( resource ); } public void removeTestResource( Resource resource ) { testResources.remove( resource ); } public void setDefaultGoal( String defaultGoal ) { build.setDefaultGoal( defaultGoal ); } public void setDirectory( String directory ) { build.setDirectory( directory ); } public void setExtensions( List extensions ) { build.setExtensions( extensions ); } public void setFinalName( String finalName ) { build.setFinalName( finalName ); } public void setOutputDirectory( String outputDirectory ) { build.setOutputDirectory( outputDirectory ); } public void setPluginManagement( PluginManagement pluginManagement ) { build.setPluginManagement( pluginManagement ); } public void setPlugins( List plugins ) { build.setPlugins( plugins ); } public void setResources( List resources ) { this.resources = resources; } public void setScriptSourceDirectory( String scriptSourceDirectory ) { build.setScriptSourceDirectory( scriptSourceDirectory ); } public void setSourceDirectory( String sourceDirectory ) { build.setSourceDirectory( sourceDirectory ); } public void setTestOutputDirectory( String testOutputDirectory ) { build.setTestOutputDirectory( testOutputDirectory ); } public void setTestResources( List testResources ) { this.testResources = testResources; } public void setTestSourceDirectory( String testSourceDirectory ) { build.setTestSourceDirectory( testSourceDirectory ); } public String toString() { return build.toString(); } public void addFilter( String string ) { build.addFilter( string ); } //-- void addFilter(String) public List getFilters() { return build.getFilters(); } //-- java.util.List getFilters() public void removeFilter( String string ) { build.removeFilter( string ); } //-- void removeFilter(String) public void setFilters( List filters ) { build.setFilters( filters ); } //-- void setFilters(java.util.List) } maven2-core-2.2.1/maven-project/src/main/java/org/apache/maven/project/validation/0000755000175000017500000000000011250552246027716 5ustar twernertwerner././@LongLink0000000000000000000000000000014600000000000011566 Lustar rootrootmaven2-core-2.2.1/maven-project/src/main/java/org/apache/maven/project/validation/ModelValidator.javamaven2-core-2.2.1/maven-project/src/main/java/org/apache/maven/project/validation/ModelValidator.jav0000644000175000017500000000224110551365651033332 0ustar twernertwernerpackage org.apache.maven.project.validation; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import org.apache.maven.model.Model; /** * @author Trygve Laugstøl * @version $Id: ModelValidator.java 495147 2007-01-11 07:47:53Z jvanzyl $ */ public interface ModelValidator { String ROLE = ModelValidator.class.getName(); ModelValidationResult validate( Model model ); } ././@LongLink0000000000000000000000000000015500000000000011566 Lustar rootrootmaven2-core-2.2.1/maven-project/src/main/java/org/apache/maven/project/validation/ModelValidationResult.javamaven2-core-2.2.1/maven-project/src/main/java/org/apache/maven/project/validation/ModelValidationRes0000644000175000017500000000471210551365651033377 0ustar twernertwernerpackage org.apache.maven.project.validation; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import java.util.ArrayList; import java.util.Collections; import java.util.List; /** * @author Trygve Laugstøl * @version $Id: ModelValidationResult.java 495147 2007-01-11 07:47:53Z jvanzyl $ */ public class ModelValidationResult { /** */ private final static String NEWLINE = System.getProperty( "line.separator" ); /** */ private List messages; public ModelValidationResult() { messages = new ArrayList(); } public int getMessageCount() { return messages.size(); } public String getMessage( int i ) { return messages.get( i ).toString(); } public List getMessages() { return Collections.unmodifiableList( messages ); } public void addMessage( String message ) { messages.add( message ); } public String toString() { return render( "" ); } public String render( String indentation ) { if ( messages.size() == 0 ) { return indentation + "There were no validation errors."; } StringBuffer message = new StringBuffer(); // if ( messages.size() == 1 ) // { // message.append( "There was 1 validation error: " ); // } // else // { // message.append( "There was " + messages.size() + " validation errors: " + NEWLINE ); // } // for ( int i = 0; i < messages.size(); i++ ) { message.append( indentation + "[" + i + "] " + messages.get( i ).toString() + NEWLINE ); } return message.toString(); } } ././@LongLink0000000000000000000000000000015500000000000011566 Lustar rootrootmaven2-core-2.2.1/maven-project/src/main/java/org/apache/maven/project/validation/DefaultModelValidator.javamaven2-core-2.2.1/maven-project/src/main/java/org/apache/maven/project/validation/DefaultModelValida0000644000175000017500000003247311235644451033343 0ustar twernertwernerpackage org.apache.maven.project.validation; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import org.apache.maven.artifact.Artifact; import org.apache.maven.model.Build; import org.apache.maven.model.Dependency; import org.apache.maven.model.DependencyManagement; import org.apache.maven.model.Model; import org.apache.maven.model.Parent; import org.apache.maven.model.Plugin; import org.apache.maven.model.ReportPlugin; import org.apache.maven.model.Reporting; import org.apache.maven.model.Repository; import org.apache.maven.model.Resource; import org.codehaus.plexus.util.StringUtils; import java.io.File; import java.util.Iterator; import java.util.List; /** * @author Trygve Laugstøl * @version $Id: DefaultModelValidator.java 800540 2009-08-03 20:31:37Z jdcasey $ */ public class DefaultModelValidator implements ModelValidator { private static final String ID_REGEX = "[A-Za-z0-9_\\-.]+"; /////////////////////////////////////////////////////////////////////////// // ModelValidator Implementation public ModelValidationResult validate( final Model model ) { ModelValidationResult result = new ModelValidationResult(); validateStringNotEmpty( "modelVersion", result, model.getModelVersion() ); validateId( "groupId", result, model.getGroupId() ); validateId( "artifactId", result, model.getArtifactId() ); validateStringNotEmpty( "packaging", result, model.getPackaging() ); if ( !model.getModules().isEmpty() && !"pom".equals( model.getPackaging() ) ) { result.addMessage( "Packaging '" + model.getPackaging() + "' is invalid. Aggregator projects " + "require 'pom' as packaging." ); } Parent parent = model.getParent(); if ( parent != null ) { if ( parent.getGroupId().equals( model.getGroupId() ) && parent.getArtifactId().equals( model.getArtifactId() ) ) { result.addMessage( "The parent element cannot have the same ID as the project." ); } } validateStringNotEmpty( "version", result, model.getVersion() ); for ( Iterator it = model.getDependencies().iterator(); it.hasNext(); ) { Dependency d = (Dependency) it.next(); validateId( "dependencies.dependency.artifactId", result, d.getArtifactId() ); validateId( "dependencies.dependency.groupId", result, d.getGroupId() ); validateStringNotEmpty( "dependencies.dependency.type", result, d.getType(), d.getManagementKey() ); validateStringNotEmpty( "dependencies.dependency.version", result, d.getVersion(), d.getManagementKey() ); if ( Artifact.SCOPE_SYSTEM.equals( d.getScope() ) ) { String systemPath = d.getSystemPath(); if ( StringUtils.isEmpty( systemPath ) ) { result.addMessage( "For dependency " + d + ": system-scoped dependency must specify systemPath." ); } else { if ( ! new File( systemPath ).isAbsolute() ) { result.addMessage( "For dependency " + d + ": system-scoped dependency must " + "specify an absolute path systemPath." ); } } } else if ( StringUtils.isNotEmpty( d.getSystemPath() ) ) { result.addMessage( "For dependency " + d + ": only dependency with system scope can specify systemPath." ); } } DependencyManagement mgmt = model.getDependencyManagement(); if ( mgmt != null ) { for ( Iterator it = mgmt.getDependencies().iterator(); it.hasNext(); ) { Dependency d = (Dependency) it.next(); validateSubElementStringNotEmpty( d, "dependencyManagement.dependencies.dependency.artifactId", result, d.getArtifactId() ); validateSubElementStringNotEmpty( d, "dependencyManagement.dependencies.dependency.groupId", result, d.getGroupId() ); if ( Artifact.SCOPE_SYSTEM.equals( d.getScope() ) ) { String systemPath = d.getSystemPath(); if ( StringUtils.isEmpty( systemPath ) ) { result.addMessage( "For managed dependency " + d + ": system-scoped dependency must specify systemPath." ); } else { if ( ! new File( systemPath ).isAbsolute() ) { result.addMessage( "For managed dependency " + d + ": system-scoped dependency must " + "specify an absolute path systemPath." ); } } } else if ( StringUtils.isNotEmpty( d.getSystemPath() ) ) { result.addMessage( "For managed dependency " + d + ": only dependency with system scope can specify systemPath." ); } else if ( Artifact.SCOPE_IMPORT.equals( d.getScope() ) ) { if ( !"pom".equals( d.getType() ) ) { result.addMessage( "For managed dependency " + d + ": dependencies with import scope must have type 'pom'." ); } else if ( d.getClassifier() != null ) { result.addMessage( "For managed dependency " + d + ": dependencies with import scope must NOT have a classifier." ); } } } } Build build = model.getBuild(); if ( build != null ) { for ( Iterator it = build.getPlugins().iterator(); it.hasNext(); ) { Plugin p = (Plugin) it.next(); validateStringNotEmpty( "build.plugins.plugin.artifactId", result, p.getArtifactId() ); validateStringNotEmpty( "build.plugins.plugin.groupId", result, p.getGroupId() ); } for ( Iterator it = build.getResources().iterator(); it.hasNext(); ) { Resource r = (Resource) it.next(); validateStringNotEmpty( "build.resources.resource.directory", result, r.getDirectory() ); } for ( Iterator it = build.getTestResources().iterator(); it.hasNext(); ) { Resource r = (Resource) it.next(); validateStringNotEmpty( "build.testResources.testResource.directory", result, r.getDirectory() ); } } Reporting reporting = model.getReporting(); if ( reporting != null ) { for ( Iterator it = reporting.getPlugins().iterator(); it.hasNext(); ) { ReportPlugin p = (ReportPlugin) it.next(); validateStringNotEmpty( "reporting.plugins.plugin.artifactId", result, p.getArtifactId() ); validateStringNotEmpty( "reporting.plugins.plugin.groupId", result, p.getGroupId() ); } } validateRepositories( result, model.getRepositories(), "repositories.repository" ); validateRepositories( result, model.getPluginRepositories(), "pluginRepositories.pluginRepository" ); forcePluginExecutionIdCollision( model, result ); return result; } private boolean validateId( final String fieldName, final ModelValidationResult result, final String id ) { if ( !validateStringNotEmpty( fieldName, result, id ) ) { return false; } else { boolean match = id.matches( ID_REGEX ); if ( !match ) { result.addMessage( "'" + fieldName + "' with value '" + id + "' does not match a valid id pattern." ); } return match; } } private void validateRepositories( final ModelValidationResult result, final List repositories, final String prefix ) { for ( Iterator it = repositories.iterator(); it.hasNext(); ) { Repository repository = (Repository) it.next(); validateStringNotEmpty( prefix + ".id", result, repository.getId() ); validateStringNotEmpty( prefix + ".url", result, repository.getUrl() ); } } private void forcePluginExecutionIdCollision( final Model model, final ModelValidationResult result ) { Build build = model.getBuild(); if ( build != null ) { List plugins = build.getPlugins(); if ( plugins != null ) { for ( Iterator it = plugins.iterator(); it.hasNext(); ) { Plugin plugin = (Plugin) it.next(); // this will force an IllegalStateException, even if we don't have to do inheritance assembly. try { plugin.getExecutionsAsMap(); } catch ( IllegalStateException collisionException ) { result.addMessage( collisionException.getMessage() ); } } } } } // ---------------------------------------------------------------------- // Field validation // ---------------------------------------------------------------------- private boolean validateStringNotEmpty( final String fieldName, final ModelValidationResult result, final String string ) { return validateStringNotEmpty( fieldName, result, string, null ); } /** * Asserts: *

    *

      *
    • string.length != null *
    • string.length > 0 *
    */ private boolean validateStringNotEmpty( final String fieldName, final ModelValidationResult result, final String string, final String sourceHint ) { if ( !validateNotNull( fieldName, result, string, sourceHint ) ) { return false; } if ( string.length() > 0 ) { return true; } if ( sourceHint != null ) { result.addMessage( "'" + fieldName + "' is missing for " + sourceHint ); } else { result.addMessage( "'" + fieldName + "' is missing." ); } return false; } /** * Asserts: *

    *

      *
    • string.length != null *
    • string.length > 0 *
    */ private boolean validateSubElementStringNotEmpty( final Object subElementInstance, final String fieldName, final ModelValidationResult result, final String string ) { if ( !validateSubElementNotNull( subElementInstance, fieldName, result, string ) ) { return false; } if ( string.length() > 0 ) { return true; } result.addMessage( "In " + subElementInstance + ":\n\n -> '" + fieldName + "' is missing." ); return false; } /** * Asserts: *

    *

      *
    • string != null *
    */ private boolean validateNotNull( final String fieldName, final ModelValidationResult result, final Object object, final String sourceHint ) { if ( object != null ) { return true; } if ( sourceHint != null ) { result.addMessage( "'" + fieldName + "' is missing for " + sourceHint ); } else { result.addMessage( "'" + fieldName + "' is missing." ); } return false; } /** * Asserts: *

    *

      *
    • string != null *
    */ private boolean validateSubElementNotNull( final Object subElementInstance, final String fieldName, final ModelValidationResult result, final Object object ) { if ( object != null ) { return true; } result.addMessage( "In " + subElementInstance + ":\n\n -> '" + fieldName + "' is missing." ); return false; } } maven2-core-2.2.1/maven-project/src/main/java/org/apache/maven/project/path/0000755000175000017500000000000011250552246026520 5ustar twernertwernermaven2-core-2.2.1/maven-project/src/main/java/org/apache/maven/project/path/PathTranslator.java0000644000175000017500000000257010551365651032342 0ustar twernertwernerpackage org.apache.maven.project.path; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import org.apache.maven.model.Model; import java.io.File; /** * @author Jason van Zyl * @version $Id: PathTranslator.java 495147 2007-01-11 07:47:53Z jvanzyl $ */ public interface PathTranslator { String ROLE = PathTranslator.class.getName(); void alignToBaseDirectory( Model model, File basedir ); String alignToBaseDirectory( String path, File basedir ); void unalignFromBaseDirectory( Model model, File basedir ); String unalignFromBaseDirectory( String directory, File basedir ); } ././@LongLink0000000000000000000000000000014700000000000011567 Lustar rootrootmaven2-core-2.2.1/maven-project/src/main/java/org/apache/maven/project/path/DefaultPathTranslator.javamaven2-core-2.2.1/maven-project/src/main/java/org/apache/maven/project/path/DefaultPathTranslator.ja0000644000175000017500000002110111156527474033314 0ustar twernertwernerpackage org.apache.maven.project.path; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import org.apache.maven.model.Build; import org.apache.maven.model.Model; import org.apache.maven.model.Reporting; import org.apache.maven.model.Resource; import java.io.File; import java.util.ArrayList; import java.util.Iterator; import java.util.List; /** * Default implementation of {@link PathTranslator}. */ public class DefaultPathTranslator implements PathTranslator { private static final String[] BASEDIR_EXPRESSIONS = { "${basedir}", "${pom.basedir}", "${project.basedir}" }; public void alignToBaseDirectory( Model model, File basedir ) { if ( basedir == null ) { return; } Build build = model.getBuild(); if ( build != null ) { build.setDirectory( alignToBaseDirectory( build.getDirectory(), basedir ) ); build.setSourceDirectory( alignToBaseDirectory( build.getSourceDirectory(), basedir ) ); build.setTestSourceDirectory( alignToBaseDirectory( build.getTestSourceDirectory(), basedir ) ); // TODO: MNG-3731 // build.setScriptSourceDirectory( alignToBaseDirectory( build.getScriptSourceDirectory(), basedir ) ); for ( Iterator i = build.getResources().iterator(); i.hasNext(); ) { Resource resource = (Resource) i.next(); resource.setDirectory( alignToBaseDirectory( resource.getDirectory(), basedir ) ); } for ( Iterator i = build.getTestResources().iterator(); i.hasNext(); ) { Resource resource = (Resource) i.next(); resource.setDirectory( alignToBaseDirectory( resource.getDirectory(), basedir ) ); } if ( build.getFilters() != null ) { List filters = new ArrayList(); for ( Iterator i = build.getFilters().iterator(); i.hasNext(); ) { String filter = (String) i.next(); filters.add( alignToBaseDirectory( filter, basedir ) ); } build.setFilters( filters ); } build.setOutputDirectory( alignToBaseDirectory( build.getOutputDirectory(), basedir ) ); build.setTestOutputDirectory( alignToBaseDirectory( build.getTestOutputDirectory(), basedir ) ); } Reporting reporting = model.getReporting(); if ( reporting != null ) { reporting.setOutputDirectory( alignToBaseDirectory( reporting.getOutputDirectory(), basedir ) ); } } /** * {@inheritDoc} */ public String alignToBaseDirectory( String path, File basedir ) { if ( basedir == null ) { return path; } if ( path == null ) { return null; } String s = stripBasedirToken( path ); File file = new File( s ); if ( file.isAbsolute() ) { // path was already absolute, just normalize file separator and we're done s = file.getPath(); } else if ( file.getPath().startsWith( File.separator ) ) { // drive-relative Windows path, don't align with project directory but with drive root s = file.getAbsolutePath(); } else { // an ordinary relative path, align with project directory s = new File( new File( basedir, s ).toURI().normalize() ).getAbsolutePath(); } return s; } private String stripBasedirToken( String s ) { if ( s != null ) { String basedirExpr = null; for ( int i = 0; i < BASEDIR_EXPRESSIONS.length; i++ ) { basedirExpr = BASEDIR_EXPRESSIONS[i]; if ( s.startsWith( basedirExpr ) ) { break; } else { basedirExpr = null; } } if ( basedirExpr != null ) { if ( s.length() > basedirExpr.length() ) { // Take out basedir expression and the leading slash s = chopLeadingFileSeparator( s.substring( basedirExpr.length() ) ); } else { s = "."; } } } return s; } /** * Removes the leading directory separator from the specified filesystem path (if any). For platform-independent * behavior, this method accepts both the forward slash and the backward slash as separator. * * @param path The filesystem path, may be null. * @return The altered filesystem path or null if the input path was null. */ private String chopLeadingFileSeparator( String path ) { if ( path != null ) { if ( path.startsWith( "/" ) || path.startsWith( "\\" ) ) { path = path.substring( 1 ); } } return path; } /** * {@inheritDoc} */ public void unalignFromBaseDirectory( Model model, File basedir ) { if ( basedir == null ) { return; } Build build = model.getBuild(); if ( build != null ) { build.setDirectory( unalignFromBaseDirectory( build.getDirectory(), basedir ) ); build.setSourceDirectory( unalignFromBaseDirectory( build.getSourceDirectory(), basedir ) ); build.setTestSourceDirectory( unalignFromBaseDirectory( build.getTestSourceDirectory(), basedir ) ); build.setScriptSourceDirectory( unalignFromBaseDirectory( build.getScriptSourceDirectory(), basedir ) ); for ( Iterator i = build.getResources().iterator(); i.hasNext(); ) { Resource resource = (Resource) i.next(); resource.setDirectory( unalignFromBaseDirectory( resource.getDirectory(), basedir ) ); } for ( Iterator i = build.getTestResources().iterator(); i.hasNext(); ) { Resource resource = (Resource) i.next(); resource.setDirectory( unalignFromBaseDirectory( resource.getDirectory(), basedir ) ); } if ( build.getFilters() != null ) { List filters = new ArrayList(); for ( Iterator i = build.getFilters().iterator(); i.hasNext(); ) { String filter = (String) i.next(); filters.add( unalignFromBaseDirectory( filter, basedir ) ); } build.setFilters( filters ); } build.setOutputDirectory( unalignFromBaseDirectory( build.getOutputDirectory(), basedir ) ); build.setTestOutputDirectory( unalignFromBaseDirectory( build.getTestOutputDirectory(), basedir ) ); } Reporting reporting = model.getReporting(); if ( reporting != null ) { reporting.setOutputDirectory( unalignFromBaseDirectory( reporting.getOutputDirectory(), basedir ) ); } } /** * {@inheritDoc} */ public String unalignFromBaseDirectory( String path, File basedir ) { if ( basedir == null ) { return path; } if ( path == null ) { return null; } path = path.trim(); String base = basedir.getAbsolutePath(); if ( path.startsWith( base ) ) { path = chopLeadingFileSeparator( path.substring( base.length() ) ); } if ( !new File( path ).isAbsolute() ) { path = path.replace( '\\', '/' ); } return path; } } maven2-core-2.2.1/maven-project/src/main/java/org/apache/maven/project/MavenProjectHelper.java0000644000175000017500000000276010772004567032177 0ustar twernertwernerpackage org.apache.maven.project; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import java.io.File; import java.util.List; public interface MavenProjectHelper { String ROLE = MavenProjectHelper.class.getName(); void attachArtifact( MavenProject project, File artifactFile, String artifactClassifier ); void attachArtifact( MavenProject project, String artifactType, File artifactFile ); void attachArtifact( MavenProject project, String artifactType, String artifactClassifier, File artifactFile ); void addResource( MavenProject project, String resourceDirectory, List includes, List excludes ); void addTestResource( MavenProject project, String resourceDirectory, List includes, List excludes ); } maven2-core-2.2.1/maven-project/src/main/java/org/apache/maven/project/ProjectSorter.java0000644000175000017500000003674711226741032031251 0ustar twernertwernerpackage org.apache.maven.project; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import java.io.File; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.Set; import org.apache.maven.artifact.ArtifactUtils; import org.apache.maven.model.Dependency; import org.apache.maven.model.Extension; import org.apache.maven.model.Plugin; import org.apache.maven.model.ReportPlugin; import org.codehaus.plexus.util.dag.CycleDetectedException; import org.codehaus.plexus.util.dag.DAG; import org.codehaus.plexus.util.dag.TopologicalSorter; import org.codehaus.plexus.util.dag.Vertex; /** * Sort projects by dependencies. * * @author Brett Porter * @version $Id: ProjectSorter.java 793745 2009-07-13 23:24:10Z jdcasey $ */ public class ProjectSorter { private final DAG dag; private final Map projectMap; private final List sortedProjects; private MavenProject topLevelProject; /** * Sort a list of projects. *
      *
    • collect all the vertices for the projects that we want to build.
    • *
    • 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.
    • *
    • do a topo sort on the graph that remains.
    • *
    * @throws DuplicateProjectException if any projects are duplicated by id * @throws MissingProjectException */ public ProjectSorter( List projects ) throws CycleDetectedException, DuplicateProjectException, MissingProjectException { this( projects, null, null, false, false ); } public ProjectSorter( List projects, List selectedProjectNames, String resumeFrom, boolean make, boolean makeDependents ) throws CycleDetectedException, DuplicateProjectException, MissingProjectException { dag = new DAG(); projectMap = new HashMap(); for ( Iterator i = projects.iterator(); i.hasNext(); ) { MavenProject project = (MavenProject) i.next(); String id = ArtifactUtils.versionlessKey( project.getGroupId(), project.getArtifactId() ); if ( dag.getVertex( id ) != null ) { throw new DuplicateProjectException( "Project '" + id + "' is duplicated in the reactor" ); } dag.addVertex( id ); projectMap.put( id, project ); } for ( Iterator i = projects.iterator(); i.hasNext(); ) { MavenProject project = (MavenProject) i.next(); String id = ArtifactUtils.versionlessKey( project.getGroupId(), project.getArtifactId() ); for ( Iterator j = project.getDependencies().iterator(); j.hasNext(); ) { Dependency dependency = (Dependency) j.next(); String dependencyId = ArtifactUtils .versionlessKey( dependency.getGroupId(), dependency.getArtifactId() ); if ( dag.getVertex( dependencyId ) != null ) { project.addProjectReference( (MavenProject) projectMap.get( dependencyId ) ); dag.addEdge( id, dependencyId ); } } MavenProject parent = project.getParent(); if ( parent != null ) { String parentId = ArtifactUtils.versionlessKey( parent.getGroupId(), parent.getArtifactId() ); if ( dag.getVertex( parentId ) != null ) { // Parent is added as an edge, but must not cause a cycle - so we remove any other edges it has in conflict if ( dag.hasEdge( parentId, id ) ) { dag.removeEdge( parentId, id ); } dag.addEdge( id, parentId ); } } List buildPlugins = project.getBuildPlugins(); if ( buildPlugins != null ) { for ( Iterator j = buildPlugins.iterator(); j.hasNext(); ) { Plugin plugin = (Plugin) j.next(); String pluginId = ArtifactUtils.versionlessKey( plugin.getGroupId(), plugin.getArtifactId() ); if ( dag.getVertex( pluginId ) != null && !pluginId.equals( id ) ) { addEdgeWithParentCheck( projectMap, pluginId, project, id ); } if ( !pluginId.equals( id ) ) { for ( Iterator k = plugin.getDependencies().iterator(); k.hasNext(); ) { Dependency dependency = (Dependency) k.next(); String dependencyId = ArtifactUtils .versionlessKey( dependency.getGroupId(), dependency.getArtifactId() ); if ( dag.getVertex( dependencyId ) != null ) { // If the plugin in which this dependency is listed is actually used here, // it will probably be stuck using an older version of this project that // already exists in the local repository. If not yet installed, it is // likely that we'll get an ArtifactNotFoundException when this plugin // is executed to build this project. // // If the plugin is NOT actually used here, it may actually belong in the // pluginManagement section. if ( !id.equals( dependencyId ) ) { project.addProjectReference( (MavenProject) projectMap.get( dependencyId ) ); addEdgeWithParentCheck( projectMap, dependencyId, project, id ); // TODO: Shouldn't we add an edge between the plugin and its dependency? // Note that doing this may result in cycles...run // ProjectSorterTest.testPluginDependenciesInfluenceSorting_DeclarationInParent() // for more information, if you change this: // dag.addEdge( pluginId, dependencyId ); } } } } } } List reportPlugins = project.getReportPlugins(); if ( reportPlugins != null ) { for ( Iterator j = reportPlugins.iterator(); j.hasNext(); ) { ReportPlugin plugin = (ReportPlugin) j.next(); String pluginId = ArtifactUtils.versionlessKey( plugin.getGroupId(), plugin.getArtifactId() ); if ( dag.getVertex( pluginId ) != null && !pluginId.equals( id ) ) { addEdgeWithParentCheck( projectMap, pluginId, project, id ); } } } for ( Iterator j = project.getBuildExtensions().iterator(); j.hasNext(); ) { Extension extension = (Extension) j.next(); String extensionId = ArtifactUtils.versionlessKey( extension.getGroupId(), extension.getArtifactId() ); if ( dag.getVertex( extensionId ) != null ) { addEdgeWithParentCheck( projectMap, extensionId, project, id ); } } } List sortedProjects = new ArrayList(); for ( Iterator i = TopologicalSorter.sort( dag ).iterator(); i.hasNext(); ) { String id = (String) i.next(); sortedProjects.add( projectMap.get( id ) ); } // TODO: !![jc; 28-jul-2005] check this; if we're using '-r' and there are aggregator tasks, this will result in weirdness. for ( Iterator i = sortedProjects.iterator(); i.hasNext() && topLevelProject == null; ) { MavenProject project = (MavenProject) i.next(); if ( project.isExecutionRoot() ) { topLevelProject = project; } } sortedProjects = applyMakeFilter( sortedProjects, dag, projectMap, topLevelProject, selectedProjectNames, make, makeDependents ); resumeFrom( resumeFrom, sortedProjects, projectMap, topLevelProject ); this.sortedProjects = Collections.unmodifiableList( sortedProjects ); } // make selected projects and possibly projects they depend on, or projects that depend on them private static List applyMakeFilter( List sortedProjects, DAG dag, Map projectMap, MavenProject topLevelProject, List selectedProjectNames, boolean make, boolean makeDependents ) throws MissingProjectException { if ( selectedProjectNames == null ) return sortedProjects; MavenProject[] selectedProjects = new MavenProject[selectedProjectNames.size()]; for ( int i = 0; i < selectedProjects.length; i++ ) { selectedProjects[i] = findProject( (String) selectedProjectNames.get( i ), projectMap, topLevelProject ); } Set projectsToMake = new HashSet( Arrays.asList( selectedProjects ) ); for ( int i = 0; i < selectedProjects.length; i++ ) { MavenProject project = selectedProjects[i]; String id = ArtifactUtils.versionlessKey( project.getGroupId(), project.getArtifactId() ); Vertex v = dag.getVertex( id ); if ( make ) { gatherDescendents ( v, projectMap, projectsToMake, new HashSet() ); } if ( makeDependents ) { gatherAncestors ( v, projectMap, projectsToMake, new HashSet() ); } } for ( Iterator i = sortedProjects.iterator(); i.hasNext(); ) { MavenProject project = (MavenProject) i.next(); if ( !projectsToMake.contains( project ) ) { i.remove(); } } return sortedProjects; } private static void resumeFrom( String resumeFrom, List sortedProjects, Map projectMap, MavenProject topLevelProject ) throws MissingProjectException { if ( resumeFrom == null ) return; MavenProject resumeFromProject = findProject( resumeFrom, projectMap, topLevelProject ); for ( Iterator i = sortedProjects.iterator(); i.hasNext(); ) { MavenProject project = (MavenProject) i.next(); if ( resumeFromProject.equals( project ) ) break; i.remove(); } if ( sortedProjects.isEmpty() ) { throw new MissingProjectException( "Couldn't resume, project was not scheduled to run: " + resumeFrom ); } } private static MavenProject findProject( String projectName, Map projectMap, MavenProject topLevelProject ) throws MissingProjectException { MavenProject project = (MavenProject) projectMap.get( projectName ); if ( project != null ) return project; // in that case, it must be a file path File baseDir; if ( topLevelProject == null ) { baseDir = new File( System.getProperty( "user.dir" ) ); } else { baseDir = topLevelProject.getBasedir(); // or should this be .getFile().getParentFile() ? } File projectDir = new File( baseDir, projectName ); if ( !projectDir.exists() ) { throw new MissingProjectException( "Couldn't find specified project dir: " + projectDir.getAbsolutePath() ); } if ( !projectDir.isDirectory() ) { throw new MissingProjectException( "Couldn't find specified project dir (not a directory): " + projectDir.getAbsolutePath() ); } for ( Iterator i = projectMap.values().iterator(); i.hasNext(); ) { project = (MavenProject) i.next(); if ( projectDir.equals( project.getFile().getParentFile() ) ) return project; } throw new MissingProjectException( "Couldn't find specified project in module list: " + projectDir.getAbsolutePath() ); } private static void gatherDescendents ( Vertex v, Map projectMap, Set out, Set visited ) { if ( visited.contains( v ) ) return; visited.add( v ); out.add( projectMap.get( v.getLabel() ) ); for ( Iterator i = v.getChildren().iterator(); i.hasNext(); ) { Vertex child = (Vertex) i.next(); gatherDescendents( child, projectMap, out, visited ); } } private static void gatherAncestors ( Vertex v, Map projectMap, Set out, Set visited ) { if ( visited.contains( v ) ) return; visited.add( v ); out.add( projectMap.get( v.getLabel() ) ); for ( Iterator i = v.getParents().iterator(); i.hasNext(); ) { Vertex parent = (Vertex) i.next(); gatherAncestors( parent, projectMap, out, visited ); } } private void addEdgeWithParentCheck( Map projectMap, String projectRefId, MavenProject project, String id ) throws CycleDetectedException { MavenProject extProject = (MavenProject) projectMap.get( projectRefId ); if ( extProject == null ) { return; } project.addProjectReference( extProject ); MavenProject extParent = extProject.getParent(); if ( extParent != null ) { String parentId = ArtifactUtils.versionlessKey( extParent.getGroupId(), extParent.getArtifactId() ); // Don't add edge from parent to extension if a reverse edge already exists if ( !dag.hasEdge( projectRefId, id ) || !parentId.equals( id ) ) { dag.addEdge( id, projectRefId ); } } } public MavenProject getTopLevelProject() { return topLevelProject; } public List getSortedProjects() { return sortedProjects; } public boolean hasMultipleProjects() { return sortedProjects.size() > 1; } public List getDependents( String id ) { return dag.getParentLabels( id ); } public DAG getDAG() { return dag; } public Map getProjectMap() { return projectMap; } } maven2-core-2.2.1/maven-project/src/main/java/org/apache/maven/project/injection/0000755000175000017500000000000011250552246027546 5ustar twernertwerner././@LongLink0000000000000000000000000000014600000000000011566 Lustar rootrootmaven2-core-2.2.1/maven-project/src/main/java/org/apache/maven/project/injection/ProfileInjector.javamaven2-core-2.2.1/maven-project/src/main/java/org/apache/maven/project/injection/ProfileInjector.jav0000644000175000017500000000205510772004567033356 0ustar twernertwernerpackage org.apache.maven.project.injection; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import org.apache.maven.model.Model; import org.apache.maven.model.Profile; public interface ProfileInjector { String ROLE = ProfileInjector.class.getName(); void inject( Profile profile, Model model ); } ././@LongLink0000000000000000000000000000015500000000000011566 Lustar rootrootmaven2-core-2.2.1/maven-project/src/main/java/org/apache/maven/project/injection/DefaultProfileInjector.javamaven2-core-2.2.1/maven-project/src/main/java/org/apache/maven/project/injection/DefaultProfileInjec0000644000175000017500000005204311102041274033341 0ustar twernertwernerpackage org.apache.maven.project.injection; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import org.apache.maven.model.Build; import org.apache.maven.model.BuildBase; import org.apache.maven.model.ConfigurationContainer; import org.apache.maven.model.Dependency; import org.apache.maven.model.DependencyManagement; import org.apache.maven.model.DistributionManagement; import org.apache.maven.model.Model; import org.apache.maven.model.Plugin; import org.apache.maven.model.PluginContainer; import org.apache.maven.model.PluginExecution; import org.apache.maven.model.PluginManagement; import org.apache.maven.model.Profile; import org.apache.maven.model.ReportPlugin; import org.apache.maven.model.ReportSet; import org.apache.maven.model.Reporting; import org.apache.maven.project.ModelUtils; import org.codehaus.plexus.util.StringUtils; import org.codehaus.plexus.util.xml.Xpp3Dom; import java.util.ArrayList; import java.util.Iterator; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; import java.util.Properties; /** * Inject profile data into a Model, using the profile as the dominant data source, and * persisting results of the injection in the Model. * * This will look similar to the ModelUtils/DefaultModelInheritanceAssembler code, but * they are distinct. In model inheritance, the child provides data dominance AND persists * the results of the merge...sort of a 'merge-out' system. * * In this system, the profile is dominant, but the model receives the merge result...sort * of a 'merge-in' system. The two pieces of code look like they could be combined with a * set of flags to determine which direction to merge 'to', but there are enough differences * in the code to justify the extra code involved with separating them, in order to simplify * the logic. */ public class DefaultProfileInjector implements ProfileInjector { public void inject( Profile profile, Model model ) { model.setDependencies( injectDependencies( profile.getDependencies(), model.getDependencies() ) ); injectModules( profile, model ); model.setRepositories( ModelUtils.mergeRepositoryLists( profile.getRepositories(), model.getRepositories() ) ); model.setPluginRepositories( ModelUtils.mergeRepositoryLists( profile.getPluginRepositories(), model .getPluginRepositories() ) ); injectReporting( profile, model ); injectDependencyManagement( profile, model ); injectDistributionManagement( profile, model ); injectBuild( profile, model ); Properties props = new Properties(); props.putAll( model.getProperties() ); props.putAll( profile.getProperties() ); model.setProperties( props ); } private void injectBuild( Profile profile, Model model ) { BuildBase profileBuild = profile.getBuild(); Build modelBuild = model.getBuild(); // if the parent build is null, obviously we cannot inherit from it... if ( profileBuild != null ) { if ( modelBuild == null ) { modelBuild = new Build(); model.setBuild( modelBuild ); } if ( profileBuild.getDirectory() != null ) { modelBuild.setDirectory( profileBuild.getDirectory() ); } if ( profileBuild.getDefaultGoal() != null ) { modelBuild.setDefaultGoal( profileBuild.getDefaultGoal() ); } if ( profileBuild.getFinalName() != null ) { modelBuild.setFinalName( profileBuild.getFinalName() ); } ModelUtils.mergeFilterLists( modelBuild.getFilters(), profileBuild.getFilters() ); ModelUtils.mergeResourceLists( modelBuild.getResources(), profileBuild.getResources() ); ModelUtils.mergeResourceLists( modelBuild.getTestResources(), profileBuild.getTestResources() ); injectPlugins( profileBuild, modelBuild ); // Plugin management :: aggregate PluginManagement profilePM = profileBuild.getPluginManagement(); PluginManagement modelPM = modelBuild.getPluginManagement(); if ( modelPM == null ) { modelBuild.setPluginManagement( profilePM ); } else { injectPlugins( profilePM, modelPM ); } } } /** * This should be the resulting ordering of plugins after injection: * * Given: * * model: X -> A -> B -> D -> E * profile: Y -> A -> C -> D -> F * * Result: * * X -> Y -> A -> B -> C -> D -> E -> F */ protected void injectPlugins( PluginContainer profileContainer, PluginContainer modelContainer ) { if ( ( profileContainer == null ) || ( modelContainer == null ) ) { // nothing to do... return; } List modelPlugins = modelContainer.getPlugins(); if ( modelPlugins == null ) { modelContainer.setPlugins( profileContainer.getPlugins() ); } else if ( profileContainer.getPlugins() != null ) { List mergedPlugins = new ArrayList(); Map profilePlugins = profileContainer.getPluginsAsMap(); for ( Iterator it = modelPlugins.iterator(); it.hasNext(); ) { Plugin modelPlugin = (Plugin) it.next(); Plugin profilePlugin = (Plugin) profilePlugins.get( modelPlugin.getKey() ); if ( ( profilePlugin != null ) && !mergedPlugins.contains( profilePlugin ) ) { Plugin mergedPlugin = modelPlugin; injectPluginDefinition( profilePlugin, modelPlugin ); mergedPlugins.add( mergedPlugin ); } } List results = ModelUtils.orderAfterMerge( mergedPlugins, modelPlugins, profileContainer.getPlugins() ); modelContainer.setPlugins( results ); modelContainer.flushPluginMap(); } } private void injectPluginDefinition( Plugin profilePlugin, Plugin modelPlugin ) { if ( ( profilePlugin == null ) || ( modelPlugin == null ) ) { // nothing to do. return; } if ( profilePlugin.isExtensions() ) { modelPlugin.setExtensions( true ); } if ( profilePlugin.getVersion() != null ) { modelPlugin.setVersion( profilePlugin.getVersion() ); } modelPlugin.setDependencies( injectDependencies( profilePlugin.getDependencies(), modelPlugin.getDependencies() ) ); // merge the lists of goals that are not attached to an injectConfigurationContainer( profilePlugin, modelPlugin ); // from here to the end of the method is dealing with merging of the section. List modelExecutions = modelPlugin.getExecutions(); if ( ( modelExecutions == null ) || modelExecutions.isEmpty() ) { modelPlugin.setExecutions( profilePlugin.getExecutions() ); } else { Map executions = new LinkedHashMap(); Map profileExecutions = profilePlugin.getExecutionsAsMap(); for ( Iterator it = modelExecutions.iterator(); it.hasNext(); ) { PluginExecution modelExecution = (PluginExecution) it.next(); PluginExecution profileExecution = (PluginExecution) profileExecutions.get( modelExecution.getId() ); if ( profileExecution != null ) { injectConfigurationContainer( profileExecution, modelExecution ); if ( profileExecution.getPhase() != null ) { modelExecution.setPhase( profileExecution.getPhase() ); } List profileGoals = profileExecution.getGoals(); List modelGoals = modelExecution.getGoals(); List goals = new ArrayList(); if ( ( modelGoals != null ) && !modelGoals.isEmpty() ) { goals.addAll( modelGoals ); } if ( profileGoals != null ) { for ( Iterator goalIterator = profileGoals.iterator(); goalIterator.hasNext(); ) { String goal = (String) goalIterator.next(); if ( !goals.contains( goal ) ) { goals.add( goal ); } } } modelExecution.setGoals( goals ); } executions.put( modelExecution.getId(), modelExecution ); } for ( Iterator it = profileExecutions.entrySet().iterator(); it.hasNext(); ) { Map.Entry entry = (Map.Entry) it.next(); String id = (String) entry.getKey(); if ( !executions.containsKey( id ) ) { executions.put( id, entry.getValue() ); } } modelPlugin.setExecutions( new ArrayList( executions.values() ) ); modelPlugin.flushExecutionMap(); } } /** * Merge two DOMs. Copy the dominant DOM so the original one is left unchanged. *

    * Use this method instead of a direct call to {@link Xpp3Dom#mergeXpp3Dom(Xpp3Dom, Xpp3Dom)}. * Profiles are dominant, thus they are merge targets, but they may be merged in several times * (e.g. if they are inherited). So with the second merge, you don't get the profile's original * DOM, but an already merged one. * * @param dominant Dominant DOM * @param recessive Recessive DOM * @return Merged DOM */ private Xpp3Dom merge( Xpp3Dom dominant, Xpp3Dom recessive ) { Xpp3Dom dominantCopy = ( dominant == null ) ? null : new Xpp3Dom( dominant ); return Xpp3Dom.mergeXpp3Dom( dominantCopy, recessive ); } private void injectConfigurationContainer( ConfigurationContainer profileContainer, ConfigurationContainer modelContainer ) { Xpp3Dom configuration = (Xpp3Dom) profileContainer.getConfiguration(); Xpp3Dom parentConfiguration = (Xpp3Dom) modelContainer.getConfiguration(); configuration = merge( configuration, parentConfiguration ); modelContainer.setConfiguration( configuration ); } /** * Append modules specified in the profile to the end of the list supplied by the model, if * they don't already exist. */ private void injectModules( Profile profile, Model model ) { List modules = new ArrayList(); List modelModules = model.getModules(); if ( ( modelModules != null ) && !modelModules.isEmpty() ) { modules.addAll( modelModules ); } List profileModules = profile.getModules(); if ( profileModules != null ) { for ( Iterator it = profileModules.iterator(); it.hasNext(); ) { String module = (String) it.next(); if ( !modules.contains( module ) ) { modules.add( module ); } } } model.setModules( modules ); } private void injectDistributionManagement( Profile profile, Model model ) { DistributionManagement pDistMgmt = profile.getDistributionManagement(); DistributionManagement mDistMgmt = model.getDistributionManagement(); if ( mDistMgmt == null ) { model.setDistributionManagement( pDistMgmt ); } else if ( pDistMgmt != null ) { if ( pDistMgmt.getRepository() != null ) { mDistMgmt.setRepository( pDistMgmt.getRepository() ); } if ( pDistMgmt.getSnapshotRepository() != null ) { mDistMgmt.setSnapshotRepository( pDistMgmt.getSnapshotRepository() ); } if ( StringUtils.isNotEmpty( pDistMgmt.getDownloadUrl() ) ) { mDistMgmt.setDownloadUrl( pDistMgmt.getDownloadUrl() ); } if ( pDistMgmt.getRelocation() != null ) { mDistMgmt.setRelocation( pDistMgmt.getRelocation() ); } if ( pDistMgmt.getSite() != null ) { mDistMgmt.setSite( pDistMgmt.getSite() ); } // NOTE: We SHOULD NOT be inheriting status, since this is an assessment of the POM quality. } } private void injectDependencyManagement( Profile profile, Model model ) { DependencyManagement modelDepMgmt = model.getDependencyManagement(); DependencyManagement profileDepMgmt = profile.getDependencyManagement(); if ( profileDepMgmt != null ) { if ( modelDepMgmt == null ) { model.setDependencyManagement( profileDepMgmt ); } else { Map depsMap = new LinkedHashMap(); List deps = modelDepMgmt.getDependencies(); if ( deps != null ) { for ( Iterator it = deps.iterator(); it.hasNext(); ) { Dependency dependency = (Dependency) it.next(); depsMap.put( dependency.getManagementKey(), dependency ); } } deps = profileDepMgmt.getDependencies(); if ( deps != null ) { for ( Iterator it = deps.iterator(); it.hasNext(); ) { Dependency dependency = (Dependency) it.next(); depsMap.put( dependency.getManagementKey(), dependency ); } } modelDepMgmt.setDependencies( new ArrayList( depsMap.values() ) ); } } } private void injectReporting( Profile profile, Model model ) { // Reports :: aggregate Reporting profileReporting = profile.getReporting(); Reporting modelReporting = model.getReporting(); if ( profileReporting != null ) { if ( modelReporting == null ) { model.setReporting( profileReporting ); } else { if ( StringUtils.isEmpty( modelReporting.getOutputDirectory() ) ) { modelReporting.setOutputDirectory( profileReporting.getOutputDirectory() ); } Map mergedReportPlugins = new LinkedHashMap(); Map profileReportersByKey = profileReporting.getReportPluginsAsMap(); List modelReportPlugins = modelReporting.getPlugins(); if ( modelReportPlugins != null ) { for ( Iterator it = modelReportPlugins.iterator(); it.hasNext(); ) { ReportPlugin modelReportPlugin = (ReportPlugin) it.next(); String inherited = modelReportPlugin.getInherited(); if ( StringUtils.isEmpty( inherited ) || Boolean.valueOf( inherited ).booleanValue() ) { ReportPlugin profileReportPlugin = (ReportPlugin) profileReportersByKey .get( modelReportPlugin.getKey() ); ReportPlugin mergedReportPlugin = modelReportPlugin; if ( profileReportPlugin != null ) { mergedReportPlugin = profileReportPlugin; mergeReportPlugins( profileReportPlugin, modelReportPlugin ); } else if ( StringUtils.isEmpty( inherited ) ) { mergedReportPlugin.unsetInheritanceApplied(); } mergedReportPlugins.put( mergedReportPlugin.getKey(), mergedReportPlugin ); } } } for ( Iterator it = profileReportersByKey.entrySet().iterator(); it.hasNext(); ) { Map.Entry entry = (Map.Entry) it.next(); String key = (String) entry.getKey(); if ( !mergedReportPlugins.containsKey( key ) ) { mergedReportPlugins.put( key, entry.getValue() ); } } modelReporting.setPlugins( new ArrayList( mergedReportPlugins.values() ) ); modelReporting.flushReportPluginMap(); } } } private void mergeReportPlugins( ReportPlugin dominant, ReportPlugin recessive ) { if ( StringUtils.isEmpty( recessive.getVersion() ) ) { recessive.setVersion( dominant.getVersion() ); } Xpp3Dom dominantConfig = (Xpp3Dom) dominant.getConfiguration(); Xpp3Dom recessiveConfig = (Xpp3Dom) recessive.getConfiguration(); recessive.setConfiguration( merge( dominantConfig, recessiveConfig ) ); Map mergedReportSets = new LinkedHashMap(); Map dominantReportSetsById = dominant.getReportSetsAsMap(); for ( Iterator it = recessive.getReportSets().iterator(); it.hasNext(); ) { ReportSet recessiveReportSet = (ReportSet) it.next(); ReportSet dominantReportSet = (ReportSet) dominantReportSetsById.get( recessiveReportSet.getId() ); ReportSet merged = recessiveReportSet; if ( dominantReportSet != null ) { merged = recessiveReportSet; Xpp3Dom dominantRSConfig = (Xpp3Dom) dominantReportSet.getConfiguration(); Xpp3Dom mergedRSConfig = (Xpp3Dom) merged.getConfiguration(); merged.setConfiguration( merge( dominantRSConfig, mergedRSConfig ) ); List mergedReports = merged.getReports(); if ( mergedReports == null ) { mergedReports = new ArrayList(); merged.setReports( mergedReports ); } List dominantRSReports = dominantReportSet.getReports(); if ( dominantRSReports != null ) { for ( Iterator reportIterator = dominantRSReports.iterator(); reportIterator.hasNext(); ) { String report = (String) reportIterator.next(); if ( !mergedReports.contains( report ) ) { mergedReports.add( report ); } } } mergedReportSets.put( merged.getId(), merged ); } } for ( Iterator rsIterator = dominantReportSetsById.entrySet().iterator(); rsIterator.hasNext(); ) { Map.Entry entry = (Map.Entry) rsIterator.next(); String key = (String) entry.getKey(); if ( !mergedReportSets.containsKey( key ) ) { mergedReportSets.put( key, entry.getValue() ); } } recessive.setReportSets( new ArrayList( mergedReportSets.values() ) ); recessive.flushReportSetMap(); } private List injectDependencies( List profileDeps, List modelDeps ) { Map depsMap = new LinkedHashMap(); if ( modelDeps != null ) { for ( Iterator it = modelDeps.iterator(); it.hasNext(); ) { Dependency dependency = (Dependency) it.next(); depsMap.put( dependency.getManagementKey(), dependency ); } } if ( profileDeps != null ) { for ( Iterator it = profileDeps.iterator(); it.hasNext(); ) { Dependency dependency = (Dependency) it.next(); depsMap.put( dependency.getManagementKey(), dependency ); } } return new ArrayList( depsMap.values() ); } } ././@LongLink0000000000000000000000000000016300000000000011565 Lustar rootrootmaven2-core-2.2.1/maven-project/src/main/java/org/apache/maven/project/injection/DefaultModelDefaultsInjector.javamaven2-core-2.2.1/maven-project/src/main/java/org/apache/maven/project/injection/DefaultModelDefault0000644000175000017500000001145710551365651033360 0ustar twernertwernerpackage org.apache.maven.project.injection; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import org.apache.maven.model.Build; import org.apache.maven.model.Dependency; import org.apache.maven.model.DependencyManagement; import org.apache.maven.model.Model; import org.apache.maven.model.Plugin; import org.apache.maven.model.PluginManagement; import org.apache.maven.project.ModelUtils; import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.TreeMap; /** * @author jdcasey Created on Feb 1, 2005 */ public class DefaultModelDefaultsInjector implements ModelDefaultsInjector { public void injectDefaults( Model model ) { injectDependencyDefaults( model.getDependencies(), model.getDependencyManagement() ); if ( model.getBuild() != null ) { injectPluginDefaults( model.getBuild(), model.getBuild().getPluginManagement() ); } } private void injectPluginDefaults( Build build, PluginManagement pluginManagement ) { if ( pluginManagement == null ) { // nothing to inject. return ; } List buildPlugins = build.getPlugins(); if ( buildPlugins != null && !buildPlugins.isEmpty() ) { Map pmPlugins = pluginManagement.getPluginsAsMap(); if ( pmPlugins != null && !pmPlugins.isEmpty() ) { for ( Iterator it = buildPlugins.iterator(); it.hasNext(); ) { Plugin buildPlugin = (Plugin) it.next(); Plugin pmPlugin = (Plugin) pmPlugins.get( buildPlugin.getKey() ); if ( pmPlugin != null ) { mergePluginWithDefaults( buildPlugin, pmPlugin ); } } } } } public void mergePluginWithDefaults( Plugin plugin, Plugin def ) { ModelUtils.mergePluginDefinitions( plugin, def, false ); } private void injectDependencyDefaults( List dependencies, DependencyManagement dependencyManagement ) { if ( dependencyManagement != null ) { // a given project's dependencies should be smaller than the // group-defined defaults set... // in other words, the project's deps will probably be a subset of // those specified in defaults. Map depsMap = new TreeMap(); for ( Iterator it = dependencies.iterator(); it.hasNext(); ) { Dependency dep = (Dependency) it.next(); depsMap.put( dep.getManagementKey(), dep ); } List managedDependencies = dependencyManagement.getDependencies(); for ( Iterator it = managedDependencies.iterator(); it.hasNext(); ) { Dependency def = (Dependency) it.next(); String key = def.getManagementKey(); Dependency dep = (Dependency) depsMap.get( key ); if ( dep != null ) { mergeDependencyWithDefaults( dep, def ); } } } } private void mergeDependencyWithDefaults( Dependency dep, Dependency def ) { if ( dep.getScope() == null && def.getScope() != null ) { dep.setScope( def.getScope() ); dep.setSystemPath( def.getSystemPath() ); } if ( dep.getVersion() == null && def.getVersion() != null ) { dep.setVersion( def.getVersion() ); } if ( dep.getClassifier() == null && def.getClassifier() != null ) { dep.setClassifier( def.getClassifier() ); } if ( dep.getType() == null && def.getType() != null ) { dep.setType( def.getType() ); } List exclusions = dep.getExclusions(); if ( exclusions == null || exclusions.isEmpty() ) { dep.setExclusions( def.getExclusions() ); } } }././@LongLink0000000000000000000000000000015400000000000011565 Lustar rootrootmaven2-core-2.2.1/maven-project/src/main/java/org/apache/maven/project/injection/ModelDefaultsInjector.javamaven2-core-2.2.1/maven-project/src/main/java/org/apache/maven/project/injection/ModelDefaultsInject0000644000175000017500000000223710551365651033367 0ustar twernertwernerpackage org.apache.maven.project.injection; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import org.apache.maven.model.Model; import org.apache.maven.model.Plugin; /** * @author jdcasey Created on Feb 1, 2005 */ public interface ModelDefaultsInjector { String ROLE = ModelDefaultsInjector.class.getName(); void injectDefaults( Model model ); void mergePluginWithDefaults( Plugin plugin, Plugin def ); }maven2-core-2.2.1/maven-project/src/main/java/org/apache/maven/project/MissingProjectException.java0000644000175000017500000000254111101576551033250 0ustar twernertwernerpackage org.apache.maven.project; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ /** * Exception that occurs when the user has identifed a project to make, but that project doesn't exist. * * @author Dan Fabulich * @version $Id: MissingProjectException.java 708543 2008-10-28 11:54:17Z bentmann $ */ public class MissingProjectException extends Exception { public MissingProjectException( String message ) { super( message ); } public MissingProjectException( String message, Exception e ) { super( message, e ); } } ././@LongLink0000000000000000000000000000015000000000000011561 Lustar rootrootmaven2-core-2.2.1/maven-project/src/main/java/org/apache/maven/project/ProjectBuilderConfiguration.javamaven2-core-2.2.1/maven-project/src/main/java/org/apache/maven/project/ProjectBuilderConfiguration.j0000644000175000017500000000157211101576551033411 0ustar twernertwernerpackage org.apache.maven.project; import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.profiles.ProfileManager; import java.util.Date; import java.util.Properties; public interface ProjectBuilderConfiguration { ArtifactRepository getLocalRepository(); ProfileManager getGlobalProfileManager(); Properties getUserProperties(); Properties getExecutionProperties(); ProjectBuilderConfiguration setGlobalProfileManager( ProfileManager globalProfileManager ); ProjectBuilderConfiguration setLocalRepository( ArtifactRepository localRepository ); ProjectBuilderConfiguration setUserProperties( Properties userProperties ); ProjectBuilderConfiguration setExecutionProperties( Properties executionProperties ); Date getBuildStartTime(); ProjectBuilderConfiguration setBuildStartTime( Date buildStartTime ); } maven2-core-2.2.1/maven-project/src/main/java/org/apache/maven/project/artifact/0000755000175000017500000000000011250552246027361 5ustar twernertwerner././@LongLink0000000000000000000000000000015400000000000011565 Lustar rootrootmaven2-core-2.2.1/maven-project/src/main/java/org/apache/maven/project/artifact/ProjectArtifactFactory.javamaven2-core-2.2.1/maven-project/src/main/java/org/apache/maven/project/artifact/ProjectArtifactFacto0000644000175000017500000000416411221205616033344 0ustar twernertwernerpackage org.apache.maven.project.artifact; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.DefaultArtifact; import org.apache.maven.artifact.factory.DefaultArtifactFactory; import org.apache.maven.artifact.handler.ArtifactHandler; import org.apache.maven.artifact.versioning.VersionRange; import org.apache.maven.project.MavenProject; public class ProjectArtifactFactory extends DefaultArtifactFactory { public Artifact create( MavenProject project ) { ArtifactHandler handler = getArtifactHandlerManager().getArtifactHandler( project.getPackaging() ); return new DefaultArtifact( project.getGroupId(), project.getArtifactId(), VersionRange.createFromVersion( project.getVersion() ), null, project.getPackaging(), null, handler, false ); } public Artifact create( MavenProject project, String type, String classifier, boolean optional ) { ArtifactHandler handler = getArtifactHandlerManager().getArtifactHandler( type ); return new DefaultArtifact( project.getGroupId(), project.getArtifactId(), VersionRange.createFromVersion( project.getVersion() ), null, project.getPackaging(), null, handler, optional ); } } ././@LongLink0000000000000000000000000000015300000000000011564 Lustar rootrootmaven2-core-2.2.1/maven-project/src/main/java/org/apache/maven/project/artifact/ActiveProjectArtifact.javamaven2-core-2.2.1/maven-project/src/main/java/org/apache/maven/project/artifact/ActiveProjectArtifac0000644000175000017500000002367211173447175033362 0ustar twernertwernerpackage org.apache.maven.project.artifact; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.handler.ArtifactHandler; import org.apache.maven.artifact.metadata.ArtifactMetadata; import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.artifact.resolver.filter.ArtifactFilter; import org.apache.maven.artifact.versioning.ArtifactVersion; import org.apache.maven.artifact.versioning.OverConstrainedVersionException; import org.apache.maven.artifact.versioning.VersionRange; import org.apache.maven.project.MavenProject; import java.io.File; import java.util.Collection; import java.util.List; /** * Wraps an active project instance to be able to receive updates from its artifact without affecting the original * attributes of this artifact. * * @author Brett Porter * @version $Id: ActiveProjectArtifact.java 767324 2009-04-21 22:53:49Z jdcasey $ * @todo I think this exposes a design flaw in that the immutable and mutable parts of an artifact are in one class and * should be split. ie scope, file, etc depend on the context of use, whereas everything else is immutable. */ public class ActiveProjectArtifact implements Artifact { private final Artifact artifact; private final MavenProject project; public ActiveProjectArtifact( MavenProject project, Artifact artifact ) { this.artifact = artifact; this.project = project; artifact.setFile( project.getArtifact().getFile() ); artifact.setResolved( true ); } /** {@inheritDoc} */ public File getFile() { // we need to get the latest file for the project, not the artifact that was created at one point in time return project.getArtifact().getFile(); } /** {@inheritDoc} */ public String getGroupId() { return artifact.getGroupId(); } /** {@inheritDoc} */ public String getArtifactId() { return artifact.getArtifactId(); } /** {@inheritDoc} */ public String getVersion() { return artifact.getVersion(); } /** {@inheritDoc} */ public void setVersion( String version ) { artifact.setVersion( version ); } /** {@inheritDoc} */ public String getScope() { return artifact.getScope(); } /** {@inheritDoc} */ public String getType() { return artifact.getType(); } /** {@inheritDoc} */ public String getClassifier() { return artifact.getClassifier(); } /** {@inheritDoc} */ public boolean hasClassifier() { return artifact.hasClassifier(); } /** {@inheritDoc} */ public void setFile( File destination ) { artifact.setFile( destination ); project.getArtifact().setFile( destination ); } /** {@inheritDoc} */ public String getBaseVersion() { return artifact.getBaseVersion(); } /** {@inheritDoc} */ public void setBaseVersion( String baseVersion ) { artifact.setBaseVersion( baseVersion ); } /** {@inheritDoc} */ public String getId() { return artifact.getId(); } /** {@inheritDoc} */ public String getDependencyConflictId() { return artifact.getDependencyConflictId(); } /** {@inheritDoc} */ public void addMetadata( ArtifactMetadata metadata ) { artifact.addMetadata( metadata ); } /** {@inheritDoc} */ public Collection getMetadataList() { return artifact.getMetadataList(); } /** {@inheritDoc} */ public void setRepository( ArtifactRepository remoteRepository ) { artifact.setRepository( remoteRepository ); } /** {@inheritDoc} */ public ArtifactRepository getRepository() { return artifact.getRepository(); } /** {@inheritDoc} */ public void updateVersion( String version, ArtifactRepository localRepository ) { artifact.updateVersion( version, localRepository ); } /** {@inheritDoc} */ public String getDownloadUrl() { return artifact.getDownloadUrl(); } /** {@inheritDoc} */ public void setDownloadUrl( String downloadUrl ) { artifact.setDownloadUrl( downloadUrl ); } /** {@inheritDoc} */ public ArtifactFilter getDependencyFilter() { return artifact.getDependencyFilter(); } /** {@inheritDoc} */ public void setDependencyFilter( ArtifactFilter artifactFilter ) { artifact.setDependencyFilter( artifactFilter ); } /** {@inheritDoc} */ public ArtifactHandler getArtifactHandler() { return artifact.getArtifactHandler(); } /** {@inheritDoc} */ public List getDependencyTrail() { return artifact.getDependencyTrail(); } /** {@inheritDoc} */ public void setDependencyTrail( List dependencyTrail ) { artifact.setDependencyTrail( dependencyTrail ); } /** {@inheritDoc} */ public void setScope( String scope ) { artifact.setScope( scope ); } /** {@inheritDoc} */ public VersionRange getVersionRange() { return artifact.getVersionRange(); } /** {@inheritDoc} */ public void setVersionRange( VersionRange newRange ) { artifact.setVersionRange( newRange ); } /** {@inheritDoc} */ public void selectVersion( String version ) { artifact.selectVersion( version ); } /** {@inheritDoc} */ public void setGroupId( String groupId ) { artifact.setGroupId( groupId ); } /** {@inheritDoc} */ public void setArtifactId( String artifactId ) { artifact.setArtifactId( artifactId ); } /** {@inheritDoc} */ public boolean isSnapshot() { return artifact.isSnapshot(); } /** {@inheritDoc} */ public int compareTo( Artifact a ) { return artifact.compareTo( a ); } /** {@inheritDoc} */ public void setResolved( boolean resolved ) { artifact.setResolved( resolved ); } /** {@inheritDoc} */ public boolean isResolved() { return artifact.isResolved(); } /** {@inheritDoc} */ public void setResolvedVersion( String version ) { artifact.setResolvedVersion( version ); } /** {@inheritDoc} */ public void setArtifactHandler( ArtifactHandler handler ) { artifact.setArtifactHandler( handler ); } /** {@inheritDoc} */ public String toString() { return "active project artifact:\n\tartifact = " + artifact + ";\n\tproject: " + project; } /** {@inheritDoc} */ public boolean isRelease() { return artifact.isRelease(); } /** {@inheritDoc} */ public void setRelease( boolean release ) { artifact.setRelease( release ); } /** {@inheritDoc} */ public List getAvailableVersions() { return artifact.getAvailableVersions(); } /** {@inheritDoc} */ public void setAvailableVersions( List versions ) { artifact.setAvailableVersions( versions ); } /** {@inheritDoc} */ public boolean isOptional() { return artifact.isOptional(); } /** {@inheritDoc} */ public ArtifactVersion getSelectedVersion() throws OverConstrainedVersionException { return artifact.getSelectedVersion(); } /** {@inheritDoc} */ public boolean isSelectedVersionKnown() throws OverConstrainedVersionException { return artifact.isSelectedVersionKnown(); } /** {@inheritDoc} */ public void setOptional( boolean optional ) { artifact.setOptional( optional ); } /** {@inheritDoc} */ public int hashCode() { int result = 17; result = 37 * result + getGroupId().hashCode(); result = 37 * result + getArtifactId().hashCode(); result = 37 * result + getType().hashCode(); if ( getVersion() != null ) { result = 37 * result + getVersion().hashCode(); } result = 37 * result + ( getClassifier() != null ? getClassifier().hashCode() : 0 ); return result; } /** {@inheritDoc} */ public boolean equals( Object o ) { if ( o == this ) { return true; } if ( !( o instanceof Artifact ) ) { return false; } Artifact a = (Artifact) o; if ( !a.getGroupId().equals( getGroupId() ) ) { return false; } else if ( !a.getArtifactId().equals( getArtifactId() ) ) { return false; } else if ( !a.getVersion().equals( getVersion() ) ) { return false; } else if ( !a.getType().equals( getType() ) ) { return false; } else if ( a.getClassifier() == null ? getClassifier() != null : !a.getClassifier().equals( getClassifier() ) ) { return false; } return true; } public ArtifactMetadata getMetadata( Class metadataClass ) { return artifact.getMetadata( metadataClass ); } } ././@LongLink0000000000000000000000000000014600000000000011566 Lustar rootrootmaven2-core-2.2.1/maven-project/src/main/java/org/apache/maven/project/artifact/AttachedArtifact.javamaven2-core-2.2.1/maven-project/src/main/java/org/apache/maven/project/artifact/AttachedArtifact.jav0000644000175000017500000001301210772004567033261 0ustar twernertwernerpackage org.apache.maven.project.artifact; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.DefaultArtifact; import org.apache.maven.artifact.InvalidArtifactRTException; import org.apache.maven.artifact.handler.ArtifactHandler; import org.apache.maven.artifact.metadata.ArtifactMetadata; import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.artifact.versioning.VersionRange; import java.util.Collection; import java.util.Collections; import java.util.List; public class AttachedArtifact extends DefaultArtifact { private final Artifact parent; public AttachedArtifact( Artifact parent, String type, String classifier, ArtifactHandler artifactHandler ) { super( parent.getGroupId(), parent.getArtifactId(), parent.getVersionRange(), parent.getScope(), type, classifier, artifactHandler, parent.isOptional() ); setDependencyTrail( Collections.singletonList( parent.getId() ) ); this.parent = parent; if ( getId().equals( parent.getId() ) ) { throw new InvalidArtifactRTException( parent.getGroupId(), parent.getArtifactId(), parent.getVersion(), parent.getType(), "An attached artifact must have a different ID than its corresponding main artifact." ); } } public AttachedArtifact( Artifact parent, String type, ArtifactHandler artifactHandler ) { this( parent, type, null, artifactHandler ); } public void setArtifactId( String artifactId ) { throw new UnsupportedOperationException( "Cannot change the artifactId for an attached artifact. It is derived from the main artifact." ); } public List getAvailableVersions() { return parent.getAvailableVersions(); } public void setAvailableVersions( List availableVersions ) { throw new UnsupportedOperationException( "Cannot change the version information for an attached artifact. It is derived from the main artifact." ); } public String getBaseVersion() { return parent.getBaseVersion(); } public void setBaseVersion( String baseVersion ) { throw new UnsupportedOperationException( "Cannot change the version information for an attached artifact. It is derived from the main artifact." ); } public String getDownloadUrl() { return parent.getDownloadUrl(); } public void setDownloadUrl( String downloadUrl ) { throw new UnsupportedOperationException( "Cannot change the download information for an attached artifact. It is derived from the main artifact." ); } public void setGroupId( String groupId ) { throw new UnsupportedOperationException( "Cannot change the groupId on attached artifacts. It is derived from the main artifact." ); } public ArtifactRepository getRepository() { return parent.getRepository(); } public void setRepository( ArtifactRepository repository ) { throw new UnsupportedOperationException( "Cannot change the repository information for an attached artifact. It is derived from the main artifact." ); } public String getScope() { return parent.getScope(); } public void setScope( String scope ) { throw new UnsupportedOperationException( "Cannot change the scoping information for an attached artifact. It is derived from the main artifact." ); } public String getVersion() { return parent.getVersion(); } public void setVersion( String version ) { throw new UnsupportedOperationException( "Cannot change the version information for an attached artifact. It is derived from the main artifact." ); } public VersionRange getVersionRange() { return parent.getVersionRange(); } public void setVersionRange( VersionRange range ) { throw new UnsupportedOperationException( "Cannot change the version information for an attached artifact. It is derived from the main artifact." ); } public boolean isRelease() { return parent.isRelease(); } public void setRelease( boolean release ) { throw new UnsupportedOperationException( "Cannot change the version information for an attached artifact. It is derived from the main artifact." ); } public boolean isSnapshot() { return parent.isSnapshot(); } public void addMetadata( ArtifactMetadata metadata ) { // ignore. The parent artifact will handle metadata. // we must fail silently here to avoid problems with the artifact transformers. } public Collection getMetadataList() { return Collections.EMPTY_LIST; } } ././@LongLink0000000000000000000000000000015500000000000011566 Lustar rootrootmaven2-core-2.2.1/maven-project/src/main/java/org/apache/maven/project/artifact/ProjectArtifactMetadata.javamaven2-core-2.2.1/maven-project/src/main/java/org/apache/maven/project/artifact/ProjectArtifactMetad0000644000175000017500000001117211147323515033345 0ustar twernertwernerpackage org.apache.maven.project.artifact; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import java.io.File; import java.io.IOException; import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.metadata.AbstractArtifactMetadata; import org.apache.maven.artifact.metadata.ArtifactMetadata; import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.artifact.repository.metadata.RepositoryMetadataStoreException; import org.codehaus.plexus.util.FileUtils; /** * Attach a POM to an artifact. * * @author Brett Porter * @version $Id: ProjectArtifactMetadata.java 745955 2009-02-19 18:39:09Z jdcasey $ */ public class ProjectArtifactMetadata extends AbstractArtifactMetadata { private File originalFile; private File transformedFile; private boolean versionExpressionsResolved = false; public ProjectArtifactMetadata( Artifact artifact ) { this( artifact, null ); } public ProjectArtifactMetadata( Artifact artifact, File file ) { super( artifact ); this.originalFile = file; } public String getRemoteFilename() { return getFilename(); } public String getLocalFilename( ArtifactRepository repository ) { return getFilename(); } private String getFilename() { return getArtifactId() + "-" + artifact.getVersion() + ".pom"; } public void storeInLocalRepository( ArtifactRepository localRepository, ArtifactRepository remoteRepository ) throws RepositoryMetadataStoreException { File f = transformedFile == null ? originalFile : transformedFile; if ( f == null ) { return; } File destination = new File( localRepository.getBasedir(), localRepository.pathOfLocalRepositoryMetadata( this, remoteRepository ) ); // ---------------------------------------------------------------------------- // I'm fully aware that the file could just be moved using File.rename but // there are bugs in various JVM that have problems doing this across // different filesystem. So we'll incur the small hit to actually copy // here and be safe. jvz. // ---------------------------------------------------------------------------- try { FileUtils.copyFile( f, destination ); } catch ( IOException e ) { throw new RepositoryMetadataStoreException( "Error copying POM to the local repository.", e ); } } public String toString() { return "project information for " + artifact.getArtifactId() + " " + artifact.getVersion(); } public boolean storedInArtifactVersionDirectory() { return true; } public String getBaseVersion() { return artifact.getBaseVersion(); } public Object getKey() { return "project " + artifact.getGroupId() + ":" + artifact.getArtifactId(); } public void merge( ArtifactMetadata metadata ) { ProjectArtifactMetadata m = (ProjectArtifactMetadata) metadata; if ( !m.originalFile.equals( originalFile ) ) { throw new IllegalStateException( "Cannot add two different pieces of metadata for: " + getKey() ); } } public boolean isVersionExpressionsResolved() { return versionExpressionsResolved; } public void setVersionExpressionsResolved( boolean versionExpressionsResolved ) { this.versionExpressionsResolved = versionExpressionsResolved; } public void setFile( File file ) { this.transformedFile = file; } public File getFile() { return transformedFile == null ? originalFile : transformedFile; } } ././@LongLink0000000000000000000000000000015100000000000011562 Lustar rootrootmaven2-core-2.2.1/maven-project/src/main/java/org/apache/maven/project/artifact/MavenMetadataSource.javamaven2-core-2.2.1/maven-project/src/main/java/org/apache/maven/project/artifact/MavenMetadataSource.0000644000175000017500000005372011135767225033270 0ustar twernertwernerpackage org.apache.maven.project.artifact; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import java.io.File; import java.util.ArrayList; import java.util.Collections; import java.util.HashSet; import java.util.Iterator; import java.util.LinkedHashSet; import java.util.List; import java.util.Set; import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.factory.ArtifactFactory; import org.apache.maven.artifact.metadata.ArtifactMetadataRetrievalException; import org.apache.maven.artifact.metadata.ArtifactMetadataSource; import org.apache.maven.artifact.metadata.ResolutionGroup; import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.artifact.repository.metadata.ArtifactRepositoryMetadata; import org.apache.maven.artifact.repository.metadata.Metadata; import org.apache.maven.artifact.repository.metadata.RepositoryMetadata; import org.apache.maven.artifact.repository.metadata.RepositoryMetadataManager; import org.apache.maven.artifact.repository.metadata.RepositoryMetadataResolutionException; import org.apache.maven.artifact.resolver.filter.AndArtifactFilter; import org.apache.maven.artifact.resolver.filter.ArtifactFilter; import org.apache.maven.artifact.resolver.filter.ExcludesArtifactFilter; import org.apache.maven.artifact.versioning.DefaultArtifactVersion; import org.apache.maven.artifact.versioning.InvalidVersionSpecificationException; import org.apache.maven.artifact.versioning.VersionRange; import org.apache.maven.model.Dependency; import org.apache.maven.model.DistributionManagement; import org.apache.maven.model.Exclusion; import org.apache.maven.model.Relocation; import org.apache.maven.project.DefaultProjectBuilderConfiguration; import org.apache.maven.project.InvalidProjectModelException; import org.apache.maven.project.MavenProject; import org.apache.maven.project.MavenProjectBuilder; import org.apache.maven.project.ProjectBuildingException; import org.apache.maven.project.validation.ModelValidationResult; import org.codehaus.plexus.logging.AbstractLogEnabled; import org.codehaus.plexus.util.StringUtils; /** * @author Jason van Zyl * @author Brett Porter * @version $Id: MavenMetadataSource.java 736547 2009-01-22 03:57:09Z jdcasey $ */ public class MavenMetadataSource extends AbstractLogEnabled implements ArtifactMetadataSource { public static final String ROLE_HINT = "maven"; private MavenProjectBuilder mavenProjectBuilder; private ArtifactFactory artifactFactory; private RepositoryMetadataManager repositoryMetadataManager; // lazily instantiated and cached. private MavenProject superProject; private Set warnedPoms = new HashSet(); /** * Resolve all relocations in the POM for this artifact, and return the new artifact coordinate. */ public Artifact retrieveRelocatedArtifact( Artifact artifact, ArtifactRepository localRepository, List remoteRepositories ) throws ArtifactMetadataRetrievalException { if ( artifact instanceof ActiveProjectArtifact ) { return artifact; } ProjectRelocation rel = retrieveRelocatedProject( artifact, localRepository, remoteRepositories ); if ( rel == null ) { return artifact; } MavenProject project = rel.project; if ( project == null || getRelocationKey( artifact ).equals( getRelocationKey( project.getArtifact() ) ) ) { return artifact; } // NOTE: Using artifact information here, since some POMs are deployed // to central with one version in the filename, but another in the string! // Case in point: org.apache.ws.commons:XmlSchema:1.1:pom. // // Since relocation triggers a reconfiguration of the artifact's information // in retrieveRelocatedProject(..), this is safe to do. Artifact result = null; if ( artifact.getClassifier() != null ) { result = artifactFactory.createArtifactWithClassifier( artifact.getGroupId(), artifact.getArtifactId(), artifact.getVersion(), artifact.getType(), artifact.getClassifier() ); } else { result = artifactFactory.createArtifact( artifact.getGroupId(), artifact.getArtifactId(), artifact.getVersion(), artifact.getScope(), artifact.getType() ); } result.setResolved( artifact.isResolved() ); result.setFile( artifact.getFile() ); result.setScope( artifact.getScope() ); result.setArtifactHandler( artifact.getArtifactHandler() ); result.setDependencyFilter( artifact.getDependencyFilter() ); result.setDependencyTrail( artifact.getDependencyTrail() ); result.setOptional( artifact.isOptional() ); result.setRelease( artifact.isRelease() ); return result; } private String getRelocationKey( Artifact artifact ) { return artifact.getGroupId() + ":" + artifact.getArtifactId() + ":" + artifact.getVersion(); } private ProjectRelocation retrieveRelocatedProject( Artifact artifact, ArtifactRepository localRepository, List remoteRepositories ) throws ArtifactMetadataRetrievalException { MavenProject project = null; Artifact pomArtifact; boolean done = false; do { // TODO: can we just modify the original? pomArtifact = artifactFactory.createProjectArtifact( artifact.getGroupId(), artifact.getArtifactId(), artifact.getVersion(), artifact.getScope() ); if ( Artifact.SCOPE_SYSTEM.equals( artifact.getScope() ) ) { done = true; } else { try { project = mavenProjectBuilder.buildFromRepository( pomArtifact, remoteRepositories, localRepository, true ); } catch ( InvalidProjectModelException e ) { String id = pomArtifact.getId(); if ( !warnedPoms.contains( id ) ) { warnedPoms.add( pomArtifact.getId() ); getLogger().warn( "POM for \'" + pomArtifact + "\' is invalid.\n\nIts dependencies (if any) will NOT be available to the current build." ); if ( getLogger().isDebugEnabled() ) { getLogger().debug( "Reason: " + e.getMessage() ); ModelValidationResult validationResult = e.getValidationResult(); if ( validationResult != null ) { getLogger().debug( "\nValidation Errors:" ); for ( Iterator i = validationResult.getMessages().iterator(); i.hasNext(); ) { getLogger().debug( i.next().toString() ); } getLogger().debug( "\n" ); } } } project = null; } catch ( ProjectBuildingException e ) { throw new ArtifactMetadataRetrievalException( "Unable to read the metadata file for artifact '" + artifact.getDependencyConflictId() + "': " + e.getMessage(), e, artifact ); } if ( project != null ) { Relocation relocation = null; DistributionManagement distMgmt = project.getDistributionManagement(); if ( distMgmt != null ) { relocation = distMgmt.getRelocation(); artifact.setDownloadUrl( distMgmt.getDownloadUrl() ); pomArtifact.setDownloadUrl( distMgmt.getDownloadUrl() ); } if ( relocation != null ) { if ( relocation.getGroupId() != null ) { artifact.setGroupId( relocation.getGroupId() ); project.setGroupId( relocation.getGroupId() ); } if ( relocation.getArtifactId() != null ) { artifact.setArtifactId( relocation.getArtifactId() ); project.setArtifactId( relocation.getArtifactId() ); } if ( relocation.getVersion() != null ) { //note: see MNG-3454. This causes a problem, but fixing it may break more. artifact.setVersionRange( VersionRange.createFromVersion( relocation.getVersion() ) ); project.setVersion( relocation.getVersion() ); } if ( artifact.getDependencyFilter() != null && !artifact.getDependencyFilter().include( artifact ) ) { return null; } //MNG-2861: the artifact data has changed. If the available versions where previously retrieved, //we need to update it. TODO: shouldn't the versions be merged across relocations? List available = artifact.getAvailableVersions(); if ( available != null && !available.isEmpty() ) { artifact.setAvailableVersions( retrieveAvailableVersions( artifact, localRepository, remoteRepositories ) ); } String message = "\n This artifact has been relocated to " + artifact.getGroupId() + ":" + artifact.getArtifactId() + ":" + artifact.getVersion() + ".\n"; if ( relocation.getMessage() != null ) { message += " " + relocation.getMessage() + "\n"; } if ( artifact.getDependencyTrail() != null && artifact.getDependencyTrail().size() == 1 ) { getLogger().warn( "While downloading " + pomArtifact.getGroupId() + ":" + pomArtifact.getArtifactId() + ":" + pomArtifact.getVersion() + message + "\n" ); } else { getLogger().debug( "While downloading " + pomArtifact.getGroupId() + ":" + pomArtifact.getArtifactId() + ":" + pomArtifact.getVersion() + message + "\n" ); } } else { done = true; } } else { done = true; } } } while ( !done ); ProjectRelocation rel = new ProjectRelocation(); rel.project = project; rel.pomArtifact = pomArtifact; return rel; } /** * Retrieve the metadata for the project from the repository. * Uses the ProjectBuilder, to enable post-processing and inheritance calculation before retrieving the * associated artifacts. */ public ResolutionGroup retrieve( Artifact artifact, ArtifactRepository localRepository, List remoteRepositories ) throws ArtifactMetadataRetrievalException { ProjectRelocation rel = retrieveRelocatedProject( artifact, localRepository, remoteRepositories ); if ( rel == null ) { return null; } MavenProject project = rel.project; Artifact pomArtifact = rel.pomArtifact; // last ditch effort to try to get this set... if ( artifact.getDownloadUrl() == null && pomArtifact != null ) { // TODO: this could come straight from the project, negating the need to set it in the project itself? artifact.setDownloadUrl( pomArtifact.getDownloadUrl() ); } ResolutionGroup result; if ( project == null ) { // if the project is null, we encountered an invalid model (read: m1 POM) // we'll just return an empty resolution group. // or used the inherited scope (should that be passed to the buildFromRepository method above?) result = new ResolutionGroup( pomArtifact, Collections.EMPTY_SET, Collections.EMPTY_LIST ); } else { Set artifacts = Collections.EMPTY_SET; if ( !artifact.getArtifactHandler().isIncludesDependencies() ) { // TODO: we could possibly use p.getDependencyArtifacts instead of this call, but they haven't been filtered // or used the inherited scope (should that be passed to the buildFromRepository method above?) try { artifacts = project.createArtifacts( artifactFactory, artifact.getScope(), artifact.getDependencyFilter() ); } catch ( InvalidDependencyVersionException e ) { throw new ArtifactMetadataRetrievalException( "Error in metadata for artifact '" + artifact.getDependencyConflictId() + "': " + e.getMessage(), e ); } } List repositories = aggregateRepositoryLists( remoteRepositories, project.getRemoteArtifactRepositories() ); result = new ResolutionGroup( pomArtifact, artifacts, repositories ); } return result; } private List aggregateRepositoryLists( List remoteRepositories, List remoteArtifactRepositories ) throws ArtifactMetadataRetrievalException { if ( superProject == null ) { try { superProject = mavenProjectBuilder.buildStandaloneSuperProject( new DefaultProjectBuilderConfiguration() ); } catch ( ProjectBuildingException e ) { throw new ArtifactMetadataRetrievalException( "Unable to parse the Maven built-in model: " + e.getMessage(), e ); } } List repositories = new ArrayList(); repositories.addAll( remoteRepositories ); // ensure that these are defined for ( Iterator it = superProject.getRemoteArtifactRepositories().iterator(); it.hasNext(); ) { ArtifactRepository superRepo = (ArtifactRepository) it.next(); for ( Iterator aggregatedIterator = repositories.iterator(); aggregatedIterator.hasNext(); ) { ArtifactRepository repo = (ArtifactRepository) aggregatedIterator.next(); // if the repository exists in the list and was introduced by another POM's super-pom, // remove it...the repository definitions from the super-POM should only be at the end of // the list. // if the repository has been redefined, leave it. if ( repo.getId().equals( superRepo.getId() ) && repo.getUrl().equals( superRepo.getUrl() ) ) { aggregatedIterator.remove(); } } } // this list should contain the super-POM repositories, so we don't have to explicitly add them back. for ( Iterator it = remoteArtifactRepositories.iterator(); it.hasNext(); ) { ArtifactRepository repository = (ArtifactRepository) it.next(); if ( !repositories.contains( repository ) ) { repositories.add( repository ); } } return repositories; } /** * @todo desperately needs refactoring. It's just here because it's implementation is maven-project specific * @return {@link Set} < {@link Artifact} > */ public static Set createArtifacts( ArtifactFactory artifactFactory, List dependencies, String inheritedScope, ArtifactFilter dependencyFilter, MavenProject project ) throws InvalidDependencyVersionException { Set projectArtifacts = new LinkedHashSet( dependencies.size() ); for ( Iterator i = dependencies.iterator(); i.hasNext(); ) { Dependency d = (Dependency) i.next(); String scope = d.getScope(); if ( StringUtils.isEmpty( scope ) ) { scope = Artifact.SCOPE_COMPILE; d.setScope( scope ); } VersionRange versionRange; try { versionRange = VersionRange.createFromVersionSpec( d.getVersion() ); } catch ( InvalidVersionSpecificationException e ) { throw new InvalidDependencyVersionException( "Unable to parse version '" + d.getVersion() + "' for dependency '" + d.getManagementKey() + "': " + e.getMessage(), e ); } Artifact artifact = artifactFactory.createDependencyArtifact( d.getGroupId(), d.getArtifactId(), versionRange, d.getType(), d.getClassifier(), scope, inheritedScope, d.isOptional() ); if ( Artifact.SCOPE_SYSTEM.equals( scope ) ) { artifact.setFile( new File( d.getSystemPath() ) ); } ArtifactFilter artifactFilter = dependencyFilter; // MNG-3769: It would be nice to be able to process relocations here, // so we could have this filtering step apply to post-relocated dependencies. // HOWEVER, this would require a much more invasive POM resolution process // in order to look for relocations, which would make the early steps in // a Maven build way too heavy. if ( artifact != null && ( artifactFilter == null || artifactFilter.include( artifact ) ) ) { if ( d.getExclusions() != null && !d.getExclusions().isEmpty() ) { List exclusions = new ArrayList(); for ( Iterator j = d.getExclusions().iterator(); j.hasNext(); ) { Exclusion e = (Exclusion) j.next(); exclusions.add( e.getGroupId() + ":" + e.getArtifactId() ); } ArtifactFilter newFilter = new ExcludesArtifactFilter( exclusions ); if ( artifactFilter != null ) { AndArtifactFilter filter = new AndArtifactFilter(); filter.add( artifactFilter ); filter.add( newFilter ); artifactFilter = filter; } else { artifactFilter = newFilter; } } artifact.setDependencyFilter( artifactFilter ); if ( project != null ) { artifact = project.replaceWithActiveArtifact( artifact ); } projectArtifacts.add( artifact ); } } return projectArtifacts; } public List retrieveAvailableVersions( Artifact artifact, ArtifactRepository localRepository, List remoteRepositories ) throws ArtifactMetadataRetrievalException { RepositoryMetadata metadata = new ArtifactRepositoryMetadata( artifact ); try { repositoryMetadataManager.resolve( metadata, remoteRepositories, localRepository ); } catch ( RepositoryMetadataResolutionException e ) { throw new ArtifactMetadataRetrievalException( e.getMessage(), e ); } List versions; Metadata repoMetadata = metadata.getMetadata(); if ( repoMetadata != null && repoMetadata.getVersioning() != null ) { List metadataVersions = repoMetadata.getVersioning().getVersions(); versions = new ArrayList( metadataVersions.size() ); for ( Iterator i = metadataVersions.iterator(); i.hasNext(); ) { String version = (String) i.next(); versions.add( new DefaultArtifactVersion( version ) ); } } else { versions = Collections.EMPTY_LIST; } return versions; } private static final class ProjectRelocation { private MavenProject project; private Artifact pomArtifact; } } ././@LongLink0000000000000000000000000000016700000000000011571 Lustar rootrootmaven2-core-2.2.1/maven-project/src/main/java/org/apache/maven/project/artifact/InvalidDependencyVersionException.javamaven2-core-2.2.1/maven-project/src/main/java/org/apache/maven/project/artifact/InvalidDependencyVer0000644000175000017500000000236310551365651033357 0ustar twernertwernerpackage org.apache.maven.project.artifact; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ /** * Thrown if a dependency has an invalid version. * * @author Brett Porter * @version $Id: InvalidDependencyVersionException.java 495147 2007-01-11 07:47:53Z jvanzyl $ */ public class InvalidDependencyVersionException extends Exception { public InvalidDependencyVersionException( String message, Exception cause ) { super( message, cause ); } } ././@LongLink0000000000000000000000000000014600000000000011566 Lustar rootrootmaven2-core-2.2.1/maven-project/src/main/java/org/apache/maven/project/DuplicateProjectException.javamaven2-core-2.2.1/maven-project/src/main/java/org/apache/maven/project/DuplicateProjectException.jav0000644000175000017500000000254110772004567033416 0ustar twernertwernerpackage org.apache.maven.project; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ /** * Exception that occurs when the project list contains duplicate projects instead of ignoring one. * * @author Brett Porter * @version $Id: DuplicateProjectException.java 640549 2008-03-24 20:05:11Z bentmann $ */ public class DuplicateProjectException extends Exception { public DuplicateProjectException( String message ) { super( message ); } public DuplicateProjectException( String message, Exception e ) { super( message, e ); } } ././@LongLink0000000000000000000000000000015100000000000011562 Lustar rootrootmaven2-core-2.2.1/maven-project/src/main/java/org/apache/maven/project/InvalidProjectModelException.javamaven2-core-2.2.1/maven-project/src/main/java/org/apache/maven/project/InvalidProjectModelException.0000644000175000017500000000406110772004567033351 0ustar twernertwernerpackage org.apache.maven.project; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import org.apache.maven.project.validation.ModelValidationResult; public class InvalidProjectModelException extends ProjectBuildingException { private final String pomLocation; private ModelValidationResult validationResult; public InvalidProjectModelException( String projectId, String pomLocation, String message, Throwable cause ) { super( projectId, message, cause ); this.pomLocation = pomLocation; } public InvalidProjectModelException( String projectId, String pomLocation, String message, ModelValidationResult validationResult ) { super( projectId, message ); this.pomLocation = pomLocation; this.validationResult = validationResult; } public InvalidProjectModelException( String projectId, String pomLocation, String message ) { super( projectId, message ); this.pomLocation = pomLocation; } public final String getPomLocation() { return pomLocation; } public final ModelValidationResult getValidationResult() { return validationResult; } public String getMessage() { return super.getMessage() + " at " + this.pomLocation; } } maven2-core-2.2.1/maven-project/src/main/java/org/apache/maven/project/inheritance/0000755000175000017500000000000011250552246030055 5ustar twernertwerner././@LongLink0000000000000000000000000000017100000000000011564 Lustar rootrootmaven2-core-2.2.1/maven-project/src/main/java/org/apache/maven/project/inheritance/DefaultModelInheritanceAssembler.javamaven2-core-2.2.1/maven-project/src/main/java/org/apache/maven/project/inheritance/DefaultModelInher0000644000175000017500000004420711151504752033341 0ustar twernertwernerpackage org.apache.maven.project.inheritance; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import org.apache.maven.model.Build; import org.apache.maven.model.Dependency; import org.apache.maven.model.DependencyManagement; import org.apache.maven.model.DeploymentRepository; import org.apache.maven.model.DistributionManagement; import org.apache.maven.model.Model; import org.apache.maven.model.PluginManagement; import org.apache.maven.model.Reporting; import org.apache.maven.model.Scm; import org.apache.maven.model.Site; import org.apache.maven.project.ModelUtils; import org.codehaus.plexus.util.StringUtils; import java.util.ArrayList; import java.util.Iterator; import java.util.LinkedList; import java.util.List; import java.util.Map; import java.util.Properties; import java.util.StringTokenizer; import java.util.TreeMap; /** * @author Jason van Zyl * @version $Id: DefaultModelInheritanceAssembler.java,v 1.4 2004/08/23 20:24:54 * jdcasey Exp $ * @todo generate this with modello to keep it in sync with changes in the model. */ public class DefaultModelInheritanceAssembler implements ModelInheritanceAssembler { public void copyModel( Model dest, Model source ) { assembleModelInheritance( dest, source, null, false ); } public void assembleModelInheritance( Model child, Model parent, String childPathAdjustment ) { assembleModelInheritance( child, parent, childPathAdjustment, true ); } public void assembleModelInheritance( Model child, Model parent ) { assembleModelInheritance( child, parent, null, true ); } private void assembleModelInheritance( Model child, Model parent, String childPathAdjustment, boolean appendPaths ) { // cannot inherit from null parent. if ( parent == null ) { return; } // Group id if ( child.getGroupId() == null ) { child.setGroupId( parent.getGroupId() ); } // version if ( child.getVersion() == null ) { // The parent version may have resolved to something different, so we take what we asked for... // instead of - child.setVersion( parent.getVersion() ); if ( child.getParent() != null ) { child.setVersion( child.getParent().getVersion() ); } } // inceptionYear if ( child.getInceptionYear() == null ) { child.setInceptionYear( parent.getInceptionYear() ); } // url if ( child.getUrl() == null ) { if ( parent.getUrl() != null ) { child.setUrl( appendPath( parent.getUrl(), child.getArtifactId(), childPathAdjustment, appendPaths ) ); } else { child.setUrl( parent.getUrl() ); } } assembleDistributionInheritence( child, parent, childPathAdjustment, appendPaths ); // issueManagement if ( child.getIssueManagement() == null ) { child.setIssueManagement( parent.getIssueManagement() ); } // description if ( child.getDescription() == null ) { child.setDescription( parent.getDescription() ); } // Organization if ( child.getOrganization() == null ) { child.setOrganization( parent.getOrganization() ); } // Scm assembleScmInheritance( child, parent, childPathAdjustment, appendPaths ); // ciManagement if ( child.getCiManagement() == null ) { child.setCiManagement( parent.getCiManagement() ); } // developers if ( child.getDevelopers().size() == 0 ) { child.setDevelopers( parent.getDevelopers() ); } // licenses if ( child.getLicenses().size() == 0 ) { child.setLicenses( parent.getLicenses() ); } // developers if ( child.getContributors().size() == 0 ) { child.setContributors( parent.getContributors() ); } // mailingLists if ( child.getMailingLists().size() == 0 ) { child.setMailingLists( parent.getMailingLists() ); } // Build assembleBuildInheritance( child, parent ); assembleDependencyInheritance( child, parent ); child.setRepositories( ModelUtils.mergeRepositoryLists( child.getRepositories(), parent.getRepositories() ) ); child.setPluginRepositories( ModelUtils.mergeRepositoryLists( child.getPluginRepositories(), parent.getPluginRepositories() ) ); assembleReportingInheritance( child, parent ); assembleDependencyManagementInheritance( child, parent ); Properties props = new Properties(); props.putAll( parent.getProperties() ); props.putAll( child.getProperties() ); child.setProperties( props ); } private void assembleDependencyManagementInheritance( Model child, Model parent ) { DependencyManagement parentDepMgmt = parent.getDependencyManagement(); DependencyManagement childDepMgmt = child.getDependencyManagement(); if ( parentDepMgmt != null ) { if ( childDepMgmt == null ) { child.setDependencyManagement( parentDepMgmt ); } else { List childDeps = childDepMgmt.getDependencies(); Map mappedChildDeps = new TreeMap(); for ( Iterator it = childDeps.iterator(); it.hasNext(); ) { Dependency dep = (Dependency) it.next(); mappedChildDeps.put( dep.getManagementKey(), dep ); } for ( Iterator it = parentDepMgmt.getDependencies().iterator(); it.hasNext(); ) { Dependency dep = (Dependency) it.next(); if ( !mappedChildDeps.containsKey( dep.getManagementKey() ) ) { childDepMgmt.addDependency( dep ); } } } } } private void assembleReportingInheritance( Model child, Model parent ) { // Reports :: aggregate Reporting childReporting = child.getReporting(); Reporting parentReporting = parent.getReporting(); if ( parentReporting != null ) { if ( childReporting == null ) { childReporting = new Reporting(); child.setReporting( childReporting ); } if ( childReporting.isExcludeDefaultsValue() == null ) { childReporting.setExcludeDefaultsValue( parentReporting.isExcludeDefaultsValue() ); } if ( StringUtils.isEmpty( childReporting.getOutputDirectory() ) ) { childReporting.setOutputDirectory( parentReporting.getOutputDirectory() ); } ModelUtils.mergeReportPluginLists( childReporting, parentReporting, true ); } } private void assembleDependencyInheritance( Model child, Model parent ) { child.setDependencies( ModelUtils.mergeDependencyList( child.getDependencies(), parent.getDependencies() ) ); } private void assembleBuildInheritance( Model child, Model parent ) { Build childBuild = child.getBuild(); Build parentBuild = parent.getBuild(); if ( parentBuild != null ) { if ( childBuild == null ) { childBuild = new Build(); child.setBuild( childBuild ); } assembleBuildInheritance( childBuild, parentBuild, true ); } } public void assembleBuildInheritance( Build childBuild, Build parentBuild, boolean handleAsInheritance ) { // The build has been set but we want to step in here and fill in // values that have not been set by the child. if ( childBuild.getSourceDirectory() == null ) { childBuild.setSourceDirectory( parentBuild.getSourceDirectory() ); } if ( childBuild.getScriptSourceDirectory() == null ) { childBuild.setScriptSourceDirectory( parentBuild.getScriptSourceDirectory() ); } if ( childBuild.getTestSourceDirectory() == null ) { childBuild.setTestSourceDirectory( parentBuild.getTestSourceDirectory() ); } if ( childBuild.getOutputDirectory() == null ) { childBuild.setOutputDirectory( parentBuild.getOutputDirectory() ); } if ( childBuild.getTestOutputDirectory() == null ) { childBuild.setTestOutputDirectory( parentBuild.getTestOutputDirectory() ); } // Extensions are accumlated ModelUtils.mergeExtensionLists( childBuild, parentBuild ); if ( childBuild.getDirectory() == null ) { childBuild.setDirectory( parentBuild.getDirectory() ); } if ( childBuild.getDefaultGoal() == null ) { childBuild.setDefaultGoal( parentBuild.getDefaultGoal() ); } if ( childBuild.getFinalName() == null ) { childBuild.setFinalName( parentBuild.getFinalName() ); } ModelUtils.mergeFilterLists( childBuild.getFilters(), parentBuild.getFilters() ); List resources = childBuild.getResources(); if ( ( resources == null ) || resources.isEmpty() ) { childBuild.setResources( parentBuild.getResources() ); } resources = childBuild.getTestResources(); if ( ( resources == null ) || resources.isEmpty() ) { childBuild.setTestResources( parentBuild.getTestResources() ); } // Plugins are aggregated if Plugin.inherit != false ModelUtils.mergePluginLists( childBuild, parentBuild, handleAsInheritance ); // Plugin management :: aggregate PluginManagement dominantPM = childBuild.getPluginManagement(); PluginManagement recessivePM = parentBuild.getPluginManagement(); if ( ( dominantPM == null ) && ( recessivePM != null ) ) { // FIXME: Filter out the inherited == false stuff! childBuild.setPluginManagement( recessivePM ); } else { ModelUtils.mergePluginLists( childBuild.getPluginManagement(), parentBuild.getPluginManagement(), false ); } } private void assembleScmInheritance( Model child, Model parent, String childPathAdjustment, boolean appendPaths ) { if ( parent.getScm() != null ) { Scm parentScm = parent.getScm(); Scm childScm = child.getScm(); if ( childScm == null ) { childScm = new Scm(); child.setScm( childScm ); } if ( StringUtils.isEmpty( childScm.getConnection() ) && !StringUtils.isEmpty( parentScm.getConnection() ) ) { childScm.setConnection( appendPath( parentScm.getConnection(), child.getArtifactId(), childPathAdjustment, appendPaths ) ); } if ( StringUtils.isEmpty( childScm.getDeveloperConnection() ) && !StringUtils.isEmpty( parentScm.getDeveloperConnection() ) ) { childScm .setDeveloperConnection( appendPath( parentScm.getDeveloperConnection(), child.getArtifactId(), childPathAdjustment, appendPaths ) ); } if ( StringUtils.isEmpty( childScm.getUrl() ) && !StringUtils.isEmpty( parentScm.getUrl() ) ) { childScm.setUrl( appendPath( parentScm.getUrl(), child.getArtifactId(), childPathAdjustment, appendPaths ) ); } } } private void assembleDistributionInheritence( Model child, Model parent, String childPathAdjustment, boolean appendPaths ) { if ( parent.getDistributionManagement() != null ) { DistributionManagement parentDistMgmt = parent.getDistributionManagement(); DistributionManagement childDistMgmt = child.getDistributionManagement(); if ( childDistMgmt == null ) { childDistMgmt = new DistributionManagement(); child.setDistributionManagement( childDistMgmt ); } if ( childDistMgmt.getSite() == null ) { if ( parentDistMgmt.getSite() != null ) { Site site = new Site(); childDistMgmt.setSite( site ); site.setId( parentDistMgmt.getSite().getId() ); site.setName( parentDistMgmt.getSite().getName() ); site.setUrl( parentDistMgmt.getSite().getUrl() ); if ( site.getUrl() != null ) { site.setUrl( appendPath( site.getUrl(), child.getArtifactId(), childPathAdjustment, appendPaths ) ); } } } if ( childDistMgmt.getRepository() == null ) { if ( parentDistMgmt.getRepository() != null ) { DeploymentRepository repository = copyDistributionRepository( parentDistMgmt.getRepository() ); childDistMgmt.setRepository( repository ); } } if ( childDistMgmt.getSnapshotRepository() == null ) { if ( parentDistMgmt.getSnapshotRepository() != null ) { DeploymentRepository repository = copyDistributionRepository( parentDistMgmt.getSnapshotRepository() ); childDistMgmt.setSnapshotRepository( repository ); } } if ( StringUtils.isEmpty( childDistMgmt.getDownloadUrl() ) ) { childDistMgmt.setDownloadUrl( parentDistMgmt.getDownloadUrl() ); } // NOTE: We SHOULD NOT be inheriting status, since this is an assessment of the POM quality. // NOTE: We SHOULD NOT be inheriting relocation, since this relates to a single POM } } private static DeploymentRepository copyDistributionRepository( DeploymentRepository parentRepository ) { DeploymentRepository repository = new DeploymentRepository(); repository.setId( parentRepository.getId() ); repository.setName( parentRepository.getName() ); repository.setUrl( parentRepository.getUrl() ); repository.setLayout( parentRepository.getLayout() ); repository.setUniqueVersion( parentRepository.isUniqueVersion() ); return repository; } // TODO: This should eventually be migrated to DefaultPathTranslator. protected String appendPath( String parentPath, String childPath, String pathAdjustment, boolean appendPaths ) { String uncleanPath = parentPath; if ( appendPaths ) { if ( pathAdjustment != null ) { uncleanPath += "/" + pathAdjustment; } if ( childPath != null ) { uncleanPath += "/" + childPath; } } String cleanedPath = ""; int protocolIdx = uncleanPath.indexOf( "://" ); if ( protocolIdx > -1 ) { cleanedPath = uncleanPath.substring( 0, protocolIdx + 3 ); uncleanPath = uncleanPath.substring( protocolIdx + 3 ); } if ( uncleanPath.startsWith( "//" ) ) { // preserve leading double slash for UNC paths like "file:////host/pom.xml" cleanedPath += "//"; } else if ( uncleanPath.startsWith( "/" ) ) { cleanedPath += "/"; } return cleanedPath + resolvePath( uncleanPath ); } // TODO: Move this to plexus-utils' PathTool. private static String resolvePath( String uncleanPath ) { LinkedList pathElements = new LinkedList(); StringTokenizer tokenizer = new StringTokenizer( uncleanPath, "/" ); while ( tokenizer.hasMoreTokens() ) { String token = tokenizer.nextToken(); if ( token.equals( "" ) ) { // Empty path entry ("...//.."), remove. } else if ( token.equals( ".." ) ) { if ( pathElements.isEmpty() ) { // FIXME: somehow report to the user // that there are too many '..' elements. // For now, ignore the extra '..'. } else { pathElements.removeLast(); } } else { pathElements.addLast( token ); } } StringBuffer cleanedPath = new StringBuffer(); while ( !pathElements.isEmpty() ) { cleanedPath.append( pathElements.removeFirst() ); if ( !pathElements.isEmpty() ) { cleanedPath.append( '/' ); } } return cleanedPath.toString(); } } ././@LongLink0000000000000000000000000000016200000000000011564 Lustar rootrootmaven2-core-2.2.1/maven-project/src/main/java/org/apache/maven/project/inheritance/ModelInheritanceAssembler.javamaven2-core-2.2.1/maven-project/src/main/java/org/apache/maven/project/inheritance/ModelInheritanceA0000644000175000017500000000304711034716010033306 0ustar twernertwernerpackage org.apache.maven.project.inheritance; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import org.apache.maven.model.Build; import org.apache.maven.model.Model; /** * @author Jason van Zyl * @version $Id: ModelInheritanceAssembler.java 674878 2008-07-08 16:55:36Z jdcasey $ */ public interface ModelInheritanceAssembler { String ROLE = ModelInheritanceAssembler.class.getName(); void assembleModelInheritance( Model child, Model parent, String childPathAdjustment ); void assembleModelInheritance( Model child, Model parent ); void assembleBuildInheritance( Build childBuild, Build parentBuild, boolean handleAsInheritance ); void copyModel( Model dest, Model source ); } ././@LongLink0000000000000000000000000000014700000000000011567 Lustar rootrootmaven2-core-2.2.1/maven-project/src/main/java/org/apache/maven/project/DefaultMavenProjectBuilder.javamaven2-core-2.2.1/maven-project/src/main/java/org/apache/maven/project/DefaultMavenProjectBuilder.ja0000644000175000017500000031667211221205616033322 0ustar twernertwernerpackage org.apache.maven.project; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.ArtifactStatus; import org.apache.maven.artifact.ArtifactUtils; import org.apache.maven.artifact.InvalidRepositoryException; import org.apache.maven.artifact.manager.WagonManager; import org.apache.maven.artifact.metadata.ArtifactMetadataSource; import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.artifact.repository.ArtifactRepositoryFactory; import org.apache.maven.artifact.repository.ArtifactRepositoryPolicy; import org.apache.maven.artifact.resolver.ArtifactNotFoundException; import org.apache.maven.artifact.resolver.ArtifactResolutionException; import org.apache.maven.artifact.resolver.ArtifactResolutionResult; import org.apache.maven.artifact.resolver.ArtifactResolver; import org.apache.maven.artifact.resolver.filter.ExcludesArtifactFilter; import org.apache.maven.artifact.versioning.InvalidVersionSpecificationException; import org.apache.maven.artifact.versioning.ManagedVersionMap; import org.apache.maven.artifact.versioning.VersionRange; import org.apache.maven.model.Build; import org.apache.maven.model.Dependency; import org.apache.maven.model.DependencyManagement; import org.apache.maven.model.DistributionManagement; import org.apache.maven.model.Exclusion; import org.apache.maven.model.Extension; import org.apache.maven.model.Model; import org.apache.maven.model.Parent; import org.apache.maven.model.Plugin; import org.apache.maven.model.PluginExecution; import org.apache.maven.model.PluginManagement; import org.apache.maven.model.Profile; import org.apache.maven.model.ReportPlugin; import org.apache.maven.model.Repository; import org.apache.maven.model.Resource; import org.apache.maven.model.io.xpp3.MavenXpp3Reader; import org.apache.maven.profiles.DefaultProfileManager; import org.apache.maven.profiles.MavenProfilesBuilder; import org.apache.maven.profiles.ProfileManager; import org.apache.maven.profiles.ProfilesConversionUtils; import org.apache.maven.profiles.ProfilesRoot; import org.apache.maven.profiles.activation.ProfileActivationException; import org.apache.maven.project.artifact.InvalidDependencyVersionException; import org.apache.maven.project.artifact.ProjectArtifactFactory; import org.apache.maven.project.inheritance.ModelInheritanceAssembler; import org.apache.maven.project.injection.ModelDefaultsInjector; import org.apache.maven.project.injection.ProfileInjector; import org.apache.maven.project.interpolation.ModelInterpolationException; import org.apache.maven.project.interpolation.ModelInterpolator; import org.apache.maven.project.path.PathTranslator; import org.apache.maven.project.validation.ModelValidationResult; import org.apache.maven.project.validation.ModelValidator; import org.apache.maven.wagon.events.TransferListener; import org.codehaus.plexus.PlexusConstants; import org.codehaus.plexus.PlexusContainer; import org.codehaus.plexus.component.repository.exception.ComponentLookupException; import org.codehaus.plexus.context.Context; import org.codehaus.plexus.context.ContextException; import org.codehaus.plexus.logging.AbstractLogEnabled; import org.codehaus.plexus.personality.plexus.lifecycle.phase.Contextualizable; import org.codehaus.plexus.personality.plexus.lifecycle.phase.Initializable; import org.codehaus.plexus.util.IOUtil; import org.codehaus.plexus.util.ReaderFactory; import org.codehaus.plexus.util.StringUtils; import org.codehaus.plexus.util.xml.pull.XmlPullParserException; import java.io.File; import java.io.FileNotFoundException; import java.io.IOException; import java.io.Reader; import java.io.StringReader; import java.net.URL; import java.util.ArrayList; import java.util.Collections; import java.util.Date; import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; import java.util.LinkedHashSet; import java.util.LinkedList; import java.util.List; import java.util.Map; import java.util.Set; import java.util.TreeMap; /*:apt ----- POM lifecycle ----- POM Lifecycle Order of operations when building a POM * inheritance * path translation * interpolation * defaults injection Current processing is: * inheritance * interpolation * defaults injection * path translation I'm not sure how this is working at all ... i think i have a case where this is failing but i need to encapsulate as a test so i can fix it. Also need to think of the in working build directory versus looking things up from the repository i.e buildFromSource vs buildFromRepository. Notes * when the model is read it may not have a groupId, as it must be inherited * the inheritance assembler must use models that are unadulterated! */ /** * @version $Id: DefaultMavenProjectBuilder.java 788791 2009-06-26 17:55:26Z jdcasey $ */ public class DefaultMavenProjectBuilder extends AbstractLogEnabled implements MavenProjectBuilder, Initializable, Contextualizable { // TODO: remove private PlexusContainer container; protected MavenProfilesBuilder profilesBuilder; protected ArtifactResolver artifactResolver; protected ArtifactMetadataSource artifactMetadataSource; private ProjectArtifactFactory artifactFactory; private ModelInheritanceAssembler modelInheritanceAssembler; private ProfileInjector profileInjector; private ModelValidator validator; private Map rawProjectCache = new HashMap(); private Map processedProjectCache = new HashMap(); // TODO: make it a component private MavenXpp3Reader modelReader; private PathTranslator pathTranslator; private ModelDefaultsInjector modelDefaultsInjector; private ModelInterpolator modelInterpolator; private ArtifactRepositoryFactory artifactRepositoryFactory; // ---------------------------------------------------------------------- // I am making this available for use with a new method that takes a // a monitor wagon monitor as a parameter so that tools can use the // methods here and receive callbacks. MNG-1015 // ---------------------------------------------------------------------- private WagonManager wagonManager; public static final String MAVEN_MODEL_VERSION = "4.0.0"; public void initialize() { modelReader = new MavenXpp3Reader(); } // ---------------------------------------------------------------------- // MavenProjectBuilder Implementation // ---------------------------------------------------------------------- public MavenProject build( File pom, ProjectBuilderConfiguration config ) throws ProjectBuildingException { return buildFromSourceFileInternal( pom, config, true ); } public MavenProject build( File pom, ProjectBuilderConfiguration config, boolean checkDistributionManagementStatus ) throws ProjectBuildingException { return buildFromSourceFileInternal( pom, config, checkDistributionManagementStatus ); } public MavenProject build( File projectDescriptor, ArtifactRepository localRepository, ProfileManager profileManager ) throws ProjectBuildingException { ProjectBuilderConfiguration config = new DefaultProjectBuilderConfiguration().setLocalRepository( localRepository ).setGlobalProfileManager( profileManager ); return buildFromSourceFileInternal( projectDescriptor, config, true ); } public MavenProject build( File projectDescriptor, ArtifactRepository localRepository, ProfileManager profileManager, boolean checkDistributionManagementStatus ) throws ProjectBuildingException { ProjectBuilderConfiguration config = new DefaultProjectBuilderConfiguration().setLocalRepository( localRepository ).setGlobalProfileManager( profileManager ); return buildFromSourceFileInternal( projectDescriptor, config, checkDistributionManagementStatus ); } // jvz:note // When asked for something from the repository are we getting it from the reactor? Yes, when using this call // we are assuming that the reactor has been run and we have collected the projects required to satisfy it0042 // which means the projects in the reactor are required for finding classes in /target/classes. Not // sure this is ideal. I remove all caching from the builder and all reactor related ITs which assume // access to simbling project resources failed. public MavenProject buildFromRepository( Artifact artifact, List remoteArtifactRepositories, ArtifactRepository localRepository, boolean allowStubModel ) throws ProjectBuildingException { String cacheKey = createCacheKey( artifact.getGroupId(), artifact.getArtifactId(), artifact.getVersion() ); MavenProject project = (MavenProject) processedProjectCache.get( cacheKey ); if ( project != null ) { return project; } Model model = findModelFromRepository( artifact, remoteArtifactRepositories, localRepository, allowStubModel ); ProjectBuilderConfiguration config = new DefaultProjectBuilderConfiguration().setLocalRepository( localRepository ); return buildInternal( "Artifact [" + artifact + "]", model, config, remoteArtifactRepositories, null, false ); } public MavenProject buildFromRepository( Artifact artifact, List remoteArtifactRepositories, ArtifactRepository localRepository ) throws ProjectBuildingException { return buildFromRepository( artifact, remoteArtifactRepositories, localRepository, true ); } // what is using this externally? jvz. public MavenProject buildStandaloneSuperProject( ArtifactRepository localRepository ) throws ProjectBuildingException { //TODO mkleint - use the (Container, Properties) constructor to make system properties embeddable ProfileManager profileManager = new DefaultProfileManager( container ); return buildStandaloneSuperProject( new DefaultProjectBuilderConfiguration().setLocalRepository( localRepository ) .setGlobalProfileManager( profileManager ) ); } public MavenProject buildStandaloneSuperProject( ArtifactRepository localRepository, ProfileManager profileManager ) throws ProjectBuildingException { return buildStandaloneSuperProject( new DefaultProjectBuilderConfiguration().setLocalRepository( localRepository ) .setGlobalProfileManager( profileManager ) ); } public MavenProject buildStandaloneSuperProject( ProjectBuilderConfiguration config ) throws ProjectBuildingException { Model superModel = getSuperModel(); superModel.setGroupId( STANDALONE_SUPERPOM_GROUPID ); superModel.setArtifactId( STANDALONE_SUPERPOM_ARTIFACTID ); superModel.setVersion( STANDALONE_SUPERPOM_VERSION ); List activeProfiles; ProfileManager profileManager = config.getGlobalProfileManager(); if ( profileManager == null ) { profileManager = new DefaultProfileManager( container ); } profileManager.addProfiles( superModel.getProfiles() ); String projectId = safeVersionlessKey( STANDALONE_SUPERPOM_GROUPID, STANDALONE_SUPERPOM_ARTIFACTID ); activeProfiles = injectActiveProfiles( profileManager, superModel ); MavenProject project = new MavenProject( superModel ); project.setManagedVersionMap( createManagedVersionMap( projectId, superModel.getDependencyManagement(), null ) ); project.setActiveProfiles( activeProfiles ); project.setOriginalModel( superModel ); try { project = processProjectLogic( "", project, config, null, null, true, true ); project.setExecutionRoot( true ); return project; } catch ( ModelInterpolationException e ) { throw new ProjectBuildingException( projectId, e.getMessage(), e ); } catch ( InvalidRepositoryException e ) { throw new ProjectBuildingException( projectId, e.getMessage(), e ); } } public MavenProject buildWithDependencies( File projectDescriptor, ArtifactRepository localRepository, ProfileManager profileManager ) throws ProjectBuildingException, ArtifactResolutionException, ArtifactNotFoundException { return buildWithDependencies( projectDescriptor, localRepository, profileManager, null ); } // note:jvz This was added for the embedder. /** @todo move to metadatasource itself? */ public MavenProject buildWithDependencies( File projectDescriptor, ArtifactRepository localRepository, ProfileManager profileManager, TransferListener transferListener ) throws ProjectBuildingException, ArtifactResolutionException, ArtifactNotFoundException { MavenProject project = build( projectDescriptor, localRepository, profileManager, false ); // ---------------------------------------------------------------------- // Typically when the project builder is being used from maven proper // the transitive dependencies will not be resolved here because this // requires a lot of work when we may only be interested in running // something simple like 'm2 clean'. So the artifact collector is used // in the dependency resolution phase if it is required by any of the // goals being executed. But when used as a component in another piece // of code people may just want to build maven projects and have the // dependencies resolved for whatever reason: this is why we keep // this snippet of code here. // ---------------------------------------------------------------------- // TODO: such a call in MavenMetadataSource too - packaging not really the intention of type Artifact projectArtifact = project.getArtifact(); String projectId = safeVersionlessKey( project.getGroupId(), project.getArtifactId() ); // Map managedVersions = createManagedVersionMap( projectId, project.getDependencyManagement() ); Map managedVersions = project.getManagedVersionMap(); ensureMetadataSourceIsInitialized(); try { project.setDependencyArtifacts( project.createArtifacts( artifactFactory, null, null ) ); } catch ( InvalidDependencyVersionException e ) { throw new ProjectBuildingException( projectId, "Unable to build project due to an invalid dependency version: " + e.getMessage(), e ); } if ( transferListener != null ) { wagonManager.setDownloadMonitor( transferListener ); } ArtifactResolutionResult result = artifactResolver.resolveTransitively( project.getDependencyArtifacts(), projectArtifact, managedVersions, localRepository, project.getRemoteArtifactRepositories(), artifactMetadataSource ); project.setArtifacts( result.getArtifacts() ); return project; } // ---------------------------------------------------------------------- // // ---------------------------------------------------------------------- private void ensureMetadataSourceIsInitialized() throws ProjectBuildingException { if ( artifactMetadataSource == null ) { try { artifactMetadataSource = (ArtifactMetadataSource) container.lookup( ArtifactMetadataSource.ROLE ); } catch ( ComponentLookupException e ) { throw new ProjectBuildingException( "all", "Cannot lookup metadata source for building the project.", e ); } } } private Map createManagedVersionMap( String projectId, DependencyManagement dependencyManagement, MavenProject parent ) throws ProjectBuildingException { Map map = null; List deps; if ( ( dependencyManagement != null ) && ( ( deps = dependencyManagement.getDependencies() ) != null ) && ( deps.size() > 0 ) ) { map = new ManagedVersionMap( map ); if ( getLogger().isDebugEnabled() ) { getLogger().debug( "Adding managed dependencies for " + projectId ); } for ( Iterator i = dependencyManagement.getDependencies().iterator(); i.hasNext(); ) { Dependency d = (Dependency) i.next(); try { VersionRange versionRange = VersionRange.createFromVersionSpec( d.getVersion() ); Artifact artifact = artifactFactory.createDependencyArtifact( d.getGroupId(), d.getArtifactId(), versionRange, d.getType(), d.getClassifier(), d.getScope(), d.isOptional() ); if ( getLogger().isDebugEnabled() ) { getLogger().debug( " " + artifact ); } // If the dependencyManagement section listed exclusions, // add them to the managed artifacts here so that transitive // dependencies will be excluded if necessary. if ( ( null != d.getExclusions() ) && !d.getExclusions().isEmpty() ) { List exclusions = new ArrayList(); Iterator exclItr = d.getExclusions().iterator(); while ( exclItr.hasNext() ) { Exclusion e = (Exclusion) exclItr.next(); exclusions.add( e.getGroupId() + ":" + e.getArtifactId() ); } ExcludesArtifactFilter eaf = new ExcludesArtifactFilter( exclusions ); artifact.setDependencyFilter( eaf ); } else { artifact.setDependencyFilter( null ); } map.put( d.getManagementKey(), artifact ); } catch ( InvalidVersionSpecificationException e ) { throw new ProjectBuildingException( projectId, "Unable to parse version '" + d.getVersion() + "' for dependency '" + d.getManagementKey() + "': " + e.getMessage(), e ); } } } else if ( map == null ) { map = Collections.EMPTY_MAP; } return map; } private MavenProject buildFromSourceFileInternal( File projectDescriptor, ProjectBuilderConfiguration config, boolean checkDistributionManagementStatus ) throws ProjectBuildingException { Model model = readModel( "unknown", projectDescriptor, true ); MavenProject project = buildInternal( projectDescriptor.getAbsolutePath(), model, config, buildArtifactRepositories( getSuperModel() ), projectDescriptor, true ); if ( checkDistributionManagementStatus ) { if ( ( project.getDistributionManagement() != null ) && ( project.getDistributionManagement().getStatus() != null ) ) { String projectId = safeVersionlessKey( project.getGroupId(), project.getArtifactId() ); throw new ProjectBuildingException( projectId, "Invalid project file: distribution status must not be specified for a project outside of the repository" ); } } return project; } private Model findModelFromRepository( Artifact artifact, List remoteArtifactRepositories, ArtifactRepository localRepository, boolean allowStubModel ) throws ProjectBuildingException { String projectId = safeVersionlessKey( artifact.getGroupId(), artifact.getArtifactId() ); normalizeToArtifactRepositories( remoteArtifactRepositories, projectId ); Artifact projectArtifact; // if the artifact is not a POM, we need to construct a POM artifact based on the artifact parameter given. if ( "pom".equals( artifact.getType() ) ) { projectArtifact = artifact; } else { getLogger().debug( "Attempting to build MavenProject instance for Artifact (" + artifact.getGroupId() + ":" + artifact.getArtifactId() + ":" + artifact.getVersion() + ") of type: " + artifact.getType() + "; constructing POM artifact instead." ); projectArtifact = artifactFactory.createProjectArtifact( artifact.getGroupId(), artifact.getArtifactId(), artifact.getVersion(), artifact.getScope() ); } Model model; try { artifactResolver.resolve( projectArtifact, remoteArtifactRepositories, localRepository ); File file = projectArtifact.getFile(); model = readModel( projectId, file, false ); String downloadUrl = null; ArtifactStatus status = ArtifactStatus.NONE; DistributionManagement distributionManagement = model.getDistributionManagement(); if ( distributionManagement != null ) { downloadUrl = distributionManagement.getDownloadUrl(); status = ArtifactStatus.valueOf( distributionManagement.getStatus() ); } checkStatusAndUpdate( projectArtifact, status, file, remoteArtifactRepositories, localRepository ); // TODO: this is gross. Would like to give it the whole model, but maven-artifact shouldn't depend on that // Can a maven-core implementation of the Artifact interface store it, and be used in the exceptions? if ( downloadUrl != null ) { projectArtifact.setDownloadUrl( downloadUrl ); } else { projectArtifact.setDownloadUrl( model.getUrl() ); } } catch ( ArtifactResolutionException e ) { throw new ProjectBuildingException( projectId, "Error getting POM for '" + projectId + "' from the repository: " + e.getMessage(), e ); } catch ( ArtifactNotFoundException e ) { if ( allowStubModel ) { getLogger().debug( "Artifact not found - using stub model: " + e.getMessage() ); model = createStubModel( projectArtifact ); } else { throw new ProjectBuildingException( projectId, "POM '" + projectId + "' not found in repository: " + e.getMessage(), e ); } } return model; } private List normalizeToArtifactRepositories( List remoteArtifactRepositories, String projectId ) throws ProjectBuildingException { List normalized = new ArrayList( remoteArtifactRepositories.size() ); boolean normalizationNeeded = false; for ( Iterator it = remoteArtifactRepositories.iterator(); it.hasNext(); ) { Object item = it.next(); if ( item instanceof ArtifactRepository ) { normalized.add( item ); } else if ( item instanceof Repository ) { Repository repo = (Repository) item; try { item = ProjectUtils.buildArtifactRepository( repo, artifactRepositoryFactory, container ); normalized.add( item ); normalizationNeeded = true; } catch ( InvalidRepositoryException e ) { throw new ProjectBuildingException( projectId, "Error building artifact repository for id: " + repo.getId(), e ); } } else { throw new ProjectBuildingException( projectId, "Error building artifact repository from non-repository information item: " + item ); } } if ( normalizationNeeded ) { return normalized; } else { return remoteArtifactRepositories; } } private void checkStatusAndUpdate( Artifact projectArtifact, ArtifactStatus status, File file, List remoteArtifactRepositories, ArtifactRepository localRepository ) throws ArtifactNotFoundException { // TODO: configurable actions dependant on status if ( !projectArtifact.isSnapshot() && ( status.compareTo( ArtifactStatus.DEPLOYED ) < 0 ) ) { // use default policy (enabled, daily update, warn on bad checksum) ArtifactRepositoryPolicy policy = new ArtifactRepositoryPolicy(); // TODO: re-enable [MNG-798/865] policy.setUpdatePolicy( ArtifactRepositoryPolicy.UPDATE_POLICY_NEVER ); if ( policy.checkOutOfDate( new Date( file.lastModified() ) ) ) { getLogger().info( projectArtifact.getArtifactId() + ": updating metadata due to status of '" + status + "'" ); try { projectArtifact.setResolved( false ); artifactResolver.resolveAlways( projectArtifact, remoteArtifactRepositories, localRepository ); } catch ( ArtifactResolutionException e ) { getLogger().warn( "Error updating POM - using existing version" ); getLogger().debug( "Cause", e ); } catch ( ArtifactNotFoundException e ) { getLogger().warn( "Error updating POM - not found. Removing local copy." ); getLogger().debug( "Cause", e ); file.delete(); throw e; } } } } // jvz:note // This is used when requested artifacts do not have an associated POM. This is for the case where we are // using an m1 repo where the only thing required to be present are the JAR files. private Model createStubModel( Artifact projectArtifact ) { getLogger().debug( "Using defaults for missing POM " + projectArtifact ); Model model = new Model(); model.setModelVersion( "4.0.0" ); model.setArtifactId( projectArtifact.getArtifactId() ); model.setGroupId( projectArtifact.getGroupId() ); model.setVersion( projectArtifact.getVersion() ); // TODO: not correct in some instances model.setPackaging( projectArtifact.getType() ); model.setDistributionManagement( new DistributionManagement() ); model.getDistributionManagement().setStatus( ArtifactStatus.GENERATED.toString() ); return model; } // jvz:note // We've got a mixture of things going in the USD and from the repository, sometimes the descriptor // is a real file and sometimes null which makes things confusing. private MavenProject buildInternal( String pomLocation, Model model, ProjectBuilderConfiguration config, List parentSearchRepositories, File projectDescriptor, boolean strict ) throws ProjectBuildingException { File projectDir = null; if ( projectDescriptor != null ) { projectDir = projectDescriptor.getAbsoluteFile().getParentFile(); } Model superModel = getSuperModel(); ProfileManager externalProfileManager = config.getGlobalProfileManager(); ProfileManager superProjectProfileManager; if ( externalProfileManager != null ) { superProjectProfileManager = new DefaultProfileManager( container, externalProfileManager.getRequestProperties() ); } else { superProjectProfileManager = new DefaultProfileManager( container ); } List activeProfiles; superProjectProfileManager.addProfiles( superModel.getProfiles() ); activeProfiles = injectActiveProfiles( superProjectProfileManager, superModel ); MavenProject superProject = new MavenProject( superModel ); superProject.setActiveProfiles( activeProfiles ); //noinspection CollectionDeclaredAsConcreteClass LinkedList lineage = new LinkedList(); // TODO: the aRWR can get out of sync with project.model.repositories. We should do all the processing of // profiles, etc on the models then recreate the aggregated sets at the end from the project repositories (they // must still be created along the way so that parent poms can be discovered, however) // Use a TreeSet to ensure ordering is retained Set aggregatedRemoteWagonRepositories = new LinkedHashSet(); String projectId = safeVersionlessKey( model.getGroupId(), model.getArtifactId() ); List activeExternalProfiles; try { if ( externalProfileManager != null ) { activeExternalProfiles = externalProfileManager.getActiveProfiles(); } else { activeExternalProfiles = Collections.EMPTY_LIST; } } catch ( ProfileActivationException e ) { throw new ProjectBuildingException( projectId, "Failed to calculate active external profiles.", e ); } for ( Iterator i = activeExternalProfiles.iterator(); i.hasNext(); ) { Profile externalProfile = (Profile) i.next(); for ( Iterator repoIterator = externalProfile.getRepositories().iterator(); repoIterator.hasNext(); ) { Repository mavenRepo = (Repository) repoIterator.next(); ArtifactRepository artifactRepo = null; try { artifactRepo = ProjectUtils.buildArtifactRepository( mavenRepo, artifactRepositoryFactory, container ); } catch ( InvalidRepositoryException e ) { throw new ProjectBuildingException( projectId, e.getMessage(), e ); } aggregatedRemoteWagonRepositories.add( artifactRepo ); } } MavenProject project = null; try { project = assembleLineage( model, lineage, config, projectDescriptor, parentSearchRepositories, aggregatedRemoteWagonRepositories, strict ); } catch ( InvalidRepositoryException e ) { throw new ProjectBuildingException( projectId, e.getMessage(), e ); } // we don't have to force the collision exception for superModel here, it's already been done in getSuperModel() MavenProject previousProject = superProject; Model previous = superProject.getModel(); for ( Iterator i = lineage.iterator(); i.hasNext(); ) { MavenProject currentProject = (MavenProject) i.next(); Model current = currentProject.getModel(); String pathAdjustment = null; try { pathAdjustment = previousProject.getModulePathAdjustment( currentProject ); } catch ( IOException e ) { getLogger().debug( "Cannot determine whether " + currentProject.getId() + " is a module of " + previousProject.getId() + ". Reason: " + e.getMessage(), e ); } modelInheritanceAssembler.assembleModelInheritance( current, previous, pathAdjustment ); previous = current; previousProject = currentProject; } // only add the super repository if it wasn't overridden by a profile or project List repositories = new ArrayList( aggregatedRemoteWagonRepositories ); List superRepositories = buildArtifactRepositories( superModel ); for ( Iterator i = superRepositories.iterator(); i.hasNext(); ) { ArtifactRepository repository = (ArtifactRepository) i.next(); if ( !repositories.contains( repository ) ) { repositories.add( repository ); } } // merge any duplicated plugin definitions together, using the first appearance as the dominant one. ModelUtils.mergeDuplicatePluginDefinitions( project.getModel().getBuild() ); try { project = processProjectLogic( pomLocation, project, config, projectDir, repositories, strict, false ); } catch ( ModelInterpolationException e ) { throw new InvalidProjectModelException( projectId, pomLocation, e.getMessage(), e ); } catch ( InvalidRepositoryException e ) { throw new InvalidProjectModelException( projectId, pomLocation, e.getMessage(), e ); } processedProjectCache.put( createCacheKey( project.getGroupId(), project.getArtifactId(), project.getVersion() ), project ); // jvz:note // this only happens if we are building from a source file if ( projectDescriptor != null ) { Build build = project.getBuild(); project.addCompileSourceRoot( build.getSourceDirectory() ); project.addScriptSourceRoot( build.getScriptSourceDirectory() ); project.addTestCompileSourceRoot( build.getTestSourceDirectory() ); // Only track the file of a POM in the source tree project.setFile( projectDescriptor ); } project.setManagedVersionMap( createManagedVersionMap( projectId, project.getDependencyManagement(), project.getParent() ) ); return project; } private String safeVersionlessKey( String groupId, String artifactId ) { String gid = groupId; if ( StringUtils.isEmpty( gid ) ) { gid = "unknown"; } String aid = artifactId; if ( StringUtils.isEmpty( aid ) ) { aid = "unknown"; } return ArtifactUtils.versionlessKey( gid, aid ); } private List buildArtifactRepositories( Model model ) throws ProjectBuildingException { try { return ProjectUtils.buildArtifactRepositories( model.getRepositories(), artifactRepositoryFactory, container ); } catch ( InvalidRepositoryException e ) { String projectId = safeVersionlessKey( model.getGroupId(), model.getArtifactId() ); throw new ProjectBuildingException( projectId, e.getMessage(), e ); } } /** * @todo can this take in a model instead of a project and still be successful? * @todo In fact, does project REALLY need a MavenProject as a parent? Couldn't it have just a wrapper around a * model that supported parents which were also the wrapper so that inheritence was assembled. We don't really need * the resolved source roots, etc for the parent - that occurs for the parent when it is constructed independently * and projects are not cached or reused */ private MavenProject processProjectLogic( String pomLocation, MavenProject project, ProjectBuilderConfiguration config, File projectDir, List remoteRepositories, boolean strict, boolean isSuperPom ) throws ProjectBuildingException, ModelInterpolationException, InvalidRepositoryException { Model model = project.getModel(); List activeProfiles = project.getActiveProfiles(); if ( activeProfiles == null ) { activeProfiles = new ArrayList(); } ProfileManager profileMgr = config == null ? null : config.getGlobalProfileManager(); List injectedProfiles = injectActiveProfiles( profileMgr, model ); activeProfiles.addAll( injectedProfiles ); // -------------------------------------------------------------------------------- Build dynamicBuild = model.getBuild(); model.setBuild( ModelUtils.cloneBuild( dynamicBuild ) ); model = modelInterpolator.interpolate( model, projectDir, config, getLogger().isDebugEnabled() ); mergeDeterministicBuildElements( model.getBuild(), dynamicBuild ); model.setBuild( dynamicBuild ); // MNG-3482: Make sure depMgmt is interpolated before merging. if ( !isSuperPom ) { mergeManagedDependencies( model, config.getLocalRepository(), remoteRepositories ); } // interpolation is before injection, because interpolation is off-limits in the injected variables modelDefaultsInjector.injectDefaults( model ); MavenProject parentProject = project.getParent(); Model originalModel = project.getOriginalModel(); // We will return a different project object using the new model (hence the need to return a project, not just modify the parameter) project = new MavenProject( model, getLogger() ); project.setOriginalModel( originalModel ); project.setActiveProfiles( activeProfiles ); // TODO: maybe not strictly correct, while we should enfore that packaging has a type handler of the same id, we don't Artifact projectArtifact = artifactFactory.create( project ); project.setArtifact( projectArtifact ); project.setProjectBuilderConfiguration( config ); project.setPluginArtifactRepositories( ProjectUtils.buildArtifactRepositories( model.getPluginRepositories(), artifactRepositoryFactory, container ) ); DistributionManagement dm = model.getDistributionManagement(); if ( dm != null ) { ArtifactRepository repo = ProjectUtils.buildDeploymentArtifactRepository( dm.getRepository(), artifactRepositoryFactory, container ); project.setReleaseArtifactRepository( repo ); if ( dm.getSnapshotRepository() != null ) { repo = ProjectUtils.buildDeploymentArtifactRepository( dm.getSnapshotRepository(), artifactRepositoryFactory, container ); project.setSnapshotArtifactRepository( repo ); } } if ( parentProject != null ) { String cacheKey = createCacheKey( parentProject.getGroupId(), parentProject.getArtifactId(), parentProject.getVersion() ); MavenProject processedParent = (MavenProject) processedProjectCache.get( cacheKey ); Artifact parentArtifact; // yeah, this null check might be a bit paranoid, but better safe than sorry... if ( processedParent != null ) { project.setParent( processedParent ); parentArtifact = processedParent.getArtifact(); } else { project.setParent( parentProject ); parentArtifact = artifactFactory.createParentArtifact( parentProject.getGroupId(), parentProject.getArtifactId(), parentProject.getVersion() ); } project.setParentArtifact( parentArtifact ); } // Must validate before artifact construction to make sure dependencies are good ModelValidationResult validationResult = validator.validate( model ); String projectId = safeVersionlessKey( model.getGroupId(), model.getArtifactId() ); if ( validationResult.getMessageCount() > 0 ) { throw new InvalidProjectModelException( projectId, pomLocation, "Failed to validate POM", validationResult ); } project.setRemoteArtifactRepositories( ProjectUtils.buildArtifactRepositories( model.getRepositories(), artifactRepositoryFactory, container ) ); // TODO: these aren't taking active project artifacts into consideration in the reactor project.setPluginArtifacts( createPluginArtifacts( projectId, project.getBuildPlugins() ) ); project.setReportArtifacts( createReportArtifacts( projectId, project.getReportPlugins() ) ); project.setExtensionArtifacts( createExtensionArtifacts( projectId, project.getBuildExtensions() ) ); return project; } private void mergeDeterministicBuildElements( Build interpolatedBuild, Build dynamicBuild ) { mergeDeterministicPluginElements( interpolatedBuild.getPlugins(), dynamicBuild.getPlugins() ); PluginManagement dPluginMgmt = dynamicBuild.getPluginManagement(); PluginManagement iPluginMgmt = interpolatedBuild.getPluginManagement(); if ( dPluginMgmt != null ) { mergeDeterministicPluginElements( iPluginMgmt.getPlugins(), dPluginMgmt.getPlugins() ); } if ( dynamicBuild.getExtensions() != null ) { dynamicBuild.setExtensions( interpolatedBuild.getExtensions() ); } } private void mergeDeterministicPluginElements( List iPlugins, List dPlugins ) { if ( dPlugins != null ) { for ( int i = 0; i < dPlugins.size(); i++ ) { Plugin dPlugin = (Plugin) dPlugins.get( i ); Plugin iPlugin = (Plugin) iPlugins.get( i ); dPlugin.setGroupId( iPlugin.getGroupId() ); dPlugin.setArtifactId( iPlugin.getArtifactId() ); dPlugin.setVersion( iPlugin.getVersion() ); dPlugin.setDependencies( iPlugin.getDependencies() ); List dExecutions = dPlugin.getExecutions(); if ( dExecutions != null ) { List iExecutions = iPlugin.getExecutions(); for ( int j = 0; j < dExecutions.size(); j++ ) { PluginExecution dExec = (PluginExecution) dExecutions.get( j ); PluginExecution iExec = (PluginExecution) iExecutions.get( j ); dExec.setId( iExec.getId() ); } } } } } /** * @noinspection CollectionDeclaredAsConcreteClass * @todo We need to find an effective way to unit test parts of this method! * @todo Refactor this into smaller methods with discrete purposes. */ private MavenProject assembleLineage( Model model, LinkedList lineage, ProjectBuilderConfiguration config, File projectDescriptor, List parentSearchRepositories, Set aggregatedRemoteWagonRepositories, boolean strict ) throws ProjectBuildingException, InvalidRepositoryException { Model originalModel = ModelUtils.cloneModel( model ); File projectDir = null; if ( projectDescriptor != null ) { projectDir = projectDescriptor.getAbsoluteFile().getParentFile(); } ProfileManager externalProfileManager = config.getGlobalProfileManager(); ProfileManager profileManager; if ( externalProfileManager != null ) { profileManager = new DefaultProfileManager( container, externalProfileManager.getRequestProperties() ); } else { //TODO mkleint - use the (Container, Properties constructor to make system properties embeddable profileManager = new DefaultProfileManager( container ); } if ( externalProfileManager != null ) { profileManager.explicitlyActivate( externalProfileManager.getExplicitlyActivatedIds() ); profileManager.explicitlyDeactivate( externalProfileManager.getExplicitlyDeactivatedIds() ); } List activeProfiles; try { profileManager.addProfiles( model.getProfiles() ); loadProjectExternalProfiles( profileManager, projectDir ); activeProfiles = injectActiveProfiles( profileManager, model ); } catch ( ProfileActivationException e ) { String projectId = safeVersionlessKey( model.getGroupId(), model.getArtifactId() ); throw new ProjectBuildingException( projectId, "Failed to activate local (project-level) build profiles: " + e.getMessage(), e ); } if ( !model.getRepositories().isEmpty() ) { List respositories = buildArtifactRepositories( model ); for ( Iterator it = respositories.iterator(); it.hasNext(); ) { ArtifactRepository repository = (ArtifactRepository) it.next(); if ( !aggregatedRemoteWagonRepositories.contains( repository ) ) { aggregatedRemoteWagonRepositories.add( repository ); } } } MavenProject project = new MavenProject( model, getLogger() ); project.setFile( projectDescriptor ); project.setActiveProfiles( activeProfiles ); project.setOriginalModel( originalModel ); lineage.addFirst( project ); Parent parentModel = model.getParent(); String projectId = safeVersionlessKey( model.getGroupId(), model.getArtifactId() ); if ( parentModel != null ) { if ( StringUtils.isEmpty( parentModel.getGroupId() ) ) { throw new ProjectBuildingException( projectId, "Missing groupId element from parent element" ); } else if ( StringUtils.isEmpty( parentModel.getArtifactId() ) ) { throw new ProjectBuildingException( projectId, "Missing artifactId element from parent element" ); } else if ( parentModel.getGroupId().equals( model.getGroupId() ) && parentModel.getArtifactId().equals( model.getArtifactId() ) ) { throw new ProjectBuildingException( projectId, "Parent element is a duplicate of " + "the current project " ); } else if ( StringUtils.isEmpty( parentModel.getVersion() ) ) { throw new ProjectBuildingException( projectId, "Missing version element from parent element" ); } // the only way this will have a value is if we find the parent on disk... File parentDescriptor = null; model = null; String parentKey = createCacheKey( parentModel.getGroupId(), parentModel.getArtifactId(), parentModel.getVersion() ); MavenProject parentProject = (MavenProject) rawProjectCache.get( parentKey ); if ( parentProject != null ) { model = ModelUtils.cloneModel( parentProject.getOriginalModel() ); parentDescriptor = parentProject.getFile(); } String parentRelativePath = parentModel.getRelativePath(); // if we can't find a cached model matching the parent spec, then let's try to look on disk using // if ( ( model == null ) && ( projectDir != null ) && StringUtils.isNotEmpty( parentRelativePath ) ) { parentDescriptor = new File( projectDir, parentRelativePath ); if ( getLogger().isDebugEnabled() ) { getLogger().debug( "Searching for parent-POM: " + parentModel.getId() + " of project: " + project.getId() + " in relative path: " + parentRelativePath ); } if ( parentDescriptor.isDirectory() ) { if ( getLogger().isDebugEnabled() ) { getLogger().debug( "Path specified in (" + parentRelativePath + ") is a directory. Searching for 'pom.xml' within this directory." ); } parentDescriptor = new File( parentDescriptor, "pom.xml" ); if ( !parentDescriptor.exists() ) { if ( getLogger().isDebugEnabled() ) { getLogger().debug( "Parent-POM: " + parentModel.getId() + " for project: " + project.getId() + " cannot be loaded from relative path: " + parentDescriptor + "; path does not exist." ); } } } if ( parentDescriptor != null ) { try { parentDescriptor = parentDescriptor.getCanonicalFile(); } catch ( IOException e ) { getLogger().debug( "Failed to canonicalize potential parent POM: \'" + parentDescriptor + "\'", e ); parentDescriptor = null; } } if ( ( parentDescriptor != null ) && parentDescriptor.exists() ) { Model candidateParent = readModel( projectId, parentDescriptor, strict ); String candidateParentGroupId = candidateParent.getGroupId(); if ( ( candidateParentGroupId == null ) && ( candidateParent.getParent() != null ) ) { candidateParentGroupId = candidateParent.getParent().getGroupId(); } String candidateParentVersion = candidateParent.getVersion(); if ( ( candidateParentVersion == null ) && ( candidateParent.getParent() != null ) ) { candidateParentVersion = candidateParent.getParent().getVersion(); } if ( parentModel.getGroupId().equals( candidateParentGroupId ) && parentModel.getArtifactId().equals( candidateParent.getArtifactId() ) && parentModel.getVersion().equals( candidateParentVersion ) ) { model = candidateParent; getLogger().debug( "Using parent-POM from the project hierarchy at: \'" + parentModel.getRelativePath() + "\' for project: " + project.getId() ); } else { getLogger().debug( "Invalid parent-POM referenced by relative path '" + parentModel.getRelativePath() + "' in parent specification in " + project.getId() + ":" + "\n Specified: " + parentModel.getId() + "\n Found: " + candidateParent.getId() ); } } else if ( getLogger().isDebugEnabled() ) { getLogger().debug( "Parent-POM: " + parentModel.getId() + " not found in relative path: " + parentRelativePath ); } } Artifact parentArtifact = null; // only resolve the parent model from the repository system if we didn't find it on disk... if ( model == null ) { // MNG-2302: parent's File was being populated incorrectly when parent is loaded from repo. // keep this in line with other POMs loaded from the repository...the file should be null. parentDescriptor = null; //!! (**) // ---------------------------------------------------------------------- // Do we have the necessary information to actually find the parent // POMs here?? I don't think so ... Say only one remote repository is // specified and that is ibiblio then this model that we just read doesn't // have any repository information ... I think we might have to inherit // as we go in order to do this. // ---------------------------------------------------------------------- // we must add the repository this POM was found in too, by chance it may be located where the parent is // we can't query the parent to ask where it is :) List remoteRepositories = new ArrayList( aggregatedRemoteWagonRepositories ); remoteRepositories.addAll( parentSearchRepositories ); if ( getLogger().isDebugEnabled() ) { getLogger().debug( "Retrieving parent-POM: " + parentModel.getId() + " for project: " + project.getId() + " from the repository." ); } parentArtifact = artifactFactory.createParentArtifact( parentModel.getGroupId(), parentModel.getArtifactId(), parentModel.getVersion() ); try { model = findModelFromRepository( parentArtifact, remoteRepositories, config.getLocalRepository(), false ); } catch ( ProjectBuildingException e ) { throw new ProjectBuildingException( project.getId(), "Cannot find parent: " + e.getProjectId() + " for project: " + project.getId(), e ); } } if ( ( model != null ) && !"pom".equals( model.getPackaging() ) ) { throw new ProjectBuildingException( projectId, "Parent: " + model.getId() + " of project: " + projectId + " has wrong packaging: " + model.getPackaging() + ". Must be 'pom'." ); } MavenProject parent = assembleLineage( model, lineage, config, parentDescriptor, parentSearchRepositories, aggregatedRemoteWagonRepositories, strict ); project.setParent( parent ); project.setParentArtifact( parentArtifact ); } rawProjectCache.put( createCacheKey( project.getGroupId(), project.getArtifactId(), project.getVersion() ), new MavenProject( project ) ); return project; } private void mergeManagedDependencies(Model model, ArtifactRepository localRepository, List parentSearchRepositories) throws ProjectBuildingException { DependencyManagement modelDepMgmt = model.getDependencyManagement(); if (modelDepMgmt != null) { Map depsMap = new TreeMap(); Iterator iter = modelDepMgmt.getDependencies().iterator(); boolean doInclude = false; while (iter.hasNext()) { Dependency dep = (Dependency) iter.next(); depsMap.put( dep.getManagementKey(), dep ); if ( dep.getType().equals( "pom" ) && Artifact.SCOPE_IMPORT.equals( dep.getScope() ) ) { doInclude = true; } } Map newDeps = new TreeMap(depsMap); iter = modelDepMgmt.getDependencies().iterator(); if (doInclude) { while (iter.hasNext()) { Dependency dep = (Dependency)iter.next(); if ( dep.getType().equals( "pom" ) && Artifact.SCOPE_IMPORT.equals( dep.getScope() ) ) { Artifact artifact = artifactFactory.createProjectArtifact( dep.getGroupId(), dep.getArtifactId(), dep.getVersion(), dep.getScope() ); MavenProject project = buildFromRepository(artifact, parentSearchRepositories, localRepository, false); DependencyManagement depMgmt = project.getDependencyManagement(); if (depMgmt != null) { if ( getLogger().isDebugEnabled() ) { getLogger().debug( "Importing managed dependencies for " + dep.toString() ); } for ( Iterator it = depMgmt.getDependencies().iterator(); it.hasNext(); ) { Dependency includedDep = (Dependency) it.next(); String key = includedDep.getManagementKey(); if (!newDeps.containsKey(key)) { newDeps.put( includedDep.getManagementKey(), includedDep ); } } newDeps.remove(dep.getManagementKey()); } } } List deps = new ArrayList(newDeps.values()); modelDepMgmt.setDependencies(deps); } } } private List injectActiveProfiles( ProfileManager profileManager, Model model ) throws ProjectBuildingException { List activeProfiles; if ( profileManager != null ) { try { activeProfiles = profileManager.getActiveProfiles(); } catch ( ProfileActivationException e ) { String projectId = safeVersionlessKey( model.getGroupId(), model.getArtifactId() ); throw new ProjectBuildingException( projectId, e.getMessage(), e ); } for ( Iterator it = activeProfiles.iterator(); it.hasNext(); ) { Profile profile = (Profile) it.next(); profileInjector.inject( profile, model ); } } else { activeProfiles = Collections.EMPTY_LIST; } return activeProfiles; } private void loadProjectExternalProfiles( ProfileManager profileManager, File projectDir ) throws ProfileActivationException { if ( projectDir != null ) { try { ProfilesRoot root = profilesBuilder.buildProfiles( projectDir ); if ( root != null ) { List active = root.getActiveProfiles(); if ( ( active != null ) && !active.isEmpty() ) { profileManager.explicitlyActivate( root.getActiveProfiles() ); } for ( Iterator it = root.getProfiles().iterator(); it.hasNext(); ) { org.apache.maven.profiles.Profile rawProfile = (org.apache.maven.profiles.Profile) it.next(); Profile converted = ProfilesConversionUtils.convertFromProfileXmlProfile( rawProfile ); profileManager.addProfile( converted ); } } } catch ( IOException e ) { throw new ProfileActivationException( "Cannot read profiles.xml resource from directory: " + projectDir, e ); } catch ( XmlPullParserException e ) { throw new ProfileActivationException( "Cannot parse profiles.xml resource from directory: " + projectDir, e ); } } } private Model readModel( String projectId, File file, boolean strict ) throws ProjectBuildingException { Reader reader = null; try { reader = ReaderFactory.newXmlReader( file ); return readModel( projectId, file.getAbsolutePath(), reader, strict ); } catch ( FileNotFoundException e ) { throw new ProjectBuildingException( projectId, "Could not find the model file '" + file.getAbsolutePath() + "'.", e ); } catch ( IOException e ) { throw new ProjectBuildingException( projectId, "Failed to build model from file '" + file.getAbsolutePath() + "'.\nError: \'" + e.getLocalizedMessage() + "\'", e ); } finally { IOUtil.close( reader ); } } private Model readModel( String projectId, String pomLocation, Reader reader, boolean strict ) throws IOException, InvalidProjectModelException { String modelSource = IOUtil.toString( reader ); if ( modelSource.indexOf( "" + MAVEN_MODEL_VERSION ) < 0 ) { throw new InvalidProjectModelException( projectId, pomLocation, "Not a v" + MAVEN_MODEL_VERSION + " POM." ); } StringReader sReader = new StringReader( modelSource ); try { return modelReader.read( sReader, strict ); } catch ( XmlPullParserException e ) { throw new InvalidProjectModelException( projectId, pomLocation, "Parse error reading POM. Reason: " + e.getMessage(), e ); } } private Model readModel( String projectId, URL url, boolean strict ) throws ProjectBuildingException { Reader reader = null; try { reader = ReaderFactory.newXmlReader( url.openStream() ); return readModel( projectId, url.toExternalForm(), reader, strict ); } catch ( IOException e ) { throw new ProjectBuildingException( projectId, "Failed build model from URL \'" + url.toExternalForm() + "\'\nError: \'" + e.getLocalizedMessage() + "\'", e ); } finally { IOUtil.close( reader ); } } private static String createCacheKey( String groupId, String artifactId, String version ) { return groupId + ":" + artifactId + ":" + version; } protected Set createPluginArtifacts( String projectId, List plugins ) throws ProjectBuildingException { Set pluginArtifacts = new LinkedHashSet(); for ( Iterator i = plugins.iterator(); i.hasNext(); ) { Plugin p = (Plugin) i.next(); String version; if ( StringUtils.isEmpty( p.getVersion() ) ) { version = "RELEASE"; } else { version = p.getVersion(); } Artifact artifact; try { artifact = artifactFactory.createPluginArtifact( p.getGroupId(), p.getArtifactId(), VersionRange.createFromVersionSpec( version ) ); } catch ( InvalidVersionSpecificationException e ) { throw new ProjectBuildingException( projectId, "Unable to parse version '" + version + "' for plugin '" + ArtifactUtils.versionlessKey( p.getGroupId(), p.getArtifactId() ) + "': " + e.getMessage(), e ); } if ( artifact != null ) { pluginArtifacts.add( artifact ); } } return pluginArtifacts; } // TODO: share with createPluginArtifacts? protected Set createReportArtifacts( String projectId, List reports ) throws ProjectBuildingException { Set pluginArtifacts = new LinkedHashSet(); if ( reports != null ) { for ( Iterator i = reports.iterator(); i.hasNext(); ) { ReportPlugin p = (ReportPlugin) i.next(); String version; if ( StringUtils.isEmpty( p.getVersion() ) ) { version = "RELEASE"; } else { version = p.getVersion(); } Artifact artifact; try { artifact = artifactFactory.createPluginArtifact( p.getGroupId(), p.getArtifactId(), VersionRange.createFromVersionSpec( version ) ); } catch ( InvalidVersionSpecificationException e ) { throw new ProjectBuildingException( projectId, "Unable to parse version '" + version + "' for report '" + ArtifactUtils.versionlessKey( p.getGroupId(), p.getArtifactId() ) + "': " + e.getMessage(), e ); } if ( artifact != null ) { pluginArtifacts.add( artifact ); } } } return pluginArtifacts; } // TODO: share with createPluginArtifacts? protected Set createExtensionArtifacts( String projectId, List extensions ) throws ProjectBuildingException { Set extensionArtifacts = new LinkedHashSet(); if ( extensions != null ) { for ( Iterator i = extensions.iterator(); i.hasNext(); ) { Extension ext = (Extension) i.next(); String version; if ( StringUtils.isEmpty( ext.getVersion() ) ) { version = "RELEASE"; } else { version = ext.getVersion(); } Artifact artifact; try { VersionRange versionRange = VersionRange.createFromVersionSpec( version ); artifact = artifactFactory.createExtensionArtifact( ext.getGroupId(), ext.getArtifactId(), versionRange ); } catch ( InvalidVersionSpecificationException e ) { throw new ProjectBuildingException( projectId, "Unable to parse version '" + version + "' for extension '" + ArtifactUtils.versionlessKey( ext.getGroupId(), ext.getArtifactId() ) + "': " + e.getMessage(), e ); } if ( artifact != null ) { extensionArtifacts.add( artifact ); } } } return extensionArtifacts; } // ---------------------------------------------------------------------- // // ---------------------------------------------------------------------- private Model getSuperModel() throws ProjectBuildingException { URL url = DefaultMavenProjectBuilder.class.getResource( "pom-" + MAVEN_MODEL_VERSION + ".xml" ); String projectId = safeVersionlessKey( STANDALONE_SUPERPOM_GROUPID, STANDALONE_SUPERPOM_ARTIFACTID ); return readModel( projectId, url, true ); } public void contextualize( Context context ) throws ContextException { container = (PlexusContainer) context.get( PlexusConstants.PLEXUS_KEY ); } /** * {@inheritDoc} */ public void calculateConcreteState( MavenProject project, ProjectBuilderConfiguration config ) throws ModelInterpolationException { calculateConcreteStateInternal( project, config, true, new HashSet() ); } /** * {@inheritDoc} */ public void calculateConcreteState( MavenProject project, ProjectBuilderConfiguration config, boolean processProjectReferences ) throws ModelInterpolationException { calculateConcreteStateInternal( project, config, processProjectReferences, ( processProjectReferences ? new HashSet() : null ) ); } /* * NOTE: This is a code hotspot, PLEASE be careful about the performance of logic inside or * called from this method. * * NOTE: If processProjectReferences == false, processedProjects MUST NOT BE USED. It will be null. */ private void calculateConcreteStateInternal( MavenProject project, ProjectBuilderConfiguration config, boolean processProjectReferences, Set processedProjects ) throws ModelInterpolationException { if ( processProjectReferences ) { processedProjects.add( project.getId() ); } restoreDynamicStateInternal( project, config, processProjectReferences, processProjectReferences ? new HashSet( processedProjects ) : null ); if ( !project.isConcrete() ) { if ( project.getParent() != null ) { calculateConcreteStateInternal( project.getParent(), config, processProjectReferences, processedProjects ); } Build build = project.getBuild(); if ( build != null ) { initResourceMergeIds( build.getResources() ); initResourceMergeIds( build.getTestResources() ); } // NOTE: Since interpolation makes a copy through serialization, we don't need this. // See note below. // // Model model = ModelUtils.cloneModel( project.getModel() ); File basedir = project.getBasedir(); // NOTE: If we ever get past serialization/deserialization for interpolation, we'll need to copy the model here! Model model = ModelUtils.cloneModel( project.getModel() ); model = modelInterpolator.interpolate( model, project.getBasedir(), config, getLogger().isDebugEnabled() ); List originalInterpolatedCompileSourceRoots = interpolateListOfStrings( project.getCompileSourceRoots(), model, project.getBasedir(), config, getLogger().isDebugEnabled() ); project.preserveCompileSourceRoots( originalInterpolatedCompileSourceRoots ); project.setCompileSourceRoots( originalInterpolatedCompileSourceRoots == null ? null : translateListOfPaths( originalInterpolatedCompileSourceRoots, basedir ) ); List originalInterpolatedTestCompileSourceRoots = interpolateListOfStrings( project.getTestCompileSourceRoots(), model, project.getBasedir(), config, getLogger().isDebugEnabled() ); project.preserveTestCompileSourceRoots( originalInterpolatedTestCompileSourceRoots ); project.setTestCompileSourceRoots( originalInterpolatedTestCompileSourceRoots == null ? null : translateListOfPaths( originalInterpolatedTestCompileSourceRoots, basedir ) ); List originalInterpolatedScriptSourceRoots = interpolateListOfStrings( project.getScriptSourceRoots(), model, project.getBasedir(), config, getLogger().isDebugEnabled() ); project.preserveScriptSourceRoots( originalInterpolatedScriptSourceRoots ); // TODO: MNG-3731 project.setScriptSourceRoots( originalInterpolatedScriptSourceRoots ); // project.setScriptSourceRoots( originalInterpolatedScriptSourceRoots == null ? null // : translateListOfPaths( originalInterpolatedScriptSourceRoots, basedir ) ); if ( basedir != null ) { pathTranslator.alignToBaseDirectory( model, basedir ); } project.preserveBuild( ModelUtils.cloneBuild( model.getBuild() ) ); project.preserveProperties(); project.preserveBasedir(); project.setBuild( model.getBuild() ); if ( project.getExecutionProject() != null ) { calculateConcreteStateInternal( project.getExecutionProject(), config, processProjectReferences, processedProjects ); } project.setConcrete( true ); } if ( processProjectReferences ) { calculateConcreteProjectReferences( project, config, processedProjects ); } } private void initResourceMergeIds( List resources ) { if ( resources != null ) { for ( Iterator it = resources.iterator(); it.hasNext(); ) { Resource resource = (Resource) it.next(); resource.initMergeId(); } } } private void calculateConcreteProjectReferences( MavenProject project, ProjectBuilderConfiguration config, Set processedProjects ) throws ModelInterpolationException { Map projectRefs = project.getProjectReferences(); if ( projectRefs != null ) { for ( Iterator it = projectRefs.values().iterator(); it.hasNext(); ) { MavenProject reference = (MavenProject) it.next(); if ( !processedProjects.contains( reference.getId() ) ) { calculateConcreteStateInternal( reference, config, true, processedProjects ); } } } } private List translateListOfPaths( List paths, File basedir ) { if ( paths == null ) { return null; } else if ( basedir == null ) { return paths; } List result = new ArrayList( paths.size() ); for ( Iterator it = paths.iterator(); it.hasNext(); ) { String path = (String) it.next(); String aligned = pathTranslator.alignToBaseDirectory( path, basedir ); result.add( aligned ); } return result; } /** * {@inheritDoc} */ public void restoreDynamicState( MavenProject project, ProjectBuilderConfiguration config ) throws ModelInterpolationException { restoreDynamicStateInternal( project, config, true, new HashSet() ); } /** * {@inheritDoc} */ public void restoreDynamicState( MavenProject project, ProjectBuilderConfiguration config, boolean processProjectReferences ) throws ModelInterpolationException { restoreDynamicStateInternal( project, config, processProjectReferences, ( processProjectReferences ? new HashSet() : null ) ); } /* * NOTE: This is a code hotspot, PLEASE be careful about the performance of logic inside or * called from this method. * * NOTE: If processProjectReferences == false, processedProjects MUST NOT BE USED. It will be null. */ private void restoreDynamicStateInternal( MavenProject project, ProjectBuilderConfiguration config, boolean processProjectReferences, Set processedProjects ) throws ModelInterpolationException { if ( processProjectReferences ) { processedProjects.add( project.getId() ); } if ( project.isConcrete() && projectWasChanged( project ) ) { if ( project.getParent() != null ) { restoreDynamicStateInternal( project.getParent(), config, processProjectReferences, processedProjects ); } restoreBuildRoots( project, config, getLogger().isDebugEnabled() ); restoreModelBuildSection( project, config, getLogger().isDebugEnabled() ); if ( project.getExecutionProject() != null ) { restoreDynamicStateInternal( project.getExecutionProject(), config, processProjectReferences, processedProjects ); } project.setConcrete( false ); } if ( processProjectReferences ) { restoreDynamicProjectReferences( project, config, processedProjects ); } } private boolean projectWasChanged( MavenProject project ) { if ( !objectEquals( project.getBasedir(), project.getPreservedBasedir() ) ) { return true; } if ( !objectEquals( project.getProperties(), project.getPreservedProperties() ) ) { return true; } Build oBuild = project.getOriginalInterpolatedBuild(); Build build = project.getBuild(); if ( !objectEquals( oBuild.getDirectory(), build.getDirectory() ) ) { return true; } if ( !objectEquals( oBuild.getOutputDirectory(), build.getOutputDirectory() ) ) { return true; } if ( !objectEquals( oBuild.getSourceDirectory(), build.getSourceDirectory() ) ) { return true; } if ( !objectEquals( oBuild.getTestSourceDirectory(), build.getTestSourceDirectory() ) ) { return true; } if ( !objectEquals( oBuild.getScriptSourceDirectory(), build.getScriptSourceDirectory() ) ) { return true; } return false; } private boolean objectEquals( Object obj1, Object obj2 ) { return obj1 == null ? obj2 == null : obj2 != null && ( obj1 == obj2 || obj1.equals( obj2 ) ); } private void propagateNewPlugins( MavenProject project ) { Build changedBuild = project.getBuild(); Build dynamicBuild = project.getDynamicBuild(); if ( changedBuild == null || dynamicBuild == null ) { return; } List changedPlugins = changedBuild.getPlugins(); List dynamicPlugins = dynamicBuild.getPlugins(); if ( changedPlugins != null && dynamicPlugins != null && changedPlugins.size() != dynamicPlugins.size() ) { changedPlugins.removeAll( dynamicPlugins ); if ( !changedPlugins.isEmpty() ) { for ( Iterator it = changedPlugins.iterator(); it.hasNext(); ) { Plugin plugin = (Plugin) it.next(); dynamicBuild.addPlugin( plugin ); } } } dynamicBuild.flushPluginMap(); } private void restoreDynamicProjectReferences( MavenProject project, ProjectBuilderConfiguration config, Set processedProjects ) throws ModelInterpolationException { Map projectRefs = project.getProjectReferences(); if ( projectRefs != null ) { for ( Iterator it = projectRefs.values().iterator(); it.hasNext(); ) { MavenProject projectRef = (MavenProject) it.next(); if ( !processedProjects.contains( projectRef.getId() ) ) { restoreDynamicStateInternal( projectRef, config, true, processedProjects ); } } } } private void restoreBuildRoots( MavenProject project, ProjectBuilderConfiguration config, boolean debugMessages ) throws ModelInterpolationException { project.setCompileSourceRoots( restoreListOfStrings( project.getDynamicCompileSourceRoots(), project.getOriginalInterpolatedCompileSourceRoots(), project.getCompileSourceRoots(), project, config, debugMessages ) ); project.setTestCompileSourceRoots( restoreListOfStrings( project.getDynamicTestCompileSourceRoots(), project.getOriginalInterpolatedTestCompileSourceRoots(), project.getTestCompileSourceRoots(), project, config, debugMessages ) ); project.setScriptSourceRoots( restoreListOfStrings( project.getDynamicScriptSourceRoots(), project.getOriginalInterpolatedScriptSourceRoots(), project.getScriptSourceRoots(), project, config, debugMessages ) ); project.clearRestorableRoots(); } private void restoreModelBuildSection( MavenProject project, ProjectBuilderConfiguration config, boolean debugMessages ) throws ModelInterpolationException { Build changedBuild = project.getBuild(); Build dynamicBuild = project.getDynamicBuild(); Build originalInterpolatedBuild = project.getOriginalInterpolatedBuild(); dynamicBuild.setResources( restoreResources( dynamicBuild.getResources(), originalInterpolatedBuild.getResources(), changedBuild.getResources(), project, config, debugMessages ) ); dynamicBuild.setTestResources( restoreResources( dynamicBuild.getTestResources(), originalInterpolatedBuild.getTestResources(), changedBuild.getTestResources(), project, config, debugMessages ) ); dynamicBuild.setFilters( restoreListOfStrings( dynamicBuild.getFilters(), originalInterpolatedBuild.getFilters(), changedBuild.getFilters(), project, config, debugMessages ) ); dynamicBuild.setFinalName( restoreString( dynamicBuild.getFinalName(), originalInterpolatedBuild.getFinalName(), changedBuild.getFinalName(), project, config, debugMessages ) ); dynamicBuild.setDefaultGoal( restoreString( dynamicBuild.getDefaultGoal(), originalInterpolatedBuild.getDefaultGoal(), changedBuild.getDefaultGoal(), project, config, debugMessages ) ); dynamicBuild.setSourceDirectory( restoreString( dynamicBuild.getSourceDirectory(), originalInterpolatedBuild.getSourceDirectory(), changedBuild.getSourceDirectory(), project, config, debugMessages ) ); dynamicBuild.setTestSourceDirectory( restoreString( dynamicBuild.getTestSourceDirectory(), originalInterpolatedBuild.getTestSourceDirectory(), changedBuild.getTestSourceDirectory(), project, config, debugMessages ) ); dynamicBuild.setScriptSourceDirectory( restoreString( dynamicBuild.getScriptSourceDirectory(), originalInterpolatedBuild.getScriptSourceDirectory(), changedBuild.getScriptSourceDirectory(), project, config, debugMessages ) ); dynamicBuild.setOutputDirectory( restoreString( dynamicBuild.getOutputDirectory(), originalInterpolatedBuild.getOutputDirectory(), changedBuild.getOutputDirectory(), project, config, debugMessages ) ); dynamicBuild.setTestOutputDirectory( restoreString( dynamicBuild.getTestOutputDirectory(), originalInterpolatedBuild.getTestOutputDirectory(), changedBuild.getTestOutputDirectory(), project, config, debugMessages ) ); dynamicBuild.setDirectory( restoreString( dynamicBuild.getDirectory(), originalInterpolatedBuild.getDirectory(), changedBuild.getDirectory(), project, config, debugMessages ) ); propagateNewPlugins( project ); project.setBuild( dynamicBuild ); project.clearRestorableBuild(); } private List interpolateListOfStrings( List originalStrings, Model model, File projectDir, ProjectBuilderConfiguration config, boolean debugMessages ) throws ModelInterpolationException { if ( originalStrings == null ) { return null; } List result = new ArrayList(); for ( Iterator it = originalStrings.iterator(); it.hasNext(); ) { String original = (String) it.next(); String interpolated = modelInterpolator.interpolate( original, model, projectDir, config, debugMessages ); result.add( interpolated ); } return result; } private String restoreString( String originalString, String originalInterpolatedString, String changedString, MavenProject project, ProjectBuilderConfiguration config, boolean debugMessages ) throws ModelInterpolationException { if ( originalString == null ) { return changedString; } else if ( changedString == null ) { return originalString; } Model model = project.getModel(); String relativeChangedString; if ( project.getBasedir() != null ) { relativeChangedString = pathTranslator.unalignFromBaseDirectory( changedString, project.getBasedir() ); } else { relativeChangedString = changedString; } String interpolatedOriginal = modelInterpolator.interpolate( originalString, model, project.getBasedir(), config, debugMessages ); interpolatedOriginal = pathTranslator.unalignFromBaseDirectory( interpolatedOriginal, project.getBasedir() ); String interpolatedOriginal2 = modelInterpolator.interpolate( originalInterpolatedString, model, project.getBasedir(), config, debugMessages ); interpolatedOriginal2 = pathTranslator.alignToBaseDirectory( interpolatedOriginal2, project.getBasedir() ); String interpolatedChanged = modelInterpolator.interpolate( changedString, model, project.getBasedir(), config, debugMessages ); interpolatedChanged = pathTranslator.alignToBaseDirectory( interpolatedChanged, project.getBasedir() ); String relativeInterpolatedChanged = modelInterpolator.interpolate( relativeChangedString, model, project.getBasedir(), config, debugMessages ); if ( interpolatedOriginal.equals( interpolatedChanged ) || interpolatedOriginal2.equals( interpolatedChanged ) ) { return originalString; } else if ( interpolatedOriginal.equals( relativeInterpolatedChanged ) || interpolatedOriginal2.equals( relativeInterpolatedChanged ) ) { return originalString; } return relativeChangedString; } private List restoreListOfStrings( List originalStrings, List originalInterpolatedStrings, List changedStrings, MavenProject project, ProjectBuilderConfiguration config, boolean debugMessages ) throws ModelInterpolationException { if ( originalStrings == null ) { return changedStrings; } else if ( changedStrings == null ) { return originalStrings; } List result = new ArrayList(); Map orig = new HashMap(); for ( int idx = 0; idx < originalStrings.size(); idx++ ) { String[] permutations = new String[2]; permutations[0] = pathTranslator.alignToBaseDirectory( (String) originalInterpolatedStrings.get( idx ), project.getBasedir() ); permutations[1] = (String) originalStrings.get( idx ); orig.put( permutations[0], permutations ); } for ( Iterator it = changedStrings.iterator(); it.hasNext(); ) { String changedString = (String) it.next(); String relativeChangedString; if ( project.getBasedir() != null ) { relativeChangedString = pathTranslator.unalignFromBaseDirectory( changedString, project.getBasedir() ); } else { relativeChangedString = changedString; } String interpolated = modelInterpolator.interpolate( changedString, project.getModel(), project.getBasedir(), config, debugMessages ); interpolated = pathTranslator.alignToBaseDirectory( interpolated, project.getBasedir() ); String relativeInterpolated = modelInterpolator.interpolate( relativeChangedString, project.getModel(), project.getBasedir(), config, debugMessages ); String[] original = (String[]) orig.get( interpolated ); if ( original == null ) { original = (String[]) orig.get( relativeInterpolated ); } if ( original == null ) { result.add( relativeChangedString ); } else { result.add( original[1] ); } } return result; } private List restoreResources( List originalResources, List originalInterpolatedResources, List changedResources, MavenProject project, ProjectBuilderConfiguration config, boolean debugMessages ) throws ModelInterpolationException { if ( originalResources == null || changedResources == null ) { return originalResources; } List result = new ArrayList(); Map originalResourcesByMergeId = new HashMap(); for ( int idx = 0; idx < originalResources.size(); idx++ ) { Resource[] permutations = new Resource[2]; permutations[0] = (Resource) originalInterpolatedResources.get( idx ); permutations[1] = (Resource) originalResources.get( idx ); originalResourcesByMergeId.put( permutations[0].getMergeId(), permutations ); } for ( Iterator it = changedResources.iterator(); it.hasNext(); ) { Resource resource = (Resource) it.next(); String mergeId = resource.getMergeId(); if ( mergeId == null || !originalResourcesByMergeId.containsKey( mergeId ) ) { result.add( resource ); } else { Resource originalInterpolatedResource = ( (Resource[]) originalResourcesByMergeId.get( mergeId ) )[0]; Resource originalResource = ( (Resource[]) originalResourcesByMergeId.get( mergeId ) )[1]; String dir = modelInterpolator.interpolate( resource.getDirectory(), project.getModel(), project.getBasedir(), config, getLogger().isDebugEnabled() ); String oDir = originalInterpolatedResource.getDirectory(); if ( !dir.equals( oDir ) ) { originalResource.setDirectory( pathTranslator.unalignFromBaseDirectory( dir, project.getBasedir() ) ); } if ( resource.getTargetPath() != null ) { String target = modelInterpolator.interpolate( resource.getTargetPath(), project.getModel(), project.getBasedir(), config, getLogger().isDebugEnabled() ); String oTarget = originalInterpolatedResource.getTargetPath(); if ( !target.equals( oTarget ) ) { originalResource.setTargetPath( pathTranslator.unalignFromBaseDirectory( target, project.getBasedir() ) ); } } originalResource.setFiltering( resource.isFiltering() ); originalResource.setExcludes( collectRestoredListOfPatterns( resource.getExcludes(), originalResource.getExcludes(), originalInterpolatedResource.getExcludes() ) ); originalResource.setIncludes( collectRestoredListOfPatterns( resource.getIncludes(), originalResource.getIncludes(), originalInterpolatedResource.getIncludes() ) ); result.add( originalResource ); } } return result; } private List collectRestoredListOfPatterns( List patterns, List originalPatterns, List originalInterpolatedPatterns ) { LinkedHashSet collectedPatterns = new LinkedHashSet(); collectedPatterns.addAll( originalPatterns ); for ( Iterator it = patterns.iterator(); it.hasNext(); ) { String pattern = (String) it.next(); if ( !originalInterpolatedPatterns.contains( pattern ) ) { collectedPatterns.add( pattern ); } } return collectedPatterns.isEmpty() ? Collections.EMPTY_LIST : new ArrayList( collectedPatterns ); } } ././@LongLink0000000000000000000000000000014700000000000011567 Lustar rootrootmaven2-core-2.2.1/maven-project/src/main/java/org/apache/maven/project/MavenProjectBuildingResult.javamaven2-core-2.2.1/maven-project/src/main/java/org/apache/maven/project/MavenProjectBuildingResult.ja0000644000175000017500000000420010551365651033353 0ustar twernertwernerpackage org.apache.maven.project; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import org.apache.maven.project.validation.ModelValidationResult; /** * @author Trygve Laugstøl * @version $Id: MavenProjectBuildingResult.java 495147 2007-01-11 07:47:53Z jvanzyl $ */ public class MavenProjectBuildingResult { /** */ private MavenProject project; /** */ private ModelValidationResult modelValidationResult; /** */ private boolean successful; /** * @param project */ public MavenProjectBuildingResult( MavenProject project ) { this.project = project; successful = true; } public MavenProjectBuildingResult( ModelValidationResult modelValidationResult ) { this.modelValidationResult = modelValidationResult; successful = modelValidationResult.getMessageCount() == 0; } /** * @return Returns the modelValidationResult. */ public ModelValidationResult getModelValidationResult() { return modelValidationResult; } /** * @return Returns the project. */ public MavenProject getProject() { return project; } /** * Returns true if the project is valid. * * @return Returns true if the project is valid. */ public boolean isSuccessful() { return successful; } } maven2-core-2.2.1/maven-project/pom.xml0000644000175000017500000000532511236625310017663 0ustar twernertwerner 4.0.0 org.apache.maven maven 2.2.1 maven-project Maven Project Builder This library is used to not only read Maven project object model files, but to assemble inheritence and to retrieve remote models as required. org.apache.maven maven-settings org.apache.maven maven-artifact-test test org.apache.maven maven-profile org.apache.maven maven-model org.apache.maven maven-artifact-manager org.apache.maven maven-plugin-registry org.codehaus.plexus plexus-interpolation org.codehaus.plexus plexus-utils org.apache.maven maven-artifact org.codehaus.plexus plexus-container-default maven2-core-2.2.1/maven-plugin-parameter-documenter/0000755000175000017500000000000011250552236022314 5ustar twernertwernermaven2-core-2.2.1/maven-plugin-parameter-documenter/src/0000755000175000017500000000000011250552236023103 5ustar twernertwernermaven2-core-2.2.1/maven-plugin-parameter-documenter/src/site/0000755000175000017500000000000011250552236024047 5ustar twernertwernermaven2-core-2.2.1/maven-plugin-parameter-documenter/src/site/site.xml0000644000175000017500000000013211002611514025517 0ustar twernertwerner

    maven2-core-2.2.1/maven-plugin-parameter-documenter/src/test/0000755000175000017500000000000011250552236024062 5ustar twernertwernermaven2-core-2.2.1/maven-plugin-parameter-documenter/src/test/resources/0000755000175000017500000000000011250552236026074 5ustar twernertwernermaven2-core-2.2.1/maven-plugin-parameter-documenter/src/test/resources/test.paramdoc.xml0000644000175000017500000000353310772004567031375 0ustar twernertwerner localRepository /path/to/local/repository ]]> The ArtifactRepository instance referencing the local artifact repository. -Dmaven.repo.local=/path/to/local/repo Override the local repository location on a per-build basis. reactorProjects This is the current list of projects being built by Maven. maven2-core-2.2.1/maven-plugin-parameter-documenter/src/test/java/0000755000175000017500000000000011250552236025003 5ustar twernertwernermaven2-core-2.2.1/maven-plugin-parameter-documenter/src/test/java/org/0000755000175000017500000000000011250552236025572 5ustar twernertwernermaven2-core-2.2.1/maven-plugin-parameter-documenter/src/test/java/org/apache/0000755000175000017500000000000011250552236027013 5ustar twernertwernermaven2-core-2.2.1/maven-plugin-parameter-documenter/src/test/java/org/apache/maven/0000755000175000017500000000000011250552236030121 5ustar twernertwernermaven2-core-2.2.1/maven-plugin-parameter-documenter/src/test/java/org/apache/maven/usability/0000755000175000017500000000000011250552236032126 5ustar twernertwerner././@LongLink0000000000000000000000000000014500000000000011565 Lustar rootrootmaven2-core-2.2.1/maven-plugin-parameter-documenter/src/test/java/org/apache/maven/usability/plugin/maven2-core-2.2.1/maven-plugin-parameter-documenter/src/test/java/org/apache/maven/usability/plugin/0000755000175000017500000000000011250552236033424 5ustar twernertwerner././@LongLink0000000000000000000000000000016700000000000011571 Lustar rootrootmaven2-core-2.2.1/maven-plugin-parameter-documenter/src/test/java/org/apache/maven/usability/plugin/Xpp3ParseTest.javamaven2-core-2.2.1/maven-plugin-parameter-documenter/src/test/java/org/apache/maven/usability/plugin/0000644000175000017500000000403410772004567033436 0ustar twernertwernerpackage org.apache.maven.usability.plugin; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import junit.framework.TestCase; import org.apache.maven.usability.plugin.io.xpp3.ParamdocXpp3Reader; import org.codehaus.plexus.util.xml.pull.XmlPullParserException; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.util.Map; import java.util.Properties; public class Xpp3ParseTest extends TestCase { public void testParse() throws IOException, XmlPullParserException { InputStream testDocStream = getClass().getClassLoader().getResourceAsStream( "test.paramdoc.xml" ); ParamdocXpp3Reader reader = new ParamdocXpp3Reader(); ExpressionDocumentation documentation = reader.read(new InputStreamReader( testDocStream ) ); Map exprs = documentation.getExpressionsBySyntax(); Expression expr = (Expression) exprs.get( "localRepository" ); assertNotNull( expr ); Properties p = expr.getCliOptions(); assertNotNull( p ); assertEquals( 1, p.size() ); assertEquals( "Override the local repository location on a per-build basis.", p.getProperty( "-Dmaven.repo.local=/path/to/local/repo" ) ); } } maven2-core-2.2.1/maven-plugin-parameter-documenter/src/main/0000755000175000017500000000000011250552236024027 5ustar twernertwernermaven2-core-2.2.1/maven-plugin-parameter-documenter/src/main/mdo/0000755000175000017500000000000011250552236024606 5ustar twernertwernermaven2-core-2.2.1/maven-plugin-parameter-documenter/src/main/mdo/paramdoc.mdo0000644000175000017500000001262311146611627027105 0ustar twernertwerner paramdoc Paramdoc package org.apache.maven.usability.plugin 1.0.0 ExpressionDocumentation The root of a parameter plugin expression document. 1.0.0 expressions The list of plugin parameter expressions described by this document. Expression * 1.0.0 1.0.0 Expression A plugin parameter expression supported by Maven 1.0.0 syntax The syntax of the expression String true 1.0.0 description The description of what this expression references, and what it's generally used for. String true 1.0.0 configuration The place and syntax used to change the value of this expression. String 1.0.0 cliOptions The command-line switches used to change the value of this expression. Properties String * 1.0.0 apiMethods The programmatic methods used to change the value of this expression. Properties String * 1.0.0 deprecation A preferred alternative to this expression, in the case where it's deprecated. String 1.0.0 ban A preferred alternative to this expression, in the case where it's banned from use. String 1.0.0 editable Whether the value of this expression can be changed. boolean true maven2-core-2.2.1/maven-plugin-parameter-documenter/pom.xml0000644000175000017500000000364511236625310023637 0ustar twernertwerner 4.0.0 org.apache.maven maven 2.2.1 maven-plugin-parameter-documenter Maven Plugin Parameter Documenter API org.codehaus.plexus plexus-utils org.codehaus.plexus plexus-container-default org.codehaus.modello modello-maven-plugin 1.0.0 src/main/mdo/paramdoc.mdo maven2-core-2.2.1/pom.xml0000644000175000017500000005361111236625310015112 0ustar twernertwerner 4.0.0 org.apache.maven maven-parent 11 ../pom/maven/pom.xml maven 2.2.1 pom Maven Maven is a project development management and comprehension tool. Based on the concept of a project object model: builds, dependency management, documentation creation, site publication, and distribution publication are all controlled from the declarative file. Maven can be extended by plugins to utilise a number of other development tools for reporting or the build process. http://maven.apache.org 2001 jira http://jira.codehaus.org/browse/MNG Maven User List users-subscribe@maven.apache.org users-unsubscribe@maven.apache.org users@maven.apache.org http://mail-archives.apache.org/mod_mbox/maven-users http://www.mail-archive.com/users@maven.apache.org/ http://www.nabble.com/Maven---Users-f178.html http://maven.users.markmail.org/ Maven Developer List dev-subscribe@maven.apache.org dev-unsubscribe@maven.apache.org dev@maven.apache.org http://mail-archives.apache.org/mod_mbox/maven-dev http://www.mail-archive.com/dev@maven.apache.org/ http://www.nabble.com/Maven-Developers-f179.html http://maven.dev.markmail.org/ Maven Issues List issues-subscribe@maven.apache.org issues-unsubscribe@maven.apache.org http://mail-archives.apache.org/mod_mbox/maven-issues/ http://www.mail-archive.com/issues@maven.apache.org http://www.nabble.com/Maven---Issues-f15573.html http://maven.issues.markmail.org/ Maven Commits List commits-subscribe@maven.apache.org commits-unsubscribe@maven.apache.org http://mail-archives.apache.org/mod_mbox/maven-commits http://www.mail-archive.com/commits@maven.apache.org http://www.nabble.com/Maven---Commits-f15575.html http://maven.commits.markmail.org/ Maven Announcements List announce@maven.apache.org announce-subscribe@maven.apache.org announce-unsubscribe@maven.apache.org http://mail-archives.apache.org/mod_mbox/maven-announce/ http://www.mail-archive.com/announce@maven.apache.org http://www.nabble.com/Maven-Announcements-f15617.html http://maven.announce.markmail.org/ Maven Notifications List notifications-subscribe@maven.apache.org notifications-unsubscribe@maven.apache.org http://mail-archives.apache.org/mod_mbox/maven-notifications/ http://www.mail-archive.com/notifications@maven.apache.org http://www.nabble.com/Maven---Notifications-f15574.html http://maven.notifications.markmail.org/ scm:svn:http://svn.apache.org/repos/asf/maven/maven-2/tags/maven-2.2.1 scm:svn:https://svn.apache.org/repos/asf/maven/maven-2/tags/maven-2.2.1 http://svn.apache.org/viewvc/maven/maven-2/tags/maven-2.2.1 org.apache.maven.plugins maven-jar-plugin 2.1 org.apache.maven.plugins maven-compiler-plugin 2.0.2 1.5 1.5 maven-assembly-plugin 2.2-beta-4 maven-shade-plugin 1.0 maven-surefire-plugin 2.3 maven-deploy-plugin 2.3 maven-install-plugin 2.1 maven-site-plugin 2.0 maven-resources-plugin 2.2 maven-remote-resources-plugin 1.0-beta-2 maven-clean-plugin 2.1.1 maven-release-plugin 2.0-beta-7 https://svn.apache.org/repos/asf/maven/maven-2/tags true install org.codehaus.modello modello-maven-plugin 1.0.1 true site-docs pre-site xdoc xsd standard java xpp3-reader xpp3-writer org.codehaus.mojo clirr-maven-plugin 2.2.1 2.2.0 org/apache/maven/artifact/manager/WagonManager* org/apache/maven/extension/ExtensionManager* org/apache/maven/plugin/PluginManager* maven-enforcer-plugin 1.0-alpha-4 enforce-jdk enforce [1.5.0,] true maven-artifact maven-artifact-manager maven-artifact-test maven-compat maven-core maven-error-diagnostics maven-model maven-monitor maven-plugin-api maven-plugin-descriptor maven-plugin-parameter-documenter maven-plugin-registry maven-profile maven-project maven-reporting maven-repository-metadata maven-script maven-settings maven-toolchain apache-maven 2.2.1 1.0-beta-6 1.1 junit junit 3.8.1 test org.apache.maven maven-plugin-descriptor ${mavenVersion} org.apache.maven maven-error-diagnostics ${mavenVersion} org.apache.maven maven-model ${mavenVersion} org.apache.maven maven-project ${mavenVersion} org.apache.maven.reporting maven-reporting-api ${mavenVersion} org.apache.maven maven-repository-metadata ${mavenVersion} org.apache.maven maven-artifact ${mavenVersion} org.apache.maven maven-artifact-manager ${mavenVersion} org.apache.maven maven-artifact-test ${mavenVersion} org.apache.maven maven-settings ${mavenVersion} org.apache.maven maven-compat ${mavenVersion} org.apache.maven maven-core ${mavenVersion} org.apache.maven maven-plugin-parameter-documenter ${mavenVersion} org.apache.maven maven-profile ${mavenVersion} org.apache.maven maven-plugin-registry ${mavenVersion} org.apache.maven maven-plugin-api ${mavenVersion} org.apache.maven maven-monitor ${mavenVersion} org.apache.maven maven-toolchain ${mavenVersion} commons-cli commons-cli 1.2 org.apache.maven.doxia doxia-sink-api ${doxiaVersion} org.apache.maven.doxia doxia-logging-api ${doxiaVersion} org.codehaus.plexus plexus-interpolation 1.11 org.codehaus.plexus plexus-container-default 1.0-alpha-9-stable-1 org.codehaus.plexus plexus-utils 1.5.15 org.sonatype.plexus plexus-sec-dispatcher 1.3 org.apache.maven.wagon wagon-provider-api ${wagonVersion} org.apache.maven.wagon wagon-ssh ${wagonVersion} org.apache.maven.wagon wagon-ssh-external ${wagonVersion} org.apache.maven.wagon wagon-file ${wagonVersion} org.apache.maven.wagon wagon-webdav-jackrabbit ${wagonVersion} org.apache.maven.wagon wagon-http ${wagonVersion} org.apache.maven.wagon wagon-http-lightweight ${wagonVersion} org.slf4j slf4j-jdk14 1.5.6 org.slf4j jcl-over-slf4j 1.5.6 backport-util-concurrent backport-util-concurrent 3.1 easymock easymock 1.2_Java1.3 test classworlds classworlds 1.1 apache.website scp://people.apache.org/www/maven.apache.org/ref/${project.version}/ quality-checks org.codehaus.mojo clirr-maven-plugin clirr-check verify check release org.codehaus.mojo clirr-maven-plugin check run-its maven-core-it-runner reporting org.apache.maven.plugins maven-project-info-reports-plugin 2.1.1 org.codehaus.mojo clirr-maven-plugin reporting-aggregate org.apache.maven.plugins maven-project-info-reports-plugin 2.1.1 org.apache.maven.plugins maven-jxr-plugin 2.1 true ${project.build.sourceEncoding} org.apache.maven.plugins maven-javadoc-plugin 2.5 http://java.sun.com/j2se/1.4.2/docs/api http://java.sun.com/j2ee/1.4/docs/api http://java.sun.com/j2se/1.5.0/docs/api http://commons.apache.org/collections/apidocs-COLLECTIONS_3_0/ http://commons.apache.org/dbcp/apidocs/ http://commons.apache.org/fileupload/apidocs/ http://commons.apache.org/httpclient/apidocs/ http://commons.apache.org/logging/apidocs/ http://commons.apache.org/pool/apidocs/ http://junit.sourceforge.net/javadoc/ http://logging.apache.org/log4j/1.2/apidocs/ http://jakarta.apache.org/regexp/apidocs/ http://velocity.apache.org/engine/releases/velocity-1.5/apidocs/ true