m2 - build number system property?

classic Classic list List threaded Threaded
14 messages Options
Reply | Threaded
Open this post in threaded view
|

m2 - build number system property?

Nigel Magnay
Hi guys

does anyone know if it's possible to pass the current hudson build number into the maven builder? Perhaps by -DbuildNumber=${hudson.build.number} or something similar?

That way I can get the build number into the manifests of our artifacts which would be highly useful!

cheers,
Nigel

Reply | Threaded
Open this post in threaded view
|

Re: m2 - build number system property?

Kohsuke Kawaguchi
Administrator
2007/4/18, Nigel Magnay <[hidden email]>:
> Hi guys
>
> does anyone know if it's possible to pass the current hudson build number
> into the maven builder? Perhaps by -DbuildNumber=${hudson.build.number} or
> something similar?
>
> That way I can get the build number into the manifests of our artifacts
> which would be highly useful!

This is for the alpha m2 support? If so, please file an issue.

In fact, what if Hudson just updates the manifest file behind the
scene automatically to bake the build number in? Isn't that easier?
It's bit sneaky, but is there any harm in doing so?

--
Kohsuke Kawaguchi

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: m2 - build number system property?

Nigel Magnay
That's cool if it does it automatically - though looking at my JAR output MANIFEST.MF I don't see it being added there - I get

Manifest-Version: 1.0
Archiver-Version: Plexus Archiver
Created-By: Apache Maven
Built-By: Tomcat
Build-Jdk: 1.6.0

I've been using the maven-buildnumber plugin (http://commons.ucalgary.ca/projects/maven -buildnumber-plugin) to add the SVN revision as well and I thought it'd be nice to be able to tag which build it came from - I don't mind if it's done by hudson magic...

On 18/04/07, Kohsuke Kawaguchi <[hidden email]> wrote:
2007/4/18, Nigel Magnay <[hidden email]>:
> Hi guys
>
> does anyone know if it's possible to pass the current hudson build number
> into the maven builder? Perhaps by -DbuildNumber=${ hudson.build.number} or
> something similar?
>
> That way I can get the build number into the manifests of our artifacts
> which would be highly useful!

This is for the alpha m2 support? If so, please file an issue.

In fact, what if Hudson just updates the manifest file behind the
scene automatically to bake the build number in? Isn't that easier?
It's bit sneaky, but is there any harm in doing so?

--
Kohsuke Kawaguchi

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]


Reply | Threaded
Open this post in threaded view
|

Re: m2 - build number system property?

Renaud Bruyeron-2
In reply to this post by Kohsuke Kawaguchi
Kohsuke Kawaguchi wrote:
> In fact, what if Hudson just updates the manifest file behind the
> scene automatically to bake the build number in? Isn't that easier?
> It's bit sneaky, but is there any harm in doing so?
>
Would that work with builds that sign their jars? (I don't know much
about jar signing...)

 - Renaud

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: m2 - build number system property?

Kohsuke Kawaguchi
Administrator
In reply to this post by Nigel Magnay
2007/4/18, Nigel Magnay <[hidden email]>:
> That's cool if it does it automatically - though looking at my JAR output
> MANIFEST.MF I don't see it being added there - I get
>
> Manifest-Version: 1.0
> Archiver-Version: Plexus Archiver
> Created-By: Apache Maven
> Built-By: Tomcat
> Build-Jdk: 1.6.0

Right. It doesn't do that right now, but I'd like Hudson to do that.

--
Kohsuke Kawaguchi

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: m2 - build number system property?

Nigel Magnay
In reply to this post by Renaud Bruyeron-2
I hadn't thought of that - yes, I think that might make life difficult.
Also if there's a property, it can be used by any plugin, including the documentation generation.

I've filed it as #488


On 18/04/07, Renaud Bruyeron <[hidden email]> wrote:
Kohsuke Kawaguchi wrote:
> In fact, what if Hudson just updates the manifest file behind the
> scene automatically to bake the build number in? Isn't that easier?
> It's bit sneaky, but is there any harm in doing so?
>
Would that work with builds that sign their jars? (I don't know much
about jar signing...)

- Renaud

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]


Reply | Threaded
Open this post in threaded view
|

Re: m2 - build number system property?

Kohsuke Kawaguchi
Administrator
In reply to this post by Renaud Bruyeron-2
2007/4/18, Renaud Bruyeron <[hidden email]>:
> Would that work with builds that sign their jars? (I don't know much
> about jar signing...)

One approach I'm thinking about is to modify the mojo configuration
and add the build number entry before the jar/war plugin runs. Don't
know if it's possible (Maven code is surprisingly not extensible), but
it seems like a useful hook to have any way.

The other approach is to update the jar/war after it's created. It
would be bit mroe costly, because we'll be touching a jar file that's
already created, but this is easier to do.

In both cases it should work fine with jar signing, AFAIK.

--
Kohsuke Kawaguchi

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: m2 - build number system property?

Kohsuke Kawaguchi
Administrator
In reply to this post by Nigel Magnay
2007/4/18, Nigel Magnay <[hidden email]>:
> I hadn't thought of that - yes, I think that might make life difficult.
> Also if there's a property, it can be used by any plugin, including the
> documentation generation.
>
> I've filed it as #488

Yes, adding a property is a must wheter or not we do manifest hacking.

--
Kohsuke Kawaguchi

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: m2 - build number system property?

Nigel Magnay
In reply to this post by Kohsuke Kawaguchi
One approach I'm thinking about is to modify the mojo configuration
and add the build number entry before the jar/war plugin runs. Don't
know if it's possible (Maven code is surprisingly not extensible), but
it seems like a useful hook to have any way.

That sounds complicated compared to calling mvn -Dhudson.build.number=12345 and adding into the top level pom.xml

<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<archive>
<manifest>
<addDefaultImplementationEntries>true</addDefaultImplementationEntries>
</manifest>
<manifestEntries>
<Implementation-Build>${hudson.build.number}</Implementation-Build>
</manifestEntries>
</archive>
</configuration>
</plugin>
</plugins>
Similarly for war, ear and site generation..
Reply | Threaded
Open this post in threaded view
|

Re: m2 - build number system property?

Kohsuke Kawaguchi
Administrator
Yes, it's complicated for me, but it's easier for users, and that's
the whole point.

2007/4/18, Nigel Magnay <[hidden email]>:

> That sounds complicated compared to calling mvn -Dhudson.build.number=12345
> and adding into the top level pom.xml
>
> <plugins>
>  <plugin>
>  <groupId>org.apache.maven.plugins</groupId>
>  <artifactId>maven-jar-plugin</artifactId>
>  <configuration>
>
>  <archive>
>  <manifest>
> <addDefaultImplementationEntries>true</addDefaultImplementationEntries>
>  </manifest>
>  <manifestEntries>
>
>  <Implementation-Build>${hudson.build.number}</Implementation-Build>
>  </manifestEntries>
>  </archive>
>  </configuration>
>  </plugin>
>  </plugins>
>
> Similarly for war, ear and site generation..
>


--
Kohsuke Kawaguchi

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: m2 - build number system property?

Victor Glushenkov-2
In reply to this post by Kohsuke Kawaguchi
Kohsuke Kawaguchi wrote:
> In fact, what if Hudson just updates the manifest file behind the
> scene automatically to bake the build number in? Isn't that easier?
> It's bit sneaky, but is there any harm in doing so?
How we can determine when is the best time to add this information to
manifest 'behind the scene'?
After packaging? But if the library was signed before? Or if it's
manifest was rewritten after that by some plugin in futher lifecycle
phase?..
I don't think it's a good idea.

--
Pharmanet, Cubus Team

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: m2 - build number system property?

Kohsuke Kawaguchi
Administrator
Victor Glushenkov wrote:
> How we can determine when is the best time to add this information to
> manifest 'behind the scene'?

Hudson knows what mojos are being run, so I can check if it's
maven-jar-plugin:jar or some such goals.

> After packaging? But if the library was signed before?

See my other e-mail about the interaction of this with signing.

 > Or if it's
> manifest was rewritten after that by some plugin in futher lifecycle
> phase?..

I think this would still work as expected.

> I don't think it's a good idea.

I don't think the ones that you mentioned have an interference with
manifest patching.

Let me first try and see if it really works.

--
Kohsuke Kawaguchi
Sun Microsystems                   [hidden email]

smime.p7s (4K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: m2 - build number system property?

Victor Glushenkov-2
Kohsuke Kawaguchi wrote:
> I don't think the ones that you mentioned have an interference with
> manifest patching.
My key idea in the previous message was that library developer should
decide where and when to store build id.
I tried to show that we don't know what happens during Maven build.
What about different packaging types (we can't even imagine what kind of
packaging it could be)?
What if I want build id being hardcoded in java file? Or in my HTML page?
What if I want to use in my assembly archive's name? There are lots of
questions.
Only developer could know where and when to store this information.
We just need to provide system property.

--
Pharmanet, Cubus Team

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: m2 - build number system property?

Kohsuke Kawaguchi
Administrator
Victor Glushenkov wrote:
> Kohsuke Kawaguchi wrote:
>> I don't think the ones that you mentioned have an interference with
>> manifest patching.
> My key idea in the previous message was that library developer should
> decide where and when to store build id.
> I tried to show that we don't know what happens during Maven build.
> What about different packaging types (we can't even imagine what kind of
> packaging it could be)?

I think the point of maven is in its standard build model --- a majority
of maven projects fall into one of the standard packaging types, and the
# of actual mojos used for the package phase is even smaller.

Hudson should take advantage of this as much as possible, so that users
won't have to do as much configuration as he'd do for the free-style
project. This is all about making things easy.

The other important aspects are that:

  1. maven POM is very verbose, and asking people to write
     something in there is fairly painful. Having such entry
     also cause problems when people build projects outside Hudson.
  2. jar manifest is designed to be extensible. Having extra
     entries is OK. For example, Maven itself puts additional
     entires like "Build-Jdk". I have yet heard any complaints
     about such addition.

So I don't see any reason why Hudson should hesitate to put the build
number in it.

> What if I want build id being hardcoded in java file? Or in my HTML page?
> What if I want to use in my assembly archive's name? There are lots of
> questions.
> Only developer could know where and when to store this information.
> We just need to provide system property.

Putting the build ID automatically is not an excuse for not providing
the build number system property, as you say. And the current snapshot
does poth.

--
Kohsuke Kawaguchi
Sun Microsystems                   [hidden email]

smime.p7s (4K) Download Attachment