简体   繁体   English

如何使用Gradle脚本在jar中添加支持文件

[英]How to add supporting file in jar using gradle script

I have created a jar file using gradle. 我已经使用gradle创建了一个jar文件。 How to add supporting file to this jar file 如何将支持文件添加到此jar文件

My file structure is 我的文件结构是

       common\src\com\sp\

            in this I have a java file

       common\src\bundle

            in this I have a property file

my build.gradle is in common package 我的build.gradle在通用包中

I have run my gradle I got jar file 我已经运行了gradle我有jar文件

I have extract a jar file I have class file only I didn't get a property file how to get property files in my gradle 我提取了一个jar文件,我只有类文件,但我没有属性文件,如何在gradle中获取属性文件

my buld.gradle is given bellow 我的buld.gradle被吼叫

apply plugin: 'java'

sourceCompatibility = '1.7'
targetCompatibility = '1.7'

    dependencies {

        compile files ('lib/commons-codec-1.8.jar')
        compile files ('lib/trinidad-api.jar')
        compile files ('lib/javax.ejb_3.0.1.jar')
        compile files ('lib/toplink-grid.jar')
        compile files ('lib/trinidad-impl.jar')
        compile files ('lib/javax.servlet_1.0.0.0_2-5.jar')
        compile files ('lib/javax.jsp_1.2.0.0_2-1.jar')
        compile files ('lib/adfm.jar')
             compile gradleApi()
    compile localGroovy()
    }   
sourceSets {
    main {
        java {
            srcDirs = ['src']
        }
    }

}

Your directory structure is not following any conventions. 您的目录结构未遵循任何约定。 The resource directory should not be under the src. 资源目录不应位于src下。 It could be a sibling of src. 可能是src的同级。 Please see http://www.gradle.org/docs/current/userguide/java_plugin.html for some ideas. 请参阅http://www.gradle.org/docs/current/userguide/java_plugin.html以获得一些想法。

If you want to make it work: The java plugin has many properties, one of them is for resources- resources 如果您想使其工作:Java插件具有许多属性,其中之一是资源- 资源

sourceSets {
    main {
        java {
            srcDir = 'src'
        }
        resources {
            srcDir 'src/bundle'
        }
    }

}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM