gradle - 如何在gradle中跳过testRuntime任务?

标签 gradle build.gradle

在我的 eclipse 中,有许多使用gradle构建的项目。我想跳过gradle中的testRuntime任务。因为它太慢了,每当我更改一些代码或对项目进行更改时,都会让我等待很长时间。如何避免这种情况?我想申请所有相关项目。

更新

这是gradle任务的结果。 Eclipse正在执行后台作业,我在“进程”选项卡中检查了这些作业,并且可以看到如下所示的消息。

Gradle Build on xxx project

Executing tasks : xxxx:TestRuntime



我认为这需要时间,因为有防火墙。我想跳过此过程。我想,可以通过Eclipse或gradle配置来完成。

我的build.gradle文件
buildscript {
  repositories {
    mavenLocal()
    maven { // for thridparty lib
        url 'http://70.121.244.11:8081/nexus/content/groups/openpms-public'
        credentials {
            username 'openpms'
            password 'openpms0'
        }
     }
     maven { // for thridparty lib
        url 'http://70.121.244.11:8081/nexus/content/repositories/thirdparty'
        credentials {
            username 'developer'
            password 'developer0'
        }
     }
    maven { url 'http://70.121.224.52:8081/nexus/content/repositories/central/' }
    jcenter{ url 'http://70.121.224.52:8081/nexus/content/repositories/jcenter/' }
  }
  dependencies {
    classpath "org.akhikhl.gretty:gretty:$gretty_version"
  }
}

repositories {
    mavenLocal()
    maven {
        url 'http://70.121.244.11:8081/nexus/content/groups/openpms-public'
        credentials {
            username "$maven_username"
            password "$maven_password"
        }
     }

    maven { // for thridparty lib
        url 'http://70.121.244.11:8081/nexus/content/repositories/thirdparty'
        credentials {
            username 'developer'
            password 'developer0'
        }
     }
}

apply plugin: 'java'
apply plugin: 'war'
apply plugin: 'org.akhikhl.gretty'

sourceCompatibility = 1.6
targetCompatibility = 1.6
[compileJava, compileTestJava]*.options*.encoding = 'UTF-8' // compileGroovy, compileTestGroovy

def spring_version = '4.0.6.RELEASE'

dependencies {
    compile group: 'commons-collections', name: 'commons-collections', version: '3.2'
    compile group: 'org.opensymphony.quartz', name: 'quartz', version: '1.6.1'
    compile group: 'commons-logging', name: 'commons-logging', version: '1.0.4'
    compile group: 'javax.servlet', name: 'javax.servlet-api', version: '3.0.1'
}

gretty {
      servletContainer = 'jetty8'
      port = 8080
      contextPath = '/agent.server'
}

更新2
[sts] -----------------------------------------------------
[sts] Starting Gradle build for the following tasks: 
[sts]      tasks
[sts] -----------------------------------------------------
<org.gradle.api.plugins.quality.PmdExtension_Decorated@729eaf4b __dyn_obj__=org.gradle.api.internal.AsmBackedClassGenerator$MixInExtensibleDynamicObject@2fc49256 __mapping__=org.gradle.api.internal.ConventionAwareHelper@1263649a __consoleOutput__=false __ignoreFailures__=true __reportsDir__=true __ruleSetConfig__=false __ruleSetFiles__=true __ruleSets__=true __sourceSets__=true __targetJdk__=false __toolVersion__=true project=root project 'redca-agent' ruleSets=[basic] targetJdk=null ruleSetConfig=null ruleSetFiles=file collection consoleOutput=false toolVersion=4.3 sourceSets=[source set 'main'] ignoreFailures=true reportsDir=D:\workspace\redCAGit\redca-agent\build\reports\pmd>
:tasks

------------------------------------------------------------
All tasks runnable from root project
------------------------------------------------------------

Application tasks
-----------------
bootRun - Run the project with support for auto-detecting main class and reloading static resources
installApp - Installs the project as a JVM application along with libs and OS specific scripts.
run - Runs this project as a JVM application

Build tasks
-----------
assemble - Assembles the outputs of this project.
bootRepackage - Repackage existing JAR and WAR archives so that they can be executed from the command line using 'java -jar'
build - Assembles and tests this project.
buildDependents - Assembles and tests this project and all projects that depend on it.
buildNeeded - Assembles and tests this project and all projects it depends on.
classes - Assembles classes 'main'.
clean - Deletes the build directory.
jar - Assembles a jar archive containing the main classes.
testClasses - Assembles classes 'test'.

Build Setup tasks
-----------------
init - Initializes a new Gradle build. [incubating]
wrapper - Generates Gradle wrapper files. [incubating]

Distribution tasks
------------------
assembleDist - Assembles the main distributions
distTar - Bundles the project as a distribution.
distZip - Bundles the project as a distribution.
installDist - Installs the project as a distribution as-is.

Documentation tasks
-------------------
javadoc - Generates Javadoc API documentation for the main source code.

Help tasks
----------
components - Displays the components produced by root project 'redca-agent'. [incubating]
dependencies - Displays all dependencies declared in root project 'redca-agent'.
dependencyInsight - Displays the insight into a specific dependency in root project 'redca-agent'.
help - Displays a help message.
model - Displays the configuration model of root project 'redca-agent'. [incubating]
projects - Displays the sub-projects of root project 'redca-agent'.
properties - Displays the properties of root project 'redca-agent'.
tasks - Displays the tasks runnable from root project 'redca-agent' (some of the displayed tasks may belong to subprojects).

Verification tasks
------------------
check - Runs all checks.
test - Runs the unit tests.

Other tasks
-----------
findbugsTest - Run FindBugs analysis for test classes
pmdTest - Run PMD analysis for test classes

Rules
-----
Pattern: clean<TaskName>: Cleans the output files of a task.
Pattern: build<ConfigurationName>: Assembles the artifacts of a configuration.
Pattern: upload<ConfigurationName>: Assembles and uploads the artifacts belonging to a configuration.

To see all tasks and more detail, run gradle tasks --all

To see more detail about a task, run gradle help --task <task>

BUILD SUCCESSFUL

Total time: 2.354 secs
[sts] -----------------------------------------------------
[sts] Build finished succesfully!
[sts] Time taken: 0 min, 2 sec
[sts] -----------------------------------------------------

我想知道跳过工作testRuntime的方法。
即使不是任务,我也不担心浪费时间。
如何避免这种情况?

最佳答案

我是新手,我不会英语。请理解。

无论如何,我自己解决了。我正在使用的Eclipse gradle插件正在尝试连接可能被防火墙阻止的Internet上的存储库。所以我无法解决这个问题。有很多工作场所,包括离线的地方。

我可以跳过此操作,为程序实参提供参数,如下所示。您可以在Eclipse偏好设置> Gradle>参数中添加此属性。

--offline

关于gradle - 如何在gradle中跳过testRuntime任务?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33095342/

相关文章:

java - 如何将本地spring boot项目添加为另一个spring boot项目的依赖

android - 在新的 Android Studio 中使用 OpenCL

android - 将 Android 库添加到 Android Studio 0.3.6 上的现有项目

package - Gradle 多项目分布

Gradle:为什么根项目的 "Could not get unknown property ' com' 错误?

gradle - 如何只在gradle中使用基本的Groovy脚本?

android - 如何保留 Android 库的源代码?

gradle - 收集父项目构建目录中的文件

java - 如何在 Jenkins 上的 Gradle 构建中过滤测试而无需提交?

gradle - 如何将 jetty 或 gretty 导入到我的 gradle 脚本中