API 文件 | IdeaProject (IDEA 專案) |
---|
啟用微調 IDEA 外掛的專案詳細資訊 (*.ipr 檔案)。
混合所有可能屬性的使用範例。通常您不必直接設定 IDEA 模組,因為 Gradle 會為您設定。
import org.gradle.plugins.ide.idea.model.* plugins { id 'java' id 'idea' } idea { project { //if you want to set specific jdk and language level jdkName = '1.6' languageLevel = '1.5' //you can update the source wildcards wildcards += '!?*.ruby' //you can configure the VCS used by the project vcs = 'Git' //you can change the modules of the *.ipr //modules = project(':some-project').idea.module //you can change the output file outputFile = new File(outputFile.parentFile, 'someBetterName.ipr') //you can add project-level libraries projectLibraries << new ProjectLibrary(name: "my-library", classes: [new File("path/to/library")]) } }
為了處理邊緣情況,使用者可以對產生的 XML 檔案執行進階設定。也可以透過 beforeMerged 和 whenMerged 閉包影響 IDEA 外掛合併現有組態的方式。
beforeMerged 和 whenMerged 閉包接收 Project
物件
進階設定範例
plugins { id 'java' id 'idea' } idea { project { ipr { //you can tinker with the output *.ipr file before it's written out withXml { def node = it.asNode() node.appendNode('iLove', 'tinkering with the output *.ipr file!') } //closure executed after *.ipr content is loaded from existing file //but before gradle build information is merged beforeMerged { project -> //you can tinker with Project } //closure executed after *.ipr content is loaded from existing file //and after gradle build information is merged whenMerged { project -> //you can tinker with Project } } } }
屬性 | 描述 |
ipr | |
jdkName | 用於定義專案 SDK 的 Java 版本。 |
languageLevel | 此專案預設使用的 Java 語言等級。 |
modules | ipr 檔案的模組。 |
outputFile | 輸出 *.ipr |
projectLibraries | 要新增至 IDEA 專案的專案層級函式庫。 |
targetBytecodeVersion | 此專案使用的目標位元組碼版本。 |
vcs | 專案的 VCS。 |
wildcards | 萬用字元資源模式。 |
方法 | 描述 |
ipr(action) | 啟用進階設定,例如調整輸出 XML 或影響現有的 *.ipr 內容與 Gradle 建置資訊合併的方式。 |
區塊 | 描述 |
ipr | 啟用進階設定,例如調整輸出 XML 或影響現有的 *.ipr 內容與 Gradle 建置資訊合併的方式。 |
String
jdkName
用於定義專案 SDK 的 Java 版本。
請參閱 IdeaProject
的文件中的範例
- 使用
idea
外掛的預設值 - 用於執行 Gradle 的 Java 版本,例如
'1.6'
- 使用
idea
和java
外掛的預設值 - 用於執行 Gradle 的 Java 版本,例如
'1.6'
IdeaLanguageLevel
languageLevel
此專案預設使用的 Java 語言等級。
一般來說,不建議變更此值。相反地,建議您為 Gradle 專案設定 sourceCompatibility
和 targetCompatibility
,讓您可以完全控制 Gradle 專案中的語言等級,並確保 Gradle 和 IDEA 在編譯時使用相同的設定。
若未明確設定,則會計算為此 IDEA 專案的 IDEA 模組的最高語言等級。
- 使用
idea
外掛的預設值 JavaVersion.JAVA_1_6
- 使用
idea
和java
外掛的預設值 project.sourceCompatibility
List
<IdeaModule
>
modules
List
<IdeaModule
>ipr 檔案的模組。
請參閱 IdeaProject
的文件中的範例
- 使用
idea
外掛的預設值 project.allprojects.idea.module
File
outputFile
輸出 *.ipr
請參閱 IdeaProject
的文件中的範例。
- 使用
idea
外掛的預設值 ${project.projectDir}
/${project.name}
.ipr
Set
<ProjectLibrary
>
projectLibraries
Set
<ProjectLibrary
>要新增至 IDEA 專案的專案層級函式庫。
- 使用
idea
外掛的預設值 []
(使用scala-base
外掛為[scala-library]
)- 使用
idea
和java
外掛的預設值 []
(使用scala-base
外掛為[scala-library]
)
JavaVersion
targetBytecodeVersion
此專案使用的目標位元組碼版本。
一般來說,不建議變更此值。相反地,建議您為 Gradle 專案設定 sourceCompatibility
和 targetCompatibility
,讓您可以完全控制 Gradle 專案中的語言等級,並確保 Gradle 和 IDEA 在編譯時使用相同的設定。
當 languageLevel
未明確設定時,會計算為此 IDEA 專案的 IDEA 模組的最高目標位元組碼版本。
- 使用
idea
外掛的預設值 JavaVersion.JAVA_1_6
- 使用
idea
和java
外掛的預設值 - 所有 Java 子專案的最高
project.targetCompatibility
值,若找不到 Java 專案則為JavaVersion.JAVA_1_6
。
void
ipr
(Action
<? super XmlFileContentMerger
>
action)
Action
<? super XmlFileContentMerger
>啟用進階設定,例如調整輸出 XML 或影響現有的 *.ipr 內容與 Gradle 建置資訊合併的方式。
請參閱 IdeaProject
的文件中的範例
啟用進階設定,例如調整輸出 XML 或影響現有的 *.ipr 內容與 Gradle 建置資訊合併的方式。
請參閱 IdeaProject
的文件中的範例
- 委派至
XmlFileContentMerger
,來自ipr