1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192 |
- import org.gradle.plugins.ide.eclipse.model.SourceFolder
- configure(allprojects) {
- apply plugin: 'idea'
- apply plugin: 'eclipse-wtp'
- eclipse.project.name = "${project.name}-3.2.x"
- }
- configure(javaProjects) {
- eclipse.classpath.downloadSources = true
- // http://forums.gradle.org/gradle/topics/eclipse_wtp_deploys_testcode_to_server_example_provided
- eclipse.classpath {
- defaultOutputDir = file('bin/main')
- file.whenMerged { cp ->
- cp.entries.findAll { it instanceof SourceFolder && (it.path.contains("test") || it.path.contains("Test")) }*.output = "bin/test"
- }
- }
- // GRADLE-1422
- project.eclipseClasspath.doFirst {
- // delay adding whenMerged till the entryAttributes are added (must be the last whenMerged)
- project.eclipse.classpath.file.whenMerged { 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) {
- cp.entryAttributes.remove(attr)
- }
- }
- }
- }
- }
- tasks.withType(org.gradle.plugins.ide.eclipse.GenerateEclipseWtpComponent) {
- project.eclipse.classpath.file.whenMerged { classpath->
- project.eclipse.wtp.component.file.whenMerged { wtpComponent ->
- wtpComponent.contextPath = project.tasks.findByName('jettyRun')?.contextPath?.replaceFirst('/','')
- }
- }
- }
- }
- // STS-3057
- configure(allprojects) {
- task afterEclipseImport {
- ext.srcFile = file('.classpath')
- inputs.file srcFile
- outputs.dir srcFile
- onlyIf { srcFile.exists() }
- doLast {
- def classpath = new XmlParser().parse(srcFile)
- classpath.classpathentry.findAll{ it.@path == 'GROOVY_SUPPORT' }.each { classpath.remove(it) }
- def writer = new FileWriter(srcFile)
- new XmlNodePrinter(new PrintWriter(writer)).print(classpath)
- }
- }
- }
- // STS-2723
- project(':spring-security-samples-xmlaspectj') {
- task afterEclipseImportAjdtFix {
- ext.srcFile = afterEclipseImport.srcFile
- inputs.file srcFile
- outputs.dir srcFile
- onlyIf { srcFile.exists() }
- doLast {
- def classpath = new XmlParser().parse(srcFile)
- classpath.classpathentry.findAll{ it.@path.startsWith('/spring-security-aspects') }.each { node ->
- if(node.children().size() == 0) {
- def attrs = new Node(node,'attributes')
- def adjtAttr = new Node(attrs,'attributes',[name: 'org.eclipse.ajdt.aspectpath', value: 'org.eclipse.ajdt.aspectpath'])
- node.appendNode(adjtAttr)
- }
- }
- def writer = new FileWriter(srcFile)
- new XmlNodePrinter(new PrintWriter(writer)).print(classpath)
- }
- }
- afterEclipseImport.dependsOn afterEclipseImportAjdtFix
- }
|