| + |
+ @@ -13,9 +13,16 @@
+ |
+
| + 13 + | +
+
+
+ * See the License for the specific language governing permissions and
+
+ |
+
| + 14 + | +
+
+
+ * limitations under the License.
+
+ |
+
| + 15 + | +
+
+
+ */
+
+ |
+
| + 16 + | +
+
+ -
+ package com.palantir.javaformat.gradle
+
+ |
+
| + 17 + | +
+
+
+
+ + |
+
| + 18 + | +
+
+ -
+ import
+ |
+
| + + | +
+
+
+
+ + |
+
| + + | +
+
+
+
+ + |
+
| + + | +
+
+
+
+ + |
+
| + + | +
+
+
+
+ + |
+
| + + | +
+
+
+
+ + |
+
| + + | +
+
+
+
+ + |
+
| + + | +
+
+
+
+ + |
+
| + 19 + | +
+
+
+
+ + |
+
| + 20 + | +
+
+
+ /**
+
+ |
+
| + 21 + | +
+
+
+ * When we were getting gradle-baseline to support the configuration cache, spotless had some poorly written tasks
+
+ |
+
| + |
+ @@ -28,24 +35,26 @@ import nebula.test.IntegrationTestKitSpec
+ |
+
| + 28 + | +
+
+
+ *
+
+ |
+
| + 29 + | +
+
+
+ * This test forces creation of the spotless steps, which will reveal any eager resolution of configurations.
+
+ |
+
| + 30 + | +
+
+
+ */
+
+ |
+
| + 31 + | +
+
+ -
+
+ |
+
| + + | +
+
+
+
+ + |
+
| + + | +
+
+
+
+ + |
+
| + 32 + | +
+
+
+ // ***DELINEATOR FOR REVIEW: CLASSPATH_FILE
+
+ |
+
| + 33 + | +
+
+ -
+ private static final CLASSPATH_FILE = new File("build/impl.classpath").
+ |
+
| + 34 + | +
+
+
+
+ + |
+
| + 35 + | +
+
+
+ // ***DELINEATOR FOR REVIEW: executor
+
+ |
+
| + 36 + | +
+
+ -
+ private GradlewExecutor executor
+
+ |
+
| + 37 + | +
+
+
+
+ + |
+
| + 38 + | +
+
+
+ // ***DELINEATOR FOR REVIEW: setup
+
+ |
+
| + 39 + | +
+
+ -
+
+ |
+
| + 40 + | +
+
+ -
+
+ |
+
| + 41 + | +
+
+ -
+
+ |
+
| + 42 + | +
+
+ -
+ executor = new GradlewExecutor(projectDir)
+
+ |
+
| + 43 + | +
+
+
+ }
+
+ |
+
| + 44 + | +
+
+
+
+ + |
+
| + 45 + | +
+
+
+ // ***DELINEATOR FOR REVIEW: palantir_java_format_plugin_works_with_spotless_6_22_0
+
+ |
+
| + 46 + | +
+
+ -
+
+ |
+
| + 47 + | +
+
+ -
+
+ |
+
| + 48 + | +
+
+ -
+
+ |
+
| + + | +
+
+
+
+ + |
+
| + 49 + | +
+
+
+ buildscript {
+
+ |
+
| + 50 + | +
+
+
+ repositories {
+
+ |
+
| + 51 + | +
+
+
+ mavenCentral() { metadataSources { mavenPom(); ignoreGradleMetadataRedirection() } }
+
+ |
+
| + |
+ @@ -56,38 +65,37 @@ class SupportsSpotless622 extends IntegrationTestKitSpec {
+ |
+
| + 56 + | +
+
+
+ classpath 'com.diffplug.spotless:spotless-plugin-gradle:6.22.0'
+
+ |
+
| + 57 + | +
+
+
+ }
+
+ |
+
| + 58 + | +
+
+
+ }
+
+ |
+
| + 59 + | +
+
+ -
+
+ |
+
| + 60 + | +
+
+
+ apply plugin: 'java'
+
+ |
+
| + 61 + | +
+
+
+ apply plugin: 'com.palantir.java-format'
+
+ |
+
| + 62 + | +
+
+
+ apply plugin: 'com.palantir.consistent-versions'
+
+ |
+
| + 63 + | +
+
+
+ apply plugin: 'com.diffplug.spotless'
+
+ |
+
| + 64 + | +
+
+ -
+
+
+ |
+
| + 65 + | +
+
+ -
+ version = '0.1.0'
+
+ |
+
| + 66 + | +
+
+ -
+ '''.stripIndent(true)
+
+ |
+
| + 67 + | +
+
+
+
+ + |
+
| + + | +
+
+
+
+ + |
+
| + + | +
+
+
+
+ + |
+
| + 68 + | +
+
+
+
+ + |
+
| + 69 + | +
+
+ -
+ file("versions.props")
+
+ |
+
| + 70 + | +
+
+ -
+ file("versions.lock")
+
+ |
+
| + 71 + | +
+
+
+
+ + |
+
| + 72 + | +
+
+ -
+
+ |
+
| + + | +
+
+
+
+ + |
+
| + + | +
+
+
+
+ + |
+
| + 73 + | +
+
+
+
+ + |
+
| + 74 + | +
+
+
+ // ***DELINEATOR FOR REVIEW: when
+
+ |
+
| + 75 + | +
+
+ -
+
+ |
+
| + 76 + | +
+
+
+ dependencies {
+
+ |
+
| + 77 + | +
+
+ -
+ palantirJavaFormat files(file("
+ |
+
| + 78 + | +
+
+
+ }
+
+ |
+
| + 79 + | +
+
+
+
+ + |
+
| + 80 + | +
+
+ -
+ // This forces the realization of the spotlessJava task, creating the spotless steps.
+ |
+
| + 81 + | +
+
+ -
+ // If any configurations are eagerly resolved in the spotless steps,
+ |
+
| + 82 + | +
+
+ -
+ // consistent-versions should catch it and throw here.
+ |
+
| + 83 + | +
+
+
+ project.getTasks().getByName("spotlessJava")
+
+ |
+
| + 84 + | +
+
+ -
+
+ |
+
| + 85 + | +
+
+
+
+ + |
+
| + 86 + | +
+
+ -
+
+ |
+
| + 87 + | +
+
+ -
+ def result = executor.runGradlewTasks('classes', '--info')
+
+ |
+
| + 88 + | +
+
+
+
+ + |
+
| + 89 + | +
+
+
+ // ***DELINEATOR FOR REVIEW: then
+
+ |
+
| + 90 + | +
+
+ -
+
+ |
+
| + 91 + | +
+
+ -
+ assert result.success
+
+ |
+
| + 92 + | +
+
+
+ }
+
+ |
+
| + 93 + | +
+
+
+ }
+
+ |
+
| + |
+ |
+
| + 13 + | +
+
+
+ * See the License for the specific language governing permissions and
+
+ |
+
| + 14 + | +
+
+
+ * limitations under the License.
+
+ |
+
| + 15 + | +
+
+
+ */
+
+ |
+
| + 16 + | +
+
+ +
+ package com.palantir.javaformat.gradle;
+
+ |
+
| + 17 + | +
+
+
+
+ + |
+
| + 18 + | +
+
+ +
+ import static org.assertj.core.api.Assertions.assertThat;
+
+ |
+
| + 19 + | +
+
+ +
+
+ + |
+
| + 20 + | +
+
+ +
+ import com.palantir.gradle.testing.junit.DisabledConfigurationCache;
+
+ |
+
| + 21 + | +
+
+ +
+ import com.palantir.gradle.testing.junit.GradlePluginTests;
+
+ |
+
| + 22 + | +
+
+ +
+ import com.palantir.gradle.testing.project.RootProject;
+
+ |
+
| + 23 + | +
+
+ +
+ import java.io.File;
+
+ |
+
| + 24 + | +
+
+ +
+ import org.junit.jupiter.api.BeforeEach;
+
+ |
+
| + 25 + | +
+
+ +
+ import org.junit.jupiter.api.Test;
+
+ |
+
| + 26 + | +
+
+
+
+ + |
+
| + 27 + | +
+
+
+ /**
+
+ |
+
| + 28 + | +
+
+
+ * When we were getting gradle-baseline to support the configuration cache, spotless had some poorly written tasks
+
+ |
+
| + |
+ |
+
| + 35 + | +
+
+
+ *
+
+ |
+
| + 36 + | +
+
+
+ * This test forces creation of the spotless steps, which will reveal any eager resolution of configurations.
+
+ |
+
| + 37 + | +
+
+
+ */
+
+ |
+
| + 38 + | +
+
+ +
+ @GradlePluginTests
+
+ |
+
| + 39 + | +
+
+ +
+ @DisabledConfigurationCache
+
+ |
+
| + 40 + | +
+
+ +
+ class SupportsSpotless622 {
+
+ |
+
| + 41 + | +
+
+
+ // ***DELINEATOR FOR REVIEW: CLASSPATH_FILE
+
+ |
+
| + 42 + | +
+
+ +
+ private static final String CLASSPATH_FILE = new File("build/impl.classpath").getAbsolutePath();
+
+ |
+
| + 43 + | +
+
+
+
+ + |
+
| + 44 + | +
+
+
+ // ***DELINEATOR FOR REVIEW: executor
+
+ |
+
| + 45 + | +
+
+ +
+ private GradlewExecutor executor;
+
+ |
+
| + 46 + | +
+
+
+
+ + |
+
| + 47 + | +
+
+
+ // ***DELINEATOR FOR REVIEW: setup
+
+ |
+
| + 48 + | +
+
+ +
+ @BeforeEach
+
+ |
+
| + 49 + | +
+
+ +
+ void setup(RootProject project) {
+
+ |
+
| + 50 + | +
+
+ +
+ executor = new GradlewExecutor(project.path().toFile());
+
+ |
+
| + + | +
+
+
+
+ + |
+
| + 51 + | +
+
+
+ }
+
+ |
+
| + 52 + | +
+
+
+
+ + |
+
| + 53 + | +
+
+
+ // ***DELINEATOR FOR REVIEW: palantir_java_format_plugin_works_with_spotless_6_22_0
+
+ |
+
| + 54 + | +
+
+ +
+ @Test
+
+ |
+
| + 55 + | +
+
+ +
+ @SuppressWarnings("GradleTestPluginsBlock") // Uses buildscript with apply plugin syntax intentionally
+
+ |
+
| + 56 + | +
+
+ +
+ void palantir_java_format_plugin_works_with_spotless_6_22_0(RootProject project) throws Exception {
+
+ |
+
| + 57 + | +
+
+ +
+ project.buildGradle().overwrite("""
+
+ |
+
| + 58 + | +
+
+
+ buildscript {
+
+ |
+
| + 59 + | +
+
+
+ repositories {
+
+ |
+
| + 60 + | +
+
+
+ mavenCentral() { metadataSources { mavenPom(); ignoreGradleMetadataRedirection() } }
+
+ |
+
| + |
+ |
+
| + 65 + | +
+
+
+ classpath 'com.diffplug.spotless:spotless-plugin-gradle:6.22.0'
+
+ |
+
| + 66 + | +
+
+
+ }
+
+ |
+
| + 67 + | +
+
+
+ }
+
+ |
+
| + 68 + | +
+
+ +
+
+ + |
+
| + 69 + | +
+
+
+ apply plugin: 'java'
+
+ |
+
| + 70 + | +
+
+
+ apply plugin: 'com.palantir.java-format'
+
+ |
+
| + 71 + | +
+
+
+ apply plugin: 'com.palantir.consistent-versions'
+
+ |
+
| + 72 + | +
+
+
+ apply plugin: 'com.diffplug.spotless'
+
+ |
+
| + + | +
+
+
+
+ + |
+
| + + | +
+
+
+
+ + |
+
| + + | +
+
+
+
+ + |
+
| + 73 + | +
+
+
+
+ + |
+
| + 74 + | +
+
+ +
+ version = '0.1.0'
+
+ |
+
| + 75 + | +
+
+ +
+ """);
+
+ |
+
| + 76 + | +
+
+
+
+ + |
+
| + 77 + | +
+
+ +
+ project.file("versions.props").createEmpty();
+
+ |
+
| + 78 + | +
+
+ +
+ project.file("versions.lock").createEmpty();
+
+ |
+
| + 79 + | +
+
+
+
+ + |
+
| + 80 + | +
+
+ +
+ // Run wrapper task to generate gradlew
+
+ |
+
| + 81 + | +
+
+ +
+ GradlewExecutor.GradlewExecutionResult wrapperResult = executor.runGradlewTasks("wrapper");
+
+ |
+
| + 82 + | +
+
+ +
+ assertThat(wrapperResult.success()).isTrue();
+
+ |
+
| + 83 + | +
+
+
+
+ + |
+
| + 84 + | +
+
+
+ // ***DELINEATOR FOR REVIEW: when
+
+ |
+
| + 85 + | +
+
+ +
+ project.buildGradle().append("""
+
+ |
+
| + 86 + | +
+
+
+ dependencies {
+
+ |
+
| + 87 + | +
+
+ +
+ palantirJavaFormat files(file("%s").text.split(':'))
+
+ |
+
| + 88 + | +
+
+
+ }
+
+ |
+
| + 89 + | +
+
+
+
+ + |
+
| + 90 + | +
+
+ +
+ // This forces the realization of the spotlessJava task, creating the spotless steps.
+
+ |
+
| + 91 + | +
+
+ +
+ // If any configurations are eagerly resolved in the spotless steps,
+
+ |
+
| + 92 + | +
+
+ +
+ // consistent-versions should catch it and throw here.
+
+ |
+
| + 93 + | +
+
+
+ project.getTasks().getByName("spotlessJava")
+
+ |
+
| + 94 + | +
+
+ +
+ """, CLASSPATH_FILE);
+
+ |
+
| + 95 + | +
+
+
+
+ + |
+
| + 96 + | +
+
+ +
+ GradlewExecutor.GradlewExecutionResult result = executor.runGradlewTasks("classes", "--info");
+
+ |
+
| + + | +
+
+
+
+ + |
+
| + 97 + | +
+
+
+
+ + |
+
| + 98 + | +
+
+
+ // ***DELINEATOR FOR REVIEW: then
+
+ |
+
| + 99 + | +
+
+ +
+ assertThat(result.success()).isTrue();
+
+ |
+
| + + | +
+
+
+
+ + |
+
| + 100 + | +
+
+
+ }
+
+ |
+
| + 101 + | +
+
+
+ }
+
+ |
+