Skip to content

Commit

Permalink
baseline-class-uniqueness is updated by ./gradlew --write-locks (#1153
Browse files Browse the repository at this point in the history
)

Running `./gradlew --write-locks` will now update the baseline-class-uniqueness.lock file.
  • Loading branch information
iamdanfox authored and bulldozer-bot[bot] committed Jan 9, 2020
1 parent 58f9cdc commit 0f9d0d0
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 4 deletions.
6 changes: 6 additions & 0 deletions changelog/@unreleased/pr-1153.v2.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
type: fix
fix:
description: Running `./gradlew --write-locks` will now update the baseline-class-uniqueness.lock
file.
links:
- https://github.com/palantir/gradle-baseline/pull/1153
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@

package com.palantir.baseline.plugins;

import com.google.common.collect.ImmutableList;
import com.palantir.baseline.tasks.CheckClassUniquenessLockTask;
import java.util.List;
import org.gradle.StartParameter;
import org.gradle.api.Project;
import org.gradle.api.plugins.JavaPlugin;
import org.gradle.api.tasks.TaskProvider;
Expand All @@ -32,14 +35,25 @@
public class BaselineClassUniquenessPlugin extends AbstractBaselinePlugin {
@Override
public final void apply(Project project) {
TaskProvider<CheckClassUniquenessLockTask> lockTask =
TaskProvider<CheckClassUniquenessLockTask> checkClassUniqueness =
project.getTasks().register("checkClassUniqueness", CheckClassUniquenessLockTask.class);
project.getPlugins().apply(LifecycleBasePlugin.class);
project.getTasks().getByName(LifecycleBasePlugin.CHECK_TASK_NAME).dependsOn(lockTask);
project.getTasks().getByName(LifecycleBasePlugin.CHECK_TASK_NAME).dependsOn(checkClassUniqueness);

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

// Wire up dependencies so running `./gradlew --write-locks` will update the lock file
StartParameter startParam = project.getGradle().getStartParameter();
if (startParam.isWriteDependencyLocks()
&& !startParam.getTaskNames().contains(checkClassUniqueness.getName())) {
List<String> taskNames = ImmutableList.<String>builder()
.addAll(startParam.getTaskNames())
.add(checkClassUniqueness.getName())
.build();
startParam.setTaskNames(taskNames);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ class BaselineClassUniquenessPluginIntegrationTest extends AbstractPluginTest {
result.getOutput().contains("javax.el.ArrayELResolver");
!lockfile.exists()

with("checkClassUniqueness", "--write-locks").build()
with("--write-locks").build()
lockfile.exists()

File expected = new File("src/test/resources/com/palantir/baseline/baseline-class-uniqueness.expected.lock")
Expand Down

0 comments on commit 0f9d0d0

Please sign in to comment.