mirror of https://github.com/apache/maven.git
[MNG-7838] Fix usage of older packaged artifacts from project local repository (#1199)
This commit is contained in:
parent
b370e5e929
commit
c0813a2b53
|
@ -101,9 +101,9 @@ public File findArtifact(Artifact artifact) {
|
|||
MavenProject project = getProject(artifact);
|
||||
|
||||
if (project != null) {
|
||||
File file = findArtifact(project, artifact);
|
||||
File file = findArtifact(project, artifact, true);
|
||||
if (file == null && project != project.getExecutionProject()) {
|
||||
file = findArtifact(project.getExecutionProject(), artifact);
|
||||
file = findArtifact(project.getExecutionProject(), artifact, true);
|
||||
}
|
||||
return file;
|
||||
}
|
||||
|
@ -133,7 +133,7 @@ public List<String> findVersions(Artifact artifact) {
|
|||
.getOrDefault(artifact.getArtifactId(), Collections.emptyMap())
|
||||
.values()
|
||||
.stream()
|
||||
.filter(p -> Objects.nonNull(findArtifact(p, artifact)))
|
||||
.filter(p -> Objects.nonNull(findArtifact(p, artifact, false)))
|
||||
.map(MavenProject::getVersion)
|
||||
.collect(Collectors.collectingAndThen(Collectors.toList(), Collections::unmodifiableList));
|
||||
}
|
||||
|
@ -148,30 +148,30 @@ public Model findModel(Artifact artifact) {
|
|||
// Implementation
|
||||
//
|
||||
|
||||
private File findArtifact(MavenProject project, Artifact artifact) {
|
||||
private File findArtifact(MavenProject project, Artifact artifact, boolean checkUptodate) {
|
||||
// POMs are always returned from the file system
|
||||
if ("pom".equals(artifact.getExtension())) {
|
||||
return project.getFile();
|
||||
}
|
||||
|
||||
// First check in the project local repository
|
||||
File packagedArtifactFile = findInProjectLocalRepository(artifact);
|
||||
if (packagedArtifactFile != null
|
||||
&& packagedArtifactFile.exists()
|
||||
&& isPackagedArtifactUpToDate(project, packagedArtifactFile)) {
|
||||
return packagedArtifactFile;
|
||||
}
|
||||
|
||||
// Get the matching artifact from the project
|
||||
Artifact projectArtifact = findMatchingArtifact(project, artifact);
|
||||
if (projectArtifact != null) {
|
||||
// If the artifact has been associated to a file, use it
|
||||
packagedArtifactFile = projectArtifact.getFile();
|
||||
File packagedArtifactFile = projectArtifact.getFile();
|
||||
if (packagedArtifactFile != null && packagedArtifactFile.exists()) {
|
||||
return packagedArtifactFile;
|
||||
}
|
||||
}
|
||||
|
||||
// Check in the project local repository
|
||||
File packagedArtifactFile = findInProjectLocalRepository(artifact);
|
||||
if (packagedArtifactFile != null
|
||||
&& packagedArtifactFile.exists()
|
||||
&& (!checkUptodate || isPackagedArtifactUpToDate(project, packagedArtifactFile))) {
|
||||
return packagedArtifactFile;
|
||||
}
|
||||
|
||||
if (!hasBeenPackagedDuringThisSession(project)) {
|
||||
// fallback to loose class files only if artifacts haven't been packaged yet
|
||||
// and only for plain old jars. Not war files, not ear files, not anything else.
|
||||
|
|
Loading…
Reference in New Issue