Skip to content

Commit

Permalink
chore: get rid of Plexus DI and more
Browse files Browse the repository at this point in the history
  • Loading branch information
cstamas committed Jan 3, 2025
1 parent 1b28e22 commit e475442
Show file tree
Hide file tree
Showing 21 changed files with 225 additions and 202 deletions.
92 changes: 46 additions & 46 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -75,12 +75,12 @@
<jnr-jffi.version>1.3.11</jnr-jffi.version>
<jnr-unixsocket.version>0.38.19</jnr-unixsocket.version>
<junit.jupiter.version>5.8.2</junit.jupiter.version>
<maven.version>3.8.1</maven.version>
<maven.version>3.8.8</maven.version>
<minimum.maven.version>3.3.9</minimum.maven.version>
<mockito.version>4.5.1</mockito.version>
<project.build.outputTimestamp>2024-09-29T06:28:50Z</project.build.outputTimestamp>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<surefire.version>3.0.0-M2</surefire.version>
<surefire.version>3.5.2</surefire.version>
<system-stubs.version>2.0.1</system-stubs.version>
<version.assertj-core>3.25.3</version.assertj-core>
<version.sonar-maven-plugin>3.11.0.3922</version.sonar-maven-plugin>
Expand Down Expand Up @@ -144,16 +144,22 @@
<version>2.4.0</version>
</dependency>

<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-compress</artifactId>
<version>1.27.1</version>
</dependency>

<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.6</version>
<version>3.17.0</version>
</dependency>

<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-text</artifactId>
<version>1.1</version>
<version>1.12.0</version>
</dependency>

<dependency>
Expand Down Expand Up @@ -214,18 +220,7 @@
<dependency>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>3.1.0</version>
<exclusions>
<exclusion>
<groupId>org.apache.maven</groupId>
<artifactId>maven-project</artifactId>
</exclusion>
<!-- Doesn't work with guava which contains newer versions of utilities -->
<exclusion>
<groupId>com.google.collections</groupId>
<artifactId>google-collections</artifactId>
</exclusion>
</exclusions>
<version>3.7.1</version>
</dependency>

<dependency>
Expand All @@ -237,15 +232,8 @@

<dependency>
<groupId>org.bouncycastle</groupId>
<artifactId>bcpkix-jdk15on</artifactId>
<version>1.65</version>
</dependency>

<dependency>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-component-annotations</artifactId>
<version>1.6</version>
<scope>provided</scope>
<artifactId>bcpkix-jdk18on</artifactId>
<version>1.79</version>
</dependency>

<dependency>
Expand All @@ -257,7 +245,7 @@
<dependency>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-utils</artifactId>
<version>3.0.24</version>
<version>3.5.1</version>
</dependency>

<dependency>
Expand Down Expand Up @@ -311,7 +299,7 @@
<dependency>
<groupId>org.yaml</groupId>
<artifactId>snakeyaml</artifactId>
<version>1.32</version>
<version>2.3</version>
</dependency>

<dependency>
Expand All @@ -334,15 +322,30 @@

<pluginManagement>
<plugins>
<plugin>
<artifactId>maven-clean-plugin</artifactId>
<version>3.4.0</version>
</plugin>

<plugin>
<artifactId>maven-deploy-plugin</artifactId>
<version>2.8.2</version>
<version>3.1.3</version>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-gpg-plugin</artifactId>
<version>3.2.7</version>
</plugin>

<plugin>
<artifactId>maven-install-plugin</artifactId>
<version>3.1.3</version>
</plugin>

<plugin>
<artifactId>maven-jar-plugin</artifactId>
<version>3.2.0</version>
<version>3.4.2</version>
<configuration>
<archive>
<addMavenDescriptor>true</addMavenDescriptor>
Expand All @@ -352,17 +355,17 @@

<plugin>
<artifactId>maven-javadoc-plugin</artifactId>
<version>3.2.0</version>
<version>3.11.1</version>
</plugin>

<plugin>
<artifactId>maven-release-plugin</artifactId>
<version>3.0.0-M1</version>
<version>3.1.1</version>
</plugin>

<plugin>
<artifactId>maven-source-plugin</artifactId>
<version>3.2.0</version>
<version>3.3.1</version>
</plugin>

<plugin>
Expand Down Expand Up @@ -428,18 +431,18 @@

<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<version>3.13.0</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
<source>8</source>
<target>8</target>
<compilerArgument>-Xlint:deprecation</compilerArgument>
<showWarnings>true</showWarnings>
</configuration>
</plugin>

<plugin>
<artifactId>maven-plugin-plugin</artifactId>
<version>3.6.0</version>
<version>3.13.1</version>
<configuration>
<goalPrefix>docker</goalPrefix>
<skipErrorNoDescriptorsFound>true</skipErrorNoDescriptorsFound>
Expand All @@ -463,7 +466,7 @@

<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>3.0.2</version>
<version>3.3.1</version>
<executions>
<execution>
<id>copy-plexus-resources</id>
Expand Down Expand Up @@ -499,18 +502,16 @@
</execution>
</executions>
</plugin>

<plugin>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-component-metadata</artifactId>
<version>2.1.0</version>
<configuration>
<staticMetadataDirectory>${basedir}/target/filtered-resources/META-INF/plexus</staticMetadataDirectory>
</configuration>
<groupId>org.eclipse.sisu</groupId>
<artifactId>sisu-maven-plugin</artifactId>
<version>0.9.0.M3</version>
<executions>
<execution>
<id>index-project</id>
<goals>
<goal>generate-metadata</goal>
<goal>main-index</goal>
<goal>test-index</goal>
</goals>
</execution>
</executions>
Expand Down Expand Up @@ -544,7 +545,6 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-gpg-plugin</artifactId>
<version>1.6</version>
<configuration>
<skip>false</skip>
<gpgArguments>
Expand Down
10 changes: 2 additions & 8 deletions src/main/java/io/fabric8/maven/docker/AbstractDockerMojo.java
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@
import org.codehaus.plexus.PlexusContainer;
import org.codehaus.plexus.context.Context;
import org.codehaus.plexus.context.ContextException;
import org.codehaus.plexus.personality.plexus.lifecycle.phase.Contextualizable;
import org.fusesource.jansi.Ansi;

/**
Expand All @@ -68,7 +67,7 @@
* @author roland
* @since 26.03.14
*/
public abstract class AbstractDockerMojo extends AbstractMojo implements Contextualizable, ConfigHelper.Customizer {
public abstract class AbstractDockerMojo extends AbstractMojo implements ConfigHelper.Customizer {

// Key for indicating that a "start" goal has run
public static final String CONTEXT_KEY_START_CALLED = "CONTEXT_KEY_DOCKER_START_CALLED";
Expand Down Expand Up @@ -255,6 +254,7 @@ public abstract class AbstractDockerMojo extends AbstractMojo implements Context
List<ImageConfiguration> resolvedImages;

// Handler dealing with authentication credentials
@Component
AuthConfigFactory authConfigFactory;

protected AnsiLogger log;
Expand Down Expand Up @@ -481,12 +481,6 @@ protected List<VolumeConfiguration> getVolumes() {

// =================================================================================

@Override
public void contextualize(Context context) throws ContextException {
authConfigFactory = new AuthConfigFactory((PlexusContainer) context.get(PlexusConstants.PLEXUS_KEY));
}

// =================================================================================
protected GavLabel getGavLabel() {
// Label used for this run
return new GavLabel(project.getGroupId(), project.getArtifactId(), project.getVersion());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,8 @@
import java.io.*;
import java.util.concurrent.*;

import io.fabric8.maven.docker.util.AnsiLogger;
import io.fabric8.maven.docker.util.Logger;
import org.apache.maven.shared.utils.StringUtils;
import org.codehaus.plexus.util.StringUtils;

/**
* @author roland
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import java.io.File;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Properties;

import javax.annotation.Nonnull;
Expand All @@ -14,11 +15,11 @@
import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.execution.MavenSession;
import org.apache.maven.plugins.assembly.AssemblerConfigurationSource;
import org.apache.maven.plugins.assembly.model.Assembly;
import org.apache.maven.plugins.assembly.utils.InterpolationConstants;
import org.apache.maven.project.MavenProject;
import org.apache.maven.shared.filtering.MavenFileFilter;
import org.apache.maven.shared.filtering.MavenReaderFilter;
import org.apache.maven.shared.utils.cli.CommandLineUtils;
import org.codehaus.plexus.interpolation.fixed.FixedStringSearchInterpolator;
import org.codehaus.plexus.interpolation.fixed.PrefixedPropertiesValueSource;
import org.codehaus.plexus.interpolation.fixed.PropertiesBasedValueSource;
Expand Down Expand Up @@ -93,11 +94,6 @@ public String getFinalName() {
return ".";
}

@Override
public ArtifactRepository getLocalRepository() {
return params.getSession().getLocalRepository();
}

public MavenFileFilter getMavenFileFilter() {
return params.getMavenFileFilter();
}
Expand All @@ -108,12 +104,6 @@ public List<MavenProject> getReactorProjects() {
return params.getReactorProjects();
}

// Maybe use injection
@Override
public List<ArtifactRepository> getRemoteRepositories() {
return params.getProject().getRemoteArtifactRepositories();
}

@Override
public MavenSession getMavenSession() {
return params.getSession();
Expand Down Expand Up @@ -265,18 +255,57 @@ public boolean isUpdateOnly() {
}

@Override
public boolean isUseJvmChmod() {
public boolean isIgnorePermissions() {
return assemblyConfig != null ? assemblyConfig.isIgnorePermissions() : false;
}

@Override
public List<Assembly> getInlineDescriptors() {
return Collections.emptyList();
}

@Override
public Properties getAdditionalProperties() {
return new Properties();
}

@Override
public Integer getOverrideUid() {
return null;
}

@Override
public String getOverrideUserName() {
return null;
}

@Override
public Integer getOverrideGid() {
return null;
}

@Override
public String getOverrideGroupName() {
return null;
}

@Override
public boolean isRecompressZippedFiles() {
return false;
}

@Override
public boolean isIgnorePermissions() {
return assemblyConfig != null ? assemblyConfig.isIgnorePermissions() : false;
public String getMergeManifestMode() {
return null;
}

// =======================================================================
// Taken from AbstractAssemblyMojo

private ArtifactRepository getLocalRepository() {
return params.getSession().getLocalRepository();
}

private FixedStringSearchInterpolator mainProjectInterpolator(MavenProject mainProject)
{
if (mainProject != null) {
Expand Down Expand Up @@ -330,7 +359,18 @@ private FixedStringSearchInterpolator createCommandLinePropertiesInterpolator()

private FixedStringSearchInterpolator createEnvInterpolator() {
PrefixedPropertiesValueSource envProps = new PrefixedPropertiesValueSource(Collections.singletonList("env."),
CommandLineUtils.getSystemEnvVars(false), true );
getSystemEnvVars(), true );
return FixedStringSearchInterpolator.create( envProps );
}

private static Properties getSystemEnvVars() {
Properties envVars = new Properties();
Map<String, String> envs = System.getenv();

for(String key : envs.keySet()) {
String value = envs.get(key);
envVars.put(key, value);
}
return envVars;
}
}
Loading

0 comments on commit e475442

Please sign in to comment.