Record the steps to create an uber jar and to add information to a jar manifest. Below, I add a time stamp and "codification" information.
Manifest-Version: 1.0
Implementation-Title: Maven Custom JAR Manifest
Implementation-Version: 1.0.0-SNAPSHOT
Archiver-Version: Plexus Archiver
Built-By: gkh
codification: UTF-8 <-----
Implementation-Vendor-Id: org.gkh
Created-By: Apache Maven 3.2.1
Build-Jdk: 1.8.0_74
Implementation-Vendor: GKH
Timestamp: 20160505-0903 <-----
Add the following to the build/plugins
section of pom.xml
.
<properties>
<jarTarget>${project.build.directory}/bin</jarTarget>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.4</version>
<configuration>
<outputDirectory>${jarTarget}</outputDirectory>
<useDefaultManifestFile>true</useDefaultManifestFile>
<archive>
<addMavenDescriptor>false</addMavenDescriptor>
<manifest>
<addDefaultImplementationEntries>true</addDefaultImplementationEntries>
</manifest>
<manifestEntries>
<Timestamp>${maven.build.timestamp}</Timestamp>
<codification>${project.build.sourceEncoding}</codification>
</manifestEntries>
</archive>
</configuration>
</plugin>
</plugins>
</build>
By default Maven will download snapshots daily.
<updatePolicy>interval:5</updatePolicy>
Is there a way to make Maven download snapshot versions automatically?
To update snapshots, try with the -U option
-U,--update-snapshots Forces a check for updated
releases and snapshots on remote
repositories
http://stackoverflow.com/a/7714033/6146580 http://stackoverflow.com/a/4098009/6146580
Each repository in the project has its own update policy:
- always - always check when Maven is started for newer versions of snapshots
- never - never check for newer remote versions. Once off manual updates can be performed.
- daily (default) - check on the first run of the day (local time)
- interval:XXX - check every XXX minutes
Use always
if you always want Maven to download a newer version of snapshots, if available (Maven will always check the remote repository but only download if the version is newer).
- If you use a version of Maven >= 2.1.0-M1, then you can use the
${maven.build.timestamp}
property. For more info, see: Available Variables. - Answer from How do I add time-stamp information to Maven artifacts?.
- Maven jar plugin example, by Francisco Hernandez
- Inject Build Time (timestamp) Property Using Maven, by Aaron Gadberry
- Manifest Sections from The Apache Maven Project
- How to create a jar file with Maven, by mkyong
- Settings Reference
- How does the updatePolicy in maven really work?, answer by Pascal Thivent