spring-security/gradle/ide-integration.gradle

82 lines
3.1 KiB
Groovy

apply plugin: 'idea'
configure(javaProjects) {
apply plugin: 'idea'
apply plugin: 'eclipse'
ideaModule {
downloadJavadoc=false
excludeDirs.add(buildDir)
gradleCacheVariable = 'GRADLE_CACHE'
outputDir = "$rootProject.projectDir/intellij/out" as File
testOutputDir = "$rootProject.projectDir/intellij/testOut" as File
whenConfigured { module ->
def allClasses = module.dependencies.findAll() { dep ->
if (dep instanceof org.gradle.plugins.ide.idea.model.ModuleLibrary
&& dep.classes.find { path ->
path.url.matches('.*jcl-over-slf4j.*') ||
path.url.matches('.*servlet-api.*') ||
path.url.matches('.*jsp-api.*')
}) {
dep.scope = 'COMPILE'
dep.exported = false
}
}
}
}
// GRADLE-1116
eclipseClasspath.whenConfigured { classpath ->
classpath.entries.removeAll { entry -> entry.path.endsWith('/build/classes/test') }
}
eclipseClasspath.doFirst {
eclipseClasspath.whenConfigured { classpath ->
def includeDeps = project.configurations.getByName('runtime')?.collect { f-> f.absolutePath } as Set
classpath.entries.each { cp ->
if(cp instanceof org.gradle.plugins.ide.eclipse.model.Library) {
def include = includeDeps.contains(cp.path)
def attr = 'org.eclipse.jst.component.dependency'
if(include && project.hasProperty('war')) {
// GRADLE-1426 (part a)
cp.entryAttributes.put(attr,'/WEB-INF/lib')
} else if(!include) {
// GRADLE-1422
cp.entryAttributes.remove(attr)
}
}
}
}
}
// GRADLE-1426 (part b)
project.plugins.withType(org.gradle.api.plugins.WarPlugin.class).all {
eclipseWtpComponent.whenConfigured { wtpComp ->
wtpComp.wbModuleEntries.findAll { it instanceof org.gradle.plugins.ide.eclipse.model.WbDependentModule }.each { e ->
if(!e.handle.startsWith('module:/resource/')) {
wtpComp.wbModuleEntries.remove(e)
}
}
}
}
tasks.withType(org.gradle.plugins.ide.eclipse.GenerateEclipseWtpComponent) {
whenConfigured { wtpComponent ->
wtpComponent.contextPath = project.tasks.findByName('jettyRun')?.contextPath?.replaceFirst('/','')
}
}
}
ideaModule {
excludeDirs += file('.gradle')
excludeDirs += file('buildSrc/build')
excludeDirs += file('buildSrc/.gradle')
}
ideaProject {
javaVersion = '1.6'
subprojects = [rootProject] + javaProjects
withXml { provider ->
// Use git
def node = provider.asNode()
def vcsConfig = node.component.find { it.'@name' == 'VcsDirectoryMappings' }
vcsConfig.mapping[0].'@vcs' = 'Git'
}
}