diff --git a/api/maven-api-core/src/main/java/org/apache/maven/api/Dependency.java b/api/maven-api-core/src/main/java/org/apache/maven/api/Dependency.java index 888e247fe1..efad1415ad 100644 --- a/api/maven-api-core/src/main/java/org/apache/maven/api/Dependency.java +++ b/api/maven-api-core/src/main/java/org/apache/maven/api/Dependency.java @@ -30,6 +30,14 @@ public interface Dependency extends Artifact { @Nonnull Type getType(); + /** + * The dependency properties. + * + * @return the dependency properties, never {@code null} + */ + @Nonnull + DependencyProperties getDependencyProperties(); + @Nonnull Scope getScope(); diff --git a/api/maven-api-core/src/main/java/org/apache/maven/api/DependencyProperties.java b/api/maven-api-core/src/main/java/org/apache/maven/api/DependencyProperties.java new file mode 100644 index 0000000000..9f63416848 --- /dev/null +++ b/api/maven-api-core/src/main/java/org/apache/maven/api/DependencyProperties.java @@ -0,0 +1,59 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.maven.api; + +import java.util.Map; + +import org.apache.maven.api.annotations.Experimental; +import org.apache.maven.api.annotations.Immutable; +import org.apache.maven.api.annotations.Nonnull; + +/** + * Dependency properties supported by Maven Core. + * + * @since 4.0.0 + */ +@Experimental +@Immutable +public interface DependencyProperties { + /** + * Boolean flag telling that dependency contains all of its dependencies. Value of this key should be parsed with + * {@link Boolean#parseBoolean(String)} to obtain value. + *

+ * Important: this flag must be kept in sync with resolver! (as is used during collection) + */ + String FLAG_INCLUDES_DEPENDENCIES = "includesDependencies"; + + /** + * Boolean flag telling that dependency is meant to be placed on class path. Value of this key should be parsed with + * {@link Boolean#parseBoolean(String)} to obtain value. + */ + String FLAG_CLASS_PATH_CONSTITUENT = "classPathConstituent"; + + /** + * Returns immutable "map view" of all the properties. + */ + @Nonnull + Map asMap(); + + /** + * Returns {@code true} if given flag is {@code true}. + */ + boolean checkFlag(@Nonnull String flag); +} diff --git a/api/maven-api-core/src/main/java/org/apache/maven/api/Type.java b/api/maven-api-core/src/main/java/org/apache/maven/api/Type.java index 846a8ac23d..4401c82e11 100644 --- a/api/maven-api-core/src/main/java/org/apache/maven/api/Type.java +++ b/api/maven-api-core/src/main/java/org/apache/maven/api/Type.java @@ -20,6 +20,8 @@ import org.apache.maven.api.annotations.Experimental; import org.apache.maven.api.annotations.Immutable; +import org.apache.maven.api.annotations.Nonnull; +import org.apache.maven.api.annotations.Nullable; import org.apache.maven.api.model.Dependency; /** @@ -51,15 +53,17 @@ public interface Type { * Returns the dependency type id. * The id uniquely identifies this dependency type. * - * @return the id of this type + * @return the id of this type, never {@code null}. */ + @Nonnull String getId(); /** * Get the file extension of artifacts of this type. * - * @return the file extension + * @return the file extension, never {@code null}. */ + @Nonnull String getExtension(); /** @@ -67,17 +71,20 @@ public interface Type { * The default classifier can be overridden when specifying * the {@link Dependency#getClassifier()}. * - * @return the default classifier + * @return the default classifier, or {@code null}. */ + @Nullable String getClassifier(); /** * Specifies if the artifact contains java classes and should be * added to the classpath. * - * @return if the artifact should be added to the classpath + * @return if the artifact should be added to the class path */ - boolean isAddedToClasspath(); + default boolean isAddedToClassPath() { + return getDependencyProperties().checkFlag(DependencyProperties.FLAG_CLASS_PATH_CONSTITUENT); + } /** * Specifies if the artifact already embeds its own dependencies. @@ -86,5 +93,15 @@ public interface Type { * * @return if the artifact's dependencies are included in the artifact */ - boolean isIncludesDependencies(); + default boolean isIncludesDependencies() { + return getDependencyProperties().checkFlag(DependencyProperties.FLAG_INCLUDES_DEPENDENCIES); + } + + /** + * Gets the default properties associated with this dependency type. + * + * @return the default properties, never {@code null}. + */ + @Nonnull + DependencyProperties getDependencyProperties(); } diff --git a/maven-core/src/main/java/org/apache/maven/artifact/handler/manager/DefaultArtifactHandlerManager.java b/maven-core/src/main/java/org/apache/maven/artifact/handler/manager/DefaultArtifactHandlerManager.java index fb31efcef3..53fab056e1 100644 --- a/maven-core/src/main/java/org/apache/maven/artifact/handler/manager/DefaultArtifactHandlerManager.java +++ b/maven-core/src/main/java/org/apache/maven/artifact/handler/manager/DefaultArtifactHandlerManager.java @@ -26,47 +26,61 @@ import java.util.Set; import java.util.concurrent.ConcurrentHashMap; +import org.apache.maven.api.Type; +import org.apache.maven.api.services.TypeRegistry; import org.apache.maven.artifact.handler.ArtifactHandler; import org.apache.maven.artifact.handler.DefaultArtifactHandler; +import org.apache.maven.eventspy.AbstractEventSpy; +import org.apache.maven.execution.ExecutionEvent; + +import static java.util.Objects.requireNonNull; /** */ @Named @Singleton -public class DefaultArtifactHandlerManager implements ArtifactHandlerManager { +public class DefaultArtifactHandlerManager extends AbstractEventSpy implements ArtifactHandlerManager { + private final TypeRegistry typeRegistry; - private final Map artifactHandlers; - - private final Map allHandlers = new ConcurrentHashMap<>(); + private final ConcurrentHashMap allHandlers; @Inject - public DefaultArtifactHandlerManager(Map artifactHandlers) { - this.artifactHandlers = artifactHandlers; + public DefaultArtifactHandlerManager(TypeRegistry typeRegistry) { + this.typeRegistry = requireNonNull(typeRegistry, "null typeRegistry"); + this.allHandlers = new ConcurrentHashMap<>(); } - public ArtifactHandler getArtifactHandler(String type) { - ArtifactHandler handler = allHandlers.get(type); - - if (handler == null) { - handler = artifactHandlers.get(type); - - if (handler == null) { - handler = new DefaultArtifactHandler(type); - } else { - allHandlers.put(type, handler); + @Override + public void onEvent(Object event) { + if (event instanceof ExecutionEvent) { + ExecutionEvent executionEvent = (ExecutionEvent) event; + if (executionEvent.getType() == ExecutionEvent.Type.SessionEnded) { + allHandlers.clear(); } } + } - return handler; + public ArtifactHandler getArtifactHandler(String id) { + return allHandlers.computeIfAbsent(id, k -> { + Type type = typeRegistry.getType(id); + return new DefaultArtifactHandler( + id, + type.getExtension(), + type.getClassifier(), + null, + null, + type.isIncludesDependencies(), + "none", + type.isAddedToClassPath()); // TODO: watch out for module path + }); } public void addHandlers(Map handlers) { - // legacy support for maven-gpg-plugin:1.0 - allHandlers.putAll(handlers); + throw new UnsupportedOperationException("Adding handlers programmatically is not supported anymore"); } @Deprecated public Set getHandlerTypes() { - return artifactHandlers.keySet(); + throw new UnsupportedOperationException("Querying handlers programmatically is not supported anymore"); } } diff --git a/maven-core/src/main/java/org/apache/maven/artifact/handler/manager/LegacyArtifactHandlerManager.java b/maven-core/src/main/java/org/apache/maven/artifact/handler/manager/LegacyArtifactHandlerManager.java new file mode 100644 index 0000000000..46e480fae5 --- /dev/null +++ b/maven-core/src/main/java/org/apache/maven/artifact/handler/manager/LegacyArtifactHandlerManager.java @@ -0,0 +1,72 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.maven.artifact.handler.manager; + +import javax.inject.Inject; +import javax.inject.Named; +import javax.inject.Singleton; + +import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; + +import org.apache.maven.artifact.handler.ArtifactHandler; +import org.apache.maven.artifact.handler.DefaultArtifactHandler; +import org.apache.maven.eventspy.AbstractEventSpy; +import org.apache.maven.execution.ExecutionEvent; + +import static java.util.Objects.requireNonNull; + +/** + */ +@Named +@Singleton +public class LegacyArtifactHandlerManager extends AbstractEventSpy { + private final Map artifactHandlers; + + private final Map allHandlers = new ConcurrentHashMap<>(); + + @Inject + public LegacyArtifactHandlerManager(Map artifactHandlers) { + this.artifactHandlers = requireNonNull(artifactHandlers); + } + + @Override + public void onEvent(Object event) { + if (event instanceof ExecutionEvent) { + ExecutionEvent executionEvent = (ExecutionEvent) event; + if (executionEvent.getType() == ExecutionEvent.Type.SessionEnded) { + allHandlers.clear(); + } + } + } + + public ArtifactHandler getArtifactHandler(String type) { + requireNonNull(type, "null type"); + ArtifactHandler handler = allHandlers.get(type); + if (handler == null) { + handler = artifactHandlers.get(type); + if (handler == null) { + handler = new DefaultArtifactHandler(type); + } else { + allHandlers.put(type, handler); + } + } + return handler; + } +} diff --git a/maven-core/src/main/java/org/apache/maven/artifact/handler/providers/JavaSourceArtifactHandlerProvider.java b/maven-core/src/main/java/org/apache/maven/artifact/handler/providers/JavaSourceArtifactHandlerProvider.java deleted file mode 100644 index 467be6da8a..0000000000 --- a/maven-core/src/main/java/org/apache/maven/artifact/handler/providers/JavaSourceArtifactHandlerProvider.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.maven.artifact.handler.providers; - -import javax.inject.Inject; -import javax.inject.Named; -import javax.inject.Provider; -import javax.inject.Singleton; - -import org.apache.maven.artifact.handler.ArtifactHandler; -import org.apache.maven.artifact.handler.DefaultArtifactHandler; - -/** - * {@code java-source} artifact handler provider. - */ -@Named("java-source") -@Singleton -public class JavaSourceArtifactHandlerProvider implements Provider { - private final ArtifactHandler artifactHandler; - - @Inject - public JavaSourceArtifactHandlerProvider() { - this.artifactHandler = - new DefaultArtifactHandler("java-source", "jar", "sources", null, null, false, "java", false); - } - - @Override - public ArtifactHandler get() { - return artifactHandler; - } -} diff --git a/maven-core/src/main/java/org/apache/maven/artifact/handler/providers/JavadocArtifactHandlerProvider.java b/maven-core/src/main/java/org/apache/maven/artifact/handler/providers/JavadocArtifactHandlerProvider.java deleted file mode 100644 index cdb3b08b67..0000000000 --- a/maven-core/src/main/java/org/apache/maven/artifact/handler/providers/JavadocArtifactHandlerProvider.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.maven.artifact.handler.providers; - -import javax.inject.Inject; -import javax.inject.Named; -import javax.inject.Provider; -import javax.inject.Singleton; - -import org.apache.maven.artifact.handler.ArtifactHandler; -import org.apache.maven.artifact.handler.DefaultArtifactHandler; - -/** - * {@code javadoc} artifact handler provider. - */ -@Named("javadoc") -@Singleton -public class JavadocArtifactHandlerProvider implements Provider { - private final ArtifactHandler artifactHandler; - - @Inject - public JavadocArtifactHandlerProvider() { - this.artifactHandler = new DefaultArtifactHandler("javadoc", "jar", "javadoc", null, null, false, "java", true); - } - - @Override - public ArtifactHandler get() { - return artifactHandler; - } -} diff --git a/maven-core/src/main/java/org/apache/maven/artifact/handler/providers/MavenPluginArtifactHandlerProvider.java b/maven-core/src/main/java/org/apache/maven/artifact/handler/providers/MavenPluginArtifactHandlerProvider.java deleted file mode 100644 index 8eb28fad09..0000000000 --- a/maven-core/src/main/java/org/apache/maven/artifact/handler/providers/MavenPluginArtifactHandlerProvider.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.maven.artifact.handler.providers; - -import javax.inject.Inject; -import javax.inject.Named; -import javax.inject.Provider; -import javax.inject.Singleton; - -import org.apache.maven.artifact.handler.ArtifactHandler; -import org.apache.maven.artifact.handler.DefaultArtifactHandler; - -/** - * {@code maven-plugin} artifact handler provider. - */ -@Named("maven-plugin") -@Singleton -public class MavenPluginArtifactHandlerProvider implements Provider { - private final ArtifactHandler artifactHandler; - - @Inject - public MavenPluginArtifactHandlerProvider() { - this.artifactHandler = new DefaultArtifactHandler("maven-plugin", "jar", null, null, null, false, "java", true); - } - - @Override - public ArtifactHandler get() { - return artifactHandler; - } -} diff --git a/maven-core/src/main/java/org/apache/maven/artifact/handler/providers/PomArtifactHandlerProvider.java b/maven-core/src/main/java/org/apache/maven/artifact/handler/providers/PomArtifactHandlerProvider.java deleted file mode 100644 index 12d1107d5c..0000000000 --- a/maven-core/src/main/java/org/apache/maven/artifact/handler/providers/PomArtifactHandlerProvider.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.maven.artifact.handler.providers; - -import javax.inject.Inject; -import javax.inject.Named; -import javax.inject.Provider; -import javax.inject.Singleton; - -import org.apache.maven.artifact.handler.ArtifactHandler; -import org.apache.maven.artifact.handler.DefaultArtifactHandler; - -/** - * {@code pom} artifact handler provider. - */ -@Named("pom") -@Singleton -public class PomArtifactHandlerProvider implements Provider { - private final ArtifactHandler artifactHandler; - - @Inject - public PomArtifactHandlerProvider() { - this.artifactHandler = new DefaultArtifactHandler("pom", null, null, null, null, false, "none", false); - } - - @Override - public ArtifactHandler get() { - return artifactHandler; - } -} diff --git a/maven-core/src/main/java/org/apache/maven/artifact/handler/providers/TestJarArtifactHandlerProvider.java b/maven-core/src/main/java/org/apache/maven/artifact/handler/providers/TestJarArtifactHandlerProvider.java deleted file mode 100644 index 160bc6783b..0000000000 --- a/maven-core/src/main/java/org/apache/maven/artifact/handler/providers/TestJarArtifactHandlerProvider.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.maven.artifact.handler.providers; - -import javax.inject.Inject; -import javax.inject.Named; -import javax.inject.Provider; -import javax.inject.Singleton; - -import org.apache.maven.artifact.handler.ArtifactHandler; -import org.apache.maven.artifact.handler.DefaultArtifactHandler; - -/** - * {@code test-jar} artifact handler provider. - */ -@Named("test-jar") -@Singleton -public class TestJarArtifactHandlerProvider implements Provider { - private final ArtifactHandler artifactHandler; - - @Inject - public TestJarArtifactHandlerProvider() { - this.artifactHandler = new DefaultArtifactHandler("test-jar", "jar", "tests", null, "jar", false, "java", true); - } - - @Override - public ArtifactHandler get() { - return artifactHandler; - } -} diff --git a/maven-core/src/main/java/org/apache/maven/internal/aether/DefaultRepositorySystemSessionFactory.java b/maven-core/src/main/java/org/apache/maven/internal/aether/DefaultRepositorySystemSessionFactory.java index e17ab7c54b..6dd44ab79e 100644 --- a/maven-core/src/main/java/org/apache/maven/internal/aether/DefaultRepositorySystemSessionFactory.java +++ b/maven-core/src/main/java/org/apache/maven/internal/aether/DefaultRepositorySystemSessionFactory.java @@ -33,6 +33,7 @@ import java.util.stream.Collectors; import org.apache.maven.RepositoryUtils; +import org.apache.maven.api.services.TypeRegistry; import org.apache.maven.api.xml.XmlNode; import org.apache.maven.artifact.handler.manager.ArtifactHandlerManager; import org.apache.maven.artifact.repository.ArtifactRepository; @@ -155,6 +156,8 @@ public class DefaultRepositorySystemSessionFactory { private final RuntimeInformation runtimeInformation; + private final TypeRegistry typeRegistry; + @SuppressWarnings("checkstyle:ParameterNumber") @Inject public DefaultRepositorySystemSessionFactory( @@ -163,13 +166,15 @@ public DefaultRepositorySystemSessionFactory( @Nullable @Named("ide") WorkspaceReader workspaceRepository, SettingsDecrypter settingsDecrypter, EventSpyDispatcher eventSpyDispatcher, - RuntimeInformation runtimeInformation) { + RuntimeInformation runtimeInformation, + TypeRegistry typeRegistry) { this.artifactHandlerManager = artifactHandlerManager; this.repoSystem = repoSystem; this.workspaceRepository = workspaceRepository; this.settingsDecrypter = settingsDecrypter; this.eventSpyDispatcher = eventSpyDispatcher; this.runtimeInformation = runtimeInformation; + this.typeRegistry = typeRegistry; } @Deprecated @@ -179,7 +184,8 @@ public RepositorySystemSession newRepositorySession(MavenExecutionRequest reques @SuppressWarnings("checkstyle:methodLength") public SessionBuilder newRepositorySessionBuilder(MavenExecutionRequest request) { - SessionBuilder session = MavenRepositorySystemUtils.newSession(repoSystem.createSessionBuilder()); + SessionBuilder session = MavenRepositorySystemUtils.newSession( + repoSystem.createSessionBuilder(), new TypeRegistryAdapter(typeRegistry)); session.setCache(request.getRepositoryCache()); Map configProps = new LinkedHashMap<>(); diff --git a/maven-core/src/main/java/org/apache/maven/internal/aether/TypeRegistryAdapter.java b/maven-core/src/main/java/org/apache/maven/internal/aether/TypeRegistryAdapter.java new file mode 100644 index 0000000000..c090218060 --- /dev/null +++ b/maven-core/src/main/java/org/apache/maven/internal/aether/TypeRegistryAdapter.java @@ -0,0 +1,48 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.maven.internal.aether; + +import org.apache.maven.api.Type; +import org.apache.maven.api.services.TypeRegistry; +import org.apache.maven.internal.impl.DefaultType; +import org.eclipse.aether.artifact.ArtifactType; +import org.eclipse.aether.artifact.ArtifactTypeRegistry; + +import static java.util.Objects.requireNonNull; + +public class TypeRegistryAdapter implements ArtifactTypeRegistry { + private final TypeRegistry typeRegistry; + + public TypeRegistryAdapter(TypeRegistry typeRegistry) { + this.typeRegistry = requireNonNull(typeRegistry, "null typeRegistry"); + } + + @Override + public ArtifactType get(String typeId) { + Type type = typeRegistry.getType(typeId); + if (type instanceof ArtifactType) { + return (ArtifactType) type; + } + if (type != null) { + return new DefaultType( + type.getId(), type.getExtension(), type.getClassifier(), type.getDependencyProperties()); + } + return null; + } +} diff --git a/maven-core/src/main/java/org/apache/maven/internal/impl/DefaultDependency.java b/maven-core/src/main/java/org/apache/maven/internal/impl/DefaultDependency.java index 8a67eb3e33..0450e9a310 100644 --- a/maven-core/src/main/java/org/apache/maven/internal/impl/DefaultDependency.java +++ b/maven-core/src/main/java/org/apache/maven/internal/impl/DefaultDependency.java @@ -22,6 +22,7 @@ import org.apache.maven.api.Dependency; import org.apache.maven.api.DependencyCoordinate; +import org.apache.maven.api.DependencyProperties; import org.apache.maven.api.Scope; import org.apache.maven.api.Type; import org.apache.maven.api.Version; @@ -35,12 +36,15 @@ public class DefaultDependency implements Dependency { private final AbstractSession session; private final org.eclipse.aether.graph.Dependency dependency; + private final DependencyProperties dependencyProperties; private final String key; public DefaultDependency( @Nonnull AbstractSession session, @Nonnull org.eclipse.aether.graph.Dependency dependency) { this.session = nonNull(session, "session"); this.dependency = nonNull(dependency, "dependency"); + this.dependencyProperties = + new DefaultDependencyProperties(dependency.getArtifact().getProperties()); this.key = getGroupId() + ':' + getArtifactId() @@ -94,6 +98,11 @@ public Type getType() { return session.getService(TypeRegistry.class).getType(type); } + @Override + public DependencyProperties getDependencyProperties() { + return dependencyProperties; + } + @Override public boolean isSnapshot() { return DefaultVersionParser.checkSnapshot(dependency.getArtifact().getVersion()); diff --git a/maven-core/src/main/java/org/apache/maven/internal/impl/DefaultDependencyProperties.java b/maven-core/src/main/java/org/apache/maven/internal/impl/DefaultDependencyProperties.java new file mode 100644 index 0000000000..fc77c87182 --- /dev/null +++ b/maven-core/src/main/java/org/apache/maven/internal/impl/DefaultDependencyProperties.java @@ -0,0 +1,66 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.maven.internal.impl; + +import java.util.Arrays; +import java.util.Collection; +import java.util.Collections; +import java.util.HashMap; +import java.util.Map; + +import org.apache.maven.api.DependencyProperties; +import org.apache.maven.api.annotations.Nonnull; + +import static org.apache.maven.internal.impl.Utils.nonNull; + +/** + * Default implementation of artifact properties. + */ +public class DefaultDependencyProperties implements DependencyProperties { + private final Map properties; + + public DefaultDependencyProperties(String... flags) { + this(Arrays.asList(flags)); + } + + public DefaultDependencyProperties(@Nonnull Collection flags) { + nonNull(flags, "null flags"); + HashMap map = new HashMap<>(); + for (String flag : flags) { + map.put(flag, Boolean.TRUE.toString()); + } + this.properties = Collections.unmodifiableMap(map); + } + + public DefaultDependencyProperties(@Nonnull Map properties) { + this.properties = Collections.unmodifiableMap(nonNull(properties, "null properties")); + } + + @Nonnull + @Override + public Map asMap() { + return properties; + } + + @Override + public boolean checkFlag(@Nonnull String flag) { + nonNull(flag, "null flag"); + return Boolean.parseBoolean(properties.getOrDefault(flag, "")); + } +} diff --git a/maven-core/src/main/java/org/apache/maven/internal/impl/DefaultType.java b/maven-core/src/main/java/org/apache/maven/internal/impl/DefaultType.java new file mode 100644 index 0000000000..8a319dee3e --- /dev/null +++ b/maven-core/src/main/java/org/apache/maven/internal/impl/DefaultType.java @@ -0,0 +1,72 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.maven.internal.impl; + +import java.util.HashMap; +import java.util.Map; + +import org.apache.maven.api.DependencyProperties; +import org.apache.maven.api.Type; +import org.eclipse.aether.artifact.ArtifactProperties; +import org.eclipse.aether.artifact.ArtifactType; + +import static org.apache.maven.internal.impl.Utils.nonNull; + +public class DefaultType implements Type, ArtifactType { + private final String extension; + + private final String classifier; + + private final DependencyProperties dependencyProperties; + + public DefaultType(String id, String extension, String classifier, DependencyProperties dependencyProperties) { + nonNull(id, "null id"); + this.extension = nonNull(extension, "null extension"); + this.classifier = classifier; + nonNull(dependencyProperties, "null dependencyProperties"); + HashMap props = new HashMap<>(dependencyProperties.asMap()); + props.put(ArtifactProperties.TYPE, id); + this.dependencyProperties = new DefaultDependencyProperties(props); + } + + @Override + public String getId() { + return dependencyProperties.asMap().get(ArtifactProperties.TYPE); + } + + @Override + public String getExtension() { + return extension; + } + + @Override + public String getClassifier() { + return classifier; + } + + @Override + public DependencyProperties getDependencyProperties() { + return dependencyProperties; + } + + @Override + public Map getProperties() { + return getDependencyProperties().asMap(); + } +} diff --git a/maven-core/src/main/java/org/apache/maven/internal/impl/DefaultTypeRegistry.java b/maven-core/src/main/java/org/apache/maven/internal/impl/DefaultTypeRegistry.java index 49af896cf7..19e98fd7e7 100644 --- a/maven-core/src/main/java/org/apache/maven/internal/impl/DefaultTypeRegistry.java +++ b/maven-core/src/main/java/org/apache/maven/internal/impl/DefaultTypeRegistry.java @@ -22,59 +22,77 @@ import javax.inject.Named; import javax.inject.Singleton; +import java.util.ArrayList; +import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; + +import org.apache.maven.api.DependencyProperties; import org.apache.maven.api.Type; import org.apache.maven.api.annotations.Nonnull; import org.apache.maven.api.services.TypeRegistry; import org.apache.maven.artifact.handler.ArtifactHandler; -import org.apache.maven.artifact.handler.manager.ArtifactHandlerManager; +import org.apache.maven.artifact.handler.manager.LegacyArtifactHandlerManager; +import org.apache.maven.eventspy.AbstractEventSpy; +import org.apache.maven.execution.ExecutionEvent; import static org.apache.maven.internal.impl.Utils.nonNull; @Named @Singleton -public class DefaultTypeRegistry implements TypeRegistry { +public class DefaultTypeRegistry extends AbstractEventSpy implements TypeRegistry { + private final Map types; - private final ArtifactHandlerManager manager; + private final ConcurrentHashMap usedTypes; + + private final ConcurrentHashMap legacyTypes; + + private final LegacyArtifactHandlerManager manager; @Inject - public DefaultTypeRegistry(ArtifactHandlerManager manager) { + public DefaultTypeRegistry(Map types, LegacyArtifactHandlerManager manager) { + this.types = nonNull(types, "types"); + this.usedTypes = new ConcurrentHashMap<>(); + this.legacyTypes = new ConcurrentHashMap<>(); this.manager = nonNull(manager, "artifactHandlerManager"); } + @Override + public void onEvent(Object event) { + if (event instanceof ExecutionEvent) { + ExecutionEvent executionEvent = (ExecutionEvent) event; + if (executionEvent.getType() == ExecutionEvent.Type.SessionEnded) { + usedTypes.clear(); + legacyTypes.clear(); + } + } + } + @Override @Nonnull public Type getType(String id) { - // Copy data as the ArtifacHandler is not immutable, but Type should be. - ArtifactHandler handler = manager.getArtifactHandler(nonNull(id, "id")); - String extension = handler.getExtension(); - String classifier = handler.getClassifier(); - boolean includeDependencies = handler.isIncludesDependencies(); - boolean addedToClasspath = handler.isAddedToClasspath(); - return new Type() { - @Override - public String getId() { - return id; + nonNull(id, "null id"); + return usedTypes.computeIfAbsent(id, i -> { + Type type = types.get(id); + if (type == null) { + // legacy types ALWAYS return type (AHM never returns null) + type = legacyTypes.computeIfAbsent(id, k -> { + // Copy data as the ArtifactHandler is not immutable, but Type should be. + ArtifactHandler handler = manager.getArtifactHandler(id); + ArrayList flags = new ArrayList<>(); + if (handler.isAddedToClasspath()) { + flags.add(DependencyProperties.FLAG_CLASS_PATH_CONSTITUENT); + } + if (handler.isIncludesDependencies()) { + flags.add(DependencyProperties.FLAG_INCLUDES_DEPENDENCIES); + } + return new DefaultType( + id, + handler.getExtension(), + handler.getClassifier(), + new DefaultDependencyProperties(flags)); + }); } - - @Override - public String getExtension() { - return extension; - } - - @Override - public String getClassifier() { - return classifier; - } - - @Override - public boolean isIncludesDependencies() { - return includeDependencies; - } - - @Override - public boolean isAddedToClasspath() { - return addedToClasspath; - } - }; + return type; + }); } } diff --git a/maven-core/src/main/java/org/apache/maven/artifact/handler/providers/RarArtifactHandlerProvider.java b/maven-core/src/main/java/org/apache/maven/internal/impl/types/BomTypeProvider.java similarity index 59% rename from maven-core/src/main/java/org/apache/maven/artifact/handler/providers/RarArtifactHandlerProvider.java rename to maven-core/src/main/java/org/apache/maven/internal/impl/types/BomTypeProvider.java index 00ff11c366..29d87cc4ec 100644 --- a/maven-core/src/main/java/org/apache/maven/artifact/handler/providers/RarArtifactHandlerProvider.java +++ b/maven-core/src/main/java/org/apache/maven/internal/impl/types/BomTypeProvider.java @@ -16,31 +16,29 @@ * specific language governing permissions and limitations * under the License. */ -package org.apache.maven.artifact.handler.providers; +package org.apache.maven.internal.impl.types; -import javax.inject.Inject; import javax.inject.Named; import javax.inject.Provider; import javax.inject.Singleton; -import org.apache.maven.artifact.handler.ArtifactHandler; -import org.apache.maven.artifact.handler.DefaultArtifactHandler; +import org.apache.maven.api.Type; +import org.apache.maven.internal.impl.DefaultDependencyProperties; +import org.apache.maven.internal.impl.DefaultType; -/** - * {@code rar} artifact handler provider. - */ -@Named("rar") +@Named(BomTypeProvider.NAME) @Singleton -public class RarArtifactHandlerProvider implements Provider { - private final ArtifactHandler artifactHandler; +public class BomTypeProvider implements Provider { + public static final String NAME = "bom"; - @Inject - public RarArtifactHandlerProvider() { - this.artifactHandler = new DefaultArtifactHandler("rar", null, null, null, null, true, "java", false); + private final Type type; + + public BomTypeProvider() { + this.type = new DefaultType(NAME, "pom", null, new DefaultDependencyProperties()); } @Override - public ArtifactHandler get() { - return artifactHandler; + public Type get() { + return type; } } diff --git a/maven-core/src/main/java/org/apache/maven/artifact/handler/providers/BomArtifactHandlerProvider.java b/maven-core/src/main/java/org/apache/maven/internal/impl/types/EarTypeProvider.java similarity index 59% rename from maven-core/src/main/java/org/apache/maven/artifact/handler/providers/BomArtifactHandlerProvider.java rename to maven-core/src/main/java/org/apache/maven/internal/impl/types/EarTypeProvider.java index ccf5f34e16..2ceb095dd2 100644 --- a/maven-core/src/main/java/org/apache/maven/artifact/handler/providers/BomArtifactHandlerProvider.java +++ b/maven-core/src/main/java/org/apache/maven/internal/impl/types/EarTypeProvider.java @@ -16,31 +16,31 @@ * specific language governing permissions and limitations * under the License. */ -package org.apache.maven.artifact.handler.providers; +package org.apache.maven.internal.impl.types; -import javax.inject.Inject; import javax.inject.Named; import javax.inject.Provider; import javax.inject.Singleton; -import org.apache.maven.artifact.handler.ArtifactHandler; -import org.apache.maven.artifact.handler.DefaultArtifactHandler; +import org.apache.maven.api.DependencyProperties; +import org.apache.maven.api.Type; +import org.apache.maven.internal.impl.DefaultDependencyProperties; +import org.apache.maven.internal.impl.DefaultType; -/** - * {@code bom} artifact handler provider. - */ -@Named("bom") +@Named(EarTypeProvider.NAME) @Singleton -public class BomArtifactHandlerProvider implements Provider { - private final ArtifactHandler artifactHandler; +public class EarTypeProvider implements Provider { + public static final String NAME = "ear"; - @Inject - public BomArtifactHandlerProvider() { - this.artifactHandler = new DefaultArtifactHandler("pom", null, null, null, null, false, "none", false); + private final Type type; + + public EarTypeProvider() { + this.type = new DefaultType( + NAME, "ear", null, new DefaultDependencyProperties(DependencyProperties.FLAG_INCLUDES_DEPENDENCIES)); } @Override - public ArtifactHandler get() { - return artifactHandler; + public Type get() { + return type; } } diff --git a/maven-core/src/main/java/org/apache/maven/internal/impl/types/EjbClientTypeProvider.java b/maven-core/src/main/java/org/apache/maven/internal/impl/types/EjbClientTypeProvider.java new file mode 100644 index 0000000000..39c848357c --- /dev/null +++ b/maven-core/src/main/java/org/apache/maven/internal/impl/types/EjbClientTypeProvider.java @@ -0,0 +1,49 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.maven.internal.impl.types; + +import javax.inject.Named; +import javax.inject.Provider; +import javax.inject.Singleton; + +import org.apache.maven.api.DependencyProperties; +import org.apache.maven.api.Type; +import org.apache.maven.internal.impl.DefaultDependencyProperties; +import org.apache.maven.internal.impl.DefaultType; + +@Named(EjbClientTypeProvider.NAME) +@Singleton +public class EjbClientTypeProvider implements Provider { + public static final String NAME = "ejb-client"; + + private final Type type; + + public EjbClientTypeProvider() { + this.type = new DefaultType( + NAME, + "jar", + "client", + new DefaultDependencyProperties(DependencyProperties.FLAG_CLASS_PATH_CONSTITUENT)); + } + + @Override + public Type get() { + return type; + } +} diff --git a/maven-core/src/main/java/org/apache/maven/internal/impl/types/EjbTypeProvider.java b/maven-core/src/main/java/org/apache/maven/internal/impl/types/EjbTypeProvider.java new file mode 100644 index 0000000000..5eb237d8ba --- /dev/null +++ b/maven-core/src/main/java/org/apache/maven/internal/impl/types/EjbTypeProvider.java @@ -0,0 +1,46 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.maven.internal.impl.types; + +import javax.inject.Named; +import javax.inject.Provider; +import javax.inject.Singleton; + +import org.apache.maven.api.DependencyProperties; +import org.apache.maven.api.Type; +import org.apache.maven.internal.impl.DefaultDependencyProperties; +import org.apache.maven.internal.impl.DefaultType; + +@Named(EjbTypeProvider.NAME) +@Singleton +public class EjbTypeProvider implements Provider { + public static final String NAME = "ejb"; + + private final Type type; + + public EjbTypeProvider() { + this.type = new DefaultType( + NAME, "jar", null, new DefaultDependencyProperties(DependencyProperties.FLAG_CLASS_PATH_CONSTITUENT)); + } + + @Override + public Type get() { + return type; + } +} diff --git a/maven-core/src/main/java/org/apache/maven/internal/impl/types/JarTypeProvider.java b/maven-core/src/main/java/org/apache/maven/internal/impl/types/JarTypeProvider.java new file mode 100644 index 0000000000..4e4cc367b4 --- /dev/null +++ b/maven-core/src/main/java/org/apache/maven/internal/impl/types/JarTypeProvider.java @@ -0,0 +1,46 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.maven.internal.impl.types; + +import javax.inject.Named; +import javax.inject.Provider; +import javax.inject.Singleton; + +import org.apache.maven.api.DependencyProperties; +import org.apache.maven.api.Type; +import org.apache.maven.internal.impl.DefaultDependencyProperties; +import org.apache.maven.internal.impl.DefaultType; + +@Named(JarTypeProvider.NAME) +@Singleton +public class JarTypeProvider implements Provider { + public static final String NAME = "jar"; + + private final Type type; + + public JarTypeProvider() { + this.type = new DefaultType( + NAME, "jar", null, new DefaultDependencyProperties(DependencyProperties.FLAG_CLASS_PATH_CONSTITUENT)); + } + + @Override + public Type get() { + return type; + } +} diff --git a/maven-core/src/main/java/org/apache/maven/artifact/handler/providers/EarArtifactHandlerProvider.java b/maven-core/src/main/java/org/apache/maven/internal/impl/types/JavaSourceTypeProvider.java similarity index 59% rename from maven-core/src/main/java/org/apache/maven/artifact/handler/providers/EarArtifactHandlerProvider.java rename to maven-core/src/main/java/org/apache/maven/internal/impl/types/JavaSourceTypeProvider.java index 49cd82af74..7a0d982f81 100644 --- a/maven-core/src/main/java/org/apache/maven/artifact/handler/providers/EarArtifactHandlerProvider.java +++ b/maven-core/src/main/java/org/apache/maven/internal/impl/types/JavaSourceTypeProvider.java @@ -16,31 +16,29 @@ * specific language governing permissions and limitations * under the License. */ -package org.apache.maven.artifact.handler.providers; +package org.apache.maven.internal.impl.types; -import javax.inject.Inject; import javax.inject.Named; import javax.inject.Provider; import javax.inject.Singleton; -import org.apache.maven.artifact.handler.ArtifactHandler; -import org.apache.maven.artifact.handler.DefaultArtifactHandler; +import org.apache.maven.api.Type; +import org.apache.maven.internal.impl.DefaultDependencyProperties; +import org.apache.maven.internal.impl.DefaultType; -/** - * {@code ear} artifact handler provider. - */ -@Named("ear") +@Named(JavaSourceTypeProvider.NAME) @Singleton -public class EarArtifactHandlerProvider implements Provider { - private final ArtifactHandler artifactHandler; +public class JavaSourceTypeProvider implements Provider { + public static final String NAME = "java-source"; - @Inject - public EarArtifactHandlerProvider() { - this.artifactHandler = new DefaultArtifactHandler("ear", null, null, null, null, true, "java", false); + private final Type type; + + public JavaSourceTypeProvider() { + this.type = new DefaultType(NAME, "jar", "sources", new DefaultDependencyProperties()); } @Override - public ArtifactHandler get() { - return artifactHandler; + public Type get() { + return type; } } diff --git a/maven-core/src/main/java/org/apache/maven/internal/impl/types/JavadocTypeProvider.java b/maven-core/src/main/java/org/apache/maven/internal/impl/types/JavadocTypeProvider.java new file mode 100644 index 0000000000..d4401cc0ff --- /dev/null +++ b/maven-core/src/main/java/org/apache/maven/internal/impl/types/JavadocTypeProvider.java @@ -0,0 +1,49 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.maven.internal.impl.types; + +import javax.inject.Named; +import javax.inject.Provider; +import javax.inject.Singleton; + +import org.apache.maven.api.DependencyProperties; +import org.apache.maven.api.Type; +import org.apache.maven.internal.impl.DefaultDependencyProperties; +import org.apache.maven.internal.impl.DefaultType; + +@Named(JavadocTypeProvider.NAME) +@Singleton +public class JavadocTypeProvider implements Provider { + public static final String NAME = "javadoc"; + + private final Type type; + + public JavadocTypeProvider() { + this.type = new DefaultType( + NAME, + "jar", + "javadoc", + new DefaultDependencyProperties(DependencyProperties.FLAG_CLASS_PATH_CONSTITUENT)); + } + + @Override + public Type get() { + return type; + } +} diff --git a/maven-core/src/main/java/org/apache/maven/internal/impl/types/MavenPluginTypeProvider.java b/maven-core/src/main/java/org/apache/maven/internal/impl/types/MavenPluginTypeProvider.java new file mode 100644 index 0000000000..4fd2990c64 --- /dev/null +++ b/maven-core/src/main/java/org/apache/maven/internal/impl/types/MavenPluginTypeProvider.java @@ -0,0 +1,46 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.maven.internal.impl.types; + +import javax.inject.Named; +import javax.inject.Provider; +import javax.inject.Singleton; + +import org.apache.maven.api.DependencyProperties; +import org.apache.maven.api.Type; +import org.apache.maven.internal.impl.DefaultDependencyProperties; +import org.apache.maven.internal.impl.DefaultType; + +@Named(MavenPluginTypeProvider.NAME) +@Singleton +public class MavenPluginTypeProvider implements Provider { + public static final String NAME = "maven-plugin"; + + private final Type type; + + public MavenPluginTypeProvider() { + this.type = new DefaultType( + NAME, "jar", null, new DefaultDependencyProperties(DependencyProperties.FLAG_CLASS_PATH_CONSTITUENT)); + } + + @Override + public Type get() { + return type; + } +} diff --git a/maven-core/src/main/java/org/apache/maven/artifact/handler/providers/EjbArtifactHandlerProvider.java b/maven-core/src/main/java/org/apache/maven/internal/impl/types/ParTypeProvider.java similarity index 59% rename from maven-core/src/main/java/org/apache/maven/artifact/handler/providers/EjbArtifactHandlerProvider.java rename to maven-core/src/main/java/org/apache/maven/internal/impl/types/ParTypeProvider.java index 5508586d69..64b8ad711f 100644 --- a/maven-core/src/main/java/org/apache/maven/artifact/handler/providers/EjbArtifactHandlerProvider.java +++ b/maven-core/src/main/java/org/apache/maven/internal/impl/types/ParTypeProvider.java @@ -16,31 +16,31 @@ * specific language governing permissions and limitations * under the License. */ -package org.apache.maven.artifact.handler.providers; +package org.apache.maven.internal.impl.types; -import javax.inject.Inject; import javax.inject.Named; import javax.inject.Provider; import javax.inject.Singleton; -import org.apache.maven.artifact.handler.ArtifactHandler; -import org.apache.maven.artifact.handler.DefaultArtifactHandler; +import org.apache.maven.api.DependencyProperties; +import org.apache.maven.api.Type; +import org.apache.maven.internal.impl.DefaultDependencyProperties; +import org.apache.maven.internal.impl.DefaultType; -/** - * {@code ejb} artifact handler provider. - */ -@Named("ejb") +@Named(ParTypeProvider.NAME) @Singleton -public class EjbArtifactHandlerProvider implements Provider { - private final ArtifactHandler artifactHandler; +public class ParTypeProvider implements Provider { + public static final String NAME = "par"; - @Inject - public EjbArtifactHandlerProvider() { - this.artifactHandler = new DefaultArtifactHandler("ejb", "jar", null, null, null, false, "java", true); + private final Type type; + + public ParTypeProvider() { + this.type = new DefaultType( + NAME, "par", null, new DefaultDependencyProperties(DependencyProperties.FLAG_INCLUDES_DEPENDENCIES)); } @Override - public ArtifactHandler get() { - return artifactHandler; + public Type get() { + return type; } } diff --git a/maven-core/src/main/java/org/apache/maven/artifact/handler/providers/WarArtifactHandlerProvider.java b/maven-core/src/main/java/org/apache/maven/internal/impl/types/PomTypeProvider.java similarity index 59% rename from maven-core/src/main/java/org/apache/maven/artifact/handler/providers/WarArtifactHandlerProvider.java rename to maven-core/src/main/java/org/apache/maven/internal/impl/types/PomTypeProvider.java index 853e3c8106..4b1afe64c9 100644 --- a/maven-core/src/main/java/org/apache/maven/artifact/handler/providers/WarArtifactHandlerProvider.java +++ b/maven-core/src/main/java/org/apache/maven/internal/impl/types/PomTypeProvider.java @@ -16,31 +16,29 @@ * specific language governing permissions and limitations * under the License. */ -package org.apache.maven.artifact.handler.providers; +package org.apache.maven.internal.impl.types; -import javax.inject.Inject; import javax.inject.Named; import javax.inject.Provider; import javax.inject.Singleton; -import org.apache.maven.artifact.handler.ArtifactHandler; -import org.apache.maven.artifact.handler.DefaultArtifactHandler; +import org.apache.maven.api.Type; +import org.apache.maven.internal.impl.DefaultDependencyProperties; +import org.apache.maven.internal.impl.DefaultType; -/** - * {@code war} artifact handler provider. - */ -@Named("war") +@Named(PomTypeProvider.NAME) @Singleton -public class WarArtifactHandlerProvider implements Provider { - private final ArtifactHandler artifactHandler; +public class PomTypeProvider implements Provider { + public static final String NAME = "pom"; - @Inject - public WarArtifactHandlerProvider() { - this.artifactHandler = new DefaultArtifactHandler("war", null, null, null, null, true, "java", false); + private final Type type; + + public PomTypeProvider() { + this.type = new DefaultType(NAME, "pom", null, new DefaultDependencyProperties()); } @Override - public ArtifactHandler get() { - return artifactHandler; + public Type get() { + return type; } } diff --git a/maven-core/src/main/java/org/apache/maven/artifact/handler/providers/JarArtifactHandlerProvider.java b/maven-core/src/main/java/org/apache/maven/internal/impl/types/RarTypeProvider.java similarity index 59% rename from maven-core/src/main/java/org/apache/maven/artifact/handler/providers/JarArtifactHandlerProvider.java rename to maven-core/src/main/java/org/apache/maven/internal/impl/types/RarTypeProvider.java index 9e71af46ef..51267a5f15 100644 --- a/maven-core/src/main/java/org/apache/maven/artifact/handler/providers/JarArtifactHandlerProvider.java +++ b/maven-core/src/main/java/org/apache/maven/internal/impl/types/RarTypeProvider.java @@ -16,31 +16,31 @@ * specific language governing permissions and limitations * under the License. */ -package org.apache.maven.artifact.handler.providers; +package org.apache.maven.internal.impl.types; -import javax.inject.Inject; import javax.inject.Named; import javax.inject.Provider; import javax.inject.Singleton; -import org.apache.maven.artifact.handler.ArtifactHandler; -import org.apache.maven.artifact.handler.DefaultArtifactHandler; +import org.apache.maven.api.DependencyProperties; +import org.apache.maven.api.Type; +import org.apache.maven.internal.impl.DefaultDependencyProperties; +import org.apache.maven.internal.impl.DefaultType; -/** - * {@code jar} artifact handler provider. - */ -@Named("jar") +@Named(RarTypeProvider.NAME) @Singleton -public class JarArtifactHandlerProvider implements Provider { - private final ArtifactHandler artifactHandler; +public class RarTypeProvider implements Provider { + public static final String NAME = "rar"; - @Inject - public JarArtifactHandlerProvider() { - this.artifactHandler = new DefaultArtifactHandler("jar", null, null, null, null, false, "java", true); + private final Type type; + + public RarTypeProvider() { + this.type = new DefaultType( + NAME, "rar", null, new DefaultDependencyProperties(DependencyProperties.FLAG_INCLUDES_DEPENDENCIES)); } @Override - public ArtifactHandler get() { - return artifactHandler; + public Type get() { + return type; } } diff --git a/maven-core/src/main/java/org/apache/maven/artifact/handler/providers/EjbClientArtifactHandlerProvider.java b/maven-core/src/main/java/org/apache/maven/internal/impl/types/TestJarTypeProvider.java similarity index 57% rename from maven-core/src/main/java/org/apache/maven/artifact/handler/providers/EjbClientArtifactHandlerProvider.java rename to maven-core/src/main/java/org/apache/maven/internal/impl/types/TestJarTypeProvider.java index 4126d5ffd6..14ccf928b0 100644 --- a/maven-core/src/main/java/org/apache/maven/artifact/handler/providers/EjbClientArtifactHandlerProvider.java +++ b/maven-core/src/main/java/org/apache/maven/internal/impl/types/TestJarTypeProvider.java @@ -16,32 +16,34 @@ * specific language governing permissions and limitations * under the License. */ -package org.apache.maven.artifact.handler.providers; +package org.apache.maven.internal.impl.types; -import javax.inject.Inject; import javax.inject.Named; import javax.inject.Provider; import javax.inject.Singleton; -import org.apache.maven.artifact.handler.ArtifactHandler; -import org.apache.maven.artifact.handler.DefaultArtifactHandler; +import org.apache.maven.api.DependencyProperties; +import org.apache.maven.api.Type; +import org.apache.maven.internal.impl.DefaultDependencyProperties; +import org.apache.maven.internal.impl.DefaultType; -/** - * {@code ejb-client} artifact handler provider. - */ -@Named("ejb-client") +@Named(TestJarTypeProvider.NAME) @Singleton -public class EjbClientArtifactHandlerProvider implements Provider { - private final ArtifactHandler artifactHandler; +public class TestJarTypeProvider implements Provider { + public static final String NAME = "test-jar"; - @Inject - public EjbClientArtifactHandlerProvider() { - this.artifactHandler = - new DefaultArtifactHandler("ejb-client", "jar", "client", null, "ejb", false, "java", true); + private final Type type; + + public TestJarTypeProvider() { + this.type = new DefaultType( + NAME, + "jar", + "tests", + new DefaultDependencyProperties(DependencyProperties.FLAG_CLASS_PATH_CONSTITUENT)); } @Override - public ArtifactHandler get() { - return artifactHandler; + public Type get() { + return type; } } diff --git a/maven-core/src/main/java/org/apache/maven/internal/impl/types/WarTypeProvider.java b/maven-core/src/main/java/org/apache/maven/internal/impl/types/WarTypeProvider.java new file mode 100644 index 0000000000..c382f08af6 --- /dev/null +++ b/maven-core/src/main/java/org/apache/maven/internal/impl/types/WarTypeProvider.java @@ -0,0 +1,46 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.maven.internal.impl.types; + +import javax.inject.Named; +import javax.inject.Provider; +import javax.inject.Singleton; + +import org.apache.maven.api.DependencyProperties; +import org.apache.maven.api.Type; +import org.apache.maven.internal.impl.DefaultDependencyProperties; +import org.apache.maven.internal.impl.DefaultType; + +@Named(WarTypeProvider.NAME) +@Singleton +public class WarTypeProvider implements Provider { + public static final String NAME = "war"; + + private final Type type; + + public WarTypeProvider() { + this.type = new DefaultType( + NAME, "war", null, new DefaultDependencyProperties(DependencyProperties.FLAG_INCLUDES_DEPENDENCIES)); + } + + @Override + public Type get() { + return type; + } +} diff --git a/maven-core/src/test/java/org/apache/maven/artifact/handler/ArtifactHandlerTest.java b/maven-core/src/test/java/org/apache/maven/artifact/handler/ArtifactHandlerTest.java index 33d404519c..54d75a8234 100644 --- a/maven-core/src/test/java/org/apache/maven/artifact/handler/ArtifactHandlerTest.java +++ b/maven-core/src/test/java/org/apache/maven/artifact/handler/ArtifactHandlerTest.java @@ -24,6 +24,7 @@ import java.nio.file.Files; import java.util.List; +import org.apache.maven.artifact.handler.manager.ArtifactHandlerManager; import org.codehaus.plexus.PlexusContainer; import org.codehaus.plexus.testing.PlexusTest; import org.junit.jupiter.api.Test; @@ -72,11 +73,14 @@ void testAptConsistency() throws Exception { String addedToClasspath = trimApt(cols[6]); String includesDependencies = trimApt(cols[7]); - ArtifactHandler handler = container.lookup(ArtifactHandler.class, type); + ArtifactHandler handler = + container.lookup(ArtifactHandlerManager.class).getArtifactHandler(type); assertEquals(handler.getExtension(), extension, type + " extension"); - assertEquals(handler.getPackaging(), packaging, type + " packaging"); + // Packaging/Directory is Maven1 remnant!!! + // assertEquals(handler.getPackaging(), packaging, type + " packaging"); assertEquals(handler.getClassifier(), classifier, type + " classifier"); - assertEquals(handler.getLanguage(), language, type + " language"); + // Language is unused + // assertEquals(handler.getLanguage(), language, type + " language"); assertEquals( handler.isAddedToClasspath() ? "true" : null, addedToClasspath, type + " addedToClasspath"); assertEquals( diff --git a/maven-core/src/test/java/org/apache/maven/internal/aether/DefaultRepositorySystemSessionFactoryTest.java b/maven-core/src/test/java/org/apache/maven/internal/aether/DefaultRepositorySystemSessionFactoryTest.java index 748ccbb6e5..16b90aa4ed 100644 --- a/maven-core/src/test/java/org/apache/maven/internal/aether/DefaultRepositorySystemSessionFactoryTest.java +++ b/maven-core/src/test/java/org/apache/maven/internal/aether/DefaultRepositorySystemSessionFactoryTest.java @@ -33,6 +33,7 @@ import org.apache.maven.eventspy.internal.EventSpyDispatcher; import org.apache.maven.execution.DefaultMavenExecutionRequest; import org.apache.maven.execution.MavenExecutionRequest; +import org.apache.maven.internal.impl.DefaultTypeRegistry; import org.apache.maven.rtinfo.RuntimeInformation; import org.apache.maven.settings.Server; import org.apache.maven.settings.crypto.SettingsDecrypter; @@ -72,6 +73,9 @@ public class DefaultRepositorySystemSessionFactoryTest { @Inject protected RuntimeInformation information; + @Inject + protected DefaultTypeRegistry defaultTypeRegistry; + @Test void isNoSnapshotUpdatesTest() throws InvalidRepositoryException { DefaultRepositorySystemSessionFactory systemSessionFactory = new DefaultRepositorySystemSessionFactory( @@ -80,7 +84,8 @@ void isNoSnapshotUpdatesTest() throws InvalidRepositoryException { null, settingsDecrypter, eventSpyDispatcher, - information); + information, + defaultTypeRegistry); MavenExecutionRequest request = new DefaultMavenExecutionRequest(); request.setLocalRepository(getLocalRepository()); @@ -102,7 +107,8 @@ void isSnapshotUpdatesTest() throws InvalidRepositoryException { null, settingsDecrypter, eventSpyDispatcher, - information); + information, + defaultTypeRegistry); MavenExecutionRequest request = new DefaultMavenExecutionRequest(); request.setLocalRepository(getLocalRepository()); @@ -136,7 +142,8 @@ void wagonProviderConfigurationTest() throws InvalidRepositoryException { null, settingsDecrypter, eventSpyDispatcher, - information); + information, + defaultTypeRegistry); PlexusConfiguration plexusConfiguration = (PlexusConfiguration) systemSessionFactory .newRepositorySession(request) @@ -178,7 +185,8 @@ void httpConfigurationWithHttpHeadersTest() throws InvalidRepositoryException { null, settingsDecrypter, eventSpyDispatcher, - information); + information, + defaultTypeRegistry); Map headers = (Map) systemSessionFactory .newRepositorySession(request) @@ -214,7 +222,8 @@ void connectTimeoutConfigurationTest() throws InvalidRepositoryException { null, settingsDecrypter, eventSpyDispatcher, - information); + information, + defaultTypeRegistry); int connectionTimeout = (Integer) systemSessionFactory .newRepositorySession(request) @@ -254,7 +263,8 @@ void connectionTimeoutFromHttpConfigurationTest() throws InvalidRepositoryExcept null, settingsDecrypter, eventSpyDispatcher, - information); + information, + defaultTypeRegistry); int connectionTimeout = (Integer) systemSessionFactory .newRepositorySession(request) @@ -288,7 +298,8 @@ void requestTimeoutConfigurationTest() throws InvalidRepositoryException { null, settingsDecrypter, eventSpyDispatcher, - information); + information, + defaultTypeRegistry); int requestTimeout = (Integer) systemSessionFactory .newRepositorySession(request) @@ -328,7 +339,8 @@ void readTimeoutFromHttpConfigurationTest() throws InvalidRepositoryException { null, settingsDecrypter, eventSpyDispatcher, - information); + information, + defaultTypeRegistry); int requestTimeout = (Integer) systemSessionFactory .newRepositorySession(request) @@ -345,7 +357,8 @@ void transportConfigurationTest() throws InvalidRepositoryException { null, settingsDecrypter, eventSpyDispatcher, - information); + information, + defaultTypeRegistry); MavenExecutionRequest request = new DefaultMavenExecutionRequest(); request.setLocalRepository(getLocalRepository()); diff --git a/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/MavenRepositorySystemUtils.java b/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/MavenRepositorySystemUtils.java index e43aa5ce24..a8b5f08743 100644 --- a/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/MavenRepositorySystemUtils.java +++ b/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/MavenRepositorySystemUtils.java @@ -20,6 +20,7 @@ import org.eclipse.aether.DefaultRepositorySystemSession; import org.eclipse.aether.RepositorySystemSession.SessionBuilder; +import org.eclipse.aether.artifact.ArtifactTypeRegistry; import org.eclipse.aether.artifact.DefaultArtifactType; import org.eclipse.aether.collection.DependencyGraphTransformer; import org.eclipse.aether.collection.DependencyManager; @@ -41,6 +42,8 @@ import org.eclipse.aether.util.graph.traverser.FatArtifactTraverser; import org.eclipse.aether.util.repository.SimpleArtifactDescriptorPolicy; +import static java.util.Objects.requireNonNull; + /** * A utility class to assist in setting up a Maven-like repository system. Note: This component is meant to * assist those clients that employ the repository system outside of an IoC container, Maven plugins should instead @@ -54,13 +57,11 @@ private MavenRepositorySystemUtils() { } /** - * Creates a new Maven-like repository system session by initializing the session with values typical for - * Maven-based resolution. In more detail, this method configures settings relevant for the processing of dependency - * graphs, most other settings remain at their generic default value. Use the various setters to further configure - * the session with authentication, mirror, proxy and other information required for your environment. + * This method is deprecated, nobody should use it. * - * @return The new repository system session, never {@code null}. + * @deprecated This method is here only for legacy uses (like UTs), nothing else should use it. */ + @Deprecated public static DefaultRepositorySystemSession newSession() { DefaultRepositorySystemSession session = new DefaultRepositorySystemSession(); @@ -82,6 +83,19 @@ public static DefaultRepositorySystemSession newSession() { transformer = new ChainedDependencyGraphTransformer(transformer, new JavaDependencyContextRefiner()); session.setDependencyGraphTransformer(transformer); + session.setArtifactTypeRegistry(newArtifactTypeRegistry()); + + session.setArtifactDescriptorPolicy(new SimpleArtifactDescriptorPolicy(true, true)); + + return session; + } + + /** + * Creates new Maven-like {@link ArtifactTypeRegistry}. This method should not be used from Maven. + * + * @since 4.0.0 + */ + public static ArtifactTypeRegistry newArtifactTypeRegistry() { DefaultArtifactTypeRegistry stereotypes = new DefaultArtifactTypeRegistry(); stereotypes.add(new DefaultArtifactType("pom")); stereotypes.add(new DefaultArtifactType("maven-plugin", "jar", "", "java")); @@ -95,11 +109,7 @@ public static DefaultRepositorySystemSession newSession() { stereotypes.add(new DefaultArtifactType("ear", "ear", "", "java", false, true)); stereotypes.add(new DefaultArtifactType("rar", "rar", "", "java", false, true)); stereotypes.add(new DefaultArtifactType("par", "par", "", "java", false, true)); - session.setArtifactTypeRegistry(stereotypes); - - session.setArtifactDescriptorPolicy(new SimpleArtifactDescriptorPolicy(true, true)); - - return session; + return stereotypes; } /** @@ -109,8 +119,12 @@ public static DefaultRepositorySystemSession newSession() { * the session with authentication, mirror, proxy and other information required for your environment. * * @return The new repository system session, never {@code null}. + * @since 4.0.0 */ - public static SessionBuilder newSession(SessionBuilder session) { + public static SessionBuilder newSession(SessionBuilder session, ArtifactTypeRegistry artifactTypeRegistry) { + requireNonNull(session, "null sessionBuilder"); + requireNonNull(artifactTypeRegistry, "null artifactTypeRegistry"); + DependencyTraverser depTraverser = new FatArtifactTraverser(); session.setDependencyTraverser(depTraverser); @@ -128,21 +142,7 @@ public static SessionBuilder newSession(SessionBuilder session) { new SimpleOptionalitySelector(), new JavaScopeDeriver()); transformer = new ChainedDependencyGraphTransformer(transformer, new JavaDependencyContextRefiner()); session.setDependencyGraphTransformer(transformer); - - DefaultArtifactTypeRegistry stereotypes = new DefaultArtifactTypeRegistry(); - stereotypes.add(new DefaultArtifactType("pom")); - stereotypes.add(new DefaultArtifactType("maven-plugin", "jar", "", "java")); - stereotypes.add(new DefaultArtifactType("jar", "jar", "", "java")); - stereotypes.add(new DefaultArtifactType("ejb", "jar", "", "java")); - stereotypes.add(new DefaultArtifactType("ejb-client", "jar", "client", "java")); - stereotypes.add(new DefaultArtifactType("test-jar", "jar", "tests", "java")); - stereotypes.add(new DefaultArtifactType("javadoc", "jar", "javadoc", "java")); - stereotypes.add(new DefaultArtifactType("java-source", "jar", "sources", "java", false, false)); - stereotypes.add(new DefaultArtifactType("war", "war", "", "java", false, true)); - stereotypes.add(new DefaultArtifactType("ear", "ear", "", "java", false, true)); - stereotypes.add(new DefaultArtifactType("rar", "rar", "", "java", false, true)); - stereotypes.add(new DefaultArtifactType("par", "par", "", "java", false, true)); - session.setArtifactTypeRegistry(stereotypes); + session.setArtifactTypeRegistry(artifactTypeRegistry); session.setArtifactDescriptorPolicy(new SimpleArtifactDescriptorPolicy(true, true)); diff --git a/maven-resolver-provider/src/test/java/org/apache/maven/repository/internal/AbstractRepositoryTestCase.java b/maven-resolver-provider/src/test/java/org/apache/maven/repository/internal/AbstractRepositoryTestCase.java index e4c9b14a54..c0ea5b5107 100644 --- a/maven-resolver-provider/src/test/java/org/apache/maven/repository/internal/AbstractRepositoryTestCase.java +++ b/maven-resolver-provider/src/test/java/org/apache/maven/repository/internal/AbstractRepositoryTestCase.java @@ -26,9 +26,9 @@ import org.apache.maven.repository.internal.util.ConsoleTransferListener; import org.codehaus.plexus.PlexusContainer; import org.codehaus.plexus.testing.PlexusTest; -import org.eclipse.aether.DefaultRepositorySystemSession; import org.eclipse.aether.RepositorySystem; import org.eclipse.aether.RepositorySystemSession; +import org.eclipse.aether.RepositorySystemSession.SessionBuilder; import org.eclipse.aether.repository.LocalRepository; import org.eclipse.aether.repository.RemoteRepository; import org.junit.jupiter.api.BeforeEach; @@ -55,15 +55,14 @@ protected PlexusContainer getContainer() { } public static RepositorySystemSession newMavenRepositorySystemSession(RepositorySystem system) { - DefaultRepositorySystemSession session = MavenRepositorySystemUtils.newSession(); - - LocalRepository localRepo = new LocalRepository("target/local-repo"); - session.setLocalRepositoryManager(system.newLocalRepositoryManager(session, localRepo)); + SessionBuilder session = MavenRepositorySystemUtils.newSession( + system.createSessionBuilder(), MavenRepositorySystemUtils.newArtifactTypeRegistry()); + session.withLocalRepositories(new LocalRepository("target/local-repo")); session.setTransferListener(new ConsoleTransferListener()); session.setRepositoryListener(new ConsoleRepositoryListener()); - return session; + return session.build(); } public static RemoteRepository newTestRepository() throws MalformedURLException { diff --git a/maven-resolver-provider/src/test/java/org/apache/maven/repository/internal/MavenRepositorySystemUtilsTest.java b/maven-resolver-provider/src/test/java/org/apache/maven/repository/internal/MavenRepositorySystemUtilsTest.java deleted file mode 100644 index 094b633e9a..0000000000 --- a/maven-resolver-provider/src/test/java/org/apache/maven/repository/internal/MavenRepositorySystemUtilsTest.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.maven.repository.internal; - -import org.eclipse.aether.RepositorySystemSession; -import org.junit.jupiter.api.Test; - -import static org.junit.jupiter.api.Assertions.assertNotNull; - -class MavenRepositorySystemUtilsTest { - - @Test - void testNewSession() { - RepositorySystemSession session = MavenRepositorySystemUtils.newSession(); - assertNotNull(session); - } -}