Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Override Java constant using Maven?

Using Maven, is it possible to override a Java constant?

Imagine I have

public static final String buildBy="Eclipse";

which when using Maven shall be changed to

public static final String buildBy="Maven";

Is that possible? Thanks :-)

like image 968
stefan.at.wpf Avatar asked Apr 29 '13 20:04

stefan.at.wpf


2 Answers

Yes this is possible with filters. But you'd have to put the file under your resource directory. You could put the java file under the resource directory, but a much better way would be to extract the value into a property file, put that file under resources and have maven filter the property file.

like image 87
Daniel Kaplan Avatar answered Nov 15 '22 00:11

Daniel Kaplan


The other possibility is to use the templating maven plugin which can be used to fulfill such purposes.

like image 23
khmarbaise Avatar answered Nov 15 '22 00:11

khmarbaise