简体   繁体   English

如何在Netbeans中启用gradle守护程序?

[英]How to enable the gradle daemon in Netbeans?

While it's possible to run gradle from the CLI: 虽然可以从CLI运行gradle:

thufir@mordor:~/NetBeansProjects/gradle$ 
thufir@mordor:~/NetBeansProjects/gradle$ clear;gradle clean build;java -jar build/libs/gradle.jar 

:clean
:compileJava
:processResources UP-TO-DATE
:classes
:jar
:assemble
:compileTestJava UP-TO-DATE
:processTestResources UP-TO-DATE
:testClasses UP-TO-DATE
:test UP-TO-DATE
:check UP-TO-DATE
:build

BUILD SUCCESSFUL

Total time: 3.674 secs

This build could be faster, please consider using the Gradle Daemon: http://gradle.org/docs/2.5/userguide/gradle_daemon.html
hello world
thufir@mordor:~/NetBeansProjects/gradle$ 

How do specify to use the daemon? 如何指定使用守护程序?

build file: 构建文件:

apply plugin: 'java'

sourceCompatibility = '1.8'
[compileJava, compileTestJava]*.options*.encoding = 'UTF-8'

// NetBeans will automatically add "run" and "debug" tasks relying on the
// "mainClass" property. You may however define the property prior executing
// tasks by passing a "-PmainClass=<QUALIFIED_CLASS_NAME>" argument.
//
// Note however, that you may define your own "run" and "debug" task if you
// prefer. In this case NetBeans will not add these tasks but you may rely on
// your own implementation.
if (!hasProperty('mainClass')) {
    ext.mainClass = ''
}

repositories {
    mavenCentral()
    // You may define additional repositories, or even remove "mavenCentral()".
    // Read more about repositories here:
    //   http://www.gradle.org/docs/current/userguide/dependency_management.html#sec:repositories
}

dependencies {
    // TODO: Add dependencies here ...
    // You can read more about how to add dependency here:
    //   http://www.gradle.org/docs/current/userguide/dependency_management.html#sec:how_to_declare_your_dependencies
    testCompile group: 'junit', name: 'junit', version: '4.10'
}


jar  {
    manifest {
        attributes 'Main-Class': 'net.bounceme.mordor.gradle.HelloWorld'
    }
}

Netbeans doesn't create a gradle.properties file. Netbeans不会创建gradle.properties文件。 I added such a file: 我添加了这样的文件:

thufir@mordor:~/NetBeansProjects/gradle$ cat gradle.properties 
org.gradle.daemon=true
thufir@mordor:~/NetBeansProjects/gradle$ 

So that the daemon is enabled. 这样就启用了守护程序。 Is this the correct Netbeans way? 这是正确的Netbeans方式吗? Or, will this cause problems down the road? 还是会在以后引起问题? Seems odd that the plugin didn't include this setting. 插件未包含此设置似乎很奇怪。

Netbeans, just like other IDEs, uses the Gradle Tooling API to execute builds internally. 与其他IDE一样,Netbeans也使用Gradle Tooling API在内部执行构建。 It just so happens that the Tooling API always uses the Gradle Daemon , so no configuration is needed for Netbeans itself. 碰巧的是,Tooling API 始终使用Gradle Daemon ,因此Netbeans本身不需要任何配置。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM