diff --git a/maven-core/src/main/java/org/apache/maven/lifecycle/internal/MojoExecutor.java b/maven-core/src/main/java/org/apache/maven/lifecycle/internal/MojoExecutor.java index 89fadfdb32ff..f6c7153cfee3 100644 --- a/maven-core/src/main/java/org/apache/maven/lifecycle/internal/MojoExecutor.java +++ b/maven-core/src/main/java/org/apache/maven/lifecycle/internal/MojoExecutor.java @@ -283,7 +283,7 @@ public void ensureDependenciesAreResolved( MojoDescriptor mojoDescriptor, MavenS } } - private ArtifactFilter getArtifactFilter( MojoDescriptor mojoDescriptor ) + public static ArtifactFilter getArtifactFilter( MojoDescriptor mojoDescriptor ) { String scopeToResolve = mojoDescriptor.getDependencyResolutionRequired(); String scopeToCollect = mojoDescriptor.getDependencyCollectionRequired(); diff --git a/maven-core/src/main/java/org/apache/maven/plugin/PluginParameterExpressionEvaluator.java b/maven-core/src/main/java/org/apache/maven/plugin/PluginParameterExpressionEvaluator.java index 4f5503382313..084b78512fa0 100644 --- a/maven-core/src/main/java/org/apache/maven/plugin/PluginParameterExpressionEvaluator.java +++ b/maven-core/src/main/java/org/apache/maven/plugin/PluginParameterExpressionEvaluator.java @@ -22,7 +22,9 @@ import java.io.File; import java.util.Properties; +import org.apache.maven.artifact.resolver.filter.ArtifactFilter; import org.apache.maven.execution.MavenSession; +import org.apache.maven.lifecycle.internal.MojoExecutor; import org.apache.maven.plugin.descriptor.MojoDescriptor; import org.apache.maven.plugin.descriptor.PluginDescriptor; import org.apache.maven.project.MavenProject; @@ -244,6 +246,10 @@ else if ( "mojoExecution".equals( expression ) ) { value = mojoExecution; } + else if ( "artifactFilter".equals( expression ) ) + { + value = MojoExecutor.getArtifactFilter( mojoDescriptor ); + } else if ( "project".equals( expression ) ) { value = project; @@ -264,6 +270,31 @@ else if ( expression.startsWith( "project" ) || expression.startsWith( "pom" ) ) value = ReflectionValueExtractor.evaluate( pathExpression, project ); value = value + expression.substring( pathSeparator ); } + else if ( "project.artifacts".equals( expression ) ) + { + ArtifactFilter filter = MojoExecutor.getArtifactFilter( mojoDescriptor ); + value = project.getArtifacts( filter ); + } + else if ( "project.artifactMap".equals( expression ) ) + { + ArtifactFilter filter = MojoExecutor.getArtifactFilter( mojoDescriptor ); + value = project.getArtifactMap( filter ); + } + else if ( "project.compileClasspathElements".equals( expression ) ) + { + ArtifactFilter filter = MojoExecutor.getArtifactFilter( mojoDescriptor ); + value = project.getCompileClasspathElements( filter ); + } + else if ( "project.runtimeClasspathElements".equals( expression ) ) + { + ArtifactFilter filter = MojoExecutor.getArtifactFilter( mojoDescriptor ); + value = project.getRuntimeClasspathElements( filter ); + } + else if ( "project.testClasspathElements".equals( expression ) ) + { + ArtifactFilter filter = MojoExecutor.getArtifactFilter( mojoDescriptor ); + value = project.getTestClasspathElements( filter ); + } else { value = ReflectionValueExtractor.evaluate( expression.substring( 1 ), project ); diff --git a/maven-core/src/main/java/org/apache/maven/project/DefaultProjectBuilder.java b/maven-core/src/main/java/org/apache/maven/project/DefaultProjectBuilder.java index 12e6e2383ccd..060644bb1a40 100644 --- a/maven-core/src/main/java/org/apache/maven/project/DefaultProjectBuilder.java +++ b/maven-core/src/main/java/org/apache/maven/project/DefaultProjectBuilder.java @@ -248,7 +248,6 @@ private DependencyResolutionResult resolveDependencies( MavenProject project, Re } } project.setResolvedArtifacts( artifacts ); - project.setArtifacts( artifacts ); return resolutionResult; } diff --git a/maven-core/src/main/java/org/apache/maven/project/MavenProject.java b/maven-core/src/main/java/org/apache/maven/project/MavenProject.java index 57069a5e6a9a..bc3256c95303 100644 --- a/maven-core/src/main/java/org/apache/maven/project/MavenProject.java +++ b/maven-core/src/main/java/org/apache/maven/project/MavenProject.java @@ -32,6 +32,10 @@ import java.util.Properties; import java.util.Set; import java.util.Objects; +import java.util.concurrent.ConcurrentHashMap; +import java.util.function.Predicate; +import java.util.stream.Collectors; +import java.util.stream.Stream; import org.apache.maven.RepositoryUtils; import org.apache.maven.artifact.Artifact; @@ -111,9 +115,10 @@ public class MavenProject private Set resolvedArtifacts; - private ArtifactFilter artifactFilter; + private final ThreadLocal artifactFilter + = ThreadLocal.withInitial( () -> a -> true ); - private Set artifacts; + private final Map> artifacts = new ConcurrentHashMap<>(); private Artifact parentArtifact; @@ -151,8 +156,7 @@ public class MavenProject private Artifact artifact; - // calculated. - private Map artifactMap; + private final Map> artifactMap = new ConcurrentHashMap<>(); private Model originalModel; @@ -347,84 +351,62 @@ public List getTestCompileSourceRoots() return testCompileSourceRoots; } + @Deprecated public List getCompileClasspathElements() throws DependencyResolutionRequiredException { - List list = new ArrayList<>( getArtifacts().size() + 1 ); - - String d = getBuild().getOutputDirectory(); - if ( d != null ) - { - list.add( d ); - } - - for ( Artifact a : getArtifacts() ) - { - 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 getCompileClasspathElements( artifactFilter.get() ); + } - return list; + public List getCompileClasspathElements( ArtifactFilter artifactFilter ) + throws DependencyResolutionRequiredException + { + return Stream.concat( + ofNullable( getBuild().getOutputDirectory() ), + getClasspathElements( artifactFilter, MavenProject::compileScope ) + ).collect( Collectors.toList() ); } - // TODO this checking for file == null happens because the resolver has been confused about the root - // artifact or not. things like the stupid dummy artifact coming from surefire. + @Deprecated public List getTestClasspathElements() throws DependencyResolutionRequiredException { - List list = new ArrayList<>( getArtifacts().size() + 2 ); - - String d = getBuild().getTestOutputDirectory(); - if ( d != null ) - { - list.add( d ); - } - - d = getBuild().getOutputDirectory(); - if ( d != null ) - { - list.add( d ); - } - - for ( Artifact a : getArtifacts() ) - { - if ( a.getArtifactHandler().isAddedToClasspath() ) - { - addArtifactPath( a, list ); - } - } + return getTestClasspathElements( artifactFilter.get() ); + } - return list; + public List getTestClasspathElements( ArtifactFilter artifactFilter ) + throws DependencyResolutionRequiredException + { + return Stream.concat( Stream.concat( + ofNullable( getBuild().getTestOutputDirectory() ), + ofNullable( getBuild().getOutputDirectory() ) ), + getClasspathElements( artifactFilter, a -> true ) + ).collect( Collectors.toList() ); } + @Deprecated public List getRuntimeClasspathElements() throws DependencyResolutionRequiredException { - List list = new ArrayList<>( getArtifacts().size() + 1 ); + return getRuntimeClasspathElements( artifactFilter.get() ); + } - String d = getBuild().getOutputDirectory(); - if ( d != null ) - { - list.add( d ); - } + public List getRuntimeClasspathElements( ArtifactFilter artifactFilter ) + throws DependencyResolutionRequiredException + { + return Stream.concat( + ofNullable( getBuild().getOutputDirectory() ), + getClasspathElements( artifactFilter, MavenProject::runtimeScope ) + ).collect( Collectors.toList() ); + } - for ( Artifact a : getArtifacts() ) - { - if ( a.getArtifactHandler().isAddedToClasspath() - // TODO let the scope handler deal with this - && ( Artifact.SCOPE_COMPILE.equals( a.getScope() ) || Artifact.SCOPE_RUNTIME.equals( a.getScope() ) ) ) - { - addArtifactPath( a, list ); - } - } - return list; + private Stream getClasspathElements( ArtifactFilter artifactFilter, Predicate scopes ) + { + return getArtifacts( artifactFilter ).stream() + .filter( MavenProject::isAddedToClasspath ) + .filter( scopes ) + .filter( a -> a.getFile() != null ) + .map( a -> a.getFile().getPath() ); } // ---------------------------------------------------------------------- @@ -693,14 +675,6 @@ public void addLicense( License license ) getModel().addLicense( license ); } - public void setArtifacts( Set artifacts ) - { - this.artifacts = artifacts; - - // flush the calculated artifactMap - 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, @@ -709,36 +683,46 @@ public void setArtifacts( Set artifacts ) * @return {@link Set} < {@link Artifact} > * @see #getDependencyArtifacts() to get only direct dependencies */ + @Deprecated public Set getArtifacts() { - if ( artifacts == null ) + return getArtifacts( artifactFilter.get() ); + } + + public Set getArtifacts( ArtifactFilter filter ) + { + if ( filter == null || resolvedArtifacts == null ) { - if ( artifactFilter == null || resolvedArtifacts == null ) - { - artifacts = new LinkedHashSet<>(); - } - else + return Collections.emptySet(); + } + return artifacts.computeIfAbsent( filter, f -> + { + Set artifacts = new LinkedHashSet<>(); + for ( Artifact a : resolvedArtifacts ) { - artifacts = new LinkedHashSet<>( resolvedArtifacts.size() * 2 ); - for ( Artifact artifact : resolvedArtifacts ) + if ( f.include( a ) ) { - if ( artifactFilter.include( artifact ) ) - { - artifacts.add( artifact ); - } + artifacts.add( a ); } } - } - return artifacts; + return artifacts; + } ); } + @Deprecated public Map getArtifactMap() { - if ( artifactMap == null ) + return getArtifactMap( artifactFilter.get() ); + } + + public Map getArtifactMap( ArtifactFilter filter ) + { + if ( filter == null || resolvedArtifacts == null ) { - artifactMap = ArtifactUtils.artifactMapByVersionlessId( getArtifacts() ); + return Collections.emptyMap(); } - return artifactMap; + return artifactMap.computeIfAbsent( filter, + f -> ArtifactUtils.artifactMapByVersionlessId( getArtifacts( f ) ) ); } public void setPluginArtifacts( Set pluginArtifacts ) @@ -1229,11 +1213,6 @@ private void deepCopy( MavenProject project ) setDependencyArtifacts( Collections.unmodifiableSet( project.getDependencyArtifacts() ) ); } - if ( project.getArtifacts() != null ) - { - setArtifacts( Collections.unmodifiableSet( project.getArtifacts() ) ); - } - if ( project.getParentFile() != null ) { parentFile = new File( project.getParentFile().getAbsolutePath() ); @@ -1427,9 +1406,9 @@ public DependencyFilter getExtensionDependencyFilter() */ public void setResolvedArtifacts( Set artifacts ) { - this.resolvedArtifacts = ( artifacts != null ) ? artifacts : Collections.emptySet(); - this.artifacts = null; - this.artifactMap = null; + this.resolvedArtifacts = ( artifacts != null ) ? artifacts : Collections.emptySet(); + this.artifacts.clear(); + this.artifactMap.clear(); } /** @@ -1440,11 +1419,10 @@ public void setResolvedArtifacts( Set artifacts ) * * @param artifactFilter The artifact filter, may be {@code null} to exclude all artifacts. */ + @Deprecated public void setArtifactFilter( ArtifactFilter artifactFilter ) { - this.artifactFilter = artifactFilter; - this.artifacts = null; - this.artifactMap = null; + this.artifactFilter.set( artifactFilter ); } /** @@ -1583,227 +1561,81 @@ public List getScriptSourceRoots() @Deprecated public List getCompileArtifacts() { - List list = new ArrayList<>( getArtifacts().size() ); - - for ( Artifact a : getArtifacts() ) - { - // 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; + return getArtifacts().stream() + .filter( MavenProject::isAddedToClasspath ) // TODO classpath check doesn't belong here - that's the other method + .filter( MavenProject::compileScope ) // TODO let the scope handler deal with this + .collect( Collectors.toList() ); } @Deprecated public List getCompileDependencies() { - Set artifacts = getArtifacts(); - - if ( ( artifacts == null ) || artifacts.isEmpty() ) - { - return Collections.emptyList(); - } - - List list = new ArrayList<>( artifacts.size() ); - - for ( Artifact a : getArtifacts() ) - { - // 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 Collections.unmodifiableList( list ); + return Collections.unmodifiableList( getArtifacts().stream() + .filter( MavenProject::compileScope ) // TODO let the scope handler deal with this + .map( MavenProject::toDependency ) + .collect( Collectors.toList() ) ); } @Deprecated public List getTestArtifacts() { - List list = new ArrayList<>( getArtifacts().size() ); - - for ( Artifact a : getArtifacts() ) - { - // TODO classpath check doesn't belong here - that's the other method - if ( a.getArtifactHandler().isAddedToClasspath() ) - { - list.add( a ); - } - } - return list; + return Collections.unmodifiableList( getArtifacts().stream() + .filter( MavenProject::isAddedToClasspath ) // TODO classpath check doesn't belong here - that's the other method + .collect( Collectors.toList() ) ); } @Deprecated public List getTestDependencies() { - Set artifacts = getArtifacts(); - - if ( ( artifacts == null ) || artifacts.isEmpty() ) - { - return Collections.emptyList(); - } - - List list = new ArrayList<>( artifacts.size() ); - - for ( Artifact a : getArtifacts() ) - { - 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 Collections.unmodifiableList( list ); + return Collections.unmodifiableList( getArtifacts().stream() + .map( MavenProject::toDependency ) + .collect( Collectors.toList() ) ); } @Deprecated // used by the Maven ITs public List getRuntimeDependencies() { - Set artifacts = getArtifacts(); - - if ( ( artifacts == null ) || artifacts.isEmpty() ) - { - return Collections.emptyList(); - } - - List list = new ArrayList<>( artifacts.size() ); - - for ( Artifact a : getArtifacts() ) - { - // 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 Collections.unmodifiableList( list ); + return Collections.unmodifiableList( getArtifacts().stream() + .filter( MavenProject::runtimeScope ) // TODO let the scope handler deal with this + .map( MavenProject::toDependency ) + .collect( Collectors.toList() ) ); } @Deprecated public List getRuntimeArtifacts() { - List list = new ArrayList<>( getArtifacts().size() ); - - for ( Artifact a : getArtifacts() ) - { - // TODO classpath check doesn't belong here - that's the other method - if ( a.getArtifactHandler().isAddedToClasspath() - // TODO let the scope handler deal with this - && ( Artifact.SCOPE_COMPILE.equals( a.getScope() ) || Artifact.SCOPE_RUNTIME.equals( a.getScope() ) ) ) - { - list.add( a ); - } - } - return list; + return getArtifacts().stream() + .filter( MavenProject::isAddedToClasspath ) // TODO classpath check doesn't belong here - that's the other method + .filter( MavenProject::runtimeScope ) // TODO let the scope handler deal with this + .collect( Collectors.toList() ); } @Deprecated public List getSystemClasspathElements() throws DependencyResolutionRequiredException { - List list = new ArrayList<>( getArtifacts().size() ); - - String d = getBuild().getOutputDirectory(); - if ( d != null ) - { - list.add( d ); - } - - for ( Artifact a : getArtifacts() ) - { - if ( a.getArtifactHandler().isAddedToClasspath() ) - { - // TODO let the scope handler deal with this - if ( Artifact.SCOPE_SYSTEM.equals( a.getScope() ) ) - { - addArtifactPath( a, list ); - } - } - } - return list; + return Stream.concat( + ofNullable( getBuild().getOutputDirectory() ), + getClasspathElements( artifactFilter.get(), MavenProject::systemScope ) + ).collect( Collectors.toList() ); } @Deprecated public List getSystemArtifacts() { - List list = new ArrayList<>( getArtifacts().size() ); - - for ( Artifact a : getArtifacts() ) - { - // 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; + return getArtifacts().stream() + .filter( MavenProject::isAddedToClasspath ) // TODO classpath check doesn't belong here - that's the other method + .filter( MavenProject::systemScope ) // TODO let the scope handler deal with this + .collect( Collectors.toList() ); } @Deprecated public List getSystemDependencies() { - Set artifacts = getArtifacts(); - - if ( ( artifacts == null ) || artifacts.isEmpty() ) - { - return Collections.emptyList(); - } - - List list = new ArrayList<>( artifacts.size() ); - - for ( Artifact a : getArtifacts() ) - { - // 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 Collections.unmodifiableList( list ); + return Collections.unmodifiableList( getArtifacts().stream() + .filter( MavenProject::systemScope ) // TODO let the scope handler deal with this + .map( MavenProject::toDependency ) + .collect( Collectors.toList() ) ); } @Deprecated @@ -1986,4 +1818,47 @@ public void setProjectBuildingRequest( ProjectBuildingRequest projectBuildingReq { this.projectBuilderConfiguration = projectBuildingRequest; } + + private static Dependency toDependency( Artifact a ) + { + 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() ); + + return dependency; + } + + private static Stream ofNullable( T t ) + { + return t != null ? Stream.of( t ) : Stream.empty(); + } + + private static boolean compileScope( Artifact a ) + { + return Artifact.SCOPE_COMPILE.equals( a.getScope() ) + || Artifact.SCOPE_PROVIDED.equals( a.getScope() ) + || Artifact.SCOPE_SYSTEM.equals( a.getScope() ); + } + + private static boolean runtimeScope( Artifact a ) + { + return Artifact.SCOPE_COMPILE.equals( a.getScope() ) + || Artifact.SCOPE_RUNTIME.equals( a.getScope() ); + } + + private static boolean systemScope( Artifact a ) + { + return Artifact.SCOPE_SYSTEM.equals( a.getScope() ); + } + + private static boolean isAddedToClasspath( Artifact a ) + { + return a.getArtifactHandler().isAddedToClasspath(); + } + } diff --git a/maven-core/src/test/java/org/apache/maven/ProjectDependenciesResolverTest.java b/maven-core/src/test/java/org/apache/maven/ProjectDependenciesResolverTest.java index b648f2aec4e4..da33b32d0347 100644 --- a/maven-core/src/test/java/org/apache/maven/ProjectDependenciesResolverTest.java +++ b/maven-core/src/test/java/org/apache/maven/ProjectDependenciesResolverTest.java @@ -96,7 +96,7 @@ public void testSystemScopeDependencyIsPresentInTheCompileClasspathElements() MavenSession session = createMavenSession( pom, eps ); MavenProject project = session.getCurrentProject(); - project.setArtifacts( resolver.resolve( project, Collections.singleton( Artifact.SCOPE_COMPILE ), session ) ); + project.setResolvedArtifacts( resolver.resolve( project, Collections.singleton( Artifact.SCOPE_COMPILE ), session ) ); List elements = project.getCompileClasspathElements(); assertEquals( 2, elements.size() ); diff --git a/maven-core/src/test/java/org/apache/maven/plugin/PluginParameterExpressionEvaluatorTest.java b/maven-core/src/test/java/org/apache/maven/plugin/PluginParameterExpressionEvaluatorTest.java index 16deedd33794..a75382b419d1 100644 --- a/maven-core/src/test/java/org/apache/maven/plugin/PluginParameterExpressionEvaluatorTest.java +++ b/maven-core/src/test/java/org/apache/maven/plugin/PluginParameterExpressionEvaluatorTest.java @@ -21,10 +21,13 @@ import java.io.File; import java.util.ArrayList; +import java.util.Arrays; import java.util.Collections; +import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Properties; +import java.util.Set; import org.apache.maven.AbstractCoreMavenComponentTestCase; import org.apache.maven.artifact.Artifact; @@ -391,6 +394,45 @@ public void testShouldExtractPluginArtifacts() assertEquals( "testGroup", result.getGroupId() ); } + @Test + public void testProjectArtifacts() + throws Exception + { + MavenProject project = createDefaultProject(); + + Artifact artifact1 = createArtifact( "testGroup", "testArtifact1", "1.0" ); + Artifact artifact2 = createArtifact( "testGroup", "testArtifact2", "1.0" ); + artifact2.setScope( "test" ); + project.setResolvedArtifacts( new HashSet<>(Arrays.asList( artifact1, artifact2 ) ) ); + + ArtifactRepository repo = factory.createDefaultLocalRepository(); + + MutablePlexusContainer container = (MutablePlexusContainer) getContainer(); + MavenSession session = createSession( container, repo, new Properties() ); + session.setCurrentProject( project ); + + MojoDescriptor mojo = new MojoDescriptor(); + PluginDescriptor pd = new PluginDescriptor(); + mojo.setPluginDescriptor( pd ); + mojo.setGoal( "goal" ); + mojo.setDependencyResolutionRequired( "compile" ); + MojoExecution mojoExecution = new MojoExecution( mojo ); + ExpressionEvaluator ee = new PluginParameterExpressionEvaluator( session, mojoExecution ); + + Object value = ee.evaluate( "${project.artifacts}" ); + + assertTrue( value instanceof Set ); + + @SuppressWarnings( "unchecked" ) + Set artifacts = (Set) value; + + assertEquals( 1, artifacts.size() ); + + Artifact result = artifacts.iterator().next(); + + assertEquals( "testArtifact1", result.getArtifactId() ); + } + private MavenProject createDefaultProject() { return new MavenProject( new Model() );