mirror of https://github.com/apache/maven.git
remove <file>, add <scope>
git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@163463 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
46edb7818f
commit
8c6292c23f
|
@ -77,16 +77,16 @@ public class DefaultModelDefaultsInjector
|
|||
*/
|
||||
private void mergeWithDefaults( Dependency dep, Dependency def )
|
||||
{
|
||||
if ( dep.getScope() == null && def.getScope() != null )
|
||||
{
|
||||
dep.setScope( def.getScope() );
|
||||
}
|
||||
|
||||
if ( dep.getVersion() == null && def.getVersion() != null )
|
||||
{
|
||||
dep.setVersion( def.getVersion() );
|
||||
}
|
||||
|
||||
if ( dep.getFile() == null && def.getFile() != null )
|
||||
{
|
||||
dep.setFile( def.getFile() );
|
||||
}
|
||||
|
||||
Properties props = new Properties( def.getProperties() );
|
||||
props.putAll( dep.getProperties() );
|
||||
dep.setProperties( props );
|
||||
|
|
|
@ -96,25 +96,6 @@ public class DefaultPathTranslator
|
|||
}
|
||||
}
|
||||
|
||||
List dependencies = model.getDependencies();
|
||||
|
||||
for ( Iterator i = dependencies.iterator(); i.hasNext(); )
|
||||
{
|
||||
Dependency dependency = (Dependency) i.next();
|
||||
|
||||
s = dependency.getFile();
|
||||
|
||||
if ( s != null )
|
||||
{
|
||||
s = stripBasedirToken( s );
|
||||
|
||||
if ( requiresBaseDirectoryAlignment( s ) )
|
||||
{
|
||||
dependency.setFile( new File( projectFile.getParentFile(), s ).getPath() );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
s = stripBasedirToken( build.getOutput() );
|
||||
|
||||
if ( requiresBaseDirectoryAlignment( s ) )
|
||||
|
|
|
@ -32,33 +32,5 @@ public class ProjectBaseDirectoryAlignmentTest
|
|||
Resource resource = (Resource) build.getResources().get( 0 );
|
||||
|
||||
assertTrue( resource.getDirectory().startsWith( getBasedir() ) );
|
||||
|
||||
String relativeFile = null;
|
||||
String absoluteFile = null;
|
||||
String managedDependencyFile = null;
|
||||
for ( Iterator i = project.getDependencies().iterator(); i.hasNext(); )
|
||||
{
|
||||
Dependency d = (Dependency) i.next();
|
||||
if ( d.getGroupId().equals( "g1" ) )
|
||||
{
|
||||
relativeFile = d.getFile();
|
||||
}
|
||||
else if ( d.getGroupId().equals( "g2" ) )
|
||||
{
|
||||
absoluteFile = d.getFile();
|
||||
}
|
||||
else if ( d.getGroupId().equals( "g3" ) )
|
||||
{
|
||||
managedDependencyFile = d.getFile();
|
||||
}
|
||||
}
|
||||
|
||||
assertNotNull( "Required dependency missing: g1:d1", relativeFile );
|
||||
assertNotNull( "Required dependency missing: g2:d2", absoluteFile );
|
||||
assertNotNull( "Required dependency missing: g3:d3", managedDependencyFile );
|
||||
|
||||
assertTrue( "Relative file not adjusted", relativeFile.startsWith( getBasedir() ) );
|
||||
assertEquals( "Absolute file was incorrectly modified", "/top/level/path", absoluteFile );
|
||||
assertTrue( "Managed dependency not adjusted", managedDependencyFile.startsWith( getBasedir() ) );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -50,7 +50,7 @@ public class DefaultModelDefaultsInjectorTest
|
|||
def.setGroupId( dep.getGroupId() );
|
||||
def.setArtifactId( dep.getArtifactId() );
|
||||
def.setVersion( "1.0.1" );
|
||||
def.setFile( "file" );
|
||||
def.setScope( "scope" );
|
||||
|
||||
DependencyManagement depMgmt = new DependencyManagement();
|
||||
|
||||
|
@ -203,7 +203,7 @@ public class DefaultModelDefaultsInjectorTest
|
|||
assertEquals( "value", result.getProperties().getProperty( "test" ) );
|
||||
}
|
||||
|
||||
public void testShouldMergeDefaultFileWhenDependencyDoesntSupplyFile()
|
||||
public void testShouldMergeDefaultScopeWhenDependencyDoesntSupplyScope()
|
||||
{
|
||||
Model model = new Model();
|
||||
|
||||
|
@ -211,7 +211,7 @@ public class DefaultModelDefaultsInjectorTest
|
|||
dep.setGroupId( "myGroup" );
|
||||
dep.setArtifactId( "myArtifact" );
|
||||
dep.setVersion( "1.0.1" );
|
||||
dep.setFile( "file" );
|
||||
dep.setScope( "scope" );
|
||||
|
||||
model.addDependency( dep );
|
||||
|
||||
|
@ -232,10 +232,10 @@ public class DefaultModelDefaultsInjectorTest
|
|||
|
||||
Dependency result = (Dependency) deps.get( 0 );
|
||||
|
||||
assertEquals( "file", result.getFile() );
|
||||
assertEquals( "scope", result.getScope() );
|
||||
}
|
||||
|
||||
public void testShouldNotMergeDefaultFileWhenDependencySuppliesFile()
|
||||
public void testShouldNotMergeDefaultScopeWhenDependencySuppliesScope()
|
||||
{
|
||||
Model model = new Model();
|
||||
|
||||
|
@ -243,14 +243,14 @@ public class DefaultModelDefaultsInjectorTest
|
|||
dep.setGroupId( "myGroup" );
|
||||
dep.setArtifactId( "myArtifact" );
|
||||
dep.setVersion( "1.0.1" );
|
||||
dep.setFile( "file" );
|
||||
dep.setScope( "scope" );
|
||||
|
||||
model.addDependency( dep );
|
||||
|
||||
Dependency def = new Dependency();
|
||||
def.setGroupId( dep.getGroupId() );
|
||||
def.setArtifactId( dep.getArtifactId() );
|
||||
def.setFile( "default" );
|
||||
def.setScope( "default" );
|
||||
|
||||
DependencyManagement depMgmt = new DependencyManagement();
|
||||
|
||||
|
@ -264,7 +264,7 @@ public class DefaultModelDefaultsInjectorTest
|
|||
assertEquals( 1, deps.size() );
|
||||
|
||||
Dependency result = (Dependency) deps.get( 0 );
|
||||
assertEquals( "file", result.getFile() );
|
||||
assertEquals( "scope", result.getScope() );
|
||||
}
|
||||
|
||||
public void testShouldRejectDependencyWhereNoVersionIsFoundAfterDefaultsInjection()
|
||||
|
|
|
@ -64,7 +64,6 @@
|
|||
<artifactId>d1</artifactId>
|
||||
<version>1.0</version>
|
||||
<url>d1-url</url>
|
||||
<file>foo/bar</file>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
|
@ -72,7 +71,6 @@
|
|||
<artifactId>d2</artifactId>
|
||||
<version>2.0</version>
|
||||
<url>d2-url</url>
|
||||
<file>/top/level/path</file>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
|
@ -89,7 +87,6 @@
|
|||
<artifactId>d3</artifactId>
|
||||
<version>3.0</version>
|
||||
<url>d3-url</url>
|
||||
<file>g3/d3</file>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</dependencyManagement>
|
||||
|
|
|
@ -18,6 +18,8 @@
|
|||
| o need to clean up all the descriptions, matching anything to the current project-descriptor.xml file and
|
||||
| improving on that
|
||||
|
|
||||
| o use enums where appropriate (eg dependency scope)
|
||||
|
|
||||
-->
|
||||
<model>
|
||||
<id>maven</id>
|
||||
|
@ -808,9 +810,9 @@
|
|||
</association>
|
||||
</field>
|
||||
<field>
|
||||
<name>file</name>
|
||||
<name>scope</name>
|
||||
<version>4.0.0</version>
|
||||
<description>Override the use of a repository - retrieve it from this file</description>
|
||||
<description>The scope of the dependency - build, compile, test, runtime</description>
|
||||
<type>String</type>
|
||||
</field>
|
||||
</fields>
|
||||
|
|
Loading…
Reference in New Issue