Skip to content

Commit be3fb20

Browse files
author
Jason van Zyl
committed
MNG-5775 Make the project graph building code pluggable to allow for new/different implementations.
1 parent 7997634 commit be3fb20

25 files changed

+1263
-553
lines changed

maven-aether-provider/src/main/java/org/apache/maven/repository/internal/DefaultArtifactDescriptorReader.java

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@
5252
import org.eclipse.aether.impl.RepositoryEventDispatcher;
5353
import org.eclipse.aether.impl.VersionRangeResolver;
5454
import org.eclipse.aether.impl.VersionResolver;
55+
import org.eclipse.aether.repository.WorkspaceReader;
5556
import org.eclipse.aether.repository.WorkspaceRepository;
5657
import org.eclipse.aether.resolution.ArtifactDescriptorException;
5758
import org.eclipse.aether.resolution.ArtifactDescriptorPolicy;
@@ -215,7 +216,6 @@ public ArtifactDescriptorResult readArtifactDescriptor( RepositorySystemSession
215216
ArtifactDescriptorResult result = new ArtifactDescriptorResult( request );
216217

217218
Model model = loadPom( session, request, result );
218-
219219
if ( model != null )
220220
{
221221
Map<String, Object> config = session.getConfigProperties();
@@ -303,6 +303,18 @@ private Model loadPom( RepositorySystemSession session, ArtifactDescriptorReques
303303
}
304304

305305
Model model;
306+
307+
// hack: don't rebuild model if it was already loaded during reactor resolution
308+
final WorkspaceReader workspace = session.getWorkspaceReader();
309+
if ( workspace instanceof MavenWorkspaceReader )
310+
{
311+
model = ( (MavenWorkspaceReader) workspace ).findModel( pomArtifact );
312+
if ( model != null )
313+
{
314+
return model;
315+
}
316+
}
317+
306318
try
307319
{
308320
ModelBuildingRequest modelRequest = new DefaultModelBuildingRequest();
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
package org.apache.maven.repository.internal;
2+
3+
/*
4+
* Licensed to the Apache Software Foundation (ASF) under one
5+
* or more contributor license agreements. See the NOTICE file
6+
* distributed with this work for additional information
7+
* regarding copyright ownership. The ASF licenses this file
8+
* to you under the Apache License, Version 2.0 (the
9+
* "License"); you may not use this file except in compliance
10+
* with the License. You may obtain a copy of the License at
11+
*
12+
* http://www.apache.org/licenses/LICENSE-2.0
13+
*
14+
* Unless required by applicable law or agreed to in writing,
15+
* software distributed under the License is distributed on an
16+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17+
* KIND, either express or implied. See the License for the
18+
* specific language governing permissions and limitations
19+
* under the License.
20+
*/
21+
22+
import org.apache.maven.model.Model;
23+
import org.eclipse.aether.artifact.Artifact;
24+
import org.eclipse.aether.repository.WorkspaceReader;
25+
26+
public interface MavenWorkspaceReader
27+
extends WorkspaceReader
28+
{
29+
30+
Model findModel( Artifact artifact );
31+
32+
}

0 commit comments

Comments
 (0)