Skip to content

Commit

Permalink
Make MavenRemoveInvalidDependenciesPlugin config cache compatible
Browse files Browse the repository at this point in the history
  • Loading branch information
rpalcolea committed Nov 15, 2023
1 parent 9eab5c0 commit 9f298df
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import org.gradle.api.publish.maven.MavenPublication
* Removes from descriptor dependencies that are invalid:
* 1) No version available
*/
@CompileDynamic
class MavenRemoveInvalidDependenciesPlugin implements Plugin<Project> {
@Override
void apply(Project project) {
Expand All @@ -52,7 +53,14 @@ class MavenRemoveInvalidDependenciesPlugin implements Plugin<Project> {

@Override
void execute(XmlProvider xml) {
removeDependencies(xml)
def dependencies = xml.asNode()?.dependencies?.dependency
dependencies?.each { Node dep ->
String version = dep.version.text()
if (!version) {
dep.parent().remove(dep)
}

}
}
})
}
Expand All @@ -63,18 +71,6 @@ class MavenRemoveInvalidDependenciesPlugin implements Plugin<Project> {
}
})
}

@CompileDynamic
private void removeDependencies(XmlProvider xml) {
def dependencies = xml.asNode()?.dependencies?.dependency
dependencies?.each { Node dep ->
String version = dep.version.text()
if (!version) {
dep.parent().remove(dep)
}

}
}
}


Original file line number Diff line number Diff line change
Expand Up @@ -16,21 +16,26 @@
package nebula.plugin.publishing.maven

import nebula.plugin.publishing.BaseIntegrationTestKitSpec
import nebula.plugin.publishing.publications.SpringBootJarPlugin
import spock.lang.Subject

@Subject(SpringBootJarPlugin)
class MavenNebulaSpringBootPublishPluginIntegrationSpec extends BaseIntegrationTestKitSpec {
def setup() {
keepFiles = true

// Because Spring Boot 2.x uses project.conventions
System.setProperty('ignoreDeprecations', 'true')
// spring dependency management does not support config cache. More in https://github.com/spring-gradle-plugins/dependency-management-plugin/issues/312
disableConfigurationCache()
buildFile << """\
plugins {
id 'com.netflix.nebula.maven-publish'
id 'org.springframework.boot' version '2.7.11'
id 'io.spring.dependency-management' version '1.0.11.RELEASE'
id 'org.springframework.boot' version '2.7.17'
id 'io.spring.dependency-management' version '1.1.4'
id 'java'
id "com.netflix.nebula.info" version "12.1.3"
id "com.netflix.nebula.contacts" version "7.0.0"
id "com.netflix.nebula.info" version "12.1.6"
id "com.netflix.nebula.contacts" version "7.0.1"
}
contacts {
Expand Down Expand Up @@ -101,7 +106,7 @@ public class DemoApplication {
def spring = dependencies.find { it.artifactId == 'spring-boot-starter-web' }

then:
spring.version == '2.7.11'
spring.version == '2.7.17'

when:
def jar = new File(projectDir, "build/libs/mavenpublishingtest-0.1.0.jar")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ package nebula.plugin.publishing.maven
import nebula.plugin.publishing.BaseIntegrationTestKitSpec
import nebula.test.dependencies.DependencyGraphBuilder
import nebula.test.dependencies.GradleDependencyGenerator
import spock.lang.Subject

@Subject(MavenRemoveInvalidDependenciesPlugin)
class MavenRemoveInvalidDependenciesPluginSpec extends BaseIntegrationTestKitSpec {
File publishDir

Expand Down

0 comments on commit 9f298df

Please sign in to comment.