File tree Expand file tree Collapse file tree
main/java/org/apache/maven/resolver/internal/ant
java/org/apache/maven/resolver/internal/ant Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -654,7 +654,7 @@ private void populateCollectRequest(
654654 dependency .addExclusion (exclusion );
655655 }
656656 collectRequest .addManagedDependency (
657- ConverterUtils .toDependency (dependency , globalExclusions , session ));
657+ ConverterUtils .toManagedDependency (dependency , globalExclusions , session ));
658658 }
659659 }
660660
Original file line number Diff line number Diff line change 2626import java .util .Map ;
2727import java .util .Properties ;
2828
29+ import org .apache .commons .lang3 .ObjectUtils ;
2930import org .apache .maven .resolver .internal .ant .types .Authentication ;
3031import org .apache .maven .resolver .internal .ant .types .Dependency ;
3132import org .apache .maven .resolver .internal .ant .types .Exclusion ;
@@ -82,6 +83,16 @@ public static org.eclipse.aether.repository.Authentication toAuthentication(Auth
8283
8384 public static org .eclipse .aether .graph .Dependency toDependency (
8485 Dependency dependency , List <Exclusion > exclusions , RepositorySystemSession session ) {
86+ String scope = dependency .getScope ();
87+ return new org .eclipse .aether .graph .Dependency (
88+ toArtifact (dependency , session .getArtifactTypeRegistry ()),
89+ ObjectUtils .isEmpty (scope ) ? "compile" : scope ,
90+ false ,
91+ toExclusions (dependency .getExclusions (), exclusions ));
92+ }
93+
94+ public static org .eclipse .aether .graph .Dependency toManagedDependency (
95+ Dependency dependency , List <Exclusion > exclusions , RepositorySystemSession session ) {
8596 return new org .eclipse .aether .graph .Dependency (
8697 toArtifact (dependency , session .getArtifactTypeRegistry ()),
8798 dependency .getScope (),
Original file line number Diff line number Diff line change @@ -188,7 +188,7 @@ public String getScope() {
188188 if (isReference ()) {
189189 return getRef ().getScope ();
190190 }
191- return (scope != null ) ? scope : "compile " ;
191+ return (scope != null ) ? scope : "" ;
192192 }
193193
194194 public void setScope (String scope ) {
Original file line number Diff line number Diff line change @@ -177,4 +177,23 @@ public void testResolveTransitiveDependencyManagement() {
177177 prop ,
178178 allOf (containsString ("apiguardian-api" ), endsWith ("apiguardian-api-1.1.1.jar" )));
179179 }
180+
181+ @ Test
182+ public void testResolveTransitiveDependencyManagementTestScope () {
183+ executeTarget ("testResolveTransitiveDependencyManagementTestScope" );
184+
185+ String prop = getProject ().getProperty ("test.compile.resolve.path.org.slf4j:slf4j-api:jar" );
186+ assertThat ("slf4j-api was not resolved as a property" , prop , notNullValue ());
187+ assertThat (
188+ "slf4j-api was not resolved to default local repository" ,
189+ prop ,
190+ allOf (containsString ("slf4j-api" ), endsWith ("slf4j-api-2.0.6.jar" )));
191+
192+ prop = getProject ().getProperty ("test.resolve.path.org.apiguardian:apiguardian-api:jar" );
193+ assertThat ("apiguardian-api was not resolved as a property" , prop , notNullValue ());
194+ assertThat (
195+ "apiguardian-api was not resolved to default local repository" ,
196+ prop ,
197+ allOf (containsString ("apiguardian-api" ), endsWith ("apiguardian-api-1.1.1.jar" )));
198+ }
180199}
Original file line number Diff line number Diff line change @@ -40,7 +40,7 @@ public void testSetCoordsGidAidVer() {
4040 assertEquals ("ver" , dep .getVersion ());
4141 assertEquals ("jar" , dep .getType ());
4242 assertEquals ("" , dep .getClassifier ());
43- assertEquals ("compile " , dep .getScope ());
43+ assertEquals ("" , dep .getScope ());
4444 }
4545
4646 @ Test
Original file line number Diff line number Diff line change 122122 <target name =" testResolveTransitiveDependencyManagement" >
123123 <repo : pom file =" ${ project.dir } /transitive-depmgt-pom.xml" />
124124 <repo : resolve >
125- <properties prefix =" test.resolve.path" classpath =" compile " />
125+ <properties prefix =" test.resolve.path" classpath =" test " />
126126 </repo : resolve >
127127 </target >
128128
129+ <target name =" testResolveTransitiveDependencyManagementTestScope" >
130+ <repo : pom file =" ${ project.dir } /transitive-depmgt-pom.xml" />
131+ <repo : resolve >
132+ <properties prefix =" test.compile.resolve.path" scopes =" compile" />
133+ <properties prefix =" test.compile.resolve.classpath" classpath =" compile" />
134+ <properties prefix =" test.resolve.path" scopes =" test" />
135+ <properties prefix =" test.resolve.classpath" classpath =" test" />
136+ </repo : resolve >
137+ </target >
138+
129139</project >
You can’t perform that action at this time.
0 commit comments