簡體   English   中英

如何在IntelliJ中設置Java Gradle插件項目?

[英]How to setup a Java Gradle plugin project in IntelliJ?

我在為IntelliJ設置Java Gradle插件項目時遇到問題。

具體來說,我無法讓Java導入所需的gradle庫。

import org.gradle.api.Plugin;
import org.gradle.api.Project;

我找到了Groovy的答案並將其移植到Java。

確保已下載gradle,並將gradle bin目錄添加到了路徑中。

為項目創建一個新目錄。打開命令提示符,然后運行以下命令:

gradle init --type java-library

然后編輯生成的build.gradle文件並添加以下依賴項:

compile gradleApi()

以及以下內容:

apply plugin: 'idea'

這將導致一個build.gradle看起來像:

// Apply the java plugin to add support for Java
apply plugin: 'java'
apply plugin: 'idea'

// In this section you declare where to find the dependencies of your project
repositories {
    // Use jcenter for resolving your dependencies.
    // You can declare any Maven/Ivy/file repository here.
    jcenter()
}

dependencies {
    compile gradleApi()

    // The production code uses Guava
    compile 'com.google.guava:guava:20.0'

    // Use JUnit test framework
    testCompile 'junit:junit:4.12'
}

然后返回命令提示符,運行:

gradlew idea

並在IntelliJ中打開生成的項目

Groovy來源: 如何在IntelliJ中設置Gradle插件項目?

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM