Skip to content

Commit

Permalink
Improve build/test infrastructure to support IDEA 2022.2/2022.3 and J…
Browse files Browse the repository at this point in the history
…ava 17 (#113)

* Use Java 11 for <2022.2 and Java 17 for >=2022.2
* Upgrade Gradle to 7.5.1 for Java 17 and fixup build script accordingly
* Upgrade `intellij-gradle-plugin` for IDEA >=2022.2
* Remove Kotlin (not actually used, but messes with classpath)
* Rearrange stuff around JUnit
* Fixup several build warnings
* Do not add tail text for lookups (it was never needed and something changed in 2022.3 that is causing addition of `()`)
* Adapt tests to use message from IntelliJ instead of manually crafted
  • Loading branch information
unshare authored Nov 13, 2022
1 parent 127fdad commit a052145
Show file tree
Hide file tree
Showing 10 changed files with 267 additions and 200 deletions.
13 changes: 9 additions & 4 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,23 @@ jobs:
strategy:
fail-fast: false
matrix:
ideaVersion: [2021.2, 2021.3, LATEST-EAP-SNAPSHOT]
name: 'IDEA ${{ matrix.ideaVersion }}'
version:
- { jdk: 11, idea: 2021.2 }
- { jdk: 11, idea: 2021.3 }
- { jdk: 11, idea: 2022.1 }
- { jdk: 17, idea: 2022.2 }
- { jdk: 17, idea: LATEST-EAP-SNAPSHOT }
name: 'IDEA ${{ matrix.version.idea }}'
env:
IDEA_VERSION: ${{ matrix.ideaVersion }}
IDEA_VERSION: ${{ matrix.version.idea }}
runs-on: ubuntu-latest
steps:
- name: 'Checkout'
uses: actions/checkout@v2
- name: 'Set up JDK'
uses: actions/setup-java@v1
with:
java-version: 11
java-version: ${{ matrix.version.jdk }}
- name: 'Test'
run: ./gradlew --warning-mode=all build
- name: 'Generate coverage report'
Expand Down
49 changes: 18 additions & 31 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@ import com.hierynomus.gradle.license.tasks.LicenseCheck
import com.hierynomus.gradle.license.tasks.LicenseFormat

plugins {
id "org.jetbrains.intellij" version "1.5.2"
id "com.github.hierynomus.license" version "0.14.0"
id "org.jetbrains.intellij" version "1.9.0"
id "com.github.hierynomus.license" version "0.16.1"
id "de.undercouch.download" version "4.1.2"
id 'org.jetbrains.kotlin.jvm' version '1.4.31'
}


Expand All @@ -18,10 +17,9 @@ apply plugin: 'org.jetbrains.intellij'
apply plugin: 'license'
apply plugin: 'checkstyle'
apply plugin: 'jacoco'
apply plugin: 'kotlin'

sourceCompatibility = 1.8
targetCompatibility = 1.8
sourceCompatibility = 11
targetCompatibility = 11

repositories {
mavenLocal()
Expand All @@ -40,18 +38,6 @@ intellij {
plugins = ['java', 'Kotlin', 'properties']
}

compileKotlin {
kotlinOptions {
jvmTarget = "1.8"
}
}

compileTestKotlin {
kotlinOptions {
jvmTarget = "1.8"
}
}

// Simple function to load change-notes.html and description.html into valid text for plugin.xml
def htmlFixer = {f -> file(f).text.replace('<html>', '').replace('</html>', '')}

Expand Down Expand Up @@ -94,35 +80,34 @@ checkstyle {
}

jacoco {
toolVersion "0.8.2"
toolVersion "0.8.8"
}

jacocoTestReport {
reports {
xml.enabled = true
html.enabled = true
xml.required = true
html.required = true
}
}

dependencies {
compile 'org.jetbrains.kotlin:kotlin-stdlib-jdk8'
compile group: 'org.mapstruct', name: 'mapstruct', version: '1.5.2.Final'
testCompile group: 'junit', name: 'junit', version: '4.12'
testCompile group: 'org.assertj', name: 'assertj-core', version: '3.11.1'
testCompile group: 'org.apache.commons', name: 'commons-text', version: '1.9'
implementation('org.mapstruct:mapstruct:1.5.3.Final')
testImplementation(platform('org.junit:junit-bom:5.8.2'))
testImplementation('org.junit.jupiter:junit-jupiter')
testImplementation('org.junit.jupiter:junit-jupiter')
testRuntimeOnly("org.junit.vintage:junit-vintage-engine")
testImplementation('org.junit.platform:junit-platform-launcher')
testImplementation('org.junit.jupiter:junit-jupiter-api')
testImplementation('org.junit.jupiter:junit-jupiter-engine')
testRuntimeOnly('org.junit.vintage:junit-vintage-engine')
testImplementation('org.assertj:assertj-core:3.11.1')
testImplementation('org.apache.commons:commons-text:1.9')
}

task libs(type: Sync) {
from configurations.compile
from configurations.runtimeClasspath
into "$buildDir/libs"
preserve {
include 'mapstruct-intellij-*.jar'
}
rename 'mapstruct-1.5.2.Final.jar', 'mapstruct.jar'
rename 'mapstruct-1.5.3.Final.jar', 'mapstruct.jar'
}

def mockJdkLocation = "https://github.com/JetBrains/intellij-community/raw/master/java/mock"
Expand Down Expand Up @@ -161,6 +146,8 @@ task downloadMockJdk8() {
}

test.dependsOn( libs, downloadMockJdk7, downloadMockJdk8 )
prepareTestingSandbox.dependsOn( libs )
prepareSandbox.dependsOn( libs )

test {
useJUnitPlatform()
Expand Down
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
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-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5.1-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Loading

0 comments on commit a052145

Please sign in to comment.