Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

checkClassUniqueness works with conjure #1250

Merged
merged 4 commits into from
Feb 20, 2020
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-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']
}
}