Configurations.provided with eclipse-wtp plugin

(KwonNam Son) #1

I succeeded configurations.provided settings with ‘war’ plugin.

But it failed with eclipse-wtp plugin. eclipse-wtp published provided jar libraries even though I set wtp.component.minusConfigurations += confiburations.provided I think it’s because that the wtp project depends on a normal java project which has configurations.provided.

What should I do for WtpProject not to publish configurations.provided jar files??

My Project configurations.

JavaProjectA has configurations.provided, WarProject(with eclipse-wtp) B depends on JavaProjectA.

I refered to GRADLE-784

== AllProjects
 configurations {
  sourceSets {
main { compileClasspath += configurations.provided }
  dependencies {
    provided 'blah..' // actually servlet/jsp apis
  == JavaProjectA
// other dependencies
  == WarProjectB(with eclipse-wtp)
wtp.component.minusConfigurations += configurations.provided

Thanks. KwonNam.

(KwonNam Son) #2

I think this is because of noExportConfigurations’ bug. Anyway i solved this problem.

JavaProjectA has configurations.provided WarProjectB depends on JavaProjectA

I configured like the following, but eclipse publishes configuration.provided libraries. I found the reason is because of noExportConfigurations’ bug.

eclipse {
    classpath {
        plusConfigurations += configurations.provided
        noExportConfigurations += configurations.provided
    wtp {
        component {
            minusConfigurations += configurations.provided

noExportConfigurations generates ‘.classpath’ eclipse file. but like the following.

<classpathentry sourcepath="sourcefilepath" kind="lib" path="xxx.jar">
   <attribute name="org.eclipse.jst.component.dependency" value="../"/>

attribute name=“org.eclipse.jst.component.dependency” value="…/"/ is the reason why eclipse publishes export=false jar files.

so I had to remove thoses elements by myself like the following.

classpath.file.withXml { provider ->
                provider.asNode().classpathentry.findAll {
                    it.@kind == 'lib' && (it.@exported == null || it.@exported == 'false')
                }.each { cpe ->
                    def attributes = cpe.children()[0];
                    if (attributes == null) { return }
                      def componentDependency = attributes.attribute.find { it.@name == 'org.eclipse.jst.component.dependency'}
                    if (componentDependency == null) { return }