Home Define variables in gradle to fill data in persistence.xml
Reply: 0

Define variables in gradle to fill data in persistence.xml

user1000
1#
user1000 Published in July 16, 2018, 6:15 pm

Can I define variables in gradle, which are fill in the placeholders in the persistence.xml?

Example

gradle.properties:

dev.classes= <class>my.package.class</class>.....<class>my.package.class</class>

persistence.xml

<persistence>
   <persistence-unit name "a">
     <!--define a variable that will be overwritten by build.gradle-->
       ...
  </persistence-unit>
</persistence>

build.gradle

task replaceTokens {
  from(//persistence.xml path) {
     filter(ReplaceTokens, tokens: [//variable in xml, //value in gradle.properties])
   }
}

I need it, because I have more persistence-units in my persistence.xml, which all needs the same classes. Currently the classes are in all persistence-unit "hardcoded". It would be nicer, if I can define it only once.

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.314163 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO