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

Upgrade: Gradle & Java #77

Draft
wants to merge 5 commits into
base: master
Choose a base branch
from
Draft
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
46 changes: 24 additions & 22 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,16 +1,21 @@
import com.sun.tools.classfile.Dependency

plugins {
id 'groovy'
id 'maven-publish'
id 'com.gradle.plugin-publish' version '0.12.0'
id 'com.github.johnrengelman.shadow' version '5.1.0'
id "com.github.sherter.google-java-format" version '0.8'
id 'com.gradle.plugin-publish' version '1.2.1'
id 'com.github.johnrengelman.shadow' version '8.1.1'
id 'com.github.sherter.google-java-format' version '0.9'
}


version = file('src/main/resources/VERSION').text.trim()

sourceCompatibility = 1.8
targetCompatibility = 1.8
java {
toolchain {
languageVersion = JavaLanguageVersion.of(21)
}
}

repositories {
mavenCentral()
Expand All @@ -29,28 +34,28 @@ configurations {
dependencies {
implementation gradleApi()
bundle(project(':format')) {
exclude group: 'org.codehaus.groovy', module: 'groovy-all'
exclude group: 'org.apache.groovy', module: 'groovy-all'
}
bundle 'com.google.guava:guava:30.0-jre'
bundle 'com.google.dagger:dagger:2.23.2'
annotationProcessor 'com.google.dagger:dagger-compiler:2.23.2'
annotationProcessor 'com.google.auto.value:auto-value:1.6.5'
compileOnly 'com.google.auto.value:auto-value-annotations:1.6.5'
bundle 'com.google.guava:guava:33.2.1-jre'
bundle 'com.google.dagger:dagger:2.51.1'
annotationProcessor 'com.google.dagger:dagger-compiler:2.51.1'
annotationProcessor 'com.google.auto.value:auto-value:1.11.0'
compileOnly 'com.google.auto.value:auto-value-annotations:1.11.0'

testImplementation('org.spockframework:spock-core:1.3-groovy-2.5') {
testImplementation('org.spockframework:spock-core:2.4-M4-groovy-4.0') {
exclude group: 'org.codehaus.groovy'
}
testImplementation 'com.google.jimfs:jimfs:1.1'
testImplementation 'com.google.jimfs:jimfs:1.3.0'

integTestImplementation project(':test')
integTestImplementation gradleTestKit()
integTestImplementation('org.spockframework:spock-core:1.3-groovy-2.5') {
integTestImplementation('org.spockframework:spock-core:2.4-M4-groovy-4.0') {
exclude group: 'org.codehaus.groovy'
}
integTestImplementation sourceSets.main.output
}

def integTestGradleVersion = System.getenv('GRADLE_VERSION') ?: '2.6'
def integTestGradleVersion = System.getenv('GRADLE_VERSION') ?: '8.8'

tasks.register("integrationTest", Test) {
dependsOn publishToMavenLocal
Expand All @@ -68,7 +73,7 @@ tasks.named("check").configure {


tasks.shadowJar {
classifier = null // necessary for com.gradle.plugin-publish to pick this artifact up
archiveClassifier = null // necessary for com.gradle.plugin-publish to pick this artifact up
configurations = [project.configurations.bundle]
relocate('dagger', 'com.github.sherter.googlejavaformat.dagger')
relocate('com.google.common', 'com.github.sherter.googlejavaformatgradleplugin.com.google.common')
Expand All @@ -81,22 +86,19 @@ artifacts {
archives tasks.shadowJar
}

pluginBundle {
gradlePlugin {
website = 'https://github.com/sherter/google-java-format-gradle-plugin'
vcsUrl = 'https://github.com/sherter/google-java-format-gradle-plugin.git'
description = 'Format your Java source files with google-java-format'
tags = ['java', 'format', 'style']

plugins {
googleJavaFormatGradlePlugin {
id = 'com.github.sherter.google-java-format'
displayName = 'google-java-format gradle plugin'
tags = ['java', 'format', 'style']
implementationClass = 'com.github.sherter.googlejavaformatgradleplugin.GoogleJavaFormatPlugin'
}
}

withDependencies { List<Dependency> list ->
list.clear()
}
}

publishing {
Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.9.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
2 changes: 1 addition & 1 deletion src/main/resources/VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.9
2.0
22 changes: 13 additions & 9 deletions subprojects/format/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,27 @@ repositories {
mavenCentral()
}

sourceCompatibility = 1.8
java {
toolchain {
languageVersion = JavaLanguageVersion.of(21)
}
}

dependencies {
implementation 'org.codehaus.groovy:groovy-all:2.5.10' // v2.5.10 is the first version which runs on a Java 14 JVM.
implementation 'org.apache.groovy:groovy-all:4.0.22' // v2.5.10 is the first version which runs on a Java 14 JVM.
// At runtime, we must still support v2.3.10 (bundled with
// Gradle v2.6) on Java < 14 JVMs.
implementation 'com.google.guava:guava:30.0-jre'
testImplementation('org.spockframework:spock-core:1.3-groovy-2.5') {
implementation 'com.google.guava:guava:33.2.1-jre'
testImplementation('org.spockframework:spock-core:2.4-M4-groovy-4.0') {
exclude group: 'org.codehaus.groovy', module: 'groovy-all'
}

// for retrieving google-java-format and its dependencies from maven central
testImplementation 'org.apache.maven:maven-resolver-provider:3.6.1'
testImplementation 'org.apache.maven.resolver:maven-resolver-connector-basic:1.4.0'
testImplementation 'org.apache.maven.resolver:maven-resolver-transport-file:1.4.0'
testImplementation 'org.apache.maven.resolver:maven-resolver-transport-http:1.4.0'
testImplementation 'org.slf4j:slf4j-nop:1.7.26'
testImplementation 'org.apache.maven:maven-resolver-provider:3.9.8'
testImplementation 'org.apache.maven.resolver:maven-resolver-connector-basic:1.9.20'
testImplementation 'org.apache.maven.resolver:maven-resolver-transport-file:1.9.20'
testImplementation 'org.apache.maven.resolver:maven-resolver-transport-http:1.9.20'
testImplementation 'org.slf4j:slf4j-nop:2.0.13'
}

test {
Expand Down
11 changes: 7 additions & 4 deletions subprojects/test/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,15 @@ repositories {

dependencies {
implementation localGroovy()
testImplementation('org.spockframework:spock-core:1.3-groovy-2.5') {
testImplementation('org.spockframework:spock-core:2.4-M4-groovy-4.0') {
// gradle always loads its own groovy version, which leads to conflicts
exclude group: 'org.codehaus.groovy'
}
testImplementation 'com.google.jimfs:jimfs:1.1'
testImplementation 'com.google.jimfs:jimfs:1.3.0'
}

targetCompatibility = 1.8
sourceCompatibility = 1.8
java {
toolchain {
languageVersion = JavaLanguageVersion.of(21)
}
}