[GRADLE-2221] Cannot manually configure a facet for eclipse-wtp plugin unless War or Ear plugin is applied Created: 10/Apr/12  Updated: 12/Dec/14  Resolved: 05/Dec/14

Status: Resolved
Project: Gradle
Affects Version/s: None
Fix Version/s: 2.3-rc-1

Type: Improvement
Reporter: Gradle Forums Assignee: Radim Kubacki
Resolution: Fixed Votes: 4

Issue Links:
Duplicate
Duplicated by GRADLE-2362 eclipse-wtp should be supported on no... Resolved

 Description   

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@ ...



 Comments   
Comment by Gradle Forums [ 10/Apr/12 ]

I guess this would work ...

ear.onlyIf

{ false }

build.dependsOn jar

Comment by Gradle Forums [ 10/Apr/12 ]

> 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 = ...`.

Comment by Gradle Forums [ 10/Apr/12 ]

> 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.

Comment by Gradle Forums [ 10/Apr/12 ]

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.

Comment by Gradle Forums [ 10/Apr/12 ]

There is no `eclipse.wtp.facet(Map)`. It's `eclipse.wtp.facet.facet(Map)` (see the [DSL reference]([1]http://gradle.org/docs/current/dsl/or.... You don't have to apply the `ear` or `war` plugin to get the ability to configure facets.
----------------------------------------------------------------------------------------
[1] http://gradle.org/docs/current/dsl/org.gradle.plugins.ide.eclipse.model.EclipseWtpFacet.html))

Comment by Gradle Forums [ 10/Apr/12 ]

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!

Comment by Gradle Forums [ 10/Apr/12 ]

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

Comment by Gradle Forums [ 10/Apr/12 ]

Please find a self contained gradle project at [1]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
----------------------------------------------------------------------------------------
[1] http://db.tt/Q4Vq3GpF

Comment by Gradle Forums [ 10/Apr/12 ]

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.

Comment by Thorsten Möller [ 28/Apr/14 ]

See also http://issues.gradle.org/browse/GRADLE-2186.

Comment by Andreas Schmid [ 26/Oct/14 ]

Hi Stefano,
as I am currently working on a pull request for GRADLE-2186 (see also https://issues.gradle.org/browse/GRADLE-2186?focusedCommentId=19882&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-19882) and this issue, can you again provide the self contained gradle project above?
Cheers,
Andreas

Comment by Radim Kubacki [ 05/Dec/14 ]

Fix provided by Andreas Schmid.

Generated at Wed Jun 30 12:16:01 CDT 2021 using Jira 8.4.2#804003-sha1:d21414fc212e3af190e92c2d2ac41299b89402cf.