Skip to content

Commit

Permalink
Remove Nebula alignment implementation. Core Alignment is default now (
Browse files Browse the repository at this point in the history
…#138)

* Switch to build service for sharing resolved rules between projects

* ResolutionRulesPluginSpec.groovy: add test that shows issue with rejection rule when requested version is valid but still rejected

* Fix issue with version selector not being available when applying reject rule

* Remove Nebula alignment implementation. Core Alignment is default now

Co-authored-by: Danny Thomas <dannyt@netflix.com>
  • Loading branch information
rpalcolea and DanielThomas committed Sep 30, 2021
1 parent 5a31812 commit dfb8a5b
Show file tree
Hide file tree
Showing 26 changed files with 785 additions and 2,372 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/nebula.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ jobs:
restore-keys: |
- ${{ runner.os }}-gradlewrapper-
- name: Gradle build
run: ./gradlew --info --stacktrace build
run: ./gradlew --info --stacktrace build --scan
- name: Post-success actions
if: success()
run: ./gradlew jacocoTestReport coveralls
Expand Down
3 changes: 1 addition & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,7 @@ gradlePlugin {
}

tasks.integrationTest {
// alignment is determined via a system property, so we don't want to share state
forkEvery = 1
maxParallelForks = (int) (Runtime.getRuntime().availableProcessors() / 2 + 1)
}

pluginBundle {
Expand Down
26 changes: 10 additions & 16 deletions settings.gradle
Original file line number Diff line number Diff line change
@@ -1,18 +1,12 @@
/*
* Copyright 2015 Netflix, Inc.
*
* 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.
*
*/
plugins {
id "com.gradle.enterprise" version "3.7"
}

gradleEnterprise {
buildScan {
termsOfServiceUrl = "https://gradle.com/terms-of-service"
termsOfServiceAgree = "yes"
}
}

rootProject.name = 'gradle-resolution-rules-plugin'
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class AbstractAlignAndMigrateSpec extends AbstractAlignRulesSpec {
mavenrepo = new GradleDependencyGenerator(graph, "${projectDir}/testrepogen").generateTestMavenRepo()
}

Collection<String> dependencyInsightTasks(boolean coreAlignment) {
return ['dependencyInsight', '--dependency', 'test.nebula', "-Dnebula.features.coreAlignmentSupport=$coreAlignment"]
Collection<String> dependencyInsightTasks() {
return ['dependencyInsight', '--dependency', 'test.nebula']
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,11 @@ class AbstractRulesWithSpringBootPluginSpec extends IntegrationTestKitSpec {
""".stripIndent()
}

static def tasks(Boolean usingCoreAlignment, String groupForInsight = 'org.springframework:') {
static def tasks(String groupForInsight = 'org.springframework:') {
return [
'dependencyInsight',
'--dependency',
groupForInsight,
"-Dnebula.features.coreAlignmentSupport=$usingCoreAlignment"
groupForInsight
]
}

Expand Down Expand Up @@ -144,4 +143,4 @@ ext {$additionalExtProperty
file.createNewFile()
file << output
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class AlignAndLockWithDowngradedTransitiveDependenciesSpec extends IntegrationTe
}

@Unroll
def 'use downgraded version via a static major.minor.patch force on a transitive dependency - core alignment #coreAlignment | core locking #coreLocking'() {
def 'use downgraded version via a static major.minor.patch force on a transitive dependency | core locking #coreLocking'() {
given:
setupDependenciesAndAdjustBuildFile()
buildFile << """
Expand All @@ -56,24 +56,21 @@ class AlignAndLockWithDowngradedTransitiveDependenciesSpec extends IntegrationTe
""".stripIndent()

when:
def results = runTasks(*insightTasks(coreAlignment, coreLocking))
runTasks(*lockingTasks(coreAlignment, coreLocking))
def afterLockingResults = runTasks(*insightTasks(coreAlignment, coreLocking))
def results = runTasks(*insightTasks(coreLocking))
runTasks(*lockingTasks(coreLocking))
def afterLockingResults = runTasks(*insightTasks(coreLocking))

then:
dependenciesAreAligned(results.output, '2.9.9')
dependenciesAreAligned(afterLockingResults.output, '2.9.9')
micropatchVersionIsNotUsed(results.output, afterLockingResults.output, '2.9.9')

where:
coreAlignment | coreLocking
false | false
true | false
true | true
coreLocking << [false, true]
}

@Unroll
def 'use downgraded version via a dynamic major.minor.+ force on a transitive dependency - core alignment #coreAlignment | core locking #coreLocking'() {
def 'use downgraded version via a dynamic major.minor.+ force on a transitive dependency | core locking #coreLocking'() {
given:
setupDependenciesAndAdjustBuildFile()
buildFile << """
Expand All @@ -85,24 +82,21 @@ class AlignAndLockWithDowngradedTransitiveDependenciesSpec extends IntegrationTe
""".stripIndent()

when:
def results = runTasks(*insightTasks(coreAlignment, coreLocking))
runTasks(*lockingTasks(coreAlignment, coreLocking))
def afterLockingResults = runTasks(*insightTasks(coreAlignment, coreLocking))
def results = runTasks(*insightTasks(coreLocking))
runTasks(*lockingTasks(coreLocking))
def afterLockingResults = runTasks(*insightTasks(coreLocking))

then:
dependenciesAreAligned(results.output, '2.9.10')
dependenciesAreAligned(afterLockingResults.output, '2.9.10')
micropatchVersionIsNotUsed(results.output, afterLockingResults.output, '2.9.10')

where:
coreAlignment | coreLocking
false | false
true | false
true | true
coreLocking << [false, true]
}

@Unroll
def 'use downgraded version via a static major.minor.patch.micropatch forces on a transitive dependency - core alignment #coreAlignment | core locking #coreLocking'() {
def 'use downgraded version via a static major.minor.patch.micropatch forces on a transitive dependency| core locking #coreLocking'() {
given:
setupDependenciesAndAdjustBuildFile()
buildFile << """
Expand All @@ -114,24 +108,21 @@ class AlignAndLockWithDowngradedTransitiveDependenciesSpec extends IntegrationTe
""".stripIndent()

when:
def results = runTasks(*insightTasks(coreAlignment, coreLocking))
runTasks(*lockingTasks(coreAlignment, coreLocking))
def afterLockingResults = runTasks(*insightTasks(coreAlignment, coreLocking))
def results = runTasks(*insightTasks(coreLocking))
runTasks(*lockingTasks(coreLocking))
def afterLockingResults = runTasks(*insightTasks(coreLocking))

then:
dependenciesAreAligned(results.output, '2.9.9')
dependenciesAreAligned(afterLockingResults.output, '2.9.9')
micropatchVersionIsUsed(results.output, afterLockingResults.output, '2.9.9') // hurray!

where:
coreAlignment | coreLocking
false | false
true | false
true | true
coreLocking << [false, true]
}

@Unroll
def 'use downgraded version via a static major.minor.patch strict constraint on a transitive dependency - core alignment #coreAlignment | core locking #coreLocking'() {
def 'use downgraded version via a static major.minor.patch strict constraint on a transitive dependency| core locking #coreLocking'() {
setupDependenciesAndAdjustBuildFile()
buildFile << """
dependencies {
Expand All @@ -151,24 +142,21 @@ class AlignAndLockWithDowngradedTransitiveDependenciesSpec extends IntegrationTe
""".stripIndent()

when:
def results = runTasks(*insightTasks(coreAlignment, coreLocking))
runTasks(*lockingTasks(coreAlignment, coreLocking))
def afterLockingResults = runTasks(*insightTasks(coreAlignment, coreLocking))
def results = runTasks(*insightTasks(coreLocking))
runTasks(*lockingTasks(coreLocking))
def afterLockingResults = runTasks(*insightTasks(coreLocking))

then:
dependenciesAreAligned(results.output, '2.9.9')
dependenciesAreAligned(afterLockingResults.output, '2.9.9')
micropatchVersionIsNotUsed(results.output, afterLockingResults.output, '2.9.9')

where:
coreAlignment | coreLocking
// false | false // this is not successful
true | false
true | true
coreLocking << [false, true]
}

@Unroll
def 'use downgraded version via a dynamic major.minor.+ strict constraint on a transitive dependency - core alignment #coreAlignment | core locking #coreLocking'() {
def 'use downgraded version via a dynamic major.minor.+ strict constraint on a transitive dependency| core locking #coreLocking'() {
setupDependenciesAndAdjustBuildFile()
buildFile << """
dependencies {
Expand All @@ -190,24 +178,21 @@ class AlignAndLockWithDowngradedTransitiveDependenciesSpec extends IntegrationTe
""".stripIndent()

when:
def results = runTasks(*insightTasks(coreAlignment, coreLocking))
runTasks(*lockingTasks(coreAlignment, coreLocking))
def afterLockingResults = runTasks(*insightTasks(coreAlignment, coreLocking))
def results = runTasks(*insightTasks(coreLocking))
runTasks(*lockingTasks(coreLocking))
def afterLockingResults = runTasks(*insightTasks(coreLocking))

then:
dependenciesAreAligned(results.output, '2.9.10')
dependenciesAreAligned(afterLockingResults.output, '2.9.10')
micropatchVersionIsNotUsed(results.output, afterLockingResults.output, '2.9.10')

where:
coreAlignment | coreLocking
// false | false // this is not successful
true | false
true | true
coreLocking << [false, true]
}

@Unroll
def 'use downgraded version via matching forces with static major.minor.patch version - core alignment #coreAlignment | core locking #coreLocking'() {
def 'use downgraded version via matching forces with static major.minor.patch version| core locking #coreLocking'() {
given:
setupDependenciesAndAdjustBuildFile()
buildFile << """
Expand All @@ -223,24 +208,21 @@ class AlignAndLockWithDowngradedTransitiveDependenciesSpec extends IntegrationTe
""".stripIndent()

when:
def results = runTasks(*insightTasks(coreAlignment, coreLocking))
runTasks(*lockingTasks(coreAlignment, coreLocking))
def afterLockingResults = runTasks(*insightTasks(coreAlignment, coreLocking))
def results = runTasks(*insightTasks(coreLocking))
runTasks(*lockingTasks(coreLocking))
def afterLockingResults = runTasks(*insightTasks(coreLocking))

then:
dependenciesAreAligned(results.output, '2.9.9')
dependenciesAreAligned(afterLockingResults.output, '2.9.9')
micropatchVersionIsUsed(results.output, afterLockingResults.output, '2.9.9') // hurray!

where:
coreAlignment | coreLocking
false | false
true | false
true | true
coreLocking << [false, true]
}

@Unroll
def 'use downgraded version via matching forces with dynamic major.minor.+ version - core alignment #coreAlignment | core locking #coreLocking'() {
def 'use downgraded version via matching forces with dynamic major.minor.+ version| core locking #coreLocking'() {
given:
setupDependenciesAndAdjustBuildFile()
buildFile << """
Expand All @@ -256,28 +238,23 @@ class AlignAndLockWithDowngradedTransitiveDependenciesSpec extends IntegrationTe
""".stripIndent()

when:
def results = runTasks(*insightTasks(coreAlignment, coreLocking))
runTasks(*lockingTasks(coreAlignment, coreLocking))
def afterLockingResults = runTasks(*insightTasks(coreAlignment, coreLocking))
def results = runTasks(*insightTasks(coreLocking))
runTasks(*lockingTasks(coreLocking))
def afterLockingResults = runTasks(*insightTasks(coreLocking))

then:
dependenciesAreAligned(results.output, '2.9.10')
dependenciesAreAligned(afterLockingResults.output, '2.9.10')
micropatchVersionIsUsed(results.output, afterLockingResults.output, '2.9.10') // hurray!

where:
coreAlignment | coreLocking
false | false
true | false
true | true
coreLocking << [false, true]
}

@Unroll
def 'use downgraded version via virtual platform constraint with static major.minor.patch version - core alignment only | core locking #coreLocking'() {
def 'use downgraded version via virtual platform constraint with static major.minor.patch version | core locking #coreLocking'() {
// note: platform constraints like this are only possible with core Gradle alignment
given:
def coreAlignment = true

setupDependenciesAndAdjustBuildFile()
buildFile << """
dependencies {
Expand All @@ -291,9 +268,9 @@ class AlignAndLockWithDowngradedTransitiveDependenciesSpec extends IntegrationTe
""".stripIndent()

when:
def results = runTasks(*insightTasks(coreAlignment, coreLocking))
runTasks(*lockingTasks(coreAlignment, coreLocking))
def afterLockingResults = runTasks(*insightTasks(coreAlignment, coreLocking))
def results = runTasks(*insightTasks(coreLocking))
runTasks(*lockingTasks(coreLocking))
def afterLockingResults = runTasks(*insightTasks(coreLocking))

then:
dependenciesAreAligned(results.output, '2.9.9')
Expand All @@ -308,11 +285,9 @@ class AlignAndLockWithDowngradedTransitiveDependenciesSpec extends IntegrationTe

@Unroll
@Ignore("This does not end up with aligned dependencies. This is raised to Gradle")
def 'use downgraded version via virtual platform constraint with static major.minor.patch.micropatch version - core alignment only | core locking #coreLocking'() {
def 'use downgraded version via virtual platform constraint with static major.minor.patch.micropatch version | core locking #coreLocking'() {
// note: platform constraints like this are only possible with core Gradle alignment
given:
def coreAlignment = true

setupDependenciesAndAdjustBuildFile()
buildFile << """
dependencies {
Expand All @@ -326,9 +301,9 @@ class AlignAndLockWithDowngradedTransitiveDependenciesSpec extends IntegrationTe
""".stripIndent()

when:
def results = runTasks(*insightTasks(coreAlignment, coreLocking))
runTasks(*lockingTasks(coreAlignment, coreLocking))
def afterLockingResults = runTasks(*insightTasks(coreAlignment, coreLocking))
def results = runTasks(*insightTasks(coreLocking))
runTasks(*lockingTasks(coreLocking))
def afterLockingResults = runTasks(*insightTasks(coreLocking))

then:
dependenciesAreAligned(results.output, '2.9.9')
Expand All @@ -342,10 +317,9 @@ class AlignAndLockWithDowngradedTransitiveDependenciesSpec extends IntegrationTe
}

@Unroll
def 'use downgraded version via virtual platform constraint with dynamic version #version - core alignment only'() {
def 'use downgraded version via virtual platform constraint with dynamic version #version'() {
// note: platform constraints like this are only possible with core Gradle alignment
// this test verifies the current non-working behavior so that we can track when it changes
def coreAlignment = true
setupDependenciesAndAdjustBuildFile()
buildFile << """
dependencies {
Expand All @@ -359,7 +333,7 @@ class AlignAndLockWithDowngradedTransitiveDependenciesSpec extends IntegrationTe
""".stripIndent()

when:
def results = runTasksAndFail('dependencyInsight', '--dependency', 'com.fasterxml.jackson', "-Dnebula.features.coreAlignmentSupport=$coreAlignment", "--singlepath")
def results = runTasksAndFail('dependencyInsight', '--dependency', 'com.fasterxml.jackson', "--singlepath")

then:
results.output.contains('> fromIndex = -1')
Expand All @@ -370,19 +344,19 @@ class AlignAndLockWithDowngradedTransitiveDependenciesSpec extends IntegrationTe
DYNAMIC_RANGE | _
}

private static def insightTasks(boolean coreAlignment, boolean coreLocking) {
['dependencies', '--configuration', 'compileClasspath', *flags(coreAlignment, coreLocking)]
private static def insightTasks(boolean coreLocking) {
['dependencies', '--configuration', 'compileClasspath', *flags(coreLocking)]
}

private static def lockingTasks(boolean coreAlignment, boolean coreLocking) {
private static def lockingTasks(boolean coreLocking) {
if (coreLocking) {
return ['dependencies', '--write-locks', '--configuration', 'compileClasspath', *flags(coreAlignment, coreLocking)]
return ['dependencies', '--write-locks', '--configuration', 'compileClasspath', *flags(coreLocking)]
}
return ['generateLock', 'saveLock', *flags(coreAlignment, coreLocking)]
return ['generateLock', 'saveLock', *flags(coreLocking)]
}

private static def flags(boolean coreAlignment, boolean coreLocking) {
return ["-Dnebula.features.coreAlignmentSupport=${coreAlignment}", "-Dnebula.features.coreLockingSupport=${coreLocking}"]
private static def flags(boolean coreLocking) {
return ["-Dnebula.features.coreLockingSupport=${coreLocking}"]
}

private void setupDependenciesAndAdjustBuildFile(String version = "2.10.5") {
Expand Down

0 comments on commit dfb8a5b

Please sign in to comment.