Java插件中的Gradle - jar文件名 [英] Gradle - jar file name in java plugin

查看:124
本文介绍了Java插件中的Gradle - jar文件名的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在第一次尝试Gradle。我想用一个Maven Java项目来编译和创建一个jar文件。它正在build / libs目录中编译和创建jar文件,如
$ b


trunk -XXXVERSION-SNAPSHOT.jar


我从这个maven java项目的trunk目录运行gradle构建文件。



我想在jar文件名中得到项目名称(例如:project1),就像


project1 -XXXVERSION-SNAPSHOT.jar

在build / libs目录。
请建议。

解决方案

默认项目名称取自项目存储目录。明确指定jar的命名,应该为项目设置正确的项目名称。目前,这在 build.gradle 文件中是不可能的。相反,您必须在根目录中创建 settings.gradle 文件。这个 settings.gradle 文件应该包含以下内容:

  rootProject .name ='project1'


I am trying with Gradle first time. I am trying with a maven java project to compile and create a jar file. It is compiling and creating the jar file in build/libs directory as

trunk-XXXVERSION-SNAPSHOT.jar

I am running gradle build file from trunk directory of this maven java project.

I want to get the project name (for ex: project1) in the jar file name, something like

project1-XXXVERSION-SNAPSHOT.jar

in build/libs directory. Please suggest.

解决方案

The default project name is taken from the directory the project is stored in. Instead of changing the naming of the jar explicitly you should set the project name correct for your build. At the moment this is not possible within the build.gradle file. Instead, you have to create a settings.gradle file in your root directory. This settings.gradle file should have this one liner included:

rootProject.name = 'project1'

这篇关于Java插件中的Gradle - jar文件名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆