Cannot manually configure a facet for eclipse-wtp plugin unless Jar or Ear plugin is applied

Hi,

I am trying to create eclipse projects for my ejb artifacts. In order to do so I need elipse-wtp, which in turn requires either the ear or war plugin,

When I issue a build an ear artifact is created. Now I have tried to silence it with the following:

task ear(overwrite: true, dependsOn: jar) << {
}
build.dependsOn ear

which does build the jar that I require, but it still builds the ear though.

Any way I can configure the build task to not build the ear?

Thanks

Ciao Stefano

BTW the eclipse plugin keeps printing this warning:

Dynamic properties have been deprecated (property “deployName” on the object "org.gradle.plugins.ide.eclipse.model.EclipseModel_Decorated@ …

I guess this would work …

ear.onlyIf { false }
build.dependsOn jar

the eclipse plugin keeps printing this warning:

Dynamic properties have been deprecated (property “deployName” on the object "org.gradle.plugins.ide.eclipse.model.EclipseModel_Decorated@ …

Sounds like you are configuring the ‘deployName’ property on the wrong object. It’s ‘eclipse.wtp.component.deployName = …’.

In order to do so I need elipse-wtp, which in turn requires either the ear or war plugin,

It doesn’t require either, but will perform additional configuration if either of them is present.

When I issue a build an ear artifact is created.

This will only happen if you applied the ‘ear’ plugin.

I guess this would work …

Are you trying to get an Ear-like Eclipse configuration without actually producing an Ear? Then this might be the way to go. However, ‘build.dependsOn ear/jar’ is redundant and can be removed.

Hi,

The wtp-eclipse plugin won’t let me configure wtp.facets if the ear or war plugins are not applied

this is what I get:

FAILURE: Build failed with an exception.
  * Where:
Script '/home/ssantoro/dev/ejlipse/evb/eclipse-client-jar.gradle' line: 41
  * What went wrong:
A problem occurred evaluating script.
> No signature of method: org.gradle.plugins.ide.eclipse.model.EclipseWtp.facet() is applicable for argument types: (java.util.LinkedHashMap) values: [[type:fixed, name:java]]
  Possible solutions: facet(groovy.lang.Closure), wait(), getFacet(), wait(long), each(groovy.lang.Closure), find()
  * Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
  BUILD FAILED

I’d rather not apply the ear plugin, but I have to in order to configure eclipse as I wish.

There is no ‘eclipse.wtp.facet(Map)’. It’s ‘eclipse.wtp.facet.facet(Map)’ (see the DSL reference). You don’t have to apply the ‘ear’ or ‘war’ plugin to get the ability to configure facets.

This is the bit of eclipse dsl that did not work without applying the ear plugin:

eclipse {
       project {
         file {
             whenMerged { project ->
                project.buildCommands += [
                     new BuildCommand('org.eclipse.jdt.core.javabuilder'),
                    new BuildCommand('org.eclipse.wst.common.project.facet.core.builder'),
                    new BuildCommand('org.eclipse.wst.validation.validationbuilder'),
                    new BuildCommand('org.springframework.ide.eclipse.core.springbuilder')
                 ]
                project.buildCommands.unique()
                project.natures += [
                    'org.eclipse.jem.workbench.JavaEMFNature',
                    'org.eclipse.wst.common.modulecore.ModuleCoreNature',
                    'org.eclipse.wst.common.project.facet.core.nature',
                    'org.eclipse.jdt.core.javanature',
                    'org.springframework.ide.eclipse.core.springnature'
                ]
                project.natures.unique()
            }
        }
    }
      classpath {
        noExportConfigurations += configurations.testRuntime
    }
      jdt {
           sourceCompatibility = 1.6
          targetCompatibility = 1.6
    }
      wtp {
        component {
             deployName = project.name
        }
            facet {
             facet type: FacetType.fixed, name: 'java'
            facet type: FacetType.fixed, name: 'jst.utility'
                      facet name: 'java', version: "1.6"
            facet name: 'jst.utility', version: "1.0"
              file {
                 withXml {
xml ->
                    if ( ! xml.asNode().runtime ) {
                         NodeBuilder bld = new NodeBuilder()
                        xml.asNode().children().add(0, bld.runtime(name: eclipseJbossRuntimeName))
                    }
                }
            }
        }
    }
}

Please let met me know if I did not do it correctly, and if not how may I configure facets without applying the ear plugin.

Thanks!

Please provide a self-contained runnable build script that demonstrates the problem. Otherwise I won’t be able to help.

Please find a self contained gradle project at http://db.tt/Q4Vq3GpF

I have commented out the apply plugin: ‘ear’ in the build.gradle file

Thank You for your much appreciated offer to help

Ciao Stefano

Currently, your options are:

  • Apply the War or Ear plugin * Manually add and configure a GenerateEclipseWtpFacet task

It might be a good idea to make the eclipse-wtp plugin always add a GenerateEclipseWtpFacet task and to always initialize eclipse.wtp.facet to a non-null value.

I’ve created GRADLE-2221 for this.

Hi Stefano and Peter,

here is a third option:

Use the “gradle.projectsEvaluated” configuration closure (as eclipse-wtp tasks are configurated within “project.gradle.projectsEvaluated” in “org.gradle.plugins.ide.eclipse.EclipseWtpPlugin”):

gradle.projectsEvaluated {
  project(':common') {
    apply plugin: 'eclipse-wtp'
     eclipse {
      wtp {
        facet {
          facet type: org.gradle.plugins.ide.eclipse.model.Facet.FacetType.fixed, name: 'wst.jsdt.web'
          facet name: 'java', version: '1.6'
          facet name: 'jst.web', version: '3.0'
          facet name: 'wst.jsdt.web', version: '1.0'
        }
      }
    }
  }
}

Edit: The best is using the configuration closure at the end of your project such that all internal closures are already executed (still kind of ugly and no gradle style …)

Hi stefano,

since my reply, I have also created an already applied pull request fixing this topic. The fix weill be delivered with Gradle v2.3 (which is hopefully coming soon :slight_smile: ).

Cheers, Andreas

Hi stefano,

since my reply, I have also created an already applied pull request fixing this topic. The fix weill be delivered with Gradle v2.3 (which is hopefully coming soon :slight_smile: ).

Cheers, Andreas

Hi stefano,

since my reply, I have also created an already applied pull request fixing this topic. The fix weill be delivered with Gradle v2.3 (which is hopefully coming soon :slight_smile: ).

Cheers, Andreas