You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by jd...@apache.org on 2006/08/29 22:17:15 UTC
svn commit: r438189 - in /maven/components/trunk/maven-project/src:
main/java/org/apache/maven/profiles/
main/java/org/apache/maven/project/artifact/
test/java/org/apache/maven/project/artifact/
Author: jdcasey
Date: Tue Aug 29 13:17:14 2006
New Revision: 438189
URL: http://svn.apache.org/viewvc?rev=438189&view=rev
Log:
Fixing exclusions that bleed over into other dependencies, and modifying DefaultProfileManager to (a) deprecate constructor that takes Settings but no properties, and (b) add a constructor that takes Settings and properties.
Modified:
maven/components/trunk/maven-project/src/main/java/org/apache/maven/profiles/DefaultProfileManager.java
maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/artifact/MavenMetadataSource.java
maven/components/trunk/maven-project/src/test/java/org/apache/maven/project/artifact/MavenMetadataSourceTest.java
Modified: maven/components/trunk/maven-project/src/main/java/org/apache/maven/profiles/DefaultProfileManager.java
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-project/src/main/java/org/apache/maven/profiles/DefaultProfileManager.java?rev=438189&r1=438188&r2=438189&view=diff
==============================================================================
--- maven/components/trunk/maven-project/src/main/java/org/apache/maven/profiles/DefaultProfileManager.java (original)
+++ maven/components/trunk/maven-project/src/main/java/org/apache/maven/profiles/DefaultProfileManager.java Tue Aug 29 13:17:14 2006
@@ -66,18 +66,36 @@
*/
public DefaultProfileManager( PlexusContainer container, Properties props )
{
- this( container, (Settings)null );
- if (props != null) {
- systemProperties = 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 )
+ {
+ systemProperties = props;
+ }
}
public Properties getSystemProperties() {
Modified: maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/artifact/MavenMetadataSource.java
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/artifact/MavenMetadataSource.java?rev=438189&r1=438188&r2=438189&view=diff
==============================================================================
--- maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/artifact/MavenMetadataSource.java (original)
+++ maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/artifact/MavenMetadataSource.java Tue Aug 29 13:17:14 2006
@@ -48,7 +48,6 @@
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;
@@ -337,7 +336,9 @@
artifact.setFile( new File( d.getSystemPath() ) );
}
- if ( artifact != null && ( dependencyFilter == null || dependencyFilter.include( artifact ) ) )
+ ArtifactFilter artifactFilter = dependencyFilter;
+
+ if ( artifact != null && ( artifactFilter == null || artifactFilter.include( artifact ) ) )
{
if ( d.getExclusions() != null && !d.getExclusions().isEmpty() )
{
@@ -350,20 +351,20 @@
ArtifactFilter newFilter = new ExcludesArtifactFilter( exclusions );
- if ( dependencyFilter != null )
+ if ( artifactFilter != null )
{
AndArtifactFilter filter = new AndArtifactFilter();
- filter.add( dependencyFilter );
+ filter.add( artifactFilter );
filter.add( newFilter );
- dependencyFilter = filter;
+ artifactFilter = filter;
}
else
{
- dependencyFilter = newFilter;
+ artifactFilter = newFilter;
}
}
- artifact.setDependencyFilter( dependencyFilter );
+ artifact.setDependencyFilter( artifactFilter );
if ( project != null )
{
Modified: maven/components/trunk/maven-project/src/test/java/org/apache/maven/project/artifact/MavenMetadataSourceTest.java
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-project/src/test/java/org/apache/maven/project/artifact/MavenMetadataSourceTest.java?rev=438189&r1=438188&r2=438189&view=diff
==============================================================================
--- maven/components/trunk/maven-project/src/test/java/org/apache/maven/project/artifact/MavenMetadataSourceTest.java (original)
+++ maven/components/trunk/maven-project/src/test/java/org/apache/maven/project/artifact/MavenMetadataSourceTest.java Tue Aug 29 13:17:14 2006
@@ -3,18 +3,71 @@
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
Re: svn commit: r438189 - in /maven/components/trunk/maven-project/src: main/java/org/apache/maven/profiles/ main/java/org/apache/maven/project/artifact/ test/java/org/apache/maven/project/artifact/
Posted by John Casey <ca...@gmail.com>.
There, done. Affected issues: MNG-1797, MNG-2420
-john
On 9/5/06, John Casey <ca...@gmail.com> wrote:
>
> Sorry, I didn't have the issue number on hand. I'll look it up and add it
> to the log message now.
>
> -j
>
>
> On 8/31/06, Grzegorz Slowikowski < gslowikowski@gmail.com> wrote:
> >
> > Hello
> >
> > Why didn't you use jira issue number in commit message and didn't close
> > jira
> > issue
> > (I don't remember its number)? I'm talking about exclusions bug.
> >
> > Grzegorz Slowikowski
> >
> >
> > 2006/8/29, jdcasey@apache.org < jdcasey@apache.org>:
> > >
> > > Author: jdcasey
> > > Date: Tue Aug 29 13:17:14 2006
> > > New Revision: 438189
> > >
> > > URL: http://svn.apache.org/viewvc?rev=438189&view=rev
> > > Log:
> > > Fixing exclusions that bleed over into other dependencies, and
> > modifying
> > > DefaultProfileManager to (a) deprecate constructor that takes Settings
> > but
> > > no properties, and (b) add a constructor that takes Settings and
> > properties.
> > >
> > > Modified:
> > >
> > >
> > maven/components/trunk/maven-project/src/main/java/org/apache/maven/profiles/DefaultProfileManager.java
> > >
> > >
> > maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/artifact/MavenMetadataSource.java
> >
> > >
> > >
> > maven/components/trunk/maven-project/src/test/java/org/apache/maven/project/artifact/MavenMetadataSourceTest.java
> > >
> > > Modified:
> > >
> > maven/components/trunk/maven-project/src/main/java/org/apache/maven/profiles/DefaultProfileManager.java
> >
> > > URL:
> > > http://svn.apache.org/viewvc/maven/components/trunk/maven-project/src/main/java/org/apache/maven/profiles/DefaultProfileManager.java?rev=438189&r1=438188&r2=438189&view=diff
> >
> > >
> > >
> > ==============================================================================
> > > ---
> > >
> > maven/components/trunk/maven-project/src/main/java/org/apache/maven/profiles/DefaultProfileManager.java
> >
> > > (original)
> > > +++
> > >
> > maven/components/trunk/maven-project/src/main/java/org/apache/maven/profiles/DefaultProfileManager.java
> > > Tue Aug 29 13:17:14 2006
> > > @@ -66,18 +66,36 @@
> > > */
> > > public DefaultProfileManager( PlexusContainer container,
> > Properties
> > > props )
> > > {
> > > - this( container, (Settings)null );
> > > - if (props != null) {
> > > - systemProperties = 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 )
> > > + {
> > > + systemProperties = props;
> > > + }
> > > }
> > >
> > > public Properties getSystemProperties() {
> > >
> > > Modified:
> > >
> > maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/artifact/MavenMetadataSource.java
> > > URL:
> > >
> > http://svn.apache.org/viewvc/maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/artifact/MavenMetadataSource.java?rev=438189&r1=438188&r2=438189&view=diff
> > >
> > >
> > ==============================================================================
> >
> > > ---
> > >
> > maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/artifact/MavenMetadataSource.java
> > > (original)
> > > +++
> > >
> > maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/artifact/MavenMetadataSource.java
> >
> > > Tue Aug 29 13:17:14 2006
> > > @@ -48,7 +48,6 @@
> > > 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;
> > > @@ -337,7 +336,9 @@
> > > artifact.setFile( new File( d.getSystemPath() ) );
> > > }
> > >
> > > - if ( artifact != null && ( dependencyFilter == null ||
> > > dependencyFilter.include( artifact ) ) )
> > > + ArtifactFilter artifactFilter = dependencyFilter;
> > > +
> > > + if ( artifact != null && ( artifactFilter == null ||
> > > artifactFilter.include( artifact ) ) )
> > > {
> > > if ( d.getExclusions() != null &&
> > > !d.getExclusions().isEmpty() )
> > > {
> > > @@ -350,20 +351,20 @@
> > >
> > > ArtifactFilter newFilter = new
> > > ExcludesArtifactFilter( exclusions );
> > >
> > > - if ( dependencyFilter != null )
> > > + if ( artifactFilter != null )
> > > {
> > > AndArtifactFilter filter = new
> > > AndArtifactFilter();
> > > - filter.add( dependencyFilter );
> > > + filter.add( artifactFilter );
> > > filter.add( newFilter );
> > > - dependencyFilter = filter;
> > > + artifactFilter = filter;
> > > }
> > > else
> > > {
> > > - dependencyFilter = newFilter;
> > > + artifactFilter = newFilter;
> > > }
> > > }
> > >
> > > - artifact.setDependencyFilter( dependencyFilter );
> > > + artifact.setDependencyFilter( artifactFilter );
> > >
> > > if ( project != null )
> > > {
> > >
> > > Modified:
> > >
> > maven/components/trunk/maven-project/src/test/java/org/apache/maven/project/artifact/MavenMetadataSourceTest.java
> > > URL:
> > >
> > http://svn.apache.org/viewvc/maven/components/trunk/maven-project/src/test/java/org/apache/maven/project/artifact/MavenMetadataSourceTest.java?rev=438189&r1=438188&r2=438189&view=diff
> > >
> > >
> > ==============================================================================
> >
> > > ---
> > >
> > maven/components/trunk/maven-project/src/test/java/org/apache/maven/project/artifact/MavenMetadataSourceTest.java
> > > (original)
> > > +++
> > >
> > maven/components/trunk/maven-project/src/test/java/org/apache/maven/project/artifact/MavenMetadataSourceTest.java
> >
> > > Tue Aug 29 13:17:14 2006
> > > @@ -3,18 +3,71 @@
> > > 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
> > >
> > >
> > >
> >
> >
>
Re: svn commit: r438189 - in /maven/components/trunk/maven-project/src: main/java/org/apache/maven/profiles/ main/java/org/apache/maven/project/artifact/ test/java/org/apache/maven/project/artifact/
Posted by John Casey <ca...@gmail.com>.
Sorry, I didn't have the issue number on hand. I'll look it up and add it to
the log message now.
-j
On 8/31/06, Grzegorz Slowikowski <gs...@gmail.com> wrote:
>
> Hello
>
> Why didn't you use jira issue number in commit message and didn't close
> jira
> issue
> (I don't remember its number)? I'm talking about exclusions bug.
>
> Grzegorz Slowikowski
>
>
> 2006/8/29, jdcasey@apache.org <jd...@apache.org>:
> >
> > Author: jdcasey
> > Date: Tue Aug 29 13:17:14 2006
> > New Revision: 438189
> >
> > URL: http://svn.apache.org/viewvc?rev=438189&view=rev
> > Log:
> > Fixing exclusions that bleed over into other dependencies, and modifying
> > DefaultProfileManager to (a) deprecate constructor that takes Settings
> but
> > no properties, and (b) add a constructor that takes Settings and
> properties.
> >
> > Modified:
> >
> >
> maven/components/trunk/maven-project/src/main/java/org/apache/maven/profiles/DefaultProfileManager.java
> >
> >
> maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/artifact/MavenMetadataSource.java
> >
> >
> maven/components/trunk/maven-project/src/test/java/org/apache/maven/project/artifact/MavenMetadataSourceTest.java
> >
> > Modified:
> >
> maven/components/trunk/maven-project/src/main/java/org/apache/maven/profiles/DefaultProfileManager.java
> > URL:
> >
> http://svn.apache.org/viewvc/maven/components/trunk/maven-project/src/main/java/org/apache/maven/profiles/DefaultProfileManager.java?rev=438189&r1=438188&r2=438189&view=diff
> >
> >
> ==============================================================================
> > ---
> >
> maven/components/trunk/maven-project/src/main/java/org/apache/maven/profiles/DefaultProfileManager.java
> > (original)
> > +++
> >
> maven/components/trunk/maven-project/src/main/java/org/apache/maven/profiles/DefaultProfileManager.java
> > Tue Aug 29 13:17:14 2006
> > @@ -66,18 +66,36 @@
> > */
> > public DefaultProfileManager( PlexusContainer container, Properties
> > props )
> > {
> > - this( container, (Settings)null );
> > - if (props != null) {
> > - systemProperties = 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 )
> > + {
> > + systemProperties = props;
> > + }
> > }
> >
> > public Properties getSystemProperties() {
> >
> > Modified:
> >
> maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/artifact/MavenMetadataSource.java
> > URL:
> >
> http://svn.apache.org/viewvc/maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/artifact/MavenMetadataSource.java?rev=438189&r1=438188&r2=438189&view=diff
> >
> >
> ==============================================================================
> > ---
> >
> maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/artifact/MavenMetadataSource.java
> > (original)
> > +++
> >
> maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/artifact/MavenMetadataSource.java
> > Tue Aug 29 13:17:14 2006
> > @@ -48,7 +48,6 @@
> > 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;
> > @@ -337,7 +336,9 @@
> > artifact.setFile( new File( d.getSystemPath() ) );
> > }
> >
> > - if ( artifact != null && ( dependencyFilter == null ||
> > dependencyFilter.include( artifact ) ) )
> > + ArtifactFilter artifactFilter = dependencyFilter;
> > +
> > + if ( artifact != null && ( artifactFilter == null ||
> > artifactFilter.include( artifact ) ) )
> > {
> > if ( d.getExclusions() != null &&
> > !d.getExclusions().isEmpty() )
> > {
> > @@ -350,20 +351,20 @@
> >
> > ArtifactFilter newFilter = new
> > ExcludesArtifactFilter( exclusions );
> >
> > - if ( dependencyFilter != null )
> > + if ( artifactFilter != null )
> > {
> > AndArtifactFilter filter = new
> > AndArtifactFilter();
> > - filter.add( dependencyFilter );
> > + filter.add( artifactFilter );
> > filter.add( newFilter );
> > - dependencyFilter = filter;
> > + artifactFilter = filter;
> > }
> > else
> > {
> > - dependencyFilter = newFilter;
> > + artifactFilter = newFilter;
> > }
> > }
> >
> > - artifact.setDependencyFilter( dependencyFilter );
> > + artifact.setDependencyFilter( artifactFilter );
> >
> > if ( project != null )
> > {
> >
> > Modified:
> >
> maven/components/trunk/maven-project/src/test/java/org/apache/maven/project/artifact/MavenMetadataSourceTest.java
> > URL:
> >
> http://svn.apache.org/viewvc/maven/components/trunk/maven-project/src/test/java/org/apache/maven/project/artifact/MavenMetadataSourceTest.java?rev=438189&r1=438188&r2=438189&view=diff
> >
> >
> ==============================================================================
> > ---
> >
> maven/components/trunk/maven-project/src/test/java/org/apache/maven/project/artifact/MavenMetadataSourceTest.java
> > (original)
> > +++
> >
> maven/components/trunk/maven-project/src/test/java/org/apache/maven/project/artifact/MavenMetadataSourceTest.java
> > Tue Aug 29 13:17:14 2006
> > @@ -3,18 +3,71 @@
> > 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
> >
> >
> >
>
>
Re: svn commit: r438189 - in /maven/components/trunk/maven-project/src: main/java/org/apache/maven/profiles/ main/java/org/apache/maven/project/artifact/ test/java/org/apache/maven/project/artifact/
Posted by Grzegorz Slowikowski <gs...@gmail.com>.
Hello
Why didn't you use jira issue number in commit message and didn't close jira
issue
(I don't remember its number)? I'm talking about exclusions bug.
Grzegorz Slowikowski
2006/8/29, jdcasey@apache.org <jd...@apache.org>:
>
> Author: jdcasey
> Date: Tue Aug 29 13:17:14 2006
> New Revision: 438189
>
> URL: http://svn.apache.org/viewvc?rev=438189&view=rev
> Log:
> Fixing exclusions that bleed over into other dependencies, and modifying
> DefaultProfileManager to (a) deprecate constructor that takes Settings but
> no properties, and (b) add a constructor that takes Settings and properties.
>
> Modified:
>
> maven/components/trunk/maven-project/src/main/java/org/apache/maven/profiles/DefaultProfileManager.java
>
> maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/artifact/MavenMetadataSource.java
>
> maven/components/trunk/maven-project/src/test/java/org/apache/maven/project/artifact/MavenMetadataSourceTest.java
>
> Modified:
> maven/components/trunk/maven-project/src/main/java/org/apache/maven/profiles/DefaultProfileManager.java
> URL:
> http://svn.apache.org/viewvc/maven/components/trunk/maven-project/src/main/java/org/apache/maven/profiles/DefaultProfileManager.java?rev=438189&r1=438188&r2=438189&view=diff
>
> ==============================================================================
> ---
> maven/components/trunk/maven-project/src/main/java/org/apache/maven/profiles/DefaultProfileManager.java
> (original)
> +++
> maven/components/trunk/maven-project/src/main/java/org/apache/maven/profiles/DefaultProfileManager.java
> Tue Aug 29 13:17:14 2006
> @@ -66,18 +66,36 @@
> */
> public DefaultProfileManager( PlexusContainer container, Properties
> props )
> {
> - this( container, (Settings)null );
> - if (props != null) {
> - systemProperties = 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 )
> + {
> + systemProperties = props;
> + }
> }
>
> public Properties getSystemProperties() {
>
> Modified:
> maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/artifact/MavenMetadataSource.java
> URL:
> http://svn.apache.org/viewvc/maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/artifact/MavenMetadataSource.java?rev=438189&r1=438188&r2=438189&view=diff
>
> ==============================================================================
> ---
> maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/artifact/MavenMetadataSource.java
> (original)
> +++
> maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/artifact/MavenMetadataSource.java
> Tue Aug 29 13:17:14 2006
> @@ -48,7 +48,6 @@
> 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;
> @@ -337,7 +336,9 @@
> artifact.setFile( new File( d.getSystemPath() ) );
> }
>
> - if ( artifact != null && ( dependencyFilter == null ||
> dependencyFilter.include( artifact ) ) )
> + ArtifactFilter artifactFilter = dependencyFilter;
> +
> + if ( artifact != null && ( artifactFilter == null ||
> artifactFilter.include( artifact ) ) )
> {
> if ( d.getExclusions() != null &&
> !d.getExclusions().isEmpty() )
> {
> @@ -350,20 +351,20 @@
>
> ArtifactFilter newFilter = new
> ExcludesArtifactFilter( exclusions );
>
> - if ( dependencyFilter != null )
> + if ( artifactFilter != null )
> {
> AndArtifactFilter filter = new
> AndArtifactFilter();
> - filter.add( dependencyFilter );
> + filter.add( artifactFilter );
> filter.add( newFilter );
> - dependencyFilter = filter;
> + artifactFilter = filter;
> }
> else
> {
> - dependencyFilter = newFilter;
> + artifactFilter = newFilter;
> }
> }
>
> - artifact.setDependencyFilter( dependencyFilter );
> + artifact.setDependencyFilter( artifactFilter );
>
> if ( project != null )
> {
>
> Modified:
> maven/components/trunk/maven-project/src/test/java/org/apache/maven/project/artifact/MavenMetadataSourceTest.java
> URL:
> http://svn.apache.org/viewvc/maven/components/trunk/maven-project/src/test/java/org/apache/maven/project/artifact/MavenMetadataSourceTest.java?rev=438189&r1=438188&r2=438189&view=diff
>
> ==============================================================================
> ---
> maven/components/trunk/maven-project/src/test/java/org/apache/maven/project/artifact/MavenMetadataSourceTest.java
> (original)
> +++
> maven/components/trunk/maven-project/src/test/java/org/apache/maven/project/artifact/MavenMetadataSourceTest.java
> Tue Aug 29 13:17:14 2006
> @@ -3,18 +3,71 @@
> 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
>
>
>