Skip to content

Commit

Permalink
testImplementation should not be included by default
Browse files Browse the repository at this point in the history
 - Adding runtimeClasspath, compileClasspath and annotationProcessorPath to default includeConfigs

Signed-off-by: Johan Blomgren <[email protected]>
  • Loading branch information
blommish committed Sep 11, 2024
1 parent 37e0e45 commit 046f7af
Show file tree
Hide file tree
Showing 5 changed files with 76 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/main/java/org/cyclonedx/gradle/CycloneDxTask.java
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@
import org.gradle.api.artifacts.ResolvedArtifact;
import org.gradle.api.artifacts.ResolvedConfiguration;
import org.gradle.api.artifacts.ResolvedDependency;
import org.gradle.api.file.ProjectLayout;
import org.gradle.api.provider.ListProperty;
import org.gradle.api.provider.Property;
import org.gradle.api.tasks.Input;
Expand Down Expand Up @@ -135,6 +134,7 @@ public CycloneDxTask() {
componentVersion.convention(getProject().getVersion().toString());

includeConfigs = getProject().getObjects().listProperty(String.class);
includeConfigs.addAll("runtimeClasspath", "compileClasspath", "annotationProcessor");
skipConfigs = getProject().getObjects().listProperty(String.class);
skipProjects = getProject().getObjects().listProperty(String.class);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,49 @@ class PluginConfigurationSpec extends Specification {
assert !jsonBom.text.contains("serialNumber")
}

def "kotlin-dsl-project default config should not contain testImplementation"() {
given:
File testDir = TestUtils.duplicate("kotlin-project")

when:
def result = GradleRunner.create()
.withProjectDir(testDir)
.withArguments("cyclonedxBom", "--info", "-S")
.withPluginClasspath()
.build()

then:
// result.task(":cyclonedxBom").outcome == TaskOutcome.SUCCESS
File reportDir = new File(testDir, "build/reports")

assert reportDir.exists()
reportDir.listFiles().length == 2
File jsonBom = new File(reportDir, "bom.json")
assert !jsonBom.text.contains("commons-compress")
}

def "kotlin-dsl-project setting value with default value should be overwritten"() {
given:
File testDir = TestUtils.duplicate("kotlin-project-overwriting-default-value")

when:
def result = GradleRunner.create()
.withProjectDir(testDir)
.withArguments("cyclonedxBom", "--info", "-S")
.withPluginClasspath()
.build()

then:
// result.task(":cyclonedxBom").outcome == TaskOutcome.SUCCESS
File reportDir = new File(testDir, "build/reports")
println result.getOutput()

assert reportDir.exists()
reportDir.listFiles().length == 2
File jsonBom = new File(reportDir, "bom.json")
assert jsonBom.text.contains("commons-compress")
}

def "kotlin-dsl-project-manufacture-licenses should allow definition of manufacture-data and licenses-data"() {
given:
File testDir = TestUtils.duplicate("kotlin-project-manufacture-licenses")
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
plugins {
java
id("org.cyclonedx.bom") version "1.7.1"
}

repositories {
mavenLocal()
mavenCentral()
}

group = "com.example"
version = "1.0.0"

dependencies {
implementation("com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.8.11")
implementation("org.springframework.boot:spring-boot-starter-web:1.5.18.RELEASE")
testImplementation("org.apache.commons:commons-compress:1.24.0")
}

tasks.cyclonedxBom {
setIncludeConfigs(listOf())
setIncludeBomSerialNumber(false)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
rootProject.name = "kotlin-dsl-project"
pluginManagement {
repositories {
mavenLocal()

mavenCentral()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ version = "1.0.0"
dependencies {
implementation("com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.8.11")
implementation("org.springframework.boot:spring-boot-starter-web:1.5.18.RELEASE")
testImplementation("org.apache.commons:commons-compress:1.24.0")
}

tasks.cyclonedxBom {
Expand Down

0 comments on commit 046f7af

Please sign in to comment.