Java / Gradle:使用外部config.properties文件覆盖Jar中的属性

时间:2018-05-08 19:05:22

标签: java gradle

我正在使用以下Gradle任务创建一个Jar(这里很新,所以可能出错):

task fatJar(type: Jar) {
manifest {
    attributes 'Implementation-Title': 'Gradle Jar File Example',
            'Implementation-Version': version,
            'Main-Class': 'EntryPoint',
            'Class-Path': configurations.runtimeClasspath.files.collect { it.getName() }.join(' ')
    exclude 'META-INF/*.RSA', 'META-INF/*.SF','META-INF/*.DSA'
}

baseName = project.name
from { configurations.compile.collect { it.isDirectory() ? it : zipTree(it) } }
with jar

}

这将我的所有配置文件整齐地打包到Jar中。我想要做的是在类路径中添加一个外部目录(理想情况下,这将是Jar所在的文件夹),它可以(但可能不)包含值与jar中的值不同的配置文件。如果该目录不为空,我希望我的代码使用其中的文件。如果是,或者还有其他问题,我希望它恢复到Jar内的配置文件。我怎样才能做到这一点?

0 个答案:

没有答案
相关问题