Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public interface Artifact {

/**
* Returns a unique identifier for this artifact.
* The identifier is composed of groupId, artifactId, version, classifier, extension.
* The identifier is composed of groupId, artifactId, extension, classifier, and version.
*
* @return the unique identifier
*/
Expand All @@ -43,7 +43,7 @@ default String key() {
+ getArtifactId()
+ ':'
+ getExtension()
+ (getClassifier().length() > 0 ? ":" + getClassifier() : "")
+ (getClassifier().isEmpty() ? "" : ":" + getClassifier())
+ ':'
+ getVersion();
}
Expand Down
25 changes: 25 additions & 0 deletions maven-bom/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,31 @@ under the License.
<artifactId>maven-api-core</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-api-meta</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-api-model</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-api-settings</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-api-toolchain</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-api-xml</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-model-builder</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@
package org.apache.maven.building;

import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.nio.file.Files;
import java.util.Objects;

/**
Expand All @@ -46,7 +46,7 @@ public FileSource(File file) {

@Override
public InputStream getInputStream() throws IOException {
return new FileInputStream(file);
return Files.newInputStream(file.toPath());
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public DefaultArtifact(@Nonnull AbstractSession session, @Nonnull org.eclipse.ae
+ getArtifactId()
+ ':'
+ getExtension()
+ (getClassifier().length() > 0 ? ":" + getClassifier() : "")
+ (getClassifier().isEmpty() ? "" : ":" + getClassifier())
+ ':'
+ getVersion();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,12 @@
import javax.inject.Named;
import javax.inject.Singleton;

import java.io.BufferedInputStream;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintStream;
import java.nio.file.Files;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
Expand Down Expand Up @@ -229,7 +228,7 @@ private PluginDescriptor extractPluginDescriptor(Artifact pluginArtifact, Plugin
File pluginXml = new File(pluginFile, getPluginDescriptorLocation());

if (pluginXml.isFile()) {
try (InputStream is = new BufferedInputStream(new FileInputStream(pluginXml))) {
try (InputStream is = Files.newInputStream(pluginXml.toPath())) {
pluginDescriptor = parsePluginDescriptor(is, plugin, pluginXml.getAbsolutePath());
}
}
Expand Down
16 changes: 14 additions & 2 deletions maven-embedder/src/main/java/org/apache/maven/cli/MavenCli.java
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@ void initialize(CliRequest cliRequest) throws ExitException {
for (String arg : cliRequest.args) {
if (isAltFile) {
// this is the argument following -f/--file
Path path = topDirectory.resolve(arg);
Path path = topDirectory.resolve(stripLeadingAndTrailingQuotes(arg));
if (Files.isDirectory(path)) {
topDirectory = path;
} else if (Files.isRegularFile(path)) {
Expand All @@ -351,7 +351,7 @@ void initialize(CliRequest cliRequest) throws ExitException {
break;
} else {
// Check if this is the -f/--file option
isAltFile = arg.equals(String.valueOf(CLIManager.ALTERNATE_POM_FILE)) || arg.equals("file");
isAltFile = arg.equals("-f") || arg.equals("--file");
}
}
topDirectory = getCanonicalPath(topDirectory);
Expand Down Expand Up @@ -1616,6 +1616,18 @@ public Object getValue(String expression) {
return interpolator;
}

private static String stripLeadingAndTrailingQuotes(String str) {
final int length = str.length();
if (length > 1
&& str.startsWith("\"")
&& str.endsWith("\"")
&& str.substring(1, length - 1).indexOf('"') == -1) {
str = str.substring(1, length - 1);
}

return str;
}

private static Path getCanonicalPath(Path path) {
try {
return path.toRealPath();
Expand Down