Skip to content

Add harness to allow smooth transition for 5.x #598

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

Merged
merged 10 commits into from
Jun 5, 2020
22 changes: 18 additions & 4 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,17 @@ jobs:
command: ./gradlew :plugin-maven:check --build-cache
- store_test_results:
path: plugin-maven/build/test-results/test
test_gradle_modern_8:
<< : *env_gradle
steps:
- checkout
- *restore_cache_wrapper
- *restore_cache_deps
- run:
name: gradlew :plugin-gradle:modernTest
command: ./gradlew :plugin-gradle:modernTest --build-cache
- store_test_results:
path: plugin-gradle/build/test-results/modernTest
test_npm_8:
<< : *env_gradle
docker:
Expand Down Expand Up @@ -128,8 +139,8 @@ jobs:
# do the test
- restore_cache:
keys:
- gradle-deps-win-{{ checksum "build.gradle" }}-{{ checksum "gradle.properties" }}
- gradle-deps-win-
- gradle-deps-win2-{{ checksum "build.gradle" }}-{{ checksum "gradle.properties" }}
- gradle-deps-win2-
- run:
name: gradlew check
command: gradlew check --build-cache
Expand All @@ -142,12 +153,12 @@ jobs:
- store_test_results:
path: plugin-maven/build/test-results/test
- save_cache:
key: gradle-deps-win2-{{ checksum "build.gradle" }}-{{ checksum "gradle.properties" }}
paths:
- ~/.gradle/caches
- ~/.gradle/wrapper
- ~/.m2
- ~/project/plugin-maven/build/localMavenRepository
key: gradle-deps-win-{{ checksum "build.gradle" }}-{{ checksum "gradle.properties" }}
changelog_print:
<< : *env_gradle
steps:
Expand Down Expand Up @@ -215,7 +226,10 @@ workflows:
- test_npm_8:
requires:
- assemble_testClasses
deploy:
- test_gradle_modern_8:
requires:
- assemble_testClasses
deploy:
jobs:
- changelog_print:
filters:
Expand Down
2 changes: 2 additions & 0 deletions plugin-gradle/CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
We adhere to the [keepachangelog](https://keepachangelog.com/en/1.0.0/) format (starting after version `3.27.0`).

## [Unreleased]
### Added
* (spotless devs only) if you specify `-PspotlessModern=true` Spotless will run the in-progress Gradle `5.4+` code. The `modernTest` build task runs our test suite in this way. It will be weeks/months before this is recommended for end-users. ([#598](https://github.com/diffplug/spotless/pull/598))

## [4.2.1] - 2020-06-04
### Fixed
Expand Down
7 changes: 7 additions & 0 deletions plugin-gradle/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,13 @@ task npmTest(type: Test) {
}
}

task modernTest(type: Test) {
systemProperty 'spotlessModern', 'true'
useJUnit {
excludeCategories 'com.diffplug.spotless.category.NpmTest', 'com.diffplug.gradle.spotless.ExcludeFromPluginGradleModern'
}
}

// make it easy for eclipse to run against latest build
tasks.eclipse.dependsOn(pluginUnderTestMetadata)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
public class CppExtension extends FormatExtension implements HasBuiltinDelimiterForLicense {
static final String NAME = "cpp";

public CppExtension(SpotlessExtension spotless) {
public CppExtension(SpotlessExtensionBase spotless) {
super(spotless);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
public class CssExtension extends FormatExtension implements HasBuiltinDelimiterForLicense {
static final String NAME = "css";

public CssExtension(SpotlessExtension spotless) {
public CssExtension(SpotlessExtensionBase spotless) {
super(spotless);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,9 @@

/** Adds a `spotless{Name}Check` and `spotless{Name}Apply` task. */
public class FormatExtension {
final SpotlessExtension spotless;
final SpotlessExtensionBase spotless;

public FormatExtension(SpotlessExtension spotless) {
public FormatExtension(SpotlessExtensionBase spotless) {
this.spotless = Objects.requireNonNull(spotless);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public class FreshMarkExtension extends FormatExtension {

public final List<Action<Map<String, Object>>> propertyActions = new ArrayList<>();

public FreshMarkExtension(SpotlessExtension spotless) {
public FreshMarkExtension(SpotlessExtensionBase spotless) {
super(spotless);
addStep(FreshMarkStep.create(() -> {
Map<String, Object> map = new HashMap<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,15 @@
import com.diffplug.common.collect.ImmutableList;
import com.diffplug.spotless.Provisioner;

/** Gradle integration for Provisioner. */
/** Should be package-private. */
@Deprecated
public class GradleProvisioner {
private GradleProvisioner() {}

// @Deprecated
// public static Provisioner fromProject(Project project) {
// return project.getPlugins().apply(SpotlessPlugin.class).getExtension().registerDependenciesTask.rootProvisioner;
// }
@Deprecated
public static Provisioner fromProject(Project project) {
return project.getPlugins().apply(SpotlessPlugin.class).getExtension().registerDependenciesTask.rootProvisioner;
}

/** The provisioner used for the root project. */
static class RootProvisioner implements Provisioner {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
public class GroovyExtension extends FormatExtension implements HasBuiltinDelimiterForLicense {
static final String NAME = "groovy";

public GroovyExtension(SpotlessExtension spotless) {
public GroovyExtension(SpotlessExtensionBase spotless) {
super(spotless);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public class GroovyGradleExtension extends FormatExtension {
private static final String GRADLE_FILE_EXTENSION = "*.gradle";
static final String NAME = "groovyGradle";

public GroovyGradleExtension(SpotlessExtension spotless) {
public GroovyGradleExtension(SpotlessExtensionBase spotless) {
super(spotless);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
public class JavaExtension extends FormatExtension implements HasBuiltinDelimiterForLicense {
static final String NAME = "java";

public JavaExtension(SpotlessExtension spotless) {
public JavaExtension(SpotlessExtensionBase spotless) {
super(spotless);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
public class KotlinExtension extends FormatExtension implements HasBuiltinDelimiterForLicense {
static final String NAME = "kotlin";

public KotlinExtension(SpotlessExtension spotless) {
public KotlinExtension(SpotlessExtensionBase spotless) {
super(spotless);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public class KotlinGradleExtension extends FormatExtension {

static final String NAME = "kotlinGradle";

public KotlinGradleExtension(SpotlessExtension spotless) {
public KotlinGradleExtension(SpotlessExtensionBase spotless) {
super(spotless);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
public class ScalaExtension extends FormatExtension {
static final String NAME = "scala";

public ScalaExtension(SpotlessExtension spotless) {
public ScalaExtension(SpotlessExtensionBase spotless) {
super(spotless);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2016 DiffPlug
* Copyright 2016-2020 DiffPlug
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -30,10 +30,10 @@
import org.gradle.api.tasks.TaskAction;

public class SpotlessApply extends DefaultTask {
private SpotlessTask source;
private SpotlessTaskBase source;

/** Bidirectional link between Apply and Spotless allows check to know if Apply ran or not. */
void linkSource(SpotlessTask source) {
void linkSource(SpotlessTaskBase source) {
this.source = source;
source.applyTask = this;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
import com.diffplug.spotless.extra.integration.DiffMessageFormatter;

public class SpotlessCheck extends DefaultTask {
SpotlessTask source;
SpotlessTaskBase source;
private File spotlessOutDirectory;

@PathSensitive(PathSensitivity.RELATIVE)
Expand Down Expand Up @@ -81,9 +81,10 @@ public void visitFile(FileVisitDetails fileVisitDetails) {
});

if (!problemFiles.isEmpty()) {
Formatter formatter = source.buildFormatter();
Collections.sort(problemFiles);
throw formatViolationsFor(formatter, problemFiles);
try (Formatter formatter = source.buildFormatter()) {
Collections.sort(problemFiles);
throw formatViolationsFor(formatter, problemFiles);
}
}
}
}
Expand Down
Loading