> > 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/
>
> I agree with Karl: I think it is much nicer to use the maven-jar-plugin to
> add the version to the JAR manifest, and just read it out of there, using
> the options:
>
>   <addDefaultImplementationEntries>true</addDefaultImplementationEntries>
>   <addDefaultSpecificationEntries>true</addDefaultSpecificationEntries>
>

There is one major drawback with using the manifest file. It will not work
with unit tests as the manifest file isn't created until the jar is
created. But if your unit tests don't touch any of the code that reads the
manifest info that's not a problem.

/Anders


>
> That's not to say that code generation with Maven isn't awesome though.
> Codehaus deserves major kudos for the buildhelper-maven-plugin, especially
> since it is supported by M2E as well!
>
> In one my projects, we combine this with the groovy-maven-plugin and Apache
> Velocity to auto-generate many classes from templates in a loop.
> https://github.com/imagej/imagej-ops/blob/master/pom.xml#L190-L231
>
> I considered improving the velocity-maven-plugin [1] to support this sort
> of thing (reusing the same template to generate a list of classes), but the
> groovy approach is easy and works just fine.
>
> Now we just need an official Maven page about how to do this, since AFAICT
> all the existing blog posts and SO questions don't explain it very clearly.
>
> Great stuff,
> Curtis
>
> [1] https://code.google.com/p/velocity-maven-plugin/
>
>
> On Thu, Jul 17, 2014 at 10:18 AM, Karl Heinz Marbaise <khmarba...@gmx.de>
> 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/
> >
> > Kind regards
> > Karl-Heinz Marbaise
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscr...@maven.apache.org
> > For additional commands, e-mail: users-h...@maven.apache.org
> >
> >
>

Reply via email to