Versioning . jar in Java with Netbeans

Asked

Viewed 151 times

2

I wish that mine .jar had a version number and release date inside it, so I could inform it on the about screen for example.

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

How could I do that? There would be another form or tool that does this?

1 answer

2


Hail!

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

Additionally, there are a number of plugins that you can accomplish virtually any task regarding project structure, deploy and release project. Anyway, it’s a powerful tool. I suggest you take a look. Netbeans possesses support.

To generate a number of build i use the plugin buildnumber-maven-plugin. It connects to your repository and generates a number based on commit. It is very interesting. Below is an example that 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 commit from my GIT repository and add it to the manifest. I believe that with some configuration it can also add this information to your final file.

To set up your repository link in the project, just add in the section scm of your pom.xml.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.