EclipseWtpComponent

啟用 Eclipse 外掛的 wtp 組件詳細資訊微調

結合所有可能屬性的使用範例。請注意,通常您不必直接設定它們,因為 Gradle 會免費為您設定!

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'
    }
  }
}

為了處理邊緣情況,使用者可以對產生的 XML 檔案執行進階設定。也可以透過 beforeMerged 和 whenMerged 閉包影響 eclipse 外掛合併現有組態的方式。

beforeMerged 和 whenMerged 閉包接收 WtpComponent 物件

進階設定範例

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

屬性

屬性描述
classesDeployPath

類別的部署路徑。

contextPath

Web 應用程式的 context path (上下文路徑)

deployName

要使用的部署名稱。

file

請參閱 EclipseWtpComponent.file(org.gradle.api.Action)

libConfigurations

其檔案將被標記為部署的組態,部署路徑為 EclipseWtpComponent.getLibDeployPath()

libDeployPath

函式庫的部署路徑。

minusConfigurations

要從 wtp 部署中排除的組態。

properties

額外的 property 元素。

resources

額外的 wb-resource 元素。

rootConfigurations

其檔案將被標記為部署的組態,部署路徑為 '/'。

sourceDirs

要轉換為 wb-resource 元素的原始碼目錄。

方法

方法描述
file(action)

啟用進階設定,例如修改輸出 XML 或影響現有 wtp 組件檔案內容與 gradle 建置資訊合併的方式。

property(args)

新增一個屬性。

resource(args)

新增一個 wb-resource。

腳本區塊

區塊描述
file

啟用進階設定,例如修改輸出 XML 或影響現有 wtp 組件檔案內容與 gradle 建置資訊合併的方式

屬性詳細資訊

String classesDeployPath

類別的部署路徑。

範例請參閱 EclipseWtp 的文件

使用 eclipsewar 外掛的預設值
/WEB-INF/classes
使用 eclipseear 外掛的預設值
/

String contextPath

Web 應用程式的 context path (上下文路徑)

範例請參閱 EclipseWtp 的文件

使用 eclipsewar 外掛的預設值
project.war.baseName

String deployName

要使用的部署名稱。

範例請參閱 EclipseWtp 的文件

使用 eclipsewar 外掛的預設值
eclipse.project.name
使用 eclipseear 外掛的預設值
eclipse.project.name

Set<Configuration> libConfigurations

其檔案將被標記為部署的組態,部署路徑為 EclipseWtpComponent.getLibDeployPath()

範例請參閱 EclipseWtp 的文件

使用 eclipsewar 外掛的預設值
[project.configurations.runtimeClasspath]
使用 eclipseear 外掛的預設值
[project.configurations.earlib]

String libDeployPath

函式庫的部署路徑。

範例請參閱 EclipseWtp 的文件

使用 eclipsewar 外掛的預設值
/WEB-INF/lib
使用 eclipseear 外掛的預設值
/lib

Set<Configuration> minusConfigurations

要從 wtp 部署中排除的組態。

範例請參閱 EclipseWtp 的文件

使用 eclipsewar 外掛的預設值
[project.configurations.providedRuntime]
使用 eclipseear 外掛的預設值
[]

List<WbProperty> properties

額外的 property 元素。

範例請參閱 EclipseWtp 的文件

使用 eclipsewar 外掛的預設值
[]
使用 eclipseear 外掛的預設值
[]

List<WbResource> resources

額外的 wb-resource 元素。

範例請參閱 EclipseWtp 的文件

只有連結到現有目錄 (WbResource.getSourcePath()) 的資源才會新增到 wtp 組件檔案。原因是當專案匯入到 Eclipse 時,不存在的資源目錄宣告會導致錯誤。

使用 eclipsewar 外掛的預設值
[deployPath: '/', sourcePath: project.webAppDirName]
使用 eclipseear 外掛的預設值
[]

Set<Configuration> rootConfigurations

其檔案將被標記為部署的組態,部署路徑為 '/'。

範例請參閱 EclipseWtp 的文件

使用 eclipsewar 外掛的預設值
[]
使用 eclipseear 外掛的預設值
[project.configurations.deploy]]

Set<File> sourceDirs

要轉換為 wb-resource 元素的原始碼目錄。

範例請參閱 EclipseWtp 的文件

只有存在的原始碼目錄才會新增到 wtp 組件檔案。不存在的資源目錄宣告會導致專案匯入到 Eclipse 時發生錯誤。

使用 eclipsewar 外掛的預設值
來自 project.sourceSets.main.allSource 的原始碼目錄
使用 eclipseear 外掛的預設值
相同,除非未套用 java 外掛,否則為:[project.appDirName]

方法詳細資訊

void file(Action<? super XmlFileContentMerger> action)

啟用進階設定,例如修改輸出 XML 或影響現有 wtp 組件檔案內容與 gradle 建置資訊合併的方式。

範例請參閱 EclipseWtpComponent 的文件

void property(Map<String, String> args)

新增一個屬性。

範例請參閱 EclipseWtp 的文件

void resource(Map<String, String> args)

新增一個 wb-resource。

範例請參閱 EclipseWtp 的文件

腳本區塊詳細資訊

file { }

啟用進階設定,例如修改輸出 XML 或影響現有 wtp 組件檔案內容與 gradle 建置資訊合併的方式

傳遞到 whenMerged{} 和 beforeMerged{} 閉包的物件類型為 WtpComponent

範例請參閱 EclipseWtpComponent 的文件

委派給
來自 fileXmlFileContentMerger