All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.gradle.integtests.resolve.maven.MavenDependencyManagementImportOrderTest.groovy Maven / Gradle / Ivy

There is a newer version: 8.6
Show newest version
/*
 * Copyright 2017 the original author or authors.
 *
 * Licensed 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.
 */

package org.gradle.integtests.resolve.maven;

import org.gradle.integtests.fixtures.AbstractIntegrationSpec
import org.gradle.util.Requires
import org.gradle.util.TestPrecondition
import spock.lang.Issue

class MavenDependencyManagementImportOrderTest extends AbstractIntegrationSpec {
	@Issue("https://github.com/gradle/gradle/issues/2212")
    @Requires(TestPrecondition.ONLINE)
	def "Verify that gradle resolves org.wildfly.swarm:undertow the same as maven"() {
		when:
		buildFile.text = """
${mavenCentralRepository()}
configurations {
	test
}
dependencies {
	test('org.wildfly.swarm:undertow:2017.5.0') {
		exclude module: 'javax.el-impl'
	}
}
task verifyUndertowVersion {
	doLast {	
		def fileNames = configurations.test.files.collect { it.name }
		assert fileNames.contains('undertow-servlet-1.4.11.Final.jar')
		assert !fileNames.contains('undertow-servlet-1.2.9.Final.jar')
	}
}
		"""

		then:
		succeeds 'verifyUndertowVersion'
	}

	@Issue("https://github.com/gradle/gradle/issues/2212")
	def "Verify that if multiple boms declare the same dependency, the first bom wins"() {
		file("mavenRoot/group/level1/1/level1-1.pom").text = '''\


  4.0.0
  group
  level1
  1
  jar
  
    
      
        group
        bom1
        1
        import
      
      
        group
        bom2
        1
        import
      
    
  
  
    
      group
      level2
    
  
'''

		file("mavenRoot/group/level1/1/level1-1.jar").text = 'foo'

		file("mavenRoot/group/bom1/1/bom1-1.pom").text = '''\


  4.0.0
  group
  bom1
  1
  pom
  
    
      
        group
        level2
        1
      
    
  
'''

		file("mavenRoot/group/bom2/1/bom2-1.pom").text = '''\


  4.0.0
  group
  bom2
  1
  pom
  
    
      
        group
        level2
        2
      
    
  
'''

		file("mavenRoot/group/level2/1/level2-1.pom").text = '''\


  4.0.0
  group
  level2
  1
  jar
'''

		file("mavenRoot/group/level2/1/level2-1.jar").text = 'foo'

		file("mavenRoot/group/level2/2/level2-2.pom").text = '''\


  4.0.0
  group
  level2
  1
  jar
'''

		file("mavenRoot/group/level2/2/level2-2.jar").text = 'foo'

		when:
		buildFile.text = '''
repositories {
	maven {
		url uri(file('mavenRoot'))
	}
}
configurations {
	test
}
dependencies {
	test 'group:level1:1'
}
task verifyVersion {
	doLast {
		def fileNames = configurations.test.files.collect { it.name }
		assert fileNames.contains('level1-1.jar')
		assert fileNames.contains('level2-1.jar')
		assert !fileNames.contains('level2-2.jar')
	}
}
		'''

		then:
		succeeds 'verifyVersion'
	}


}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy