Versioning of .jar in Java with Netbeans

2

I'd like my .jar to have a version number and release date inside it, so I could tell it on the about screen for example.

So far without mystery, but the point is that with every build in Netbeans I wanted the version to be incremented automatically, as well as its release date.

How could I do this? Is there another way or tool that does this?

    
asked by anonymous 21.07.2015 / 14:36

1 answer

2

Save!

I use Maven to accomplish my project structure and configuration management. He is agnostic to IDE and suggests a way for his project to have an intelligent structure of resource organization and code.

In addition, there are a number of plugins that you can perform almost any task regarding project design, deploy and release project. Anyway, it's a powerful tool. I suggest you take a look. Netbeans has support .

To generate build number I use the plugin buildnumber-maven-plugin . It connects to your repository and generates a number based on commit . It's very interesting. Here is an example I use in my project:

<plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>buildnumber-maven-plugin</artifactId>
    <version>${build.number.plugin.version}</version>
    <executions>
        <execution>
            <phase>validate</phase>
            <goals>
                <goal>create</goal>
            </goals>
        </execution>
    </executions>
    <configuration>
        <getRevisionOnlyOnce>true</getRevisionOnlyOnce>
        <doCheck>false</doCheck>
        <doUpdate>true</doUpdate>
        <shortRevisionLength>5</shortRevisionLength>
    </configuration>
</plugin>

In this case it retrieves the first 5 digits of the code from commit from my GIT repository and adds it to the manifest. I believe that with some configuration it can also add this information to your final file.

To configure the link of your repository in the project, simply add in the scm section of your pom.xml .

    
21.07.2015 / 16:04