Skip to content

Commit

Permalink
Update to IDEA Platform Plugin 2.0.0
Browse files Browse the repository at this point in the history
This was a mess due to changes in the classpath, and minimal testing on the Groovy DSL. There remains some hardcoding of the sandbox dir that needs to be fixed.
  • Loading branch information
jshiell committed Aug 8, 2024
1 parent 806f4f3 commit 5ccee7a
Show file tree
Hide file tree
Showing 12 changed files with 154 additions and 150 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,4 @@ gradle-app.setting
/.gradletasknamecache
_support/
/out/
.intellijPlatform/
114 changes: 0 additions & 114 deletions build.gradle

This file was deleted.

112 changes: 112 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
import org.infernus.idea.checkstyle.build.CheckstyleVersions
import org.jetbrains.intellij.platform.gradle.TestFrameworkType
import org.jetbrains.intellij.platform.gradle.tasks.VerifyPluginTask

plugins {
id("java")
id("jacoco")
id("idea")
id("org.jetbrains.intellij.platform") version "2.0.0"
id("com.dorongold.task-tree") version "2.1.1"
id("org.infernus.idea.checkstyle.build")
}

version = "5.92.0"

repositories {
mavenCentral()

intellijPlatform {
defaultRepositories()
}
}

intellijPlatform {
pluginConfiguration {
id = "CheckStyle-IDEA"
name = "CheckStyle-IDEA"
version = project.version.toString()

ideaVersion {
sinceBuild = "231.9392.1"
untilBuild = provider { null }
}
}

publishing {
token.set(System.getenv("JETBRAINS_PLUGIN_REPO_TOKEN"))
}
}

java {
toolchain {
languageVersion = JavaLanguageVersion.of(17)
}
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17

}

tasks {
withType<VerifyPluginTask> {
dependsOn(copyClassesToSandbox, copyCheckstyleArtifactsToSandbox)
}

withType<Test> {
setForkEvery(1)
}

withType<JavaCompile> {
options.encoding = "UTF-8"
options.compilerArgs.addAll(listOf("-Xlint:deprecation"))
options.release.set(17)

if (name == "compileCsaccessJava" || name == "compileCsaccessTestJava") {
options.compilerArgs.addAll(listOf("-Xlint:unchecked"))
}
}
}

// workaround for Checkstyle#14123
configurations.configureEach {
resolutionStrategy.capabilitiesResolution.withCapability("com.google.collections:google-collections") {
select("com.google.guava:guava:0")
}
}

dependencies {
intellijPlatform {
intellijIdeaCommunity("2023.1.5")

bundledPlugin("com.intellij.java")

instrumentationTools()
testFramework(TestFrameworkType.Platform)
}

implementation("commons-io:commons-io:2.15.1")
implementation("commons-codec:commons-codec:1.16.0")

val checkStyleBaseVersion = (project.extra["supportedCsVersions"] as CheckstyleVersions).baseVersion
csaccessCompileOnly("com.puppycrawl.tools:checkstyle:${checkStyleBaseVersion}") {
exclude(group = "commons-logging", module = "commons-logging")
}

testImplementation("junit:junit:4.13.2")
testImplementation("org.hamcrest:hamcrest:2.2")
testImplementation("org.mockito:mockito-core:5.5.0")
}

idea.module {
isDownloadJavadoc = true
isDownloadSources = true

excludeDirs.addAll(listOf(file(".idea"), file("_support")))

// TODO We should also tell IntelliJ automatically that csaccessTest contains test code.
// The following lines should really do it, but currently don't, which seems like a Gradle bug to me:
//val SourceSet catSourceSet = sourceSets.getByName(CustomSourceSetCreator.CSACCESSTEST_SOURCESET_NAME)
//testSourceDirs.addAll(catSourceSet.getJava().getSrcDirs())
//testSourceDirs.addAll(catSourceSet.getResources().getSrcDirs())
//scopes.TEST.plus.addAll(listOf(configurations.getByName(catSourceSet.getRuntimeConfigurationName())))
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,17 +33,17 @@ public class CsaccessTestTask extends Test {
private Property<Boolean> dryRun;

public CsaccessTestTask() {
super();

final Project project = getProject();
final JavaPluginExtension jpc = project.getExtensions().getByType(JavaPluginExtension.class);
final SourceSet csaccessTestSourceSet = jpc.getSourceSets().getByName(CustomSourceSetCreator
.CSACCESSTEST_SOURCESET_NAME);
final SourceSet csaccessTestSourceSet = jpc.getSourceSets().getByName(
CustomSourceSetCreator.CSACCESSTEST_SOURCESET_NAME);

dependsOn(project.getTasks().getByName(csaccessTestSourceSet.getClassesTaskName()));

GradlePluginMain.configureTestTask(this);
setTestClassesDirs(csaccessTestSourceSet.getOutput().getClassesDirs());
setClasspath(csaccessTestSourceSet.getRuntimeClasspath()
.plus(csaccessTestSourceSet.getCompileClasspath()));
}

public static String getTaskName(final String pCheckstyleVersion) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
package org.infernus.idea.checkstyle.build;

import java.io.File;
import java.math.BigDecimal;
import java.util.stream.Collectors;

import org.gradle.api.Project;
import org.gradle.api.artifacts.ConfigurationContainer;
import org.gradle.api.file.FileCollection;
Expand All @@ -20,12 +16,16 @@
import org.gradle.testing.jacoco.tasks.JacocoReportBase;
import org.gradle.testing.jacoco.tasks.rules.JacocoViolationRule;

import java.io.File;
import java.math.BigDecimal;
import java.util.stream.Collectors;


public class CustomSourceSetCreator {
static final String CSACCESS_SOURCESET_NAME = "csaccess";
public static final String CSACCESSTEST_SOURCESET_NAME = "csaccessTest";

private static final double MINIMUM_CSACCESS_COVERAGE = 0.70d;
private static final double MINIMUM_CSACCESS_COVERAGE = 0.60d;

private final Project project;

Expand All @@ -45,15 +45,18 @@ private String getJacocoVerificationTaskName() {
return sourceSets.getByName(CSACCESS_SOURCESET_NAME).getTaskName("jacoco", "CoverageVerification");
}


public void establishCsAccessSourceSet() {
final SourceSetContainer sourceSets = (SourceSetContainer) project.getProperties().get("sourceSets");
final SourceSet mainSourceSet = sourceSets.getByName(SourceSet.MAIN_SOURCE_SET_NAME);

// Create the 'csaccess' source set
final SourceSet csaccessSourceSet = sourceSets.create(CSACCESS_SOURCESET_NAME);
csaccessSourceSet.setCompileClasspath(csaccessSourceSet.getCompileClasspath().plus(mainSourceSet.getOutput()));
csaccessSourceSet.setRuntimeClasspath(csaccessSourceSet.getRuntimeClasspath().plus(mainSourceSet.getOutput()));
csaccessSourceSet.setCompileClasspath(csaccessSourceSet.getCompileClasspath()
.plus(mainSourceSet.getOutput())
.plus(mainSourceSet.getCompileClasspath()));
csaccessSourceSet.setRuntimeClasspath(csaccessSourceSet.getRuntimeClasspath()
.plus(mainSourceSet.getOutput())
.plus(mainSourceSet.getRuntimeClasspath()));

// Derive all its configurations from 'main', so 'csaccess' code can see 'main' code
final ConfigurationContainer configurations = project.getConfigurations();
Expand All @@ -79,7 +82,6 @@ public void establishCsAccessSourceSet() {
.dependsOn(tasks.getByName(csaccessSourceSet.getClassesTaskName()));
}


public void establishCsAccessTestSourceSet() {
final SourceSetContainer sourceSets = (SourceSetContainer) project.getProperties().get("sourceSets");
final SourceSet mainSourceSet = sourceSets.getByName(SourceSet.MAIN_SOURCE_SET_NAME);
Expand All @@ -88,10 +90,14 @@ public void establishCsAccessTestSourceSet() {

// Create the 'csaccessTest' source set
final SourceSet csaccessTestSourceSet = sourceSets.create(CSACCESSTEST_SOURCESET_NAME);
csaccessTestSourceSet.setCompileClasspath(csaccessTestSourceSet.getCompileClasspath().
plus(mainSourceSet.getOutput()).plus(csaccessSourceSet.getOutput()));
csaccessTestSourceSet.setRuntimeClasspath(csaccessTestSourceSet.getRuntimeClasspath().
plus(mainSourceSet.getOutput()).plus(csaccessSourceSet.getOutput()));
csaccessTestSourceSet.setCompileClasspath(csaccessTestSourceSet.getCompileClasspath()
.plus(mainSourceSet.getOutput())
.plus(mainSourceSet.getCompileClasspath())
.plus(csaccessSourceSet.getOutput()));
csaccessTestSourceSet.setRuntimeClasspath(csaccessTestSourceSet.getRuntimeClasspath()
.plus(mainSourceSet.getOutput())
.plus(mainSourceSet.getRuntimeClasspath())
.plus(csaccessSourceSet.getOutput()));

// Derive all its configurations from 'test' and 'csaccess'
final ConfigurationContainer configurations = project.getConfigurations();
Expand Down
Loading

0 comments on commit 5ccee7a

Please sign in to comment.