From b50600ec691dd6319048a5401d309c8de7861802 Mon Sep 17 00:00:00 2001 From: forozco Date: Fri, 6 Sep 2019 14:42:11 -0400 Subject: [PATCH 1/6] automatically configure eclipse plugin --- .../baseline/plugins/BaselineIdea.groovy | 29 ++++++++++++++++--- 1 file changed, 25 insertions(+), 4 deletions(-) diff --git a/gradle-baseline-java/src/main/groovy/com/palantir/baseline/plugins/BaselineIdea.groovy b/gradle-baseline-java/src/main/groovy/com/palantir/baseline/plugins/BaselineIdea.groovy index 4d60b9682..8b648a13f 100644 --- a/gradle-baseline-java/src/main/groovy/com/palantir/baseline/plugins/BaselineIdea.groovy +++ b/gradle-baseline-java/src/main/groovy/com/palantir/baseline/plugins/BaselineIdea.groovy @@ -27,7 +27,6 @@ import org.gradle.api.Project import org.gradle.api.Task import org.gradle.api.file.FileTreeElement import org.gradle.api.specs.Spec -import org.gradle.api.tasks.compile.JavaCompile import org.gradle.plugins.ide.idea.GenerateIdeaModule import org.gradle.plugins.ide.idea.GenerateIdeaProject import org.gradle.plugins.ide.idea.GenerateIdeaWorkspace @@ -51,6 +50,7 @@ class BaselineIdea extends AbstractBaselinePlugin { addCodeStyle(node) addCopyright(node) addCheckstyle(node) + addEclipseFormat(node) addGit(node) addInspectionProjectProfile(node) addJavacSettings(node) @@ -136,6 +136,30 @@ class BaselineIdea extends AbstractBaselinePlugin { copyrightManager.@default = lastFileName } + private void addEclipseFormat(node) { + def checkstyle = project.plugins.findPlugin(BaselineFormat) + if (checkstyle == null) { + project.logger.debug "Baseline: Skipping IDEA eclipse format configuration since baseline-format not applied" + return + } + project.logger.debug "Baseline: Configuring Eclipse format for Idea" + def checkstyleFile = "LOCAL_FILE:\$PROJECT_DIR\$/.baseline/checkstyle/checkstyle.xml" + node.append(new XmlParser().parseText(""" + + + + """)) + def externalDependencies = matchOrCreateChild(node, 'component', [name: 'ExternalDependencies']) + matchOrCreateChild(externalDependencies, 'plugin', [id: 'EclipseCodeFormatterProjectSettings']) + } + private void addCheckstyle(node) { def checkstyle = project.plugins.findPlugin(BaselineCheckstyle) if (checkstyle == null) { @@ -161,9 +185,6 @@ class BaselineIdea extends AbstractBaselinePlugin { """.stripIndent())) - - def externalDependencies = matchOrCreateChild(node, 'component', [name: 'ExternalDependencies']) - matchOrCreateChild(externalDependencies, 'plugin', [id: 'CheckStyle-IDEA']) } /** From 8f77174ecf13fa7ef9b66a47f7dc11582719624b Mon Sep 17 00:00:00 2001 From: forozco Date: Fri, 6 Sep 2019 18:42:11 +0000 Subject: [PATCH 2/6] Add generated changelog entries --- changelog/@unreleased/pr-794.v2.yml | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 changelog/@unreleased/pr-794.v2.yml diff --git a/changelog/@unreleased/pr-794.v2.yml b/changelog/@unreleased/pr-794.v2.yml new file mode 100644 index 000000000..b8085f49a --- /dev/null +++ b/changelog/@unreleased/pr-794.v2.yml @@ -0,0 +1,6 @@ +type: feature +feature: + description: Automatically configure the [Intellij Eclipse format plugin](https://plugins.jetbrains.com/plugin/6546-eclipse-code-formatter) + to use the eclipse formatter + links: + - https://github.com/palantir/gradle-baseline/pull/794 From 791c4c9b97aadd203b0cb8d23b3e72f4a48a0a23 Mon Sep 17 00:00:00 2001 From: Dan Fox Date: Mon, 9 Sep 2019 10:33:23 -0400 Subject: [PATCH 3/6] Recommend both plugins --- .../groovy/com/palantir/baseline/plugins/BaselineIdea.groovy | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/gradle-baseline-java/src/main/groovy/com/palantir/baseline/plugins/BaselineIdea.groovy b/gradle-baseline-java/src/main/groovy/com/palantir/baseline/plugins/BaselineIdea.groovy index 8b648a13f..c62fa8d06 100644 --- a/gradle-baseline-java/src/main/groovy/com/palantir/baseline/plugins/BaselineIdea.groovy +++ b/gradle-baseline-java/src/main/groovy/com/palantir/baseline/plugins/BaselineIdea.groovy @@ -157,7 +157,7 @@ class BaselineIdea extends AbstractBaselinePlugin { """)) def externalDependencies = matchOrCreateChild(node, 'component', [name: 'ExternalDependencies']) - matchOrCreateChild(externalDependencies, 'plugin', [id: 'EclipseCodeFormatterProjectSettings']) + matchOrCreateChild(externalDependencies, 'plugin', [id: 'EclipseCodeFormatter']) } private void addCheckstyle(node) { @@ -185,6 +185,8 @@ class BaselineIdea extends AbstractBaselinePlugin { """.stripIndent())) + def externalDependencies = matchOrCreateChild(node, 'component', [name: 'ExternalDependencies']) + matchOrCreateChild(externalDependencies, 'plugin', [id: 'CheckStyle-IDEA']) } /** From 5bf21b46b854155fc6fd388865d91ef9a645ddb9 Mon Sep 17 00:00:00 2001 From: Dan Fox Date: Mon, 9 Sep 2019 10:35:57 -0400 Subject: [PATCH 4/6] Nits --- .../com/palantir/baseline/plugins/BaselineIdea.groovy | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/gradle-baseline-java/src/main/groovy/com/palantir/baseline/plugins/BaselineIdea.groovy b/gradle-baseline-java/src/main/groovy/com/palantir/baseline/plugins/BaselineIdea.groovy index c62fa8d06..c20c285a9 100644 --- a/gradle-baseline-java/src/main/groovy/com/palantir/baseline/plugins/BaselineIdea.groovy +++ b/gradle-baseline-java/src/main/groovy/com/palantir/baseline/plugins/BaselineIdea.groovy @@ -137,13 +137,12 @@ class BaselineIdea extends AbstractBaselinePlugin { } private void addEclipseFormat(node) { - def checkstyle = project.plugins.findPlugin(BaselineFormat) - if (checkstyle == null) { + def baselineFormat = project.plugins.findPlugin(BaselineFormat) + if (baselineFormat == null) { project.logger.debug "Baseline: Skipping IDEA eclipse format configuration since baseline-format not applied" return } - project.logger.debug "Baseline: Configuring Eclipse format for Idea" - def checkstyleFile = "LOCAL_FILE:\$PROJECT_DIR\$/.baseline/checkstyle/checkstyle.xml" + project.logger.debug "Baseline: Configuring EclipseCodeFormatter plugin for Idea" node.append(new XmlParser().parseText("""