Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Kill off dead Plexus #418

Merged
merged 1 commit into from
Feb 17, 2024
Merged
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
11 changes: 11 additions & 0 deletions modello-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,13 @@
<dependency>
<groupId>org.eclipse.sisu</groupId>
<artifactId>org.eclipse.sisu.plexus</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.sonatype.sisu</groupId>
<artifactId>sisu-guice</artifactId>
<classifier>no_aop</classifier>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.codehaus.plexus</groupId>
Expand All @@ -33,6 +35,15 @@
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-xml</artifactId>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<scope>test</scope>
</dependency>
</dependencies>

<build>
Expand Down
19 changes: 6 additions & 13 deletions modello-core/src/main/java/org/codehaus/modello/Modello.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,33 +22,26 @@
* SOFTWARE.
*/

import javax.inject.Inject;

import java.io.Reader;
import java.io.Writer;
import java.util.Properties;

import org.codehaus.modello.core.ModelloCore;
import org.codehaus.modello.model.Model;
import org.codehaus.modello.model.ModelValidationException;
import org.codehaus.plexus.DefaultPlexusContainer;
import org.codehaus.plexus.PlexusContainer;

/**
* @author <a href="mailto:jason@maven.org">Jason van Zyl</a>
* @author <a href="mailto:trygvis@inamo.no">Trygve Laugst&oslash;l</a>
*/
public class Modello {
private PlexusContainer container;

private ModelloCore core;

public Modello() throws ModelloException {
try {
container = new DefaultPlexusContainer();
private final ModelloCore core;

core = (ModelloCore) container.lookup(ModelloCore.ROLE);
} catch (Exception ex) {
throw new ModelloException("Error while starting plexus.", ex);
}
@Inject
public Modello(ModelloCore core) {
this.core = core;
}

public void generate(Reader modelReader, String outputType, Properties parameters)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import java.io.File;
import java.util.Properties;

import org.codehaus.plexus.DefaultPlexusContainer;
import org.codehaus.plexus.util.StringUtils;
import org.codehaus.plexus.util.xml.XmlStreamReader;

Expand All @@ -39,7 +40,7 @@ public class ModelloCli {
private static Properties parameters;

public static void main(String[] args) throws Exception {
Modello modello = new Modello();
Modello modello = new DefaultPlexusContainer().lookup(Modello.class);

parseArgumentsFromCommandLine(args);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,18 @@
import org.codehaus.modello.ModelloException;
import org.codehaus.modello.model.Model;
import org.codehaus.modello.model.ModelValidationException;
import org.codehaus.plexus.logging.AbstractLogEnabled;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
* @author <a href="mailto:trygvis@inamo.no">Trygve Laugst&oslash;l</a>
*/
public abstract class AbstractModelloCore extends AbstractLogEnabled implements ModelloCore {
public abstract class AbstractModelloCore implements ModelloCore {
private final Logger logger = LoggerFactory.getLogger(getClass());

protected Logger getLogger() {
return logger;
}
// ----------------------------------------------------------------------
// Partial ModelloCore implementation
// ----------------------------------------------------------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,20 @@

import java.util.Map;

import org.codehaus.plexus.logging.AbstractLogEnabled;
import org.codehaus.plexus.util.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
* @author <a href="mailto:trygvis@inamo.no">Trygve Laugst&oslash;l</a>
*/
public abstract class AbstractMetadataPlugin extends AbstractLogEnabled implements MetadataPlugin {
public abstract class AbstractMetadataPlugin implements MetadataPlugin {
private final Logger logger = LoggerFactory.getLogger(getClass());

protected Logger getLogger() {
return logger;
}

protected boolean getBoolean(Map<String, String> data, String key, boolean defaultValue) {
String value = data.get(key);

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.io.FilterWriter;
import java.io.IOException;
Expand All @@ -41,23 +43,19 @@
import org.codehaus.modello.model.ModelDefault;
import org.codehaus.modello.model.ModelField;
import org.codehaus.modello.model.Version;
import org.codehaus.plexus.PlexusConstants;
import org.codehaus.plexus.PlexusContainer;
import org.codehaus.plexus.build.BuildContext;
import org.codehaus.plexus.component.repository.exception.ComponentLookupException;
import org.codehaus.plexus.context.Context;
import org.codehaus.plexus.context.ContextException;
import org.codehaus.plexus.logging.AbstractLogEnabled;
import org.codehaus.plexus.personality.plexus.lifecycle.phase.Contextualizable;
import org.codehaus.plexus.util.StringUtils;
import org.codehaus.plexus.util.io.CachingWriter;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
* @author <a href="mailto:jason@modello.org">Jason van Zyl</a>
* @author <a href="mailto:evenisse@codehaus.org">Emmanuel Venisse</a>
*/
public abstract class AbstractModelloGenerator extends AbstractLogEnabled
implements ModelloGenerator, Contextualizable {
public abstract class AbstractModelloGenerator implements ModelloGenerator {
private final Logger logger = LoggerFactory.getLogger(getClass());

private Model model;

private File outputDirectory;
Expand All @@ -68,8 +66,13 @@ public abstract class AbstractModelloGenerator extends AbstractLogEnabled

private String encoding;

@Inject
private BuildContext buildContext;

protected Logger getLogger() {
return logger;
}

protected void initialize(Model model, Properties parameters) throws ModelloException {
this.model = model;

Expand Down Expand Up @@ -232,16 +235,6 @@ protected String getParameter(Properties parameters, String name, String default
return parameters.getProperty(name, defaultValue);
}

public void contextualize(Context ctx) throws ContextException {
PlexusContainer plexus = (PlexusContainer) ctx.get(PlexusConstants.PLEXUS_KEY);

try {
buildContext = (BuildContext) plexus.lookup(BuildContext.class.getName());
} catch (ComponentLookupException e) {
throw new ContextException("Unable to lookup required component", e);
}
}

protected BuildContext getBuildContext() {
return buildContext;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,19 @@
import java.util.Map;

import org.codehaus.modello.ModelloRuntimeException;
import org.codehaus.plexus.logging.AbstractLogEnabled;
import org.codehaus.plexus.personality.plexus.lifecycle.phase.Initializable;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
* @author <a href="mailto:trygvis@inamo.no">Trygve Laugst&oslash;l</a>
*/
public abstract class AbstractPluginManager<T> extends AbstractLogEnabled implements Initializable {
public abstract class AbstractPluginManager<T> {
private final Logger logger = LoggerFactory.getLogger(getClass());

protected Logger getLogger() {
return logger;
}

public void initialize() {}

public abstract Map<String, T> getPlugins();
Expand Down
5 changes: 5 additions & 0 deletions modello-maven-plugin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,11 @@
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-build-api</artifactId>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<scope>test</scope>
</dependency>
</dependencies>

<reporting>
Expand Down
5 changes: 5 additions & 0 deletions modello-plugins/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,11 @@
<artifactId>modello-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<scope>test</scope>
</dependency>
</dependencies>

<build>
Expand Down
10 changes: 10 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,16 @@
<artifactId>plexus-build-api</artifactId>
<version>1.2.0</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.36</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<version>1.7.36</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
Expand Down