2010-10-06 67 views

回答

3

我不知道这是否是正确的做法,但对罐复制到lib目录中我做到以下几点:

/** 
* Copies the dependencies to the lib directory in preparation for them to be added to a jar file 
*/ 
task copyRuntimeDependencies(dependsOn: configurations.runtime.buildArtifacts, type: Copy) 
    { 
    into('build/output/lib') 
    from configurations.runtime 
    from configurations.runtime.allArtifacts*.file 
    } 
+0

嗯。这似乎不再适用于Gradle 1.5。我认为在那里有一种类型。 – djangofan 2013-03-30 02:56:45

+0

检查gradle食谱总是一个好主意:http://docs.codehaus.org/display/GRADLE/Cookbook#Cookbook-Includeallruntimedependencies – Skarab 2013-03-30 12:05:26

3

这里是一个摇篮2.x到做到这一点:

task copyToLib(type: Copy) { 
    // into "build/lib" 
    into "lib" 
    from configurations.classpath 
} 
+1

或者:您可以使用类型['Sync'](http:// www.gradle.org/docs/1.5/dsl/org.gradle.api.tasks.Sync.html),它还会删除未复制的项目。 – 2013-06-10 16:31:34

+0

谢谢,这工作。我更喜欢它。谢谢。我需要将libs复制到一个文件夹中,以便我可以启用非Java进程启动程序(TFS)在命令行上启动我的JMeter Java进程。 https://github.com/djangofan/launch-jmeter – djangofan 2015-04-15 15:04:00