Skip to content
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
25 changes: 25 additions & 0 deletions .run/Run Plugin.run.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="Run Plugin" type="GradleRunConfiguration" factoryName="Gradle">
<log_file alias="IDE logs" path="$PROJECT_DIR$/build/idea-sandbox/*/log/idea.log" show_all="true" />
<ExternalSystemSettings>
<option name="executionName" />
<option name="externalProjectPath" value="$PROJECT_DIR$" />
<option name="externalSystemIdString" value="GRADLE" />
<option name="scriptParameters" value="" />
<option name="taskDescriptions">
<list />
</option>
<option name="taskNames">
<list>
<option value="runIde" />
</list>
</option>
<option name="vmOptions" value="" />
</ExternalSystemSettings>
<ExternalSystemDebugServerProcess>true</ExternalSystemDebugServerProcess>
<ExternalSystemReattachDebugProcess>true</ExternalSystemReattachDebugProcess>
<DebugAllEnabled>false</DebugAllEnabled>
<RunAsTest>false</RunAsTest>
<method v="2" />
</configuration>
</component>
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ tasks {
// }

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

withType<Test> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<String> versions;
private final Map<String, String> dependencyMappings;

private final String baseVersion;

Expand All @@ -37,7 +35,6 @@ public CheckstyleVersions(final Project project) {
final Properties properties = readProperties();
versions = buildVersionSet(properties);
baseVersion = readBaseVersion(properties);
dependencyMappings = readDependencyMap(properties);
}

private SortedSet<String> buildVersionSet(final Properties properties) {
Expand Down Expand Up @@ -89,22 +86,6 @@ private String readBaseVersion(final Properties properties) {
return baseVersionValue;
}

private Map<String, String> readDependencyMap(final Properties properties) {
final String propertyValue = properties.getProperty(PROP_DEPENDENCY_MAP);
if (propertyValue == null || propertyValue.trim().isEmpty()) {
return Collections.emptyMap();
}

final Map<String, String> 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;
}
Expand All @@ -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<String, String> getDependencyMappings() {
return dependencyMappings;
}
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -25,7 +24,6 @@
* The main plugin class. The action starts here.
*/
public class GradlePluginMain implements Plugin<Project> {
public static final String CSLIB_TARGET_SUBFOLDER = "checkstyle/lib";
private static final String CSCLASSES_TARGET_SUBFOLDER = "checkstyle/classes";

private CheckstyleVersions supportedCsVersions = null;
Expand Down Expand Up @@ -99,49 +97,10 @@ private void createCrossCheckTasks(final Project project) {
}

private void createCheckstyleArtifactTasks(final Project project) {
TaskProvider<GatherCheckstyleArtifactsTask> 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<Copy> 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<Task> taskConsumer) {
supportedCsVersions.getVersions().forEach((final String csVersion) -> {
if (!supportedCsVersions.getBaseVersion().equals(csVersion)) {
Expand Down Expand Up @@ -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());
Expand All @@ -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);
}
});
Expand Down

This file was deleted.

Loading