使用gradle添加资源,配置文件到你的jar [英] Add resources, config files to your jar using gradle

查看:402
本文介绍了使用gradle添加资源,配置文件到你的jar的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我的项目结构:



我的项目结构如何添加配置文件或任何其他资源到我的jar使用gradle?


src / main / java / com / perseus / .. --- Java包(源文件)
$ b $ s

预期的jar结构:


com / perseus / .. --- Java包(类文件)



config / *。xml --- Spring配置文件


解决方案

感谢大家,我正在将现有项目迁移到Gradle,我很喜欢改变项目结构的想法。



我已经知道了,认为这些信息可能对初学者有用。

以下是我的'build.gradle'中的一个示例任务:

  version ='1.0.0'

jar {
baseName ='analytics ''
from('src / main / java'){
include'config / ** / *。xml'
}

manifest {
属性'Implementation-Title':'Analytics Library','Implementation-Version':version
}
}


How do I add config files or any other resources into my jar using gradle?

My project structure:

src/main/java/com/perseus/.. --- Java packages (source files)

src/main/java/config/*.xml --- Spring config files

Expected jar structure:

com/perseus/.. --- Java packages (class files)

config/*.xml --- Spring config files

解决方案

Thanks guys, I was migrating an existing project to Gradle and didn't like the idea of changing the project structure that much.

I have figured it out, thought this information could be useful to beginners.

Here is a sample task from my 'build.gradle':

version = '1.0.0'

jar {
   baseName = 'analytics'
   from('src/main/java') {
      include 'config/**/*.xml'
   }

   manifest {
       attributes 'Implementation-Title': 'Analytics Library', 'Implementation-Version': version
   }
}

这篇关于使用gradle添加资源,配置文件到你的jar的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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