@@ -101,9 +101,9 @@ public File findArtifact(Artifact artifact) {
101
101
MavenProject project = getProject (artifact );
102
102
103
103
if (project != null ) {
104
- File file = findArtifact (project , artifact );
104
+ File file = findArtifact (project , artifact , true );
105
105
if (file == null && project != project .getExecutionProject ()) {
106
- file = findArtifact (project .getExecutionProject (), artifact );
106
+ file = findArtifact (project .getExecutionProject (), artifact , true );
107
107
}
108
108
return file ;
109
109
}
@@ -133,7 +133,7 @@ public List<String> findVersions(Artifact artifact) {
133
133
.getOrDefault (artifact .getArtifactId (), Collections .emptyMap ())
134
134
.values ()
135
135
.stream ()
136
- .filter (p -> Objects .nonNull (findArtifact (p , artifact )))
136
+ .filter (p -> Objects .nonNull (findArtifact (p , artifact , false )))
137
137
.map (MavenProject ::getVersion )
138
138
.collect (Collectors .collectingAndThen (Collectors .toList (), Collections ::unmodifiableList ));
139
139
}
@@ -148,30 +148,30 @@ public Model findModel(Artifact artifact) {
148
148
// Implementation
149
149
//
150
150
151
- private File findArtifact (MavenProject project , Artifact artifact ) {
151
+ private File findArtifact (MavenProject project , Artifact artifact , boolean checkUptodate ) {
152
152
// POMs are always returned from the file system
153
153
if ("pom" .equals (artifact .getExtension ())) {
154
154
return project .getFile ();
155
155
}
156
156
157
- // First check in the project local repository
158
- File packagedArtifactFile = findInProjectLocalRepository (artifact );
159
- if (packagedArtifactFile != null
160
- && packagedArtifactFile .exists ()
161
- && isPackagedArtifactUpToDate (project , packagedArtifactFile )) {
162
- return packagedArtifactFile ;
163
- }
164
-
165
157
// Get the matching artifact from the project
166
158
Artifact projectArtifact = findMatchingArtifact (project , artifact );
167
159
if (projectArtifact != null ) {
168
160
// If the artifact has been associated to a file, use it
169
- packagedArtifactFile = projectArtifact .getFile ();
161
+ File packagedArtifactFile = projectArtifact .getFile ();
170
162
if (packagedArtifactFile != null && packagedArtifactFile .exists ()) {
171
163
return packagedArtifactFile ;
172
164
}
173
165
}
174
166
167
+ // Check in the project local repository
168
+ File packagedArtifactFile = findInProjectLocalRepository (artifact );
169
+ if (packagedArtifactFile != null
170
+ && packagedArtifactFile .exists ()
171
+ && (!checkUptodate || isPackagedArtifactUpToDate (project , packagedArtifactFile ))) {
172
+ return packagedArtifactFile ;
173
+ }
174
+
175
175
if (!hasBeenPackagedDuringThisSession (project )) {
176
176
// fallback to loose class files only if artifacts haven't been packaged yet
177
177
// and only for plain old jars. Not war files, not ear files, not anything else.
0 commit comments