mirror of https://github.com/apache/maven.git
[MNG-4293] Extend Mojo API to allow resolution of both compile and runtime dependencies
git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@803422 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
9131de7039
commit
0e1d2e829d
|
@ -45,6 +45,8 @@ public interface Artifact
|
|||
|
||||
String SCOPE_COMPILE = ArtifactScopeEnum.compile.toString();
|
||||
|
||||
String SCOPE_COMPILE_PLUS_RUNTIME = "compile+runtime";
|
||||
|
||||
String SCOPE_TEST = ArtifactScopeEnum.test.toString();
|
||||
|
||||
String SCOPE_RUNTIME = ArtifactScopeEnum.runtime.toString();
|
||||
|
|
|
@ -62,6 +62,14 @@ public class ScopeArtifactFilter
|
|||
runtimeScope = true;
|
||||
testScope = false;
|
||||
}
|
||||
else if ( Artifact.SCOPE_COMPILE_PLUS_RUNTIME.equals( scope ) )
|
||||
{
|
||||
systemScope = true;
|
||||
providedScope = true;
|
||||
compileScope = true;
|
||||
runtimeScope = true;
|
||||
testScope = false;
|
||||
}
|
||||
else if ( Artifact.SCOPE_RUNTIME_PLUS_SYSTEM.equals( scope ) )
|
||||
{
|
||||
systemScope = true;
|
||||
|
|
|
@ -0,0 +1,96 @@
|
|||
package 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;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
/**
|
||||
* Tests {@link ScopeArtifactFilter}.
|
||||
*
|
||||
* @author Benjamin Bentmann
|
||||
*/
|
||||
public class ScopeArtifactFilterTest
|
||||
extends TestCase
|
||||
{
|
||||
|
||||
private Artifact newArtifact( String scope )
|
||||
{
|
||||
return new DefaultArtifact( "g", "a", "1.0", scope, "jar", "", null );
|
||||
}
|
||||
|
||||
public void testInclude_Compile()
|
||||
{
|
||||
ScopeArtifactFilter filter = new ScopeArtifactFilter( Artifact.SCOPE_COMPILE );
|
||||
|
||||
assertTrue( filter.include( newArtifact( Artifact.SCOPE_COMPILE ) ) );
|
||||
assertTrue( filter.include( newArtifact( Artifact.SCOPE_SYSTEM ) ) );
|
||||
assertTrue( filter.include( newArtifact( Artifact.SCOPE_PROVIDED ) ) );
|
||||
assertFalse( filter.include( newArtifact( Artifact.SCOPE_RUNTIME ) ) );
|
||||
assertFalse( filter.include( newArtifact( Artifact.SCOPE_TEST ) ) );
|
||||
}
|
||||
|
||||
public void testInclude_CompilePlusRuntime()
|
||||
{
|
||||
ScopeArtifactFilter filter = new ScopeArtifactFilter( Artifact.SCOPE_COMPILE_PLUS_RUNTIME );
|
||||
|
||||
assertTrue( filter.include( newArtifact( Artifact.SCOPE_COMPILE ) ) );
|
||||
assertTrue( filter.include( newArtifact( Artifact.SCOPE_SYSTEM ) ) );
|
||||
assertTrue( filter.include( newArtifact( Artifact.SCOPE_PROVIDED ) ) );
|
||||
assertTrue( filter.include( newArtifact( Artifact.SCOPE_RUNTIME ) ) );
|
||||
assertFalse( filter.include( newArtifact( Artifact.SCOPE_TEST ) ) );
|
||||
}
|
||||
|
||||
public void testInclude_Runtime()
|
||||
{
|
||||
ScopeArtifactFilter filter = new ScopeArtifactFilter( Artifact.SCOPE_RUNTIME );
|
||||
|
||||
assertTrue( filter.include( newArtifact( Artifact.SCOPE_COMPILE ) ) );
|
||||
assertFalse( filter.include( newArtifact( Artifact.SCOPE_SYSTEM ) ) );
|
||||
assertFalse( filter.include( newArtifact( Artifact.SCOPE_PROVIDED ) ) );
|
||||
assertTrue( filter.include( newArtifact( Artifact.SCOPE_RUNTIME ) ) );
|
||||
assertFalse( filter.include( newArtifact( Artifact.SCOPE_TEST ) ) );
|
||||
}
|
||||
|
||||
public void testInclude_RuntimePlusSystem()
|
||||
{
|
||||
ScopeArtifactFilter filter = new ScopeArtifactFilter( Artifact.SCOPE_RUNTIME_PLUS_SYSTEM );
|
||||
|
||||
assertTrue( filter.include( newArtifact( Artifact.SCOPE_COMPILE ) ) );
|
||||
assertTrue( filter.include( newArtifact( Artifact.SCOPE_SYSTEM ) ) );
|
||||
assertFalse( filter.include( newArtifact( Artifact.SCOPE_PROVIDED ) ) );
|
||||
assertTrue( filter.include( newArtifact( Artifact.SCOPE_RUNTIME ) ) );
|
||||
assertFalse( filter.include( newArtifact( Artifact.SCOPE_TEST ) ) );
|
||||
}
|
||||
|
||||
public void testInclude_Test()
|
||||
{
|
||||
ScopeArtifactFilter filter = new ScopeArtifactFilter( Artifact.SCOPE_TEST );
|
||||
|
||||
assertTrue( filter.include( newArtifact( Artifact.SCOPE_COMPILE ) ) );
|
||||
assertTrue( filter.include( newArtifact( Artifact.SCOPE_SYSTEM ) ) );
|
||||
assertTrue( filter.include( newArtifact( Artifact.SCOPE_PROVIDED ) ) );
|
||||
assertTrue( filter.include( newArtifact( Artifact.SCOPE_RUNTIME ) ) );
|
||||
assertTrue( filter.include( newArtifact( Artifact.SCOPE_TEST ) ) );
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue