Return-Path: X-Original-To: apmail-maven-users-archive@www.apache.org Delivered-To: apmail-maven-users-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 764AD1182A for ; Thu, 17 Jul 2014 17:58:09 +0000 (UTC) Received: (qmail 87129 invoked by uid 500); 17 Jul 2014 17:58:07 -0000 Delivered-To: apmail-maven-users-archive@maven.apache.org Received: (qmail 87035 invoked by uid 500); 17 Jul 2014 17:58:07 -0000 Mailing-List: contact users-help@maven.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Help: List-Post: List-Id: "Maven Users List" Reply-To: "Maven Users List" Delivered-To: mailing list users@maven.apache.org Received: (qmail 86300 invoked by uid 99); 17 Jul 2014 17:58:06 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 17 Jul 2014 17:58:06 +0000 X-ASF-Spam-Status: No, hits=1.5 required=5.0 tests=HTML_MESSAGE,RCVD_IN_DNSWL_LOW,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of anders.g.hammar@gmail.com designates 74.125.82.44 as permitted sender) Received: from [74.125.82.44] (HELO mail-wg0-f44.google.com) (74.125.82.44) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 17 Jul 2014 17:58:03 +0000 Received: by mail-wg0-f44.google.com with SMTP id m15so2420547wgh.15 for ; Thu, 17 Jul 2014 10:57:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:date:message-id:subject :from:to:content-type; bh=3sqkufInxMCtpYZm98q+pqqySCSuJUKIqNkSpFWpO1c=; b=ekZeZWSCiCr37JnwwUKk9Kg0e2h2l3+miUOegmLVAFN7WHE0FcMMLTYY+SqpOZHvS5 J+AecwJqZJwjJLyBYuE0aOaTSy6mb2b8YeXs8kHyjevHE9kslv3MvD3LpVfPNpTU60e1 BKEt0/AG0QvO//m9nQWp9wgtGfxWZYahAvasyI3UKWIaT+xmVk/qo1Ne6QQi5z4+JrAw Gprsdu14VyibpHyeTM+CoonbRpKXjDRwkYrIREaXPd4T+CaxXoB4nZOHjwULjufrh7zu YYpDcmRdjWX8IvXuYq/8F6IGxfdNRa3ldGdE6XfDy8k++qyw4UV7s53m0SiOlajxJVkU rLdw== MIME-Version: 1.0 X-Received: by 10.180.211.237 with SMTP id nf13mr24613597wic.47.1405619861904; Thu, 17 Jul 2014 10:57:41 -0700 (PDT) Sender: anders.g.hammar@gmail.com Received: by 10.194.32.195 with HTTP; Thu, 17 Jul 2014 10:57:41 -0700 (PDT) In-Reply-To: References: <53C7E94E.1010302@gmx.de> Date: Thu, 17 Jul 2014 19:57:41 +0200 X-Google-Sender-Auth: ytdWcBVaKYVsX7x3t8-mu7FIch0 Message-ID: Subject: Re: move data from pom to class or class to pom From: Anders Hammar To: Maven Users List Content-Type: multipart/alternative; boundary=001a11c25f428ee5ad04fe676016 X-Virus-Checked: Checked by ClamAV on apache.org --001a11c25f428ee5ad04fe676016 Content-Type: text/plain; charset=UTF-8 > > 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: > > true > true > 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 > 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-unsubscribe@maven.apache.org > > For additional commands, e-mail: users-help@maven.apache.org > > > > > --001a11c25f428ee5ad04fe676016--