Hi Alejandro,

alejandro.e...@miranda.com wrote:

> Hi Curtis,
> 
> I *think* i see you point, but wouldn't that happen ONLY if the constant
> is public and referenced in a separate jar?? where it would be inlined in
> the referring class (right?). In my case the constant is package protected
> (it would be private if it wasn't because i need it in unit tests)
> 
> The problem with defining it in the manifest is that I use this constant
> in the property of an annotation of the class
> 
> @StaticServiceProperty(mandatory = true, type = "java.lang.String", name =
> "schemaVersion", value = SchemaProviderServiceImpl.SCHEMA_VERSION,
> immutable = true)
> public class SchemaProviderServiceImpl
> 
> so I can't grab it from the manifest at runtime. I guess the way I phrased
> it in the original email implied the opposite, sorry about that


typical solution is to generate the source.

Move the Java code that should contain the version into an own directory 
tree (e.g. src/main/java-templates). Replace the version string with an 
expression (e.g. "${project.version}") and use the copy-resources goal of 
the resources plugin to filter the file into a target driectory tree (e.g. 
target/generated-sources). Bind the goal to the generate-sources phase. Then 
use additionally the build-helper plugin to add target/generated-sources as 
additional source directory and you're done.

Cheers,
Jörg


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@maven.apache.org
For additional commands, e-mail: users-h...@maven.apache.org

Reply via email to