EclipseWtpComponent - Gradle DSL Version 9.7.0

# EclipseWtpComponent

API Documentation: | `EclipseWtpComponent`

Enables fine-tuning wtp component details of the Eclipse plugin

Example of use with a blend of all possible properties. Bear in mind that usually you don't have to configure them directly because Gradle configures it for free!

    plugins {
        id 'war' // or 'ear' or 'java'
        id 'eclipse-wtp'
    }

    configurations {
      someInterestingConfiguration
      anotherConfiguration
    }

    eclipse {

      //if you want parts of paths in resulting file(s) to be replaced by variables (files):
      pathVariables 'GRADLE_HOME': file('/best/software/gradle'), 'TOMCAT_HOME': file('../tomcat')

      wtp {
        component {
          //you can configure the context path:
          contextPath = 'someContextPath'

          //you can configure the deployName:
          deployName = 'killerApp'

          //you can alter the wb-resource elements.
          //non-existing source dirs won't be added to the component file.
          sourceDirs += file('someExtraFolder')

          // dependencies to mark as deployable with lib folder deploy path
          libConfigurations += [ configurations.someInterestingConfiguration ]

          // dependencies to mark as deployable with root folder deploy path
          rootConfigurations += [ configurations.someInterestingConfiguration ]

          // dependencies to exclude from wtp deployment
          minusConfigurations << configurations.anotherConfiguration

          //you can add a wb-resource elements; mandatory keys: 'sourcePath', 'deployPath':
          //if sourcePath points to non-existing folder it will *not* be added.
          resource sourcePath: 'extra/resource', deployPath: 'deployment/resource'

          //you can add a wb-property elements; mandatory keys: 'name', 'value':
          property name: 'moodOfTheDay', value: ':-D'
        }
      }
    }

For tackling edge cases users can perform advanced configuration on resulting XML file. It is also possible to affect the way eclipse plugin merges the existing configuration via beforeMerged and whenMerged closures.

beforeMerged and whenMerged closures receive `WtpComponent` object

Examples of advanced configuration:

    plugins {
        id 'war'
        id 'eclipse-wtp'
    }

    eclipse {

      wtp {
        component {
          file {
            //if you want to mess with the resulting XML in whatever way you fancy
            withXml {
              def node = it.asNode()
              node.appendNode('xml', 'is what I love')
            }

            //closure executed after wtp component file content is loaded from existing file
            //but before gradle build information is merged
            beforeMerged { wtpComponent ->
              //tinker with WtpComponent here
            }

            //closure executed after wtp component file content is loaded from existing file
            //and after gradle build information is merged
            whenMerged { wtpComponent ->
              //you can tinker with the WtpComponent here
            }
          }
        }
      }
    }

### Properties

Property | Description
`classesDeployPath` | The deploy path for classes.
`contextPath` | The context path for the web application
`deployName` | The deploy name to be used.
`file` | Deprecated See `EclipseWtpComponent.file(org.gradle.api.Action)`
`libConfigurations` | The configurations whose files are to be marked to be deployed with a deploy path of `EclipseWtpComponent.getLibDeployPath()`.
`libDeployPath` | The deploy path for libraries.
`minusConfigurations` | The configurations whose files are to be excluded from wtp deployment.
`properties` | Additional property elements.
`resources` | Additional wb-resource elements.
`rootConfigurations` | The configurations whose files are to be marked to be deployed with a deploy path of '/'.
`sourceDirs` | Source directories to be transformed into wb-resource elements.

### Methods

Method | Description
`file(action)` | Deprecated Enables advanced configuration like tinkering with the output XML or affecting the way existing wtp component file content is merged with gradle build information.
`property(args)` | Adds a property.
`resource(args)` | Adds a wb-resource.

### Script blocks

Block | Description
`file` | Deprecated Enables advanced configuration like tinkering with the output XML or affecting the way existing wtp component file content is merged with gradle build information

### Property details

#### `String` `classesDeployPath`

The deploy path for classes.

For examples see docs for `EclipseWtp`

Default with `eclipse` and `war` plugins:
  `/WEB-INF/classes`
Default with `eclipse` and `ear` plugins:
  `/`

#### `String` `contextPath`

The context path for the web application

For examples see docs for `EclipseWtp`

Default with `eclipse` and `war` plugins:
  `project.war.baseName`

#### `String` `deployName`

The deploy name to be used.

For examples see docs for `EclipseWtp`

Default with `eclipse` and `war` plugins:
  `eclipse.project.name`
Default with `eclipse` and `ear` plugins:
  `eclipse.project.name`

#### `XmlFileContentMerger` `file` (read-only)

Note: This property is deprecated and will be removed in the next major version of Gradle.

See `EclipseWtpComponent.file(org.gradle.api.Action)`

#### ``Set`<`Configuration`>` `libConfigurations`

The configurations whose files are to be marked to be deployed with a deploy path of `EclipseWtpComponent.getLibDeployPath()`.

For examples see docs for `EclipseWtp`

Default with `eclipse` and `war` plugins:
  `[project.configurations.runtimeClasspath]`
Default with `eclipse` and `ear` plugins:
  `[project.configurations.earlib]`

#### `String` `libDeployPath`

The deploy path for libraries.

For examples see docs for `EclipseWtp`

Default with `eclipse` and `war` plugins:
  `/WEB-INF/lib`
Default with `eclipse` and `ear` plugins:
  `/lib`

#### ``Set`<`Configuration`>` `minusConfigurations`

The configurations whose files are to be excluded from wtp deployment.

For examples see docs for `EclipseWtp`

Default with `eclipse` and `war` plugins:
  `[project.configurations.providedRuntime]`
Default with `eclipse` and `ear` plugins:
  `[]`

#### ``List`<`WbProperty`>` `properties`

Additional property elements.

For examples see docs for `EclipseWtp`

Default with `eclipse` and `war` plugins:
  `[]`
Default with `eclipse` and `ear` plugins:
  `[]`

#### ``List`<`WbResource`>` `resources`

Additional wb-resource elements.

For examples see docs for `EclipseWtp`

Only resources that link to an existing directory (`WbResource.getSourcePath()`) will be added to the wtp component file. The reason is that non-existing resource directory declarations lead to errors when project is imported into Eclipse.

Default with `eclipse` and `war` plugins:
  `[deployPath: '/', sourcePath: project.webAppDirName]`
Default with `eclipse` and `ear` plugins:
  `[]`

#### ``Set`<`Configuration`>` `rootConfigurations`

The configurations whose files are to be marked to be deployed with a deploy path of '/'.

For examples see docs for `EclipseWtp`

Default with `eclipse` and `war` plugins:
  `[]`
Default with `eclipse` and `ear` plugins:
  `[project.configurations.deploy]]`

#### ``Set`<`File`>` `sourceDirs`

Source directories to be transformed into wb-resource elements.

For examples see docs for `EclipseWtp`

Only source dirs that exist will be added to the wtp component file. Non-existing resource directory declarations lead to errors when project is imported into Eclipse.

Default with `eclipse` and `war` plugins:
  source dirs from `project.sourceSets.main.allSource`
Default with `eclipse` and `ear` plugins:
  The same unless `java` plugin not applied, then: `[project.appDirName]`

### Method details

#### `void` `file`(``Action`<? super `XmlFileContentMerger`>` action)

Note: This method is deprecated and will be removed in the next major version of Gradle.

Enables advanced configuration like tinkering with the output XML or affecting the way existing wtp component file content is merged with gradle build information.

For example see docs for `EclipseWtpComponent`

#### `void` `property`(``Map`<`String`, `String`>` args)

Adds a property.

For examples see docs for `EclipseWtp`

#### `void` `resource`(``Map`<`String`, `String`>` args)

Adds a wb-resource.

For examples see docs for `EclipseWtp`

### Script block details

#### `file` { }

Note: This script block is deprecated and will be removed in the next major version of Gradle.

Enables advanced configuration like tinkering with the output XML or affecting the way existing wtp component file content is merged with gradle build information

The object passed to whenMerged{} and beforeMerged{} closures is of type `WtpComponent`

For example see docs for `EclipseWtpComponent`

Delegates to:
  `XmlFileContentMerger` from `file`