Skip to content

Commit

Permalink
Get rid of plexus.xml (#184)
Browse files Browse the repository at this point in the history
Fixes #182
  • Loading branch information
cstamas authored Sep 9, 2024
1 parent 45da0a5 commit 38c703c
Show file tree
Hide file tree
Showing 16 changed files with 286 additions and 231 deletions.
1 change: 1 addition & 0 deletions takari-lifecycle-plugin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,7 @@
<groupId>xmlunit</groupId>
<artifactId>xmlunit</artifactId>
<version>1.6</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,17 @@
*/
package io.takari.maven.plugins.configurator;

import javax.inject.Named;
import javax.inject.Singleton;
import org.codehaus.plexus.classworlds.realm.ClassRealm;
import org.codehaus.plexus.component.configurator.BasicComponentConfigurator;
import org.codehaus.plexus.component.configurator.ComponentConfigurationException;
import org.codehaus.plexus.component.configurator.ConfigurationListener;
import org.codehaus.plexus.component.configurator.expression.ExpressionEvaluator;
import org.codehaus.plexus.configuration.PlexusConfiguration;

@Singleton
@Named("takari")
public class MojoConfigurator extends BasicComponentConfigurator {

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
package io.takari.maven.plugins.configurator;

import java.util.Collection;
import javax.inject.Named;
import javax.inject.Singleton;
import org.apache.maven.lifecycle.MojoExecutionConfigurator;
import org.apache.maven.model.Plugin;
import org.apache.maven.model.PluginExecution;
Expand All @@ -16,6 +18,8 @@
import org.codehaus.plexus.util.StringUtils;
import org.codehaus.plexus.util.xml.Xpp3Dom;

@Singleton
@Named("takari")
public class TakariMojoExecutionConfigurator implements MojoExecutionConfigurator {

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
/*
* Copyright (c) 2014-2024 Takari, Inc.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-v10.html
*/
package io.takari.maven.plugins.packaging;

import java.io.IOException;
import java.io.InputStream;
import java.io.UncheckedIOException;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Properties;
import javax.inject.Provider;
import org.apache.maven.lifecycle.mapping.Lifecycle;
import org.apache.maven.lifecycle.mapping.LifecycleMapping;
import org.apache.maven.lifecycle.mapping.LifecyclePhase;

public abstract class LifecycleMappingSupport implements Provider<LifecycleMapping> {

private static final String DEFAULT_LIFECYCLE_KEY = "default";

private final Lifecycle defaultLifecycle;
private final LifecycleMapping lifecycleMapping;

public LifecycleMappingSupport() {
this.defaultLifecycle = new Lifecycle();
this.defaultLifecycle.setId(DEFAULT_LIFECYCLE_KEY);
this.defaultLifecycle.setLifecyclePhases(loadMapping());

this.lifecycleMapping = new LifecycleMapping() {
@Override
public Map<String, Lifecycle> getLifecycles() {
return Collections.singletonMap(DEFAULT_LIFECYCLE_KEY, defaultLifecycle);
}

@Override
public List<String> getOptionalMojos(String lifecycle) {
return null;
}

@Override
public Map<String, String> getPhases(String lifecycle) {
if (DEFAULT_LIFECYCLE_KEY.equals(lifecycle)) {
return defaultLifecycle.getPhases();
} else {
return null;
}
}
};
}

private Map<String, LifecyclePhase> loadMapping() {
Properties properties = new Properties();
try (InputStream inputStream = getClass().getResourceAsStream(getClass().getSimpleName() + ".properties")) {
properties.load(inputStream);
} catch (IOException e) {
throw new UncheckedIOException(e);
}
HashMap<String, LifecyclePhase> result = new HashMap<>();
for (String phase : properties.stringPropertyNames()) {
result.put(phase, new LifecyclePhase(properties.getProperty(phase)));
}
return result;
}

@Override
public LifecycleMapping get() {
return lifecycleMapping;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/*
* Copyright (c) 2014-2024 Takari, Inc.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-v10.html
*/
package io.takari.maven.plugins.packaging;

import javax.inject.Named;
import javax.inject.Singleton;

/**
* This is only to <em>shade</em> the POM packaging from Maven Core.
*/
@Singleton
@Named("pom")
public class PomLifecycleMapping extends LifecycleMappingSupport {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/*
* Copyright (c) 2014-2024 Takari, Inc.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-v10.html
*/
package io.takari.maven.plugins.packaging;

import javax.inject.Named;
import javax.inject.Singleton;
import org.apache.maven.artifact.handler.DefaultArtifactHandler;

@Singleton
@Named("takari-jar")
public class TakariJarArtifactHandler extends DefaultArtifactHandler {
public TakariJarArtifactHandler() {
super("takari-jar");
setExtension("jar");
setLanguage("java");
setAddedToClasspath(true);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/*
* Copyright (c) 2014-2024 Takari, Inc.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-v10.html
*/
package io.takari.maven.plugins.packaging;

import javax.inject.Named;
import javax.inject.Singleton;

@Singleton
@Named("takari-jar")
public class TakariJarLifecycleMapping extends LifecycleMappingSupport {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/*
* Copyright (c) 2014-2024 Takari, Inc.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-v10.html
*/
package io.takari.maven.plugins.packaging;

import javax.inject.Named;
import javax.inject.Singleton;
import org.apache.maven.artifact.handler.DefaultArtifactHandler;

@Singleton
@Named("takari-maven-component")
public class TakariMavenComponentArtifactHandler extends DefaultArtifactHandler {
public TakariMavenComponentArtifactHandler() {
super("takari-maven-component");
setExtension("jar");
setLanguage("java");
setAddedToClasspath(true);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/*
* Copyright (c) 2014-2024 Takari, Inc.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-v10.html
*/
package io.takari.maven.plugins.packaging;

import javax.inject.Named;
import javax.inject.Singleton;

@Singleton
@Named("takari-maven-component")
public class TakariMavenComponentLifecycleMapping extends LifecycleMappingSupport {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/*
* Copyright (c) 2014-2024 Takari, Inc.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-v10.html
*/
package io.takari.maven.plugins.packaging;

import javax.inject.Named;
import javax.inject.Singleton;
import org.apache.maven.artifact.handler.DefaultArtifactHandler;

@Singleton
@Named("takari-maven-plugin")
public class TakariMavenPluginArtifactHandler extends DefaultArtifactHandler {
public TakariMavenPluginArtifactHandler() {
super("takari-maven-plugin");
setExtension("jar");
setLanguage("java");
setAddedToClasspath(true);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/*
* Copyright (c) 2014-2024 Takari, Inc.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-v10.html
*/
package io.takari.maven.plugins.packaging;

import javax.inject.Named;
import javax.inject.Singleton;

@Singleton
@Named("takari-maven-plugin")
public class TakariMavenPluginLifecycleMapping extends LifecycleMappingSupport {}
Loading

0 comments on commit 38c703c

Please sign in to comment.