Announcement Announcement Module
Collapse
No announcement yet.
STS 3.3.0 m2 : Gradle and Web App Libraries Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • STS 3.3.0 m2 : Gradle and Web App Libraries

    I'm trying to set up my project using Gradle.
    Things are OK but when generating the WTP conf files gradle-WTP is adding the Web App libraries automatically to the project.

    I want to get rid of that because it's redundant with the Gradle depedencies and it doesn't handle correctly the exclusions of the transient dependencies.


    Code:
    eclipse {
    	wtp {
    		facet {
    		  facet name: 'jst.web', version: '2.5'
    		  facet name: 'java', version: '1.6'
    		  facet name: 'wst.jsdt.web', version: '1.0'
    		}
    	}	
    }
    I read that adding
    eclipse.classpath.containers.removeAll(EclipseWtpP lugin.WEB_LIBS_CONTAINER)
    should delete the web libs but it doesn't work for me (maybe I added it in the wrong place).

    Any idea?

  • #2
    Ok, tried to remove it "manually" but without any success.

    Code:
    eclipse {
    	
    	project {
    		natures 'com.springsource.sts.gradle.core.nature', 'org.eclipse.jdt.core.javanature',
    		'org.eclipse.jdt.groovy.core.groovyNature',
    		'org.eclipse.wst.common.project.facet.core.nature',
    		'org.eclipse.wst.common.modulecore.ModuleCoreNature',
    		'org.eclipse.jem.workbench.JavaEMFNature'
    	}
    	
    	wtp {
    		facet {
    		  facet name: 'jst.web', version: '2.5'
    		  facet name: 'java', version: '1.6'
    		  facet name: 'wst.jsdt.web', version: '1.0'
    		}
    	}
    	classpath{
    		file {
    			whenMerged { classpath ->
    				
    				def containers = classpath.entries.findAll {entry -> entry.kind == 'con' &&
    					entry.path == EclipseWtpPlugin.WEB_LIBS_CONTAINER }
    				classpath.entries.removeAll(containers)
    				
    			}
    		}
    	}
    }
    and

    Code:
    eclipse {
    	
    	project {
    		natures 'com.springsource.sts.gradle.core.nature', 'org.eclipse.jdt.core.javanature',
    		'org.eclipse.jdt.groovy.core.groovyNature',
    		'org.eclipse.wst.common.project.facet.core.nature',
    		'org.eclipse.wst.common.modulecore.ModuleCoreNature',
    		'org.eclipse.jem.workbench.JavaEMFNature'
    	}
    	
    	wtp {
    		facet {
    		  facet name: 'jst.web', version: '2.5'
    		  facet name: 'java', version: '1.6'
    		  facet name: 'wst.jsdt.web', version: '1.0'
    		}
    	}
    }
    
    eclipse.classpath.file {
    	whenMerged { classpath ->
    		def containers = classpath.entries.findAll {entry ->
    			entry.path == EclipseWtpPlugin.WEB_LIBS_CONTAINER }
    		classpath.entries.removeAll(containers)
    		
    	}
    }
    didn't work

    Also tried entry.path == 'org.eclipse.jst.j2ee.internal.web.container'
    Last edited by NicoTexas; Jun 10th, 2013, 11:49 PM.

    Comment


    • #3
      I've just had a similar issue, and mentioned trick has worked out for me fine.

      1) add this line in your main script, just after "apply [plugin]" section.
      eclipse.classpath.containers.removeAll(EclipseWtpP lugin.WEB_LIBS_CONTAINER)
      2) remove previously generated .classpath file(s). this is necessary because eclipseClasspath task attempts to merge existing .classpath file with generated one. Maybe that's why wtp lib container is so resilient to go away?
      3) repeat "gradle eclipse" command

      Comment


      • #4
        Thanks pijmleko !

        I was trying to remove it from the eclipse{} task.
        I'm fairly new to Gradle

        So having

        Code:
        apply plugin: 'java'
        apply plugin: 'eclipse'
        apply plugin: 'maven'
        apply plugin: 'war'
        apply plugin: 'eclipse-wtp'
        
        eclipse.classpath.containers.removeAll(EclipseWtpPlugin.WEB_LIBS_CONTAINER)
        is getting rid of the Web App libraries entry.
        But now I need to set manually the dependency management.

        I wonder why the STS Gradle Eclispe plugin (or is it gradle itself?) is adding the entry. It seems strange to me.
        Maybe I should open a bug but not sure where

        Comment


        • #5
          > I wonder why the STS Gradle Eclispe plugin (or is it gradle itself?) is adding the entry. It seems strange to me.
          > Maybe I should open a bug but not sure where

          Actualy, I think it is both. In some cases Gradle WTP plugin in adds it. If it is missing then STS Gradle tooling adds it.
          If you think it is wrong, you should raise a bug request on our issue tracker and possibly also follow up with
          Gradle forums if the behavior of the WTP plugin in Gradle is also wrong.

          Issue tracker: https://issuetracker.springsource.com/browse/STS

          Please explain why you think it is wrong however because the reason it is being added is that it was requested by another user:

          https://issuetracker.springsource.com/browse/STS-2185

          This is an old issue and maybe the behavior of Gradle eclipse and WTP plugins have since changed so there is
          no more need for STS itself to intervene and add this container. Adding the container in the tools at the time seemed
          to me to be more of a workaround for an issue with Gradle WTP plugin. Ideally STS Gradle tooling shouldn't
          have to intervene in the classpath info generated by Gradle in this way.

          As I don't use WTP tooling myself I usually defer to informed users to tell me what the correct/desired behavior
          is. So please do raise an issue and explain why the behavior is wrong and how it should behave. Then I can
          probably fix it.

          Thanks

          Kris

          Comment

          Working...
          X