Skip to content

Commit

Permalink
baseline-idea plugin adds compileOnly configuration to Intellij"s PRO…
Browse files Browse the repository at this point in the history
…VIDED scope (fixed #56) (#57)
  • Loading branch information
uschi2000 committed Apr 19, 2016
1 parent 63ed36c commit 3e41704
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ class BaselineIdea extends AbstractBaselinePlugin {
// Configure Idea module
IdeaModel ideaModuleModel = project.extensions.findByType(IdeaModel)
addJdkVersion(ideaModuleModel)
addCompileOnlyConfiguration(ideaModuleModel)
}
}

Expand Down Expand Up @@ -201,4 +202,11 @@ class BaselineIdea extends AbstractBaselinePlugin {
project.logger.info("BaselineIdea: No Java version found in sourceCompatibility property.")
}
}

def addCompileOnlyConfiguration(IdeaModel ideaModel) {
def compileOnly = project.configurations.findByName("compileOnly")
if (compileOnly) {
ideaModel.module.scopes.get("PROVIDED").plus += [ compileOnly ]
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -130,4 +130,24 @@ class BaselineIdeaIntegrationTest extends IntegrationSpec {
"Git-support-is-not-added-if-git-directory-is-not-present.ipr"), Charsets.UTF_8).read()
assert !rootIpr.contains('<mapping directory="$PROJECT_DIR$" vcs="Git"/>')
}

def 'Adds compileOnly dependencies if the configuration exists'() {
when:
buildFile << standardBuildFile
buildFile << """
configurations {
compileOnly
}
dependencies {
compileOnly localGroovy()
}
"""

then:
runTasksSuccessfully('idea')
def iml = Files.asCharSource(new File(projectDir,
"Adds-compileOnly-dependencies-if-the-configuration-exists.iml"), Charsets.UTF_8).read()
assert iml.contains('<orderEntry type="module-library" scope="PROVIDED">')
}
}

0 comments on commit 3e41704

Please sign in to comment.