Code Monkey home page Code Monkey logo

inject-maven-plugin's Introduction

Maven Injection Plugin

The plugin inject-maven-plugin lets you inject Maven properties into your compiled code as part of your build process.

Maven Central

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 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 including usage for details.

Requirements

  • Maven 3.9 or higher
  • Java 8 or higher

Development

  • Build the plugin

    mvn clean install

    Make sure you got Maven 3.9+ 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

inject-maven-plugin's People

Contributors

dependabot[bot] avatar marcelmay avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

inject-maven-plugin's Issues

Inject via annotation

Hi, can we inject via some annotation like @InjectMavenProperty:

@InjectMavenProperty( name = 'project.scm.url', default = null )
public string VER;

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.