diff --git a/.run/Run Plugin.run.xml b/.run/Run Plugin.run.xml
new file mode 100644
index 00000000..00a760e5
--- /dev/null
+++ b/.run/Run Plugin.run.xml
@@ -0,0 +1,25 @@
+
+
+
+
+
+
+
+
+
+
+
+
+ true
+ true
+ false
+ false
+
+
+
diff --git a/build.gradle.kts b/build.gradle.kts
index dad1e207..67b79f0f 100644
--- a/build.gradle.kts
+++ b/build.gradle.kts
@@ -53,7 +53,7 @@ tasks {
// }
withType {
- dependsOn(copyClassesToSandbox, copyCheckstyleArtifactsToSandbox)
+ dependsOn(copyClassesToSandbox)
}
withType {
diff --git a/buildSrc/src/main/java/org/infernus/idea/checkstyle/build/CheckstyleVersions.java b/buildSrc/src/main/java/org/infernus/idea/checkstyle/build/CheckstyleVersions.java
index f72a03d7..301f5bb3 100644
--- a/buildSrc/src/main/java/org/infernus/idea/checkstyle/build/CheckstyleVersions.java
+++ b/buildSrc/src/main/java/org/infernus/idea/checkstyle/build/CheckstyleVersions.java
@@ -21,13 +21,11 @@ public class CheckstyleVersions {
private static final String PROP_FILE = "src/main/resources/checkstyle-idea.properties";
private static final String PROP_VERSIONS_SUPPORTED = "checkstyle.versions.supported";
- private static final String PROP_DEPENDENCY_MAP = "checkstyle.dependencies.map";
private static final String PROP_NAME_BASEVERSION = "baseVersion";
private final File propertyFile;
private final SortedSet versions;
- private final Map dependencyMappings;
private final String baseVersion;
@@ -37,7 +35,6 @@ public CheckstyleVersions(final Project project) {
final Properties properties = readProperties();
versions = buildVersionSet(properties);
baseVersion = readBaseVersion(properties);
- dependencyMappings = readDependencyMap(properties);
}
private SortedSet buildVersionSet(final Properties properties) {
@@ -89,22 +86,6 @@ private String readBaseVersion(final Properties properties) {
return baseVersionValue;
}
- private Map readDependencyMap(final Properties properties) {
- final String propertyValue = properties.getProperty(PROP_DEPENDENCY_MAP);
- if (propertyValue == null || propertyValue.trim().isEmpty()) {
- return Collections.emptyMap();
- }
-
- final Map mappings = new HashMap<>();
- for (final String mapping : propertyValue.trim().split("\\s*,\\s*")) {
- if (!mapping.isEmpty()) {
- final String[] oldDependencyToNewDependency = parseKeyValueMapping(mapping);
- mappings.put(oldDependencyToNewDependency[0], oldDependencyToNewDependency[1]);
- }
- }
- return Collections.unmodifiableMap(mappings);
- }
-
public File getPropertyFile() {
return propertyFile;
}
@@ -130,17 +111,4 @@ public static Dependency createCheckstyleDependency(final Project project, final
csDep.exclude(ex);
return csDep;
}
-
- private String[] parseKeyValueMapping(final String mapping) {
- final String[] kv = mapping.split("\\s*->\\s*");
- if (kv.length != 2) {
- throw new GradleException("Internal error: Property '" + CheckstyleVersions.PROP_DEPENDENCY_MAP
- + "' contains invalid mapping '" + mapping + "'");
- }
- return kv;
- }
-
- public Map getDependencyMappings() {
- return dependencyMappings;
- }
}
diff --git a/buildSrc/src/main/java/org/infernus/idea/checkstyle/build/GatherCheckstyleArtifactsTask.java b/buildSrc/src/main/java/org/infernus/idea/checkstyle/build/GatherCheckstyleArtifactsTask.java
deleted file mode 100644
index 4448f80d..00000000
--- a/buildSrc/src/main/java/org/infernus/idea/checkstyle/build/GatherCheckstyleArtifactsTask.java
+++ /dev/null
@@ -1,143 +0,0 @@
-package org.infernus.idea.checkstyle.build;
-
-import org.apache.commons.io.FileUtils;
-import org.gradle.api.DefaultTask;
-import org.gradle.api.GradleException;
-import org.gradle.api.Project;
-import org.gradle.api.artifacts.Configuration;
-import org.gradle.api.artifacts.Dependency;
-import org.gradle.api.tasks.OutputDirectory;
-import org.gradle.api.tasks.OutputFile;
-import org.gradle.api.tasks.TaskAction;
-import org.gradle.language.base.plugins.LifecycleBasePlugin;
-
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.OutputStream;
-import java.util.*;
-
-import static java.util.stream.Collectors.toSet;
-
-
-/**
- * Download all supported versions of Checkstyle along with their transitive dependencies, for bundling with the
- * plugin.
- */
-public class GatherCheckstyleArtifactsTask
- extends DefaultTask {
- public static final String NAME = "gatherCheckstyleArtifacts";
-
- private final Map> rawVersionsToDependencies = new HashMap<>();
- private final CheckstyleVersions csVersions;
-
- @OutputDirectory
- private final File bundledJarsDir;
-
- @OutputFile
- private final File classPathsInfoFile;
-
- public GatherCheckstyleArtifactsTask() {
- super();
- setGroup(LifecycleBasePlugin.BUILD_GROUP);
- setDescription("Gathers Checkstyle libraries and their dependencies for bundling");
- final Project project = getProject();
-
- // Task Inputs: the property file with the list of supported Checkstyle versions
- csVersions = new CheckstyleVersions(project);
- getInputs().file(csVersions.getPropertyFile());
-
- // Task Outputs: the directory full of JARs, and the classpath info file
- bundledJarsDir = getTemporaryDir();
- classPathsInfoFile = new File(project.getLayout().getBuildDirectory().getAsFile().get(), "resources-generated/checkstyle-classpaths.properties");
-
- for (final String csVersion : csVersions.getVersions()) {
- final Set dependencies = resolveDependencies(project, csVersion);
- rawVersionsToDependencies.put(csVersion, dependencies);
- }
- }
-
- @TaskAction
- public void runTask() {
- final Set bundledFiles = new TreeSet<>();
- final Properties classPaths = new SortedProperties();
- final Set availableFileNames = new HashSet<>();
-
- for (final String csVersion : csVersions.getVersions()) {
- Set dependencies = rawVersionsToDependencies.get(csVersion);
- availableFileNames.addAll(dependencies.stream().map(File::getName).collect(toSet()));
- }
-
- final Map dependencyMappings = csVersions.getDependencyMappings();
- for (final String csVersion : csVersions.getVersions()) {
- Set processedDependencies = rawVersionsToDependencies.get(csVersion).stream()
- .map(dependencyFile -> {
- if (csVersions.getDependencyMappings().containsKey(dependencyFile.getName())
- && availableFileNames.contains(dependencyMappings.get(dependencyFile.getName()))) {
- return dependencyMappings.get(dependencyFile.getName());
- } else {
- bundledFiles.add(dependencyFile);
- return dependencyFile.getName();
- }
- })
- .collect(toSet());
-
- classPaths.setProperty(csVersion, convertToClassPath(processedDependencies));
- }
-
- copyFiles(bundledFiles);
- createClassPathsFile(classPaths);
- }
-
- private Set resolveDependencies(final Project project, final String checkstyleVersion) {
- final Dependency csDep = CheckstyleVersions.createCheckstyleDependency(project, checkstyleVersion);
- final Configuration csConf = project.getConfigurations().detachedConfiguration(csDep);
- // workaround for Checkstyle#14123
- csConf.getResolutionStrategy()
- .getCapabilitiesResolution()
- .withCapability("com.google.collections", "google-collections", resolutionDetails -> resolutionDetails.select("com.google.guava:guava:0"));
- return csConf.resolve();
- }
-
- private String convertToClassPath(final Collection resolvedDependencies) {
- final StringBuilder sb = new StringBuilder();
- for (final String fileName : resolvedDependencies) {
- sb.append(GradlePluginMain.CSLIB_TARGET_SUBFOLDER);
- sb.append('/');
- sb.append(fileName);
- sb.append(';');
- }
- sb.deleteCharAt(sb.length() - 1);
- return sb.toString();
- }
-
- private void copyFiles(final Set bundledJars) {
- for (final File bundledJar : bundledJars) {
- try {
- FileUtils.copyFileToDirectory(bundledJar, bundledJarsDir, true);
- } catch (IOException e) {
- throw new GradleException("Unable to copy file: " + bundledJar.getAbsolutePath(), e);
- }
- }
- }
-
- private void createClassPathsFile(final Properties classPaths) {
- //noinspection ResultOfMethodCallIgnored
- classPathsInfoFile.getParentFile().mkdir();
-
- try (OutputStream os = new FileOutputStream(classPathsInfoFile)) {
- classPaths.store(os, " Class path information for Checkstyle artifacts bundled with Checkstyle_IDEA");
- } catch (IOException e) {
- throw new GradleException("Unable to write classpath info file: " + classPathsInfoFile.getAbsolutePath(),
- e);
- }
- }
-
- public File getBundledJarsDir() {
- return bundledJarsDir;
- }
-
- public File getClassPathsInfoFile() {
- return classPathsInfoFile;
- }
-}
diff --git a/buildSrc/src/main/java/org/infernus/idea/checkstyle/build/GradlePluginMain.java b/buildSrc/src/main/java/org/infernus/idea/checkstyle/build/GradlePluginMain.java
index b480be82..9b088c3a 100644
--- a/buildSrc/src/main/java/org/infernus/idea/checkstyle/build/GradlePluginMain.java
+++ b/buildSrc/src/main/java/org/infernus/idea/checkstyle/build/GradlePluginMain.java
@@ -11,7 +11,6 @@
import org.gradle.api.plugins.JavaPluginExtension;
import org.gradle.api.tasks.Copy;
import org.gradle.api.tasks.SourceSet;
-import org.gradle.api.tasks.SourceSetContainer;
import org.gradle.api.tasks.TaskContainer;
import org.gradle.api.tasks.TaskProvider;
import org.gradle.api.tasks.testing.Test;
@@ -25,7 +24,6 @@
* The main plugin class. The action starts here.
*/
public class GradlePluginMain implements Plugin {
- public static final String CSLIB_TARGET_SUBFOLDER = "checkstyle/lib";
private static final String CSCLASSES_TARGET_SUBFOLDER = "checkstyle/classes";
private CheckstyleVersions supportedCsVersions = null;
@@ -99,49 +97,10 @@ private void createCrossCheckTasks(final Project project) {
}
private void createCheckstyleArtifactTasks(final Project project) {
- TaskProvider taskProvider =
- project.getTasks().register(GatherCheckstyleArtifactsTask.NAME, GatherCheckstyleArtifactsTask.class);
- taskProvider.configure((GatherCheckstyleArtifactsTask task) -> {
- project.getTasks().getByName(JavaPlugin.PROCESS_RESOURCES_TASK_NAME).dependsOn(task);
-
- // Add generated classpath info file to resources
- SourceSetContainer sourceSets = (SourceSetContainer) project.getProperties().get("sourceSets");
- SourceSet mainSourceSet = sourceSets.getByName(SourceSet.MAIN_SOURCE_SET_NAME);
- mainSourceSet.getResources().srcDir(task.getClassPathsInfoFile().getParentFile());
- });
-
- createCopyCheckstyleArtifactsToSandboxTask(project, false);
- createCopyCheckstyleArtifactsToSandboxTask(project, true);
-
createCopyClassesToSandboxTask(project, false);
createCopyClassesToSandboxTask(project, true);
}
- private void createCopyCheckstyleArtifactsToSandboxTask(final Project project, final boolean test) {
- final TaskContainer tasks = project.getTasks();
- final String taskName = test ? "copyCheckstyleArtifactsToTestSandbox" : "copyCheckstyleArtifactsToSandbox";
- final TaskProvider taskProvider = tasks.register(taskName, Copy.class);
- taskProvider.configure((Copy copyTask) -> {
- copyTask.setGroup("intellij");
- copyTask.setDescription("Adds the gathered Checkstyle artifacts to the prepared "
- + (test ? "test " : "") + "sandbox");
-
- final GatherCheckstyleArtifactsTask gatherTask =
- (GatherCheckstyleArtifactsTask) tasks.getByName(GatherCheckstyleArtifactsTask.NAME);
- copyTask.dependsOn(gatherTask, "prepareTestSandbox");
- if (test) {
- tasks.getByName(JavaPlugin.TEST_TASK_NAME).dependsOn(copyTask);
- tasks.getByName(CsaccessTestTask.NAME).dependsOn(copyTask);
- forEachXTest(tasks, xTask -> xTask.dependsOn(copyTask));
- } else {
- tasks.getByName("buildSearchableOptions").dependsOn(copyTask);
- }
-
- copyTask.from(gatherTask.getBundledJarsDir());
- copyTask.into(new File(project.getLayout().getBuildDirectory().getAsFile().get(), pluginSandboxDir(test, CSLIB_TARGET_SUBFOLDER)));
- });
- }
-
private void forEachXTest(final TaskContainer tasks, final Consumer taskConsumer) {
supportedCsVersions.getVersions().forEach((final String csVersion) -> {
if (!supportedCsVersions.getBaseVersion().equals(csVersion)) {
@@ -174,10 +133,8 @@ private void createCopyClassesToSandboxTask(final Project project, final boolean
tasks.getByName(JavaPlugin.TEST_TASK_NAME).dependsOn(copyTask);
tasks.getByName(CsaccessTestTask.NAME).dependsOn(copyTask);
forEachXTest(tasks, xTask -> xTask.dependsOn(copyTask));
- copyTask.mustRunAfter(tasks.getByName("copyCheckstyleArtifactsToTestSandbox"));
} else {
tasks.getByName("buildSearchableOptions").dependsOn(copyTask);
- copyTask.mustRunAfter(tasks.getByName("copyCheckstyleArtifactsToSandbox"));
}
copyTask.from(csaccessSourceSet.getOutput());
@@ -201,13 +158,10 @@ private void wireIntellijPluginTasks(final Project project) {
final TaskContainer tasks = project.getTasks();
tasks.all((Task task) -> {
if ("buildPlugin".equals(task.getName()) || "runIdea".equals(task.getName()) || "runIde".equals(task.getName())) {
- task.dependsOn(tasks.getByName("copyCheckstyleArtifactsToSandbox"));
task.dependsOn(tasks.getByName("copyClassesToSandbox"));
} else if ("prepareSandbox".equals(task.getName())) {
- tasks.getByName("copyCheckstyleArtifactsToSandbox").dependsOn(task);
tasks.getByName("copyClassesToSandbox").dependsOn(task);
} else if ("prepareTestsSandbox".equals(task.getName())) {
- tasks.getByName("copyCheckstyleArtifactsToTestSandbox").dependsOn(task);
tasks.getByName("copyClassesToTestSandbox").dependsOn(task);
}
});
diff --git a/buildSrc/src/main/java/org/infernus/idea/checkstyle/build/SortedProperties.java b/buildSrc/src/main/java/org/infernus/idea/checkstyle/build/SortedProperties.java
deleted file mode 100644
index 7d230689..00000000
--- a/buildSrc/src/main/java/org/infernus/idea/checkstyle/build/SortedProperties.java
+++ /dev/null
@@ -1,22 +0,0 @@
-package org.infernus.idea.checkstyle.build;
-
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.Enumeration;
-import java.util.List;
-import java.util.Properties;
-
-
-/**
- * Just so we generate a sorted property file with the classpath information.
- */
-class SortedProperties extends Properties {
-
- @Override
- public synchronized Enumeration