|
| 1 | +/* |
| 2 | + * (c) Copyright 2025 Palantir Technologies Inc. All rights reserved. |
| 3 | + * |
| 4 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | + * you may not use this file except in compliance with the License. |
| 6 | + * You may obtain a copy of the License at |
| 7 | + * |
| 8 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | + * |
| 10 | + * Unless required by applicable law or agreed to in writing, software |
| 11 | + * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | + * See the License for the specific language governing permissions and |
| 14 | + * limitations under the License. |
| 15 | + */ |
| 16 | + |
| 17 | +package com.palantir.javaformat.gradle |
| 18 | + |
| 19 | +import nebula.test.IntegrationTestKitSpec |
| 20 | + |
| 21 | +class FinlayTest extends IntegrationTestKitSpec { |
| 22 | + private static final CLASSPATH_FILE = new File("build/impl.classpath").absolutePath |
| 23 | + private static final NATIVE_IMAGE_FILE = new File("build/nativeImage.path") |
| 24 | + private static final NATIVE_CONFIG = String.format("palantirJavaFormatNative files(\"%s\")", NATIVE_IMAGE_FILE.text) |
| 25 | + |
| 26 | + def setup() { |
| 27 | + def extraDependencies = NATIVE_CONFIG |
| 28 | + |
| 29 | + // language=Gradle |
| 30 | + buildFile << """ |
| 31 | + buildscript { |
| 32 | + repositories { |
| 33 | + mavenCentral() { metadataSources { mavenPom(); ignoreGradleMetadataRedirection() } } |
| 34 | + gradlePluginPortal() { metadataSources { mavenPom(); ignoreGradleMetadataRedirection() } } |
| 35 | + mavenLocal() |
| 36 | + } |
| 37 | + dependencies { |
| 38 | + classpath 'com.palantir.baseline:gradle-baseline-java:999-CC7' |
| 39 | + classpath 'com.palantir.gradle.consistentversions:gradle-consistent-versions:999' |
| 40 | + } |
| 41 | + } |
| 42 | + |
| 43 | + apply plugin: 'com.palantir.baseline' |
| 44 | + apply plugin: 'com.palantir.consistent-versions' |
| 45 | +
|
| 46 | + allprojects { |
| 47 | + apply plugin: 'com.palantir.java-format' |
| 48 | + apply plugin: 'java' |
| 49 | + |
| 50 | + repositories { |
| 51 | + mavenCentral() { metadataSources { mavenPom(); ignoreGradleMetadataRedirection() } } |
| 52 | + } |
| 53 | + } |
| 54 | + version = '0.1.0' |
| 55 | + """.stripIndent(true) |
| 56 | + |
| 57 | + file("versions.props") |
| 58 | + file("versions.lock") |
| 59 | + |
| 60 | + file('gradle.properties') << """ |
| 61 | + org.gradle.jvmargs=--add-exports jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED \ |
| 62 | + --add-exports jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED \ |
| 63 | + --add-exports jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED \ |
| 64 | + --add-exports jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED \ |
| 65 | + --add-exports jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED |
| 66 | + palantir.jdk.setup.enabled=true |
| 67 | + """.stripIndent(true) |
| 68 | + runTasks('wrapper') |
| 69 | + |
| 70 | + definePluginOutsideOfPluginBlock = true |
| 71 | + keepFiles = true |
| 72 | + } |
| 73 | + |
| 74 | + def "can run build on root and subproject"() { |
| 75 | + when: |
| 76 | + def result = runTasks('build') |
| 77 | + |
| 78 | + then: |
| 79 | + result.output.contains('BUILD SUCCESSFUL') |
| 80 | + } |
| 81 | +} |
0 commit comments