# Class EclipseWtpComponent

java.lang.Object
org.gradle.plugins.ide.eclipse.model.EclipseWtpComponent

public abstract class EclipseWtpComponent extends Object
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
            }
          }
        }
      }
    }

Since:
  1.0

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `EclipseWtpComponent(Project project, XmlFileContentMerger file)`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `void`
  `file(Closure closure)`
  Deprecated.
  Will be removed in Gradle 10.
  `void`
  `file(Action<? super XmlFileContentMerger> action)`
  Deprecated.
  Will be removed in Gradle 10.
  `String`
  `getClassesDeployPath()`
  The deploy path for classes.
  `String`
  `getContextPath()`
  The context path for the web application
  `String`
  `getDeployName()`
  The deploy name to be used.
  `XmlFileContentMerger`
  `getFile()`
  Deprecated.
  Will be removed in Gradle 10.
  `org.gradle.plugins.ide.eclipse.model.internal.FileReferenceFactory`
  `getFileReferenceFactory()`
  Returns the file reference factory.
  `Set<Configuration>`
  `getLibConfigurations()`
  The configurations whose files are to be marked to be deployed with a deploy path of `getLibDeployPath()`.
  `String`
  `getLibDeployPath()`
  The deploy path for libraries.
  `Set<Configuration>`
  `getMinusConfigurations()`
  The configurations whose files are to be excluded from wtp deployment.
  `Map<String,File>`
  `getPathVariables()`
  The variables to be used for replacing absolute path in dependent-module elements.
  `Set<Configuration>`
  `getPlusConfigurations()`
  Synonym for `getLibConfigurations()`.
  `Project`
  `getProject()`
  Returns the project.
  `List<WbProperty>`
  `getProperties()`
  Additional property elements.
  `List<WbResource>`
  `getResources()`
  Additional wb-resource elements.
  `Set<Configuration>`
  `getRootConfigurations()`
  The configurations whose files are to be marked to be deployed with a deploy path of '/'.
  `Set<File>`
  `getSourceDirs()`
  Source directories to be transformed into wb-resource elements.
  `void`
  `mergeXmlComponent(WtpComponent xmlComponent)`
  Deprecated.
  Will be removed in Gradle 10.
  `void`
  `property(Map<String,String> args)`
  Adds a property.
  `void`
  `resource(Map<String,String> args)`
  Adds a wb-resource.
  `void`
  `setClassesDeployPath(String classesDeployPath)`
  Sets the classes deploy path.
  `void`
  `setContextPath(String contextPath)`
  Sets the context path.
  `void`
  `setDeployName(String deployName)`
  Sets the deploy name.
  `void`
  `setLibConfigurations(Set<Configuration> libConfigurations)`
  Sets the lib configurations.
  `void`
  `setLibDeployPath(String libDeployPath)`
  Sets the lib deploy path.
  `void`
  `setMinusConfigurations(Set<Configuration> minusConfigurations)`
  Sets the minus configurations.
  `void`
  `setPathVariables(Map<String,File> pathVariables)`
  Sets the path variables.
  `void`
  `setPlusConfigurations(Set<Configuration> plusConfigurations)`
  Synonym for `setLibConfigurations(Set)`.
  `void`
  `setProperties(List<WbProperty> properties)`
  Sets the properties.
  `void`
  `setResources(List<WbResource> resources)`
  Sets the resources.
  `void`
  `setRootConfigurations(Set<Configuration> rootConfigurations)`
  Sets the root configurations.
  `void`
  `setSourceDirs(Set<File> sourceDirs)`
  Sets the source dirs.

  ### Methods inherited from class Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Constructor Details

  - ### EclipseWtpComponent

    @Inject public EclipseWtpComponent(Project project, XmlFileContentMerger file)

- ## Method Details

  - ### getProject

    public Project getProject()
    Returns the project.
    Since:
      1.0

  - ### getFile

    @Deprecated public XmlFileContentMerger getFile()
    Deprecated.
    Will be removed in Gradle 10.
    See `file(Action)`
    Since:
      1.0

  - ### file

    @Deprecated public void file(@DelegatesTo(XmlFileContentMerger.class) Closure closure)
    Deprecated.
    Will be removed in Gradle 10.
    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`

    Since:
      1.0

  - ### file

    @Deprecated public void file(Action<? super XmlFileContentMerger> action)
    Deprecated.
    Will be removed in Gradle 10.
    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`

    Since:
      3.5

  - ### getSourceDirs

    public Set<File> getSourceDirs()
    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.

    Since:
      1.0

  - ### setSourceDirs

    public void setSourceDirs(Set<File> sourceDirs)
    Sets the source dirs.
    Since:
      1.0

  - ### getRootConfigurations

    public Set<Configuration> getRootConfigurations()
    The configurations whose files are to be marked to be deployed with a deploy path of '/'.

    For examples see docs for `EclipseWtp`

    Since:
      1.0

  - ### setRootConfigurations

    public void setRootConfigurations(Set<Configuration> rootConfigurations)
    Sets the root configurations.
    Since:
      1.0

  - ### getLibConfigurations

    public Set<Configuration> getLibConfigurations()
    The configurations whose files are to be marked to be deployed with a deploy path of `getLibDeployPath()`.

    For examples see docs for `EclipseWtp`

    Since:
      1.0

  - ### setLibConfigurations

    public void setLibConfigurations(Set<Configuration> libConfigurations)
    Sets the lib configurations.
    Since:
      1.0

  - ### getPlusConfigurations

    public Set<Configuration> getPlusConfigurations()
    Synonym for `getLibConfigurations()`.
    Since:
      1.0

  - ### setPlusConfigurations

    public void setPlusConfigurations(Set<Configuration> plusConfigurations)
    Synonym for `setLibConfigurations(Set)`.
    Since:
      1.0

  - ### getMinusConfigurations

    public Set<Configuration> getMinusConfigurations()
    The configurations whose files are to be excluded from wtp deployment.

    For examples see docs for `EclipseWtp`

    Since:
      1.0

  - ### setMinusConfigurations

    public void setMinusConfigurations(Set<Configuration> minusConfigurations)
    Sets the minus configurations.
    Since:
      1.0

  - ### getDeployName

    public String getDeployName()
    The deploy name to be used.

    For examples see docs for `EclipseWtp`

    Since:
      1.0

  - ### setDeployName

    public void setDeployName(String deployName)
    Sets the deploy name.
    Since:
      1.0

  - ### getResources

    public List<WbResource> getResources()
    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.

    Since:
      1.0

  - ### setResources

    public void setResources(List<WbResource> resources)
    Sets the resources.
    Since:
      1.0

  - ### resource

    public void resource(Map<String,String> args)
    Adds a wb-resource.

    For examples see docs for `EclipseWtp`

    Parameters:
      `args` - A map that must contain a deployPath and sourcePath key with corresponding values.
    Since:
      1.0

  - ### getProperties

    public List<WbProperty> getProperties()
    Additional property elements.

    For examples see docs for `EclipseWtp`

    Since:
      1.0

  - ### setProperties

    public void setProperties(List<WbProperty> properties)
    Sets the properties.
    Since:
      1.0

  - ### property

    public void property(Map<String,String> args)
    Adds a property.

    For examples see docs for `EclipseWtp`

    Parameters:
      `args` - A map that must contain a 'name' and 'value' key with corresponding values.
    Since:
      1.0

  - ### getContextPath

    public String getContextPath()
    The context path for the web application

    For examples see docs for `EclipseWtp`

    Since:
      1.0

  - ### setContextPath

    public void setContextPath(String contextPath)
    Sets the context path.
    Since:
      1.0

  - ### getClassesDeployPath

    public String getClassesDeployPath()
    The deploy path for classes.

    For examples see docs for `EclipseWtp`

    Since:
      1.0

  - ### setClassesDeployPath

    public void setClassesDeployPath(String classesDeployPath)
    Sets the classes deploy path.
    Since:
      1.0

  - ### getLibDeployPath

    public String getLibDeployPath()
    The deploy path for libraries.

    For examples see docs for `EclipseWtp`

    Since:
      1.0

  - ### setLibDeployPath

    public void setLibDeployPath(String libDeployPath)
    Sets the lib deploy path.
    Since:
      1.0

  - ### getPathVariables

    public Map<String,File> getPathVariables()
    The variables to be used for replacing absolute path in dependent-module elements.

    For examples see docs for `EclipseModel`

    Since:
      1.0

  - ### setPathVariables

    public void setPathVariables(Map<String,File> pathVariables)
    Sets the path variables.
    Since:
      1.0

  - ### getFileReferenceFactory

    public org.gradle.plugins.ide.eclipse.model.internal.FileReferenceFactory getFileReferenceFactory()
    Returns the file reference factory.
    Since:
      1.0

  - ### mergeXmlComponent

    @Deprecated public void mergeXmlComponent(WtpComponent xmlComponent)
    Deprecated.
    Will be removed in Gradle 10.
    Merges the existing component file content with the configuration from this model.
    Since:
      1.0