Hi Karl-Heinz, Karl Heinz Marbaise wrote:
> Hi, > > > 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. > > Best solution was already mentoined by Robert Scholte by using the > templating-maven-plugin which exactly supports that scenario without > supplemental addition of target/generated-sources folder by > build-helpr-maven-plugin etc. > > Just simply create the template files in src/main/java-templates/ use > the expressions etc. no need for supplemental configuration of > maven-resources-plugin etc. > > Best and simple solution...which i wrote longer time a go a blog about > http://blog.soebes.de/blog/2014/01/02/version-information-into-your-appas-with-maven/ nice article ;-) There's one comment I do not understand though: > The main disadvantage of this approach is that you can only use the > Implementation and Specification parts of your MANIFEST.MF file which > might be enough in some situations but not in all. You can add all kind of entries to the manifest. You may even overwrite the defaults. We use typically: ===================== %< ====================== <archive> <manifest> <addDefaultSpecificationEntries>true</addDefaultSpecificationEntries> <addDefaultImplementationEntries>true</addDefaultImplementationEntries> </manifest> <manifestEntries> <Specification-Version>${parsedVersion.majorVersion}. ${parsedVersion.minorVersion}</Specification-Version> <X-Compile-Source>${java.version.source}</X-Compile-Source> <X-Compile-Target>${java.version.target}</X-Compile-Target> <X-Builder>Maven ${maven.version}</X-Builder> <X-Build-Time>${maven.build.timestamp}</X-Build-Time> <X-Build-Os>${os.name}</X-Build-Os> </manifestEntries> </archive> ===================== %< ====================== With the $parsedVersion and $maven.version variables provided by the build- helper plugin. Cheers, Jörg --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscr...@maven.apache.org For additional commands, e-mail: users-h...@maven.apache.org