Skip to content

HomeOfTheWizard/demo-maven-sisu-custom-binding

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 

Repository files navigation

What is it ?

A maven extension containing a custom Guice module to be used in Maven's dependency injection mechanism, Sisu.

How to use it ?

This guice module is packaged as a maven extension,
so in order to activate the extension you should put its artifact name in the .mvn/extension.xml file of the maven application you want to use it. example:

<extensions xmlns="http://maven.apache.org/EXTENSIONS/1.0.0"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="http://maven.apache.org/EXTENSIONS/1.0.0 http://maven.apache.org/xsd/core-extensions-1.0.0.xsd">
	<extension>
		<groupId>com.homeofthewizard</groupId>
		<artifactId>demo-maven-sisu-custom-binding</artifactId>
		<version>1.0-SNAPSHOT</version>
	</extension>
</extensions>

Then you can easily use the objects coming from the custom binding. example:

package com.homeofthewizard;

import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugins.annotations.LifecyclePhase;
import org.apache.maven.plugins.annotations.Mojo;

import javax.inject.Inject;

@Mojo(name = "hello", defaultPhase = LifecyclePhase.GENERATE_SOURCES)
public class HelloMojo extends AbstractMojo {

    private final MyHelloer helloer;

    @Inject
    public HelloMojo(MyHelloer helloer) {
        this.helloer = helloer;
    }

    public void execute() {
        helloer.hello();
    }

}

To see in more detail how to inject objects from guice-sisu into your plugins, see this documentation

About

A demo for a custom binding creation in maven sisu

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages