How to expand property references in jar resources?

前端 未结 5 1946
挽巷
挽巷 2021-01-12 06:47

I\'m using Gradle to build a jar containing an xml file in META-INF. This file has a row like



        
5条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2021-01-12 06:51

    I took your first attempt and created a test project. I put a pom file from a jenkins plugin in ./src/main/resources/META-INF/. I assume it is a good enough xml example. I replaced the artifactId line to look like the following:

    ${artifactId}
    

    My build.gradle:

    apply plugin: 'java'
    
    jar {
        expand project.properties
    }
    

    When I ran gradle jar for the first time it exploded because I forgot to define a value for the property. My second attempt succeeded with the following commandline:

     gradle jar -PartifactId=WhoCares
    

    For testing purposes I just defined the property using -P. I'm not sure how you are trying to define your property, but perhaps that is the missing piece. Without seeing the stacktrace of your exception it's hard to know for sure, but the above example worked perfectly for me and seems to solve your problem.

提交回复
热议问题