Skip to content

Commit

Permalink
Remove custom idea JDK configuration (#718)
Browse files Browse the repository at this point in the history
  • Loading branch information
pkoenig10 authored and bulldozer-bot[bot] committed Aug 15, 2019
1 parent 3a2f350 commit cc49f6e
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 54 deletions.
5 changes: 5 additions & 0 deletions changelog/@unreleased/pr-718.v2.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
type: improvement
improvement:
description: The `baseline-idea` plugin now generates configuration more closely aligned with Gradle defaults.
links:
- https://github.com/palantir/gradle-baseline/pull/718
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ class BaselineIdea extends AbstractBaselinePlugin {
}

// Configure Idea module
addJdkVersion(ideaModuleModel)
markResourcesDirs(ideaModuleModel)
moveProjectReferencesToEnd(ideaModuleModel)
}
Expand Down Expand Up @@ -271,29 +270,6 @@ class BaselineIdea extends AbstractBaselinePlugin {
return base.appendNode(name, attributes + defaults)
}

/**
* Configures JDK and Java language level of the given IdeaModel according to the sourceCompatibility property.
*/
private void addJdkVersion(IdeaModel ideaModel) {
def compileJavaTask = (JavaCompile) project.tasks.findByName('compileJava')
if (compileJavaTask) {
def javaVersion = compileJavaTask.sourceCompatibility
def jdkVersion = 'JDK_' + javaVersion.replaceAll('\\.', '_')
project.logger.debug("BaselineIdea: Configuring IDEA Module for Java version: " + javaVersion)

if (ideaModel.project != null) {
ideaModel.project.languageLevel = javaVersion
}

ideaModel.module.jdkName = javaVersion
ideaModel.module.iml.withXml {
it.asNode().component.find { it.@name == 'NewModuleRootManager' }.@LANGUAGE_LEVEL = jdkVersion
}
} else {
project.logger.debug("BaselineIdea: No Java version found in sourceCompatibility property.")
}
}

/**
* By default the Idea plugin marks resources dirs as source dirs.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,36 +70,6 @@ class BaselineIdeaIntegrationTest extends AbstractPluginTest {
with('idea').build()
}

def 'Modules for subprojects pick up the correct sourceCompatibility'() {
when:
buildFile << standardBuildFile
buildFile << '''
sourceCompatibility = 1.6
'''.stripIndent()
def subproject = multiProject.create(["subproject1", "subproject2"])
subproject["subproject1"].buildGradle << '''
apply plugin: 'java'
apply plugin: 'com.palantir.baseline-idea'
sourceCompatibility = 1.7
'''.stripIndent()
subproject["subproject2"].buildGradle << '''
apply plugin: 'java'
apply plugin: 'com.palantir.baseline-idea'
sourceCompatibility = 1.8
'''.stripIndent()

then:
with('idea').build()
def rootIml = Files.asCharSource(new File(projectDir, projectDir.name + ".iml"), Charsets.UTF_8).read()
rootIml ==~ /(?s).*orderEntry[^\\n]*jdkName="1.6".*/
def subproject1Iml = Files.asCharSource(new File(projectDir, "subproject1/subproject1.iml"),
Charsets.UTF_8).read()
subproject1Iml ==~ /(?s).*orderEntry[^\\n]*jdkName="1.7".*/
def subproject2Iml = Files.asCharSource(new File(projectDir, "subproject2/subproject2.iml"),
Charsets.UTF_8).read()
subproject2Iml ==~ /(?s).*orderEntry[^\\n]*jdkName="1.8".*/
}

def 'Idea project has copyright configuration'() {
when:
buildFile << standardBuildFile
Expand Down

0 comments on commit cc49f6e

Please sign in to comment.