https://github.com/marcelmay/inject-maven-plugin
The Maven plugin inject-maven-plugin lets you inject Maven properties into your compiled code. Typical use case includes build info (version, build time stamp, SCM version etc.).
https://github.com/marcelmay/inject-maven-plugin
build-tool bytecode injection maven-plugin
Last synced: 3 months ago
JSON representation
The Maven plugin inject-maven-plugin lets you inject Maven properties into your compiled code. Typical use case includes build info (version, build time stamp, SCM version etc.).
- Host: GitHub
- URL: https://github.com/marcelmay/inject-maven-plugin
- Owner: marcelmay
- License: apache-2.0
- Created: 2016-10-15T20:58:46.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2026-03-09T20:06:09.000Z (3 months ago)
- Last Synced: 2026-03-10T01:40:00.051Z (3 months ago)
- Topics: build-tool, bytecode, injection, maven-plugin
- Language: Java
- Homepage: http://marcelmay.github.io/inject-maven-plugin/
- Size: 896 KB
- Stars: 9
- Watchers: 1
- Forks: 2
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
Maven Injection Plugin
==================================
The plugin *inject-maven-plugin* lets you inject Maven properties into your compiled code as part of your build process.
[](http://search.maven.org/#search%7Cga%7C1%7Cde.m3y.maven.inject-maven-plugin)
What is it good for?
--------------------
You can use the plugin to inject any properties, such as build information like build time or SCM version (provided as Maven properties by [buildnumber-maven-plugin]).
The plugin hooks into the Maven lifecycle process-classes - so after compilation but before packaging into e.g. JAR.
Note:
* It is possible to inject into Java constants, but be aware of that the Java compiler inlines values during compilation.
* It is possible to inject into Java class attribute fields, but be aware the Java compiler inlines initialization into constructor,
resulting in multiple initializations with last initialization wining.
* Preferred injection is into accessor methods, resulting in the least amount of surprise by compiler/JVM initialization specifics :-)
* The plugin uses [ByteBuddy](https://github.com/raphw/byte-buddy) byte code injection library
* Check injection, e.g. using the Java Class File Disassembler (javap) on the target class:
```javap -p -constants -c -s -cp ./target/it/inject/target/classes de.m3y.maven.inject.it.ExampleInjection```
Check out the [plugin website][site] including [usage][site_usage] for details.
[site]: http://marcelmay.github.io/inject-maven-plugin/
[site_usage]: https://marcelmay.github.io/inject-maven-plugin/usage.html
[repo-snapshot]: https://oss.sonatype.org/content/repositories/snapshots/de/m3y/maven/inject-maven-plugin/
[buildnumber-maven-plugin]: https://github.com/mojohaus/buildnumber-maven-plugin
Requirements
-----------
* Maven 3.9 or higher
* Java 8 or higher
Development
-----------
* Build the plugin
`mvn clean install`
Make sure you got [Maven 3.9+][maven_download] or higher.
* Build the site
`mvn clean site site:stage scm-publish:publish-scm -Psite`
* Release
```
mvn release:prepare -Prelease
mvn release:perform -Prelease
```
* Deploy snapshot
`mvn clean deploy -Prelease`
Note: The release profile contains the snapshot repository for distribution management
[maven_download]: http://maven.apache.org