[英]How to run Gradle JAR against local dependencies?
When I run gradle clean jar
it pulls down all my executable JAR's dependencies under ~/.gradle
and then creates my JAR. 当我运行
gradle clean jar
它将~/.gradle
下的所有可执行JAR的依赖项~/.gradle
,然后创建我的JAR。
I am then having to jump through serious hoops to run the JAR locally: 然后,我不得不跳过重重障碍才能在本地运行JAR:
lib
directory in the same folder as the newly-created JAR lib
目录 ~/.gradle
and copy them to lib
~/.gradle
挑选出我项目的所有传递依赖项(有很多)并将它们复制到lib
java -jar myapp.jar -cp "lib/*"
java -jar myapp.jar -cp "lib/*"
Every time my dependencies change (new code is added, etc.) I have to go through this process, and it makes me wonder if there is a more elegant way to run your Gradle-built apps locally. 每当我的依赖项发生变化(添加新代码等)时,我都必须经历此过程,这使我想知道是否存在更优雅的方式在本地运行Gradle构建的应用程序。
I ended up going with the application
plugin. 我最终选择了
application
插件。 It turns out that Gradle considers compile
dependencies a subset of runtime
so I didn't need to change any dependency scopes. 事实证明,Gradle将
compile
依赖项视为runtime
的子集,因此我不需要更改任何依赖项范围。 I can now just issue gradle run
and it runs my app beautifully. 我现在可以发出
gradle run
,它可以很好地运行我的应用程序。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.