[
https://issues.apache.org/jira/browse/MNG-7629?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17678096#comment-17678096
]
ASF GitHub Bot commented on MNG-7629:
-------------------------------------
MartinKanters commented on code in PR #954:
URL: https://github.com/apache/maven/pull/954#discussion_r1073152217
##########
maven-core/src/main/java/org/apache/maven/ReactorReader.java:
##########
@@ -324,4 +309,130 @@ private static boolean isTestArtifact(Artifact artifact) {
return ("test-jar".equals(artifact.getProperty("type", "")))
|| ("jar".equals(artifact.getExtension()) &&
"tests".equals(artifact.getClassifier()));
}
+
+ private File find(Artifact artifact) {
+ Path target = getArtifactPath(artifact);
+ return Files.isRegularFile(target) ? target.toFile() : null;
+ }
+
+ /**
+ * Copy packaged and attached artifacts from this project to the
+ * project local repository.
+ * This allow a subsequent build to resume while still being able
+ * to locate attached artifacts.
+ *
+ * @param project the project to copy artifacts
Review Comment:
```suggestion
* This allows a subsequent build to resume while still being able
* to locate attached artifacts.
*
* @param project the project to copy artifacts from
```
##########
maven-core/src/main/java/org/apache/maven/ReactorReader.java:
##########
@@ -117,18 +105,19 @@ public File findArtifact(Artifact artifact) {
}
public List<String> findVersions(Artifact artifact) {
- String key = ArtifactUtils.versionlessKey(artifact.getGroupId(),
artifact.getArtifactId());
-
- return
Optional.ofNullable(projectsByGA.get(key)).orElse(Collections.emptyList()).stream()
- .filter(s -> Objects.nonNull(find(s, artifact)))
+ return getProjects()
+ .getOrDefault(artifact.getGroupId(), Collections.emptyMap())
+ .getOrDefault(artifact.getArtifactId(), Collections.emptyMap())
+ .values()
+ .stream()
+ .filter(p -> Objects.nonNull(find(p, artifact)))
Review Comment:
Since `find` is also not very descriptive, let's write out `p` into `project`
##########
maven-core/src/main/java/org/apache/maven/ReactorReader.java:
##########
@@ -324,4 +309,130 @@ private static boolean isTestArtifact(Artifact artifact) {
return ("test-jar".equals(artifact.getProperty("type", "")))
|| ("jar".equals(artifact.getExtension()) &&
"tests".equals(artifact.getClassifier()));
}
+
+ private File find(Artifact artifact) {
+ Path target = getArtifactPath(artifact);
+ return Files.isRegularFile(target) ? target.toFile() : null;
+ }
+
+ /**
+ * Copy packaged and attached artifacts from this project to the
+ * project local repository.
+ * This allow a subsequent build to resume while still being able
+ * to locate attached artifacts.
+ *
+ * @param project the project to copy artifacts
+ */
+ private void installIntoProjectLocalRepository(MavenProject project) {
+ if (!hasBeenPackagedDuringThisSession(project)) {
+ return;
+ }
+ List<Artifact> artifacts = new ArrayList<>();
+
+ artifacts.add(RepositoryUtils.toArtifact(new
ProjectArtifact(project)));
+ if (!"pom".equals(project.getPackaging())) {
+ org.apache.maven.artifact.Artifact mavenMainArtifact =
project.getArtifact();
+ artifacts.add(RepositoryUtils.toArtifact(mavenMainArtifact));
+ }
+ for (org.apache.maven.artifact.Artifact attached :
project.getAttachedArtifacts()) {
+ artifacts.add(RepositoryUtils.toArtifact(attached));
+ }
+
+ for (Artifact artifact : artifacts) {
Review Comment:
You could go for streams here as well, if you like.
> Improve resolution of modules within a multi-module build
> ---------------------------------------------------------
>
> Key: MNG-7629
> URL: https://issues.apache.org/jira/browse/MNG-7629
> Project: Maven
> Issue Type: Task
> Reporter: Guillaume Nodet
> Assignee: Guillaume Nodet
> Priority: Major
> Fix For: 4.0.0-alpha-4
>
>
--
This message was sent by Atlassian Jira
(v8.20.10#820010)