Skip to content

Commit

Permalink
[MSHARED-1081] Drop m-shared-utils (#23)
Browse files Browse the repository at this point in the history
Drop m-shared-us from dependencies, use p-u
  • Loading branch information
cstamas authored Jun 10, 2022
1 parent 922e510 commit 96859f2
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 11 deletions.
7 changes: 1 addition & 6 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,6 @@
<version>${mavenVersion}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.maven.shared</groupId>
<artifactId>maven-shared-utils</artifactId>
<version>3.3.4</version>
</dependency>
<!--
Apache Commons dependencies
-->
Expand All @@ -99,7 +94,7 @@
<dependency>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-utils</artifactId>
<version>3.4.1</version>
<version>3.4.2</version>
</dependency>
<dependency>
<groupId>org.codehaus.plexus</groupId>
Expand Down
23 changes: 20 additions & 3 deletions src/main/java/org/apache/maven/archiver/MavenArchiver.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@

import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
Expand All @@ -41,8 +42,6 @@
import org.apache.maven.artifact.versioning.OverConstrainedVersionException;
import org.apache.maven.execution.MavenSession;
import org.apache.maven.project.MavenProject;
import org.apache.maven.shared.utils.PropertyUtils;
import org.apache.maven.shared.utils.StringUtils;
import org.codehaus.plexus.archiver.jar.JarArchiver;
import org.codehaus.plexus.archiver.jar.Manifest;
import org.codehaus.plexus.archiver.jar.ManifestException;
Expand All @@ -54,6 +53,7 @@
import org.codehaus.plexus.interpolation.RecursionInterceptor;
import org.codehaus.plexus.interpolation.StringSearchInterpolator;
import org.codehaus.plexus.interpolation.ValueSource;
import org.codehaus.plexus.util.StringUtils;

import static org.apache.maven.archiver.ManifestConfiguration.CLASSPATH_LAYOUT_TYPE_CUSTOM;
import static org.apache.maven.archiver.ManifestConfiguration.CLASSPATH_LAYOUT_TYPE_REPOSITORY;
Expand Down Expand Up @@ -743,12 +743,29 @@ private Artifact findArtifactWithFile( Set<Artifact> artifacts, File file )

private static String getCreatedByVersion( String groupId, String artifactId )
{
final Properties properties = PropertyUtils.loadOptionalProperties( MavenArchiver.class.getResourceAsStream(
final Properties properties = loadOptionalProperties( MavenArchiver.class.getResourceAsStream(
"/META-INF/maven/" + groupId + "/" + artifactId + "/pom.properties" ) );

return properties.getProperty( "version" );
}

private static Properties loadOptionalProperties( final InputStream inputStream )
{
Properties properties = new Properties();
if ( inputStream != null )
{
try ( InputStream in = inputStream )
{
properties.load( in );
}
catch ( IllegalArgumentException | IOException ex )
{
// ignore and return empty properties
}
}
return properties;
}

/**
* Define a value for "Created By" entry.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@
import org.apache.maven.model.Model;
import org.apache.maven.model.Organization;
import org.apache.maven.project.MavenProject;
import org.apache.maven.shared.utils.StringUtils;
import org.apache.maven.shared.utils.io.FileUtils;
import org.codehaus.plexus.archiver.jar.JarArchiver;
import org.codehaus.plexus.archiver.jar.ManifestException;
import org.codehaus.plexus.util.FileUtils;
import org.codehaus.plexus.util.StringUtils;
import org.eclipse.aether.DefaultRepositorySystemSession;
import org.eclipse.aether.RepositorySystemSession;
import org.junit.jupiter.api.Test;
Expand Down

0 comments on commit 96859f2

Please sign in to comment.