Skip to content

Commit 5719b80

Browse files
Restore method RepositoryUtils.newArtifactTypeRegistry
used by maven-artifact-transfer
1 parent cc5d123 commit 5719b80

File tree

1 file changed

+18
-7
lines changed

1 file changed

+18
-7
lines changed

impl/maven-core/src/main/java/org/apache/maven/RepositoryUtils.java

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131

3232
import org.apache.maven.artifact.handler.ArtifactHandler;
3333
import org.apache.maven.artifact.handler.DefaultArtifactHandler;
34+
import org.apache.maven.artifact.handler.manager.ArtifactHandlerManager;
3435
import org.apache.maven.artifact.repository.ArtifactRepository;
3536
import org.apache.maven.artifact.repository.ArtifactRepositoryPolicy;
3637
import org.apache.maven.impl.resolver.artifact.MavenArtifactProperties;
@@ -258,13 +259,15 @@ public static ArtifactHandler newHandler(Artifact artifact) {
258259
}
259260

260261
public static ArtifactType newArtifactType(String id, ArtifactHandler handler) {
261-
return new DefaultArtifactType(
262-
id,
263-
handler.getExtension(),
264-
handler.getClassifier(),
265-
handler.getLanguage(),
266-
handler.isAddedToClasspath(),
267-
handler.isIncludesDependencies());
262+
return handler != null
263+
? new DefaultArtifactType(
264+
id,
265+
handler.getExtension(),
266+
handler.getClassifier(),
267+
handler.getLanguage(),
268+
handler.isAddedToClasspath(),
269+
handler.isIncludesDependencies())
270+
: null;
268271
}
269272

270273
public static Dependency toDependency(
@@ -306,6 +309,14 @@ private static Exclusion toExclusion(org.apache.maven.model.Exclusion exclusion)
306309
return new Exclusion(exclusion.getGroupId(), exclusion.getArtifactId(), "*", "*");
307310
}
308311

312+
/**
313+
* @deprecated Use by maven-artifact-transfer.
314+
*/
315+
@Deprecated
316+
public static ArtifactTypeRegistry newArtifactTypeRegistry(ArtifactHandlerManager handlerManager) {
317+
return typeId -> newArtifactType(typeId, handlerManager.getArtifactHandler(typeId));
318+
}
319+
309320
public static Collection<Artifact> toArtifacts(Collection<org.apache.maven.artifact.Artifact> artifactsToConvert) {
310321
return artifactsToConvert.stream().map(RepositoryUtils::toArtifact).collect(Collectors.toList());
311322
}

0 commit comments

Comments
 (0)