Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions changelog/@unreleased/pr-1584.v2.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
type: improvement
improvement:
description: checkExplicitSourceCompatabilityTask ignores projects without java
source
links:
- https://github.com/palantir/gradle-baseline/pull/1584
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import org.gradle.api.provider.Property;
import org.gradle.api.publish.PublishingExtension;
import org.gradle.api.specs.Spec;
import org.gradle.api.tasks.SourceSetContainer;
import org.gradle.api.tasks.TaskAction;
import org.gradle.api.tasks.options.Option;
import org.gradle.util.GradleVersion;
Expand Down Expand Up @@ -74,6 +75,14 @@ public boolean isSatisfiedBy(Task element) {
return !publishing.getPublications().isEmpty();
}
});
onlyIf(new Spec<Task>() {
@Override
public boolean isSatisfiedBy(Task task) {
return getProject().getExtensions().getByType(SourceSetContainer.class).stream()
.anyMatch(
sourceSet -> !sourceSet.getAllJava().getFiles().isEmpty());
}
});
}

@Option(option = "fix", description = "Whether to apply the suggested fix to build.gradle")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ class BaselineReproducibilityIntegrationSpec extends IntegrationSpec {
writeHelloWorld()

then:
runTasksSuccessfully("checkExplicitSourceCompatibility")
def result = runTasksSuccessfully("checkExplicitSourceCompatibility")
}

def 'no-op if nothing is published'() {
Expand All @@ -87,4 +87,26 @@ class BaselineReproducibilityIntegrationSpec extends IntegrationSpec {
def output = runTasksSuccessfully("check")
output.getStandardOutput().contains("> Task :checkExplicitSourceCompatibility SKIPPED")
}

def 'no-op if there is not source'() {
when:
buildFile << """
${applyPlugin(BaselineReproducibility.class)}
apply plugin: 'java'
apply plugin: 'maven-publish'
version '1.2.3'

publishing {
publications {
maven(MavenPublication) {
from components.java
}
}
}
""".stripIndent()

then:
def output = runTasksSuccessfully("check")
output.getStandardOutput().contains("> Task :checkExplicitSourceCompatibility SKIPPED")
}
}