Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,12 @@
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.stream.Collectors;

import org.apache.maven.model.Resource;
import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugins.annotations.Component;
import org.apache.maven.plugins.annotations.Parameter;
import org.apache.maven.project.MavenProject;
import org.codehaus.modello.ModelloException;
Expand Down Expand Up @@ -80,12 +80,6 @@ public abstract class AbstractModelloGeneratorMojo extends AbstractMojo {
@Parameter(property = "packageWithVersion", defaultValue = "false", required = true)
private boolean packageWithVersion;

/**
* <p>Note: This is passed by Maven and must not be configured by the user.</p>
*/
@Component
private ModelloCore modelloCore;

/**
* The Maven project instance for the executing project.
*/
Expand Down Expand Up @@ -128,11 +122,14 @@ public abstract class AbstractModelloGeneratorMojo extends AbstractMojo {
@Parameter
private Map<String, String> pluralExceptions;

/**
* @since 1.0.1
*/
@Component
private BuildContext buildContext;
private final BuildContext buildContext;

private final ModelloCore modelloCore;

protected AbstractModelloGeneratorMojo(BuildContext buildContext, ModelloCore modelloCore) {
this.buildContext = Objects.requireNonNull(buildContext, "buildContext cannot be null");
this.modelloCore = Objects.requireNonNull(modelloCore, "modelloCore cannot be null");
}

// ----------------------------------------------------------------------
// Overridables
Expand Down Expand Up @@ -366,18 +363,6 @@ public void setPackageWithVersion(boolean packageWithVersion) {
this.packageWithVersion = packageWithVersion;
}

public ModelloCore getModelloCore() {
return modelloCore;
}

public void setModelloCore(ModelloCore modelloCore) {
this.modelloCore = modelloCore;
}

public void setBuildContext(BuildContext context) {
this.buildContext = context;
}

public MavenProject getProject() {
return project;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
* SOFTWARE.
*/

import javax.inject.Inject;

import java.io.File;
import java.util.Map;
import java.util.Optional;
Expand All @@ -31,6 +33,8 @@

import org.apache.maven.plugins.annotations.Parameter;
import org.codehaus.modello.ModelloParameterConstants;
import org.codehaus.modello.core.ModelloCore;
import org.codehaus.plexus.build.BuildContext;

/**
* @author Hervé Boutemy
Expand Down Expand Up @@ -74,6 +78,11 @@ public abstract class AbstractModelloSourceGeneratorMojo extends AbstractModello
@Parameter(defaultValue = "true")
private boolean domAsXpp3;

@Inject
public AbstractModelloSourceGeneratorMojo(BuildContext buildContext, ModelloCore modelloCore) {
super(buildContext, modelloCore);
}

@Override
protected boolean producesCompilableResult() {
return true;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
package org.codehaus.modello.maven;

import javax.inject.Inject;

import org.apache.maven.plugins.annotations.LifecyclePhase;
import org.apache.maven.plugins.annotations.Mojo;
import org.codehaus.modello.core.ModelloCore;
import org.codehaus.plexus.build.BuildContext;

/**
* Creates classes that can convert between different versions of the model.
Expand All @@ -10,6 +14,12 @@
*/
@Mojo(name = "converters", defaultPhase = LifecyclePhase.GENERATE_SOURCES, threadSafe = true)
public class ModelloConvertersMojo extends AbstractModelloSourceGeneratorMojo {

@Inject
public ModelloConvertersMojo(BuildContext buildContext, ModelloCore modelloCore) {
super(buildContext, modelloCore);
}

protected String getGeneratorType() {
return "converters";
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,23 @@
package org.codehaus.modello.maven;

import javax.inject.Inject;

import org.apache.maven.plugins.annotations.LifecyclePhase;
import org.apache.maven.plugins.annotations.Mojo;
import org.codehaus.modello.core.ModelloCore;
import org.codehaus.plexus.build.BuildContext;

/**
* Creates a DOM4J reader from the model.
*/
@Mojo(name = "dom4j-reader", defaultPhase = LifecyclePhase.GENERATE_SOURCES, threadSafe = true)
public class ModelloDom4jReaderMojo extends AbstractModelloSourceGeneratorMojo {

@Inject
public ModelloDom4jReaderMojo(BuildContext buildContext, ModelloCore modelloCore) {
super(buildContext, modelloCore);
}

protected String getGeneratorType() {
return "dom4j-reader";
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,23 @@
package org.codehaus.modello.maven;

import javax.inject.Inject;

import org.apache.maven.plugins.annotations.LifecyclePhase;
import org.apache.maven.plugins.annotations.Mojo;
import org.codehaus.modello.core.ModelloCore;
import org.codehaus.plexus.build.BuildContext;

/**
* Creates a DOM4J writer from the model.
*/
@Mojo(name = "dom4j-writer", defaultPhase = LifecyclePhase.GENERATE_SOURCES, threadSafe = true)
public class ModelloDom4jWriterMojo extends AbstractModelloSourceGeneratorMojo {

@Inject
public ModelloDom4jWriterMojo(BuildContext buildContext, ModelloCore modelloCore) {
super(buildContext, modelloCore);
}

protected String getGeneratorType() {
return "dom4j-writer";
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,18 @@
* SOFTWARE.
*/

import javax.inject.Inject;

import java.util.Map;
import java.util.Objects;

import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugins.annotations.Component;
import org.apache.maven.plugins.annotations.LifecyclePhase;
import org.apache.maven.plugins.annotations.Mojo;
import org.apache.maven.plugins.annotations.Parameter;
import org.codehaus.modello.core.ModelloCore;
import org.codehaus.modello.plugin.ModelloGenerator;
import org.codehaus.plexus.build.BuildContext;

/**
* <p>
Expand Down Expand Up @@ -85,12 +89,18 @@
*/
@Mojo(name = "generate", defaultPhase = LifecyclePhase.GENERATE_SOURCES, threadSafe = true)
public class ModelloGenerateMojo extends AbstractModelloSourceGeneratorMojo {
@Component(role = ModelloGenerator.class)
private Map<String, ModelloGenerator> generatorMap;
private final Map<String, ModelloGenerator> generatorMap;

@Parameter(property = "modello.generator.id", defaultValue = "java")
private String generatorId;

@Inject
public ModelloGenerateMojo(
BuildContext buildContext, ModelloCore modelloCore, Map<String, ModelloGenerator> generatorMap) {
super(buildContext, modelloCore);
this.generatorMap = Objects.requireNonNull(generatorMap, "generatorMap cannot be null");
}

protected String getGeneratorType() {
return generatorId;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,12 @@
* SOFTWARE.
*/

import javax.inject.Inject;

import org.apache.maven.plugins.annotations.LifecyclePhase;
import org.apache.maven.plugins.annotations.Mojo;
import org.codehaus.modello.core.ModelloCore;
import org.codehaus.plexus.build.BuildContext;

/**
* Creates a jdom writer from the model that is capable of preserving element ordering
Expand All @@ -33,6 +37,12 @@
*/
@Mojo(name = "jdom-writer", defaultPhase = LifecyclePhase.GENERATE_SOURCES, threadSafe = true)
public class ModelloJDOMWriterMojo extends AbstractModelloSourceGeneratorMojo {

@Inject
public ModelloJDOMWriterMojo(BuildContext buildContext, ModelloCore modelloCore) {
super(buildContext, modelloCore);
}

protected String getGeneratorType() {
return "jdom-writer";
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,12 @@
* SOFTWARE.
*/

import javax.inject.Inject;

import org.apache.maven.plugins.annotations.LifecyclePhase;
import org.apache.maven.plugins.annotations.Mojo;
import org.codehaus.modello.core.ModelloCore;
import org.codehaus.plexus.build.BuildContext;

/**
* Creates an Jackson extended reader from the model. An extended reader populates the parsed model with metadata about
Expand All @@ -35,6 +39,11 @@
@Mojo(name = "jackson-extended-reader", defaultPhase = LifecyclePhase.GENERATE_SOURCES, threadSafe = true)
public class ModelloJacksonExtendedReaderMojo extends ModelloXpp3ReaderMojo {

@Inject
public ModelloJacksonExtendedReaderMojo(BuildContext buildContext, ModelloCore modelloCore) {
super(buildContext, modelloCore);
}

@Override
protected String getGeneratorType() {
return "jackson-extended-reader";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,15 @@
* SOFTWARE.
*/

import javax.inject.Inject;

import java.util.Map;

import org.apache.maven.plugins.annotations.LifecyclePhase;
import org.apache.maven.plugins.annotations.Mojo;
import org.codehaus.modello.ModelloParameterConstants;
import org.codehaus.modello.core.ModelloCore;
import org.codehaus.plexus.build.BuildContext;

/**
* Creates an Jackson reader from the model.
Expand All @@ -36,6 +40,12 @@
*/
@Mojo(name = "jackson-reader", defaultPhase = LifecyclePhase.GENERATE_SOURCES, threadSafe = true)
public class ModelloJacksonReaderMojo extends AbstractModelloSourceGeneratorMojo {

@Inject
public ModelloJacksonReaderMojo(BuildContext buildContext, ModelloCore modelloCore) {
super(buildContext, modelloCore);
}

protected String getGeneratorType() {
return "jackson-reader";
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,15 @@
* SOFTWARE.
*/

import javax.inject.Inject;

import java.util.Map;

import org.apache.maven.plugins.annotations.LifecyclePhase;
import org.apache.maven.plugins.annotations.Mojo;
import org.codehaus.modello.ModelloParameterConstants;
import org.codehaus.modello.core.ModelloCore;
import org.codehaus.plexus.build.BuildContext;

/**
* Creates an Jackson writer from the model.
Expand All @@ -36,6 +40,12 @@
*/
@Mojo(name = "jackson-writer", defaultPhase = LifecyclePhase.GENERATE_SOURCES, threadSafe = true)
public class ModelloJacksonWriterMojo extends AbstractModelloSourceGeneratorMojo {

@Inject
public ModelloJacksonWriterMojo(BuildContext buildContext, ModelloCore modelloCore) {
super(buildContext, modelloCore);
}

protected String getGeneratorType() {
return "jackson-writer";
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,12 @@
* SOFTWARE.
*/

import javax.inject.Inject;

import org.apache.maven.plugins.annotations.LifecyclePhase;
import org.apache.maven.plugins.annotations.Mojo;
import org.codehaus.modello.core.ModelloCore;
import org.codehaus.plexus.build.BuildContext;

/**
* Creates Java beans from the Modello model.
Expand All @@ -32,6 +36,12 @@
*/
@Mojo(name = "java", defaultPhase = LifecyclePhase.GENERATE_SOURCES, threadSafe = true)
public class ModelloJavaMojo extends AbstractModelloSourceGeneratorMojo {

@Inject
public ModelloJavaMojo(BuildContext buildContext, ModelloCore modelloCore) {
super(buildContext, modelloCore);
}

protected String getGeneratorType() {
return "java";
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,17 @@
* SOFTWARE.
*/

import javax.inject.Inject;

import java.io.File;
import java.util.Map;

import org.apache.maven.plugins.annotations.LifecyclePhase;
import org.apache.maven.plugins.annotations.Mojo;
import org.apache.maven.plugins.annotations.Parameter;
import org.codehaus.modello.ModelloParameterConstants;
import org.codehaus.modello.core.ModelloCore;
import org.codehaus.plexus.build.BuildContext;

/**
* Creates a JSON Schema from the model.
Expand All @@ -49,6 +53,11 @@ public final class ModelloJsonSchemaGeneratorMojo extends AbstractModelloGenerat
@Parameter
private String jsonSchemaFileName;

@Inject
public ModelloJsonSchemaGeneratorMojo(BuildContext buildContext, ModelloCore modelloCore) {
super(buildContext, modelloCore);
}

@Override
protected void customizeParameters(Map<String, Object> parameters) {
super.customizeParameters(parameters);
Expand Down
Loading
Loading