Skip to content

Commit

Permalink
checkClassUniqueness works with conjure (#1250)
Browse files Browse the repository at this point in the history
checkClassUniqueness should now behave consistently when asked to analyze configurations that are `builtBy` other tasks (e.g. gradle-conjure, gradle-atlas)
  • Loading branch information
iamdanfox authored Feb 20, 2020
1 parent 2784a78 commit e890e1c
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 4 deletions.
6 changes: 6 additions & 0 deletions changelog/@unreleased/pr-1250.v2.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
type: fix
fix:
description: checkClassUniqueness should now behave consistently when asked to analyze
configurations that are `builtBy` other tasks (e.g. gradle-conjure, gradle-atlas)
links:
- https://github.com/palantir/gradle-baseline/pull/1250
2 changes: 1 addition & 1 deletion docs/best-practices/java-coding-guidelines/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ topics:
all offices)
- Java Concurrency in Practice (copies exist in all offices)
- [Writing Testable Code](http://misko.hevery.com/code-reviewers-guide/)
- [How to Design a GoodAPI and Why it Matters (Bloch)](http://lcsd05.cs.tamu.edu/slides/keynote.pdf)
- [How to Design a GoodAPI and Why it Matters (Bloch)](http://fwdinnovations.net/whitepaper/APIDesign.pdf)

## Miscellaneous

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import java.util.List;
import org.gradle.StartParameter;
import org.gradle.api.Project;
import org.gradle.api.artifacts.Configuration;
import org.gradle.api.plugins.JavaPlugin;
import org.gradle.api.tasks.TaskProvider;
import org.gradle.language.base.plugins.LifecycleBasePlugin;
Expand All @@ -41,8 +42,16 @@ public final void apply(Project project) {
project.getTasks().getByName(LifecycleBasePlugin.CHECK_TASK_NAME).dependsOn(checkClassUniqueness);

project.getPlugins().withId("java", plugin -> {
checkClassUniqueness.configure(t -> t.configurations.add(
project.getConfigurations().getByName(JavaPlugin.RUNTIME_CLASSPATH_CONFIGURATION_NAME)));
checkClassUniqueness.configure(t -> {
Configuration runtimeClasspath =
project.getConfigurations().getByName(JavaPlugin.RUNTIME_CLASSPATH_CONFIGURATION_NAME);
t.configurations.add(runtimeClasspath);

// runtimeClasspath might contain jars which are 'builtBy' other tasks, for example conjure-generated
// objects. This dependsOn ensures that all those pre-requisite tasks get invoked first, otherwise
// we see log.info warnings about missing jars e.g. 'Skipping non-existent jar foo-api-objects.jar'
t.dependsOn(runtimeClasspath);
});
});

// Wire up dependencies so running `./gradlew --write-locks` will update the lock file
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,6 @@ class BaselineIntegrationTest extends AbstractPluginTest {
with().withArguments('-s').withGradleVersion(gradleVersion).build()

where:
gradleVersion << ['5.4', '6.0-20190904072820+0000']
gradleVersion << ['5.4', '6.2']
}
}

0 comments on commit e890e1c

Please sign in to comment.