You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by gn...@apache.org on 2022/10/02 08:41:32 UTC
[maven] branch master updated: [MNG-7553] New clean API with immutable model (#703)
This is an automated email from the ASF dual-hosted git repository.
gnodet pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/maven.git
The following commit(s) were added to refs/heads/master by this push:
new 2a9f39336 [MNG-7553] New clean API with immutable model (#703)
2a9f39336 is described below
commit 2a9f39336cec1d8e52d30cc48503d51ed8672536
Author: Guillaume Nodet <gn...@gmail.com>
AuthorDate: Sun Oct 2 10:41:25 2022 +0200
[MNG-7553] New clean API with immutable model (#703)
---
apache-maven/src/assembly/maven/bin/m2.conf | 1 +
.../apache/maven/settings/GlobalSettingsTest.java | 2 +-
api/maven-api-core/pom.xml | 55 +
.../main/java/org/apache/maven/api/Artifact.java | 107 +
.../org/apache/maven/api/ArtifactCoordinate.java | 89 +
.../main/java/org/apache/maven/api/Dependency.java | 33 +-
.../org/apache/maven/api/DependencyCoordinate.java | 40 +-
.../src/main/java/org/apache/maven/api/Event.java | 77 +
.../main/java/org/apache/maven/api/EventType.java | 43 +-
.../main/java/org/apache/maven/api/Exclusion.java | 29 +-
.../java/org/apache/maven/api/JavaToolchain.java | 26 +-
.../main/java/org/apache/maven/api/Listener.java | 27 +-
.../java/org/apache/maven/api/LocalRepository.java | 31 +-
.../main/java/org/apache/maven/api/Metadata.java | 32 +-
.../java/org/apache/maven/api/MetadataStorage.java | 24 +-
.../java/org/apache/maven/api/MojoExecution.java | 34 +-
.../src/main/java/org/apache/maven/api/Node.java | 103 +
.../java/org/apache/maven/api/NodeVisitor.java | 53 +
.../main/java/org/apache/maven/api/Project.java | 105 +
.../org/apache/maven/api/RemoteRepository.java | 29 +-
.../main/java/org/apache/maven/api/Repository.java | 33 +-
.../org/apache/maven/api/RepositoryMetadata.java | 22 +-
.../java/org/apache/maven/api/ResolutionScope.java | 104 +
.../src/main/java/org/apache/maven/api/Scope.java | 41 +-
.../main/java/org/apache/maven/api/Service.java | 26 +-
.../main/java/org/apache/maven/api/Session.java | 346 +++
.../java/org/apache/maven/api/SessionData.java | 86 +
.../main/java/org/apache/maven/api/Toolchain.java | 56 +
.../src/main/java/org/apache/maven/api/Type.java | 72 +
.../main/java/org/apache/maven/api/Version.java | 27 +-
.../java/org/apache/maven/api/VersionRange.java | 29 +-
.../main/java/org/apache/maven/api/plugin/Log.java | 168 ++
.../java/org/apache/maven/api/plugin/Mojo.java | 27 +-
.../org/apache/maven/api/plugin/MojoException.java | 98 +
.../maven/api/plugin/annotations/Component.java | 56 +
.../maven/api/plugin/annotations/Execute.java | 64 +
.../plugin/annotations/InstantiationStrategy.java | 30 +-
.../api/plugin/annotations/LifecyclePhase.java | 80 +
.../apache/maven/api/plugin/annotations/Mojo.java | 98 +
.../maven/api/plugin/annotations/Parameter.java | 94 +
.../api/services/ArtifactCoordinateFactory.java | 71 +
.../services/ArtifactCoordinateFactoryRequest.java | 222 ++
.../maven/api/services/ArtifactDeployer.java | 61 +
.../api/services/ArtifactDeployerException.java | 29 +-
.../api/services/ArtifactDeployerRequest.java | 153 ++
.../apache/maven/api/services/ArtifactFactory.java | 61 +
.../maven/api/services/ArtifactFactoryRequest.java | 208 ++
.../maven/api/services/ArtifactInstaller.java | 74 +
.../api/services/ArtifactInstallerException.java | 29 +-
.../api/services/ArtifactInstallerRequest.java | 113 +
.../apache/maven/api/services/ArtifactManager.java | 64 +
.../maven/api/services/ArtifactResolver.java | 61 +
.../api/services/ArtifactResolverException.java | 26 +-
.../api/services/ArtifactResolverRequest.java | 108 +
.../maven/api/services/ArtifactResolverResult.java | 34 +-
.../org/apache/maven/api/services/BaseRequest.java | 67 +
.../maven/api/services/DependencyCollector.java | 117 +
.../api/services/DependencyCollectorException.java | 28 +-
.../api/services/DependencyCollectorRequest.java | 331 +++
.../api/services/DependencyCollectorResult.java | 35 +-
.../api/services/DependencyCoordinateFactory.java | 89 +
.../DependencyCoordinateFactoryRequest.java | 292 ++
.../maven/api/services/LocalRepositoryManager.java | 48 +
.../java/org/apache/maven/api/services/Lookup.java | 24 +-
.../apache/maven/api/services/LookupException.java | 31 +-
.../apache/maven/api/services/MavenException.java | 36 +-
.../apache/maven/api/services/MessageBuilder.java | 157 ++
.../maven/api/services/MessageBuilderFactory.java | 71 +
.../apache/maven/api/services/ProjectBuilder.java | 110 +
.../api/services/ProjectBuilderException.java | 26 +-
.../maven/api/services/ProjectBuilderProblem.java | 90 +
.../services/ProjectBuilderProblemSeverity.java | 26 +-
.../maven/api/services/ProjectBuilderRequest.java | 262 ++
.../maven/api/services/ProjectBuilderResult.java | 83 +
.../maven/api/services/ProjectBuilderSource.java | 27 +-
.../apache/maven/api/services/ProjectManager.java | 93 +
.../org/apache/maven/api/services/Prompter.java | 106 +
.../maven/api/services/PrompterException.java | 26 +-
.../maven/api/services/RepositoryFactory.java | 37 +-
.../maven/api/services/ToolchainFactory.java | 24 +-
.../maven/api/services/ToolchainManager.java | 82 +
.../api/services/ToolchainManagerException.java | 26 +-
.../apache/maven/api/services/TypeRegistry.java | 26 +-
.../apache/maven/api/services/VersionParser.java | 62 +
.../maven/api/services/VersionParserException.java | 26 +-
.../maven/api/services/xml/ModelXmlFactory.java | 25 +-
.../maven/api/services/xml/SettingsXmlFactory.java | 25 +-
.../api/services/xml/ToolchainsXmlFactory.java | 25 +-
.../apache/maven/api/services/xml/XmlFactory.java | 98 +
.../maven/api/services/xml/XmlReaderException.java | 25 +-
.../maven/api/services/xml/XmlReaderRequest.java | 236 ++
.../maven/api/services/xml/XmlWriterException.java | 25 +-
.../maven/api/services/xml/XmlWriterRequest.java | 127 +
api/maven-api-meta/pom.xml | 32 +
.../org/apache/maven/api/annotations/Consumer.java | 47 +
.../apache/maven/api/annotations/Experimental.java | 28 +-
.../apache/maven/api/annotations/Generated.java | 30 +-
.../apache/maven/api/annotations/Immutable.java | 32 +-
.../org/apache/maven/api/annotations/Nonnull.java | 33 +-
.../maven/api/annotations/NotThreadSafe.java | 30 +-
.../org/apache/maven/api/annotations/Nullable.java | 28 +-
.../org/apache/maven/api/annotations/Provider.java | 47 +
.../apache/maven/api/annotations/ThreadSafe.java | 31 +-
.../maven/api/annotations}/package-info.java | 15 +-
api/maven-api-model/pom.xml | 104 +
.../maven/api/model/ImmutableCollections.java | 738 ++++++
.../org/apache/maven/api/model/InputLocation.java | 199 ++
.../maven/api/model/InputLocationTracker.java | 15 +-
.../org/apache/maven/api/model/InputSource.java | 45 +-
.../org/apache/maven/api}/model/package-info.java | 2 +-
api/maven-api-model/src/main/mdo/common.vm | 31 +
.../maven-api-model}/src/main/mdo/maven.mdo | 682 ++---
api/maven-api-model/src/main/mdo/model.vm | 529 ++++
.../maven-api-settings}/pom.xml | 83 +-
.../maven/api/settings/ImmutableCollections.java | 738 ++++++
api/maven-api-settings/src/main/mdo/common.vm | 21 +
api/maven-api-settings/src/main/mdo/model.vm | 521 ++++
.../maven-api-settings}/src/main/mdo/settings.mdo | 13 +-
api/maven-api-settings/src/site/apt/index.apt | 36 +
.../maven-api-settings/src/site/site.xml | 41 +-
api/maven-api-toolchain/pom.xml | 105 +
.../maven/api/toolchain/ImmutableCollections.java | 738 ++++++
api/maven-api-toolchain/src/main/mdo/common.vm | 21 +
api/maven-api-toolchain/src/main/mdo/model.vm | 521 ++++
.../src/main/mdo/toolchains.mdo | 4 +-
api/maven-api-xml/pom.xml | 40 +
.../main/java/org/apache/maven/api/xml/Dom.java | 129 +
api/modello-plugin-velocity/pom.xml | 98 +
.../codehaus/modello/plugin/velocity/Helper.java | 154 ++
.../plugin/velocity/ModelloVelocityMojo.java | 86 +
.../modello/plugin/velocity/VelocityGenerator.java | 166 ++
.../main/resources/META-INF/plexus/components.xml | 21 +-
api/pom.xml | 43 +
build/checkstyle-suppressions.xml | 1 -
maven-bom/pom.xml | 5 +
.../artifact/manager/DefaultWagonManager.java | 12 +-
.../java/org/apache/maven/project/ModelUtils.java | 302 +--
.../DefaultModelInheritanceAssembler.java | 715 +----
.../StringSearchModelInterpolator.java | 3 +-
.../repository/legacy/LegacyRepositorySystem.java | 131 +-
.../org/apache/maven/project/ModelUtilsTest.java | 637 -----
.../inheritance/t12/ProjectInheritanceTest.java | 2 +
maven-core/pom.xml | 4 +
.../main/java/org/apache/maven/DefaultMaven.java | 23 +-
.../artifact/handler/DefaultArtifactHandler.java | 1 +
.../internal/DefaultBeanConfigurator.java | 47 +-
.../internal/EnhancedComponentConfigurator.java | 67 +
.../internal/EnhancedConfigurationConverter.java | 125 +
.../internal/EnhancedConverterLookup.java | 50 +
.../DefaultMavenExecutionRequestPopulator.java | 8 +-
.../org/apache/maven/execution/MavenSession.java | 44 +-
.../apache/maven/execution/SettingsAdapter.java | 126 -
.../scope/internal/MojoExecutionScopeModule.java | 9 +-
.../DefaultRepositorySystemSessionFactory.java | 60 +-
.../apache/maven/internal/impl/AbstractNode.java | 86 +
.../maven/internal/impl/AbstractSession.java | 623 +++++
.../maven/internal/impl/DefaultArtifact.java | 128 +
.../internal/impl/DefaultArtifactCoordinate.java | 113 +
.../impl/DefaultArtifactCoordinateFactory.java | 62 +
.../internal/impl/DefaultArtifactDeployer.java | 87 +
.../internal/impl/DefaultArtifactFactory.java | 63 +
.../internal/impl/DefaultArtifactInstaller.java | 76 +
.../internal/impl/DefaultArtifactManager.java | 136 +
.../internal/impl/DefaultArtifactResolver.java | 93 +
.../maven/internal/impl/DefaultDependency.java | 149 ++
.../internal/impl/DefaultDependencyCollector.java | 110 +
.../internal/impl/DefaultDependencyCoordinate.java | 132 +
.../impl/DefaultDependencyCoordinateFactory.java | 75 +
.../apache/maven/internal/impl/DefaultEvent.java | 71 +
.../internal/impl/DefaultLocalRepository.java | 69 +
.../impl/DefaultLocalRepositoryManager.java | 81 +
.../org/apache/maven/internal/impl/DefaultLog.java | 210 ++
.../apache/maven/internal/impl/DefaultLookup.java | 91 +
.../maven/internal/impl/DefaultMessageBuilder.java | 146 +
.../impl/DefaultMessageBuilderFactory.java | 60 +
.../internal/impl/DefaultModelXmlFactory.java | 123 +
.../maven/internal/impl/DefaultMojoExecution.java | 73 +
.../apache/maven/internal/impl/DefaultNode.java | 173 ++
.../apache/maven/internal/impl/DefaultProject.java | 250 ++
.../maven/internal/impl/DefaultProjectBuilder.java | 267 ++
.../maven/internal/impl/DefaultProjectManager.java | 177 ++
.../maven/internal/impl/DefaultPrompter.java | 87 +
.../impl/DefaultRemoteRepository.java} | 51 +-
.../internal/impl/DefaultRepositoryFactory.java | 88 +
.../apache/maven/internal/impl/DefaultSession.java | 397 +++
.../maven/internal/impl/DefaultSessionFactory.java | 85 +
.../internal/impl/DefaultSettingsXmlFactory.java | 103 +
.../internal/impl/DefaultToolchainManager.java | 122 +
.../internal/impl/DefaultToolchainsXmlFactory.java | 103 +
.../maven/internal/impl/DefaultTypeRegistry.java | 84 +
.../maven/internal/impl/DefaultVersionParser.java | 161 ++
.../apache/maven/internal/impl/EventSpyImpl.java | 75 +
.../maven/internal/impl/MappedCollection.java | 63 +
.../org/apache/maven/internal/impl/MappedList.java | 39 +-
.../java/org/apache/maven/internal/impl/Utils.java | 44 +-
.../apache/maven/internal/impl/WrapperNode.java | 81 +
.../DefaultLifecycleExecutionPlanCalculator.java | 48 +-
.../internal/DefaultLifecyclePluginAnalyzer.java | 8 +-
.../internal/DefaultMojoExecutionConfigurator.java | 18 +-
.../internal/DefaultProjectArtifactFactory.java | 3 +-
.../internal/LifecycleDependencyResolver.java | 62 +-
.../lifecycle/internal/MojoDescriptorCreator.java | 21 +-
.../lifecycle/internal/builder/BuilderCommon.java | 6 +-
.../maven/lifecycle/mapping/LifecycleMojo.java | 8 +-
.../providers/AbstractLifecycleProvider.java | 3 +-
.../providers/CleanLifecycleProvider.java | 4 +-
.../plugin/DefaultLifecycleBindingsInjector.java | 70 +-
.../CycleDetectedInPluginGraphException.java | 2 +-
.../maven/plugin/DefaultBuildPluginManager.java | 91 +-
.../org/apache/maven/plugin/MojoExecution.java | 22 +-
.../plugin/PluginParameterExpressionEvaluator.java | 6 +-
...a => PluginParameterExpressionEvaluatorV4.java} | 84 +-
.../plugin/internal/DefaultMavenPluginManager.java | 32 +-
.../maven/project/DefaultProjectBuilder.java | 27 +-
.../maven/project/ExtensionDescriptorBuilder.java | 10 +-
.../org/apache/maven/project/MavenProject.java | 19 +-
.../apache/maven/project/ProjectModelResolver.java | 69 +-
.../org/apache/maven/project/ProjectSorter.java | 41 +-
.../project/artifact/MavenMetadataSource.java | 6 +-
.../maven/project/artifact/ProjectArtifact.java | 4 +-
.../session/scope/internal/SessionScopeModule.java | 2 +
.../settings/DefaultMavenSettingsBuilder.java | 1 +
.../maven/settings/MavenSettingsBuilder.java | 1 +
.../org/apache/maven/settings/SettingsUtils.java | 246 +-
.../toolchain/DefaultToolchainManagerPrivate.java | 12 +-
.../maven/toolchain/DefaultToolchainsBuilder.java | 4 +-
.../apache/maven/toolchain/ToolchainFactory.java | 1 +
.../apache/maven/toolchain/ToolchainsBuilder.java | 2 +-
.../maven/toolchain/java/JavaToolchainFactory.java | 4 +-
.../main/resources/META-INF/maven/extension.xml | 2 +
.../maven/AbstractCoreMavenComponentTestCase.java | 7 +
.../DefaultBeanConfiguratorPathTest.java | 140 +
.../org/apache/maven/internal/impl/TestApi.java | 130 +
.../maven/internal/impl/TestArtifactHandler.java | 83 +
.../impl}/TestRepositorySystem.java | 64 +-
.../maven/lifecycle/LifecycleExecutorTest.java | 4 +-
.../stub/LifecycleExecutionPlanCalculatorStub.java | 2 +-
.../maven/project/EmptyLifecycleExecutor.java | 2 +-
.../maven/project/ProjectModelResolverTest.java | 27 +-
.../apache/maven/project/ProjectSorterTest.java | 2 +
.../canonical/CanonicalProjectBuilderTest.java | 5 +-
.../project/harness/Xpp3DomAttributeIterator.java | 22 +-
.../maven/project/harness/Xpp3DomNodeIterator.java | 21 +-
.../maven/project/harness/Xpp3DomNodePointer.java | 23 +-
.../project/harness/Xpp3DomPointerFactory.java | 18 +-
.../maven/repository/TestRepositorySystem.java | 5 +-
.../settings/PomConstructionWithSettingsTest.java | 2 +-
.../apache/maven/settings/SettingsUtilsTest.java | 100 +-
.../toolchain/DefaultToolchainManagerTest.java | 8 +-
.../maven/toolchain/DefaultToolchainTest.java | 4 +-
.../1.0.3/commons-logging-1.0.3.jar | Bin 0 -> 31605 bytes
.../1.0.3/commons-logging-1.0.3.jar.sha1 | 1 +
.../1.0.3/commons-logging-1.0.3.pom | 31 +
.../1.0.3/commons-logging-1.0.3.pom.sha1 | 1 +
...logging-1.0.4-javadoc-resources.jar.lastUpdated | 4 +
.../1.0.4/commons-logging-1.0.4.jar | Bin 0 -> 38015 bytes
.../1.0.4/commons-logging-1.0.4.jar.sha1 | 1 +
.../1.0.4/commons-logging-1.0.4.pom | 165 ++
.../1.0.4/commons-logging-1.0.4.pom.sha1 | 1 +
.../apiv4-repo/org/apache/apache/3/apache-3.pom | 82 +
.../org/apache/apache/3/apache-3.pom.md5 | 1 +
.../org/apache/apache/3/apache-3.pom.sha1 | 1 +
.../3.0-SNAPSHOT/maven-artifact-3.0-SNAPSHOT.jar | Bin 0 -> 163984 bytes
.../maven-artifact-3.0-SNAPSHOT.jar.md5 | 1 +
.../maven-artifact-3.0-SNAPSHOT.jar.sha1 | 1 +
.../3.0-SNAPSHOT/maven-artifact-3.0-SNAPSHOT.pom | 112 +
.../maven-artifact-3.0-SNAPSHOT.pom.md5 | 1 +
.../maven-artifact-3.0-SNAPSHOT.pom.sha1 | 1 +
.../test/test-extension/1/test-extension-1.jar | Bin 0 -> 4208 bytes
.../test/test-extension/1/test-extension-1.pom | 73 +
.../test/test-extension/1/test-extension-1.pom.md5 | 1 +
.../test-extension/1/test-extension-1.pom.sha1 | 1 +
.../1/test-lifecycle-and-artifactHandler-1.jar | Bin 0 -> 2582 bytes
.../1/test-lifecycle-and-artifactHandler-1.pom | 44 +
.../1/test-lifecycle-and-artifactHandler-1.pom.md5 | 1 +
.../test-lifecycle-and-artifactHandler-1.pom.sha1 | 1 +
.../apache/maven/maven-parent/4/maven-parent-4.pom | 304 +++
.../maven/maven-parent/4/maven-parent-4.pom.md5 | 1 +
.../maven/maven-parent/4/maven-parent-4.pom.sha1 | 1 +
.../apache/maven/maven-parent/5/maven-parent-5.pom | 466 ++++
.../maven/maven-parent/5/maven-parent-5.pom.md5 | 1 +
.../maven/maven-parent/5/maven-parent-5.pom.sha1 | 1 +
.../1.0-beta-2/wagon-provider-api-1.0-beta-2.jar | Bin 0 -> 46326 bytes
.../wagon-provider-api-1.0-beta-2.jar.md5 | 1 +
.../wagon-provider-api-1.0-beta-2.jar.sha1 | 1 +
.../1.0-beta-2/wagon-provider-api-1.0-beta-2.pom | 21 +
.../wagon-provider-api-1.0-beta-2.pom.md5 | 1 +
.../wagon-provider-api-1.0-beta-2.pom.sha1 | 1 +
.../1.0-beta-2/wagon-providers-1.0-beta-2.pom | 51 +
.../1.0-beta-2/wagon-providers-1.0-beta-2.pom.md5 | 1 +
.../1.0-beta-2/wagon-providers-1.0-beta-2.pom.sha1 | 1 +
.../1.0-beta-2/wagon-webdav-1.0-beta-2.jar | Bin 0 -> 17297 bytes
.../1.0-beta-2/wagon-webdav-1.0-beta-2.jar.md5 | 1 +
.../1.0-beta-2/wagon-webdav-1.0-beta-2.jar.sha1 | 1 +
.../1.0-beta-2/wagon-webdav-1.0-beta-2.pom | 50 +
.../1.0-beta-2/wagon-webdav-1.0-beta-2.pom.md5 | 1 +
.../1.0-beta-2/wagon-webdav-1.0-beta-2.pom.sha1 | 1 +
.../wagon/wagon/1.0-beta-2/wagon-1.0-beta-2.pom | 170 ++
.../wagon/1.0-beta-2/wagon-1.0-beta-2.pom.md5 | 1 +
.../wagon/1.0-beta-2/wagon-1.0-beta-2.pom.sha1 | 1 +
.../plexus-active-collections-1.0-beta-1.jar | Bin 0 -> 15961 bytes
.../plexus-active-collections-1.0-beta-1.jar.md5 | 1 +
.../plexus-active-collections-1.0-beta-1.jar.sha1 | 1 +
.../plexus-active-collections-1.0-beta-1.pom | 51 +
.../plexus-active-collections-1.0-beta-1.pom.md5 | 1 +
.../plexus-active-collections-1.0-beta-1.pom.sha1 | 1 +
.../plexus-classworlds-1.2-alpha-10.jar | Bin 0 -> 42472 bytes
.../plexus-classworlds-1.2-alpha-10.jar.md5 | 1 +
.../plexus-classworlds-1.2-alpha-10.jar.sha1 | 1 +
.../plexus-classworlds-1.2-alpha-10.pom | 94 +
.../plexus-classworlds-1.2-alpha-10.pom.md5 | 1 +
.../plexus-classworlds-1.2-alpha-10.pom.sha1 | 1 +
.../1.2-alpha-7/plexus-classworlds-1.2-alpha-7.jar | Bin 0 -> 42636 bytes
.../plexus-classworlds-1.2-alpha-7.jar.md5 | 1 +
.../plexus-classworlds-1.2-alpha-7.jar.sha1 | 1 +
.../1.2-alpha-7/plexus-classworlds-1.2-alpha-7.pom | 78 +
.../plexus-classworlds-1.2-alpha-7.pom.md5 | 1 +
.../plexus-classworlds-1.2-alpha-7.pom.sha1 | 1 +
.../plexus-component-api-1.0-alpha-16.jar | Bin 0 -> 33149 bytes
.../plexus-component-api-1.0-alpha-16.jar.md5 | 1 +
.../plexus-component-api-1.0-alpha-16.jar.sha1 | 1 +
.../plexus-component-api-1.0-alpha-16.pom | 63 +
.../plexus-component-api-1.0-alpha-16.pom.md5 | 1 +
.../plexus-component-api-1.0-alpha-16.pom.sha1 | 1 +
.../plexus-component-api-1.0-alpha-32.jar | Bin 0 -> 36108 bytes
.../plexus-component-api-1.0-alpha-32.jar.md5 | 1 +
.../plexus-component-api-1.0-alpha-32.jar.sha1 | 1 +
.../plexus-component-api-1.0-alpha-32.pom | 61 +
.../plexus-component-api-1.0-alpha-32.pom.md5 | 1 +
.../plexus-component-api-1.0-alpha-32.pom.sha1 | 1 +
.../1.1.6/plexus-components-1.1.6.pom | 60 +
.../1.1.6/plexus-components-1.1.6.pom.md5 | 1 +
.../1.1.6/plexus-components-1.1.6.pom.sha1 | 1 +
.../plexus-container-default-1.0-alpha-16.jar | Bin 0 -> 210679 bytes
.../plexus-container-default-1.0-alpha-16.jar.md5 | 1 +
.../plexus-container-default-1.0-alpha-16.jar.sha1 | 1 +
.../plexus-container-default-1.0-alpha-16.pom | 56 +
.../plexus-container-default-1.0-alpha-16.pom.md5 | 1 +
.../plexus-container-default-1.0-alpha-16.pom.sha1 | 1 +
.../plexus-container-default-1.0-alpha-32.jar | Bin 0 -> 238880 bytes
.../plexus-container-default-1.0-alpha-32.jar.md5 | 1 +
.../plexus-container-default-1.0-alpha-32.jar.sha1 | 1 +
.../plexus-container-default-1.0-alpha-32.pom | 98 +
.../plexus-container-default-1.0-alpha-32.pom.md5 | 1 +
.../plexus-container-default-1.0-alpha-32.pom.sha1 | 1 +
.../plexus-containers-1.0-alpha-16.pom | 49 +
.../plexus-containers-1.0-alpha-16.pom.md5 | 1 +
.../plexus-containers-1.0-alpha-16.pom.sha1 | 1 +
.../plexus-containers-1.0-alpha-32.pom | 49 +
.../plexus-containers-1.0-alpha-32.pom.md5 | 1 +
.../plexus-containers-1.0-alpha-32.pom.sha1 | 1 +
.../plexus-utils/1.0.4/plexus-utils-1.0.4.jar | Bin 0 -> 163803 bytes
.../plexus-utils/1.0.4/plexus-utils-1.0.4.jar.sha1 | 1 +
.../plexus-utils/1.0.4/plexus-utils-1.0.4.pom | 235 ++
.../plexus-utils/1.0.4/plexus-utils-1.0.4.pom.sha1 | 1 +
.../plexus/plexus-utils/1.1/plexus-utils-1.1.jar | Bin 0 -> 168568 bytes
.../plexus-utils/1.1/plexus-utils-1.1.jar.md5 | 1 +
.../plexus-utils/1.1/plexus-utils-1.1.jar.sha1 | 1 +
.../plexus/plexus-utils/1.1/plexus-utils-1.1.pom | 27 +
.../plexus-utils/1.1/plexus-utils-1.1.pom.md5 | 1 +
.../plexus-utils/1.1/plexus-utils-1.1.pom.sha1 | 1 +
.../plexus-utils/1.4.5/plexus-utils-1.4.5.jar | Bin 0 -> 205043 bytes
.../plexus-utils/1.4.5/plexus-utils-1.4.5.jar.md5 | 1 +
.../plexus-utils/1.4.5/plexus-utils-1.4.5.jar.sha1 | 1 +
.../plexus-utils/1.4.5/plexus-utils-1.4.5.pom | 61 +
.../plexus-utils/1.4.5/plexus-utils-1.4.5.pom.md5 | 1 +
.../plexus-utils/1.4.5/plexus-utils-1.4.5.pom.sha1 | 1 +
.../plexus/plexus/1.0.10/plexus-1.0.10.pom | 273 ++
.../plexus/plexus/1.0.10/plexus-1.0.10.pom.md5 | 1 +
.../plexus/plexus/1.0.10/plexus-1.0.10.pom.sha1 | 1 +
.../plexus/plexus/1.0.11/plexus-1.0.11.pom | 308 +++
.../plexus/plexus/1.0.11/plexus-1.0.11.pom.md5 | 1 +
.../plexus/plexus/1.0.11/plexus-1.0.11.pom.sha1 | 1 +
.../codehaus/plexus/plexus/1.0.4/plexus-1.0.4.pom | 205 ++
.../plexus/plexus/1.0.4/plexus-1.0.4.pom.md5 | 1 +
.../plexus/plexus/1.0.4/plexus-1.0.4.pom.sha1 | 1 +
.../codehaus/plexus/plexus/1.0.8/plexus-1.0.8.pom | 259 ++
.../plexus/plexus/1.0.8/plexus-1.0.8.pom.md5 | 1 +
.../plexus/plexus/1.0.8/plexus-1.0.8.pom.sha1 | 1 +
.../codehaus/plexus/plexus/1.0.9/plexus-1.0.9.pom | 257 ++
.../plexus/plexus/1.0.9/plexus-1.0.9.pom.md5 | 1 +
.../plexus/plexus/1.0.9/plexus-1.0.9.pom.sha1 | 1 +
...rest-core-1.3-javadoc-resources.jar.lastUpdated | 4 +
.../1.3/hamcrest-core-1.3-javadoc.jar | Bin 0 -> 242519 bytes
.../1.3/hamcrest-core-1.3-javadoc.jar.sha1 | 1 +
.../1.3/hamcrest-core-1.3-sources.jar | Bin 0 -> 32624 bytes
.../1.3/hamcrest-core-1.3-sources.jar.sha1 | 1 +
.../hamcrest-core/1.3/hamcrest-core-1.3.jar | Bin 0 -> 45024 bytes
.../hamcrest-core/1.3/hamcrest-core-1.3.jar.sha1 | 1 +
.../hamcrest-core/1.3/hamcrest-core-1.3.pom | 18 +
.../hamcrest-core/1.3/hamcrest-core-1.3.pom.sha1 | 1 +
.../hamcrest-parent/1.3/hamcrest-parent-1.3.pom | 72 +
.../1.3/hamcrest-parent-1.3.pom.sha1 | 1 +
.../main/java/org/apache/maven/cli/MavenCli.java | 3 +-
.../SettingsXmlConfigurationProcessor.java | 32 +-
.../internal/BootstrapCoreExtensionManager.java | 14 +-
.../sisu/plexus/PlexusXmlBeanConverter.java | 486 ++++
maven-model-builder/pom.xml | 5 +
.../maven/model/building/DefaultModelBuilder.java | 179 +-
.../model/building/DefaultModelBuilderFactory.java | 17 +-
.../model/building/DefaultModelBuildingEvent.java | 2 +-
.../model/building/DefaultModelProcessor.java | 2 +-
.../maven/model/building/FileToRawModelMerger.java | 110 +-
.../apache/maven/model/building/ModelCacheTag.java | 17 +-
.../maven/model/building/ModelProblemUtils.java | 4 +
.../DefaultDependencyManagementImporter.java | 21 +-
.../composition/DependencyManagementImporter.java | 6 +-
.../inheritance/DefaultInheritanceAssembler.java | 77 +-
.../model/inheritance/InheritanceAssembler.java | 4 +-
.../AbstractStringBasedModelInterpolator.java | 20 +-
.../model/interpolation/ModelInterpolator.java | 5 +-
.../StringSearchModelInterpolator.java | 527 ----
.../StringVisitorModelInterpolator.java | 1355 +---------
.../apache/maven/model/io/DefaultModelReader.java | 64 +-
.../apache/maven/model/io/DefaultModelWriter.java | 23 +-
.../org/apache/maven/model/io/ModelReader.java | 5 +-
.../org/apache/maven/model/io/ModelWriter.java | 38 +-
.../DefaultDependencyManagementInjector.java | 50 +-
.../DefaultPluginManagementInjector.java | 44 +-
.../apache/maven/model/merge/MavenModelMerger.java | 287 +-
.../normalization/DefaultModelNormalizer.java | 77 +-
.../maven/model/normalization/ModelNormalizer.java | 6 +-
.../model/path/DefaultModelPathTranslator.java | 102 +-
.../model/path/DefaultModelUrlNormalizer.java | 4 +-
.../ProfileActivationFilePathInterpolator.java | 2 +-
.../plugin/DefaultPluginConfigurationExpander.java | 6 +-
.../plugin/DefaultReportConfigurationExpander.java | 4 +-
.../model/plugin/DefaultReportingConverter.java | 14 +-
.../model/profile/DefaultProfileInjector.java | 104 +-
.../resolution/InvalidRepositoryException.java | 2 +-
.../maven/model/resolution/ModelResolver.java | 51 +-
.../model/superpom/DefaultSuperPomProvider.java | 9 +-
.../maven/model/superpom/SuperPomProvider.java | 2 +-
.../model/validation/DefaultModelValidator.java | 92 +-
.../building/DefaultModelBuilderFactoryTest.java | 8 +-
.../model/building/DefaultModelBuilderTest.java | 48 +-
.../model/building/FileToRawModelMergerTest.java | 4 +-
.../DefaultInheritanceAssemblerTest.java | 14 +-
.../AbstractModelInterpolatorTest.java | 174 +-
.../StringSearchModelInterpolatorTest.java | 618 -----
.../StringVisitorModelInterpolatorTest.java | 2 +-
.../maven/model/merge/MavenModelMergerTest.java | 78 +-
.../activation/AbstractProfileActivatorTest.java | 4 +-
.../activation/FileProfileActivatorTest.java | 24 +-
.../activation/JdkVersionProfileActivatorTest.java | 14 +-
.../activation/PropertyProfileActivatorTest.java | 23 +-
.../validation/DefaultModelValidatorTest.java | 4 +-
.../model/transform/pull/BufferingParser.java | 5 +-
maven-model/pom.xml | 85 +-
.../java/org/apache/maven/model/BaseObject.java | 73 +
.../java/org/apache/maven/model/InputLocation.java | 429 +++
.../apache/maven/model/InputLocationTracker.java | 54 +
.../java/org/apache/maven/model/InputSource.java | 150 ++
.../java/org/apache/maven/model/WrapperList.java | 129 +
.../org/apache/maven/model/WrapperProperties.java | 356 +++
.../maven/model/io/xpp3/MavenXpp3Reader.java | 166 ++
.../maven/model/io/xpp3/MavenXpp3ReaderEx.java | 169 ++
.../maven/model/io/xpp3/MavenXpp3Writer.java | 83 +
.../maven/model/io/xpp3/MavenXpp3WriterEx.java | 108 +
.../org/apache/maven/model/merge/ModelMerger.java | 2802 --------------------
maven-model/src/main/mdo/common.vm | 31 +
maven-model/src/main/mdo/merger.vm | 380 +++
maven-model/src/main/mdo/model-v3.vm | 312 +++
maven-model/src/main/mdo/reader-ex.vm | 532 ++++
maven-model/src/main/mdo/reader.vm | 551 ++++
maven-model/src/main/mdo/transformer.vm | 205 ++
maven-model/src/main/mdo/writer-ex.vm | 393 +++
maven-model/src/main/mdo/writer.vm | 331 +++
.../{ModelMergerTest.java => MavenMergerTest.java} | 80 +-
maven-plugin-api/pom.xml | 40 +
.../maven/plugin/descriptor/MojoDescriptor.java | 14 +-
.../plugin/descriptor/PluginDescriptorBuilder.java | 13 +-
.../plugin/lifecycle/ImmutableCollections.java | 738 ++++++
maven-plugin-api/src/main/mdo/common.vm | 21 +
maven-plugin-api/src/main/mdo/merger.vm | 380 +++
maven-plugin-api/src/main/mdo/model.vm | 516 ++++
maven-plugin-api/src/main/mdo/reader.vm | 899 +++++++
maven-plugin-api/src/main/mdo/writer.vm | 331 +++
maven-resolver-provider/pom.xml | 9 +
.../internal/ArtifactDescriptorUtils.java | 1 +
.../repository/internal/DefaultModelResolver.java | 67 +-
.../internal/PluginsMetadataInfoProvider.java | 3 +
.../repository/internal/RelocatedArtifact.java | 1 +
.../internal/DefaultModelResolverTest.java | 117 +-
.../settings/building/DefaultSettingsBuilder.java | 14 +-
.../building/DefaultSettingsBuildingResult.java | 2 +-
.../settings/building/SettingsBuildingResult.java | 2 +-
.../settings/crypto/DefaultSettingsDecrypter.java | 22 +-
.../crypto/DefaultSettingsDecryptionRequest.java | 6 +-
.../crypto/DefaultSettingsDecryptionResult.java | 4 +-
.../settings/crypto/SettingsDecryptionRequest.java | 4 +-
.../settings/crypto/SettingsDecryptionResult.java | 4 +-
.../maven/settings/io/DefaultSettingsReader.java | 4 +-
.../maven/settings/io/DefaultSettingsWriter.java | 4 +-
.../apache/maven/settings/io/SettingsReader.java | 2 +-
.../apache/maven/settings/io/SettingsWriter.java | 2 +-
.../maven/settings/merge/MavenSettingsMerger.java | 105 +-
.../validation/DefaultSettingsValidator.java | 12 +-
.../settings/validation/SettingsValidator.java | 2 +-
.../validation/DefaultSettingsValidatorTest.java | 128 +-
maven-settings/pom.xml | 73 +-
.../org/apache/maven/settings/RuntimeInfo.java | 55 -
.../org/apache/maven/settings/WrapperList.java | 129 +
.../apache/maven/settings/WrapperProperties.java | 356 +++
.../maven/settings/io/xpp3/SettingsXpp3Reader.java | 167 ++
.../maven/settings/io/xpp3/SettingsXpp3Writer.java | 84 +
maven-settings/src/main/mdo/common.vm | 21 +
maven-settings/src/main/mdo/merger.vm | 380 +++
maven-settings/src/main/mdo/model-v3.vm | 251 ++
maven-settings/src/main/mdo/reader.vm | 899 +++++++
maven-settings/src/main/mdo/writer.vm | 331 +++
.../building/DefaultToolchainsBuilder.java | 17 +-
.../building/DefaultToolchainsBuildingResult.java | 2 +-
.../building/ToolchainsBuildingResult.java | 2 +-
.../toolchain/io/DefaultToolchainsReader.java | 4 +-
.../toolchain/io/DefaultToolchainsWriter.java | 4 +-
.../maven/toolchain/io/ToolchainsReader.java | 2 +-
.../maven/toolchain/io/ToolchainsWriter.java | 2 +-
.../toolchain/merge/MavenToolchainMerger.java | 45 +-
.../building/DefaultToolchainsBuilderTest.java | 119 +-
.../toolchain/merge/MavenToolchainMergerTest.java | 74 +-
.../{model => merge}/toolchains-jdks-extend.xml | 0
.../{model => merge}/toolchains-jdks-extra.xml | 0
.../toolchain/{model => merge}/toolchains-jdks.xml | 0
maven-toolchain-model/pom.xml | 73 +-
.../apache/maven/toolchain/model/WrapperList.java | 129 +
.../maven/toolchain/model/WrapperProperties.java | 356 +++
maven-toolchain-model/src/main/mdo/common.vm | 21 +
maven-toolchain-model/src/main/mdo/merger.vm | 380 +++
maven-toolchain-model/src/main/mdo/model-v3.vm | 251 ++
maven-toolchain-model/src/main/mdo/reader.vm | 899 +++++++
maven-toolchain-model/src/main/mdo/writer.vm | 331 +++
{maven-toolchain-model => maven-xml-impl}/pom.xml | 31 +-
.../org/apache/maven/internal/xml/DomBuilder.java | 93 +
.../maven/internal/xml/MavenXmlException.java | 35 +-
.../maven/internal/xml/XmlPlexusConfiguration.java | 68 +
.../org/apache/maven/internal/xml/Xpp3Dom.java | 466 ++++
.../apache/maven/internal/xml/Xpp3DomBuilder.java | 215 ++
.../apache/maven/internal/xml/Xpp3DomWriter.java | 79 +
.../java/org/codehaus/plexus/util/xml/Xpp3Dom.java | 488 ++++
.../codehaus/plexus/util/xml/Xpp3DomBuilder.java | 110 +
plexus-utils/pom.xml | 172 ++
pom.xml | 10 +-
543 files changed, 39358 insertions(+), 10103 deletions(-)
diff --git a/apache-maven/src/assembly/maven/bin/m2.conf b/apache-maven/src/assembly/maven/bin/m2.conf
index c44656832..c050dc07b 100644
--- a/apache-maven/src/assembly/maven/bin/m2.conf
+++ b/apache-maven/src/assembly/maven/bin/m2.conf
@@ -7,4 +7,5 @@ load ${maven.conf}/logging
optionally ${maven.home}/lib/ext/redisson/*.jar
optionally ${maven.home}/lib/ext/hazelcast/*.jar
optionally ${maven.home}/lib/ext/*.jar
+load ${maven.home}/lib/maven-*.jar
load ${maven.home}/lib/*.jar
diff --git a/apache-maven/src/test/java/org/apache/maven/settings/GlobalSettingsTest.java b/apache-maven/src/test/java/org/apache/maven/settings/GlobalSettingsTest.java
index 70a11151f..7d1853b7a 100644
--- a/apache-maven/src/test/java/org/apache/maven/settings/GlobalSettingsTest.java
+++ b/apache-maven/src/test/java/org/apache/maven/settings/GlobalSettingsTest.java
@@ -25,7 +25,7 @@ import java.io.InputStreamReader;
import java.io.Reader;
import java.nio.charset.StandardCharsets;
-import org.apache.maven.settings.io.xpp3.SettingsXpp3Reader;
+import org.apache.maven.settings.v4.SettingsXpp3Reader;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertTrue;
diff --git a/api/maven-api-core/pom.xml b/api/maven-api-core/pom.xml
new file mode 100644
index 000000000..6ffef2472
--- /dev/null
+++ b/api/maven-api-core/pom.xml
@@ -0,0 +1,55 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<!--
+ 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.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.apache.maven</groupId>
+ <artifactId>maven-api</artifactId>
+ <version>4.0.0-alpha-1-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>maven-api-core</artifactId>
+ <name>Apache Maven Core API</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.maven</groupId>
+ <artifactId>maven-api-meta</artifactId>
+ <version>4.0.0-alpha-1-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.maven</groupId>
+ <artifactId>maven-api-model</artifactId>
+ <version>4.0.0-alpha-1-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.maven</groupId>
+ <artifactId>maven-api-settings</artifactId>
+ <version>4.0.0-alpha-1-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.maven</groupId>
+ <artifactId>maven-api-toolchain</artifactId>
+ <version>4.0.0-alpha-1-SNAPSHOT</version>
+ </dependency>
+ </dependencies>
+
+</project>
diff --git a/api/maven-api-core/src/main/java/org/apache/maven/api/Artifact.java b/api/maven-api-core/src/main/java/org/apache/maven/api/Artifact.java
new file mode 100644
index 000000000..5ebbc9783
--- /dev/null
+++ b/api/maven-api-core/src/main/java/org/apache/maven/api/Artifact.java
@@ -0,0 +1,107 @@
+package org.apache.maven.api;
+
+/*
+ * 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.
+ */
+
+import org.apache.maven.api.annotations.Experimental;
+import org.apache.maven.api.annotations.Immutable;
+import org.apache.maven.api.annotations.Nonnull;
+
+/**
+ * An artifact points to a resource such as a jar file or war application.
+ *
+ * @since 4.0
+ */
+@Experimental
+@Immutable
+public interface Artifact
+{
+
+ /**
+ * Returns a unique identifier for this artifact.
+ * The identifier is composed of groupId, artifactId, version, classifier, extension
+ * @return the unique identifier
+ */
+ default String key()
+ {
+ return getGroupId()
+ + ':' + getArtifactId()
+ + ':' + getExtension()
+ + ( getClassifier().length() > 0 ? ":" + getClassifier() : "" )
+ + ':' + getVersion();
+ }
+
+ /**
+ * The groupId of the artifact.
+ *
+ * @return The groupId.
+ */
+ @Nonnull
+ String getGroupId();
+
+ /**
+ * The artifactId of the artifact.
+ *
+ * @return The artifactId.
+ */
+ @Nonnull
+ String getArtifactId();
+
+ /**
+ * The version of the artifact.
+ *
+ * @return The version.
+ */
+ @Nonnull
+ Version getVersion();
+
+ /**
+ * The classifier of the artifact.
+ *
+ * @return The classifier or an empty string if none, never {@code null}.
+ */
+ @Nonnull
+ String getClassifier();
+
+ /**
+ * The file extension of the artifact.
+ *
+ * @return The extension.
+ */
+ @Nonnull
+ String getExtension();
+
+ /**
+ * Determines whether this artifact uses a snapshot version.
+ *
+ * @return {@code true} if the artifact is a snapshot, {@code false} otherwise.
+ * @see org.apache.maven.api.Session#isVersionSnapshot(String)
+ */
+ boolean isSnapshot();
+
+ /**
+ * Shortcut for {@code session.createArtifactCoordinate(artifact)}
+ *
+ * @return an {@link ArtifactCoordinate}
+ * @see org.apache.maven.api.Session#createArtifactCoordinate(Artifact)
+ */
+ @Nonnull
+ ArtifactCoordinate toCoordinate();
+
+}
diff --git a/api/maven-api-core/src/main/java/org/apache/maven/api/ArtifactCoordinate.java b/api/maven-api-core/src/main/java/org/apache/maven/api/ArtifactCoordinate.java
new file mode 100644
index 000000000..1f11e3219
--- /dev/null
+++ b/api/maven-api-core/src/main/java/org/apache/maven/api/ArtifactCoordinate.java
@@ -0,0 +1,89 @@
+package org.apache.maven.api;
+
+/*
+ * 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.
+ */
+
+import org.apache.maven.api.annotations.Experimental;
+import org.apache.maven.api.annotations.Immutable;
+import org.apache.maven.api.annotations.Nonnull;
+
+/**
+ * The {@code Coordinate} object is used to point to an {@link Artifact}
+ * but the version may be specified as a range instead of an exact version.
+ *
+ * @since 4.0
+ */
+@Experimental
+@Immutable
+public interface ArtifactCoordinate
+{
+
+ /**
+ * The groupId of the artifact.
+ *
+ * @return The groupId.
+ */
+ @Nonnull
+ String getGroupId();
+
+ /**
+ * The artifactId of the artifact.
+ *
+ * @return The artifactId.
+ */
+ @Nonnull
+ String getArtifactId();
+
+ /**
+ * The classifier of the artifact.
+ *
+ * @return The classifier or an empty string if none, never {@code null}.
+ */
+ @Nonnull
+ String getClassifier();
+
+ /**
+ * The version of the artifact.
+ *
+ * @return The version.
+ */
+ @Nonnull
+ VersionRange getVersion();
+
+ /**
+ * The extension of the artifact.
+ *
+ * @return The extension or an empty string if none, never {@code null}.
+ */
+ @Nonnull
+ String getExtension();
+
+ /**
+ * Unique id identifying this artifact
+ */
+ default String getId()
+ {
+ return getGroupId()
+ + ":" + getArtifactId()
+ + ":" + getExtension()
+ + ( getClassifier().isEmpty() ? "" : ":" + getClassifier() )
+ + ":" + getVersion();
+ }
+
+}
diff --git a/maven-settings-builder/src/main/java/org/apache/maven/settings/validation/SettingsValidator.java b/api/maven-api-core/src/main/java/org/apache/maven/api/Dependency.java
similarity index 59%
copy from maven-settings-builder/src/main/java/org/apache/maven/settings/validation/SettingsValidator.java
copy to api/maven-api-core/src/main/java/org/apache/maven/api/Dependency.java
index 79745ecaf..51fa632ef 100644
--- a/maven-settings-builder/src/main/java/org/apache/maven/settings/validation/SettingsValidator.java
+++ b/api/maven-api-core/src/main/java/org/apache/maven/api/Dependency.java
@@ -1,4 +1,4 @@
-package org.apache.maven.settings.validation;
+package org.apache.maven.api;
/*
* Licensed to the Apache Software Foundation (ASF) under one
@@ -19,23 +19,30 @@ package org.apache.maven.settings.validation;
* under the License.
*/
-import org.apache.maven.settings.Settings;
-import org.apache.maven.settings.building.SettingsProblemCollector;
+import org.apache.maven.api.annotations.Nonnull;
-/**
- * Validate a model settings
- *
- * @author Milos Kleint
- */
-public interface SettingsValidator
+public interface Dependency extends Artifact
{
/**
- * Validate the specified settings.
+ * The artifact type.
+ *
+ * @return The artifact type, never {@code null}.
+ */
+ @Nonnull
+ Type getType();
+
+ Scope getScope();
+
+ boolean isOptional();
+
+ /**
+ * Shortcut for {@code session.createDependencyCoordinate(dependency)}
*
- * @param settings The settings to validate, must not be {@code null}.
- * @param problems The container used to collect problems that were encountered, must not be {@code null}.
+ * @return an {@link DependencyCoordinate}
+ * @see org.apache.maven.api.Session#createDependencyCoordinate(Dependency)
*/
- void validate( Settings settings, SettingsProblemCollector problems );
+ @Nonnull
+ DependencyCoordinate toCoordinate();
}
diff --git a/maven-toolchain-builder/src/main/java/org/apache/maven/toolchain/building/ToolchainsBuildingResult.java b/api/maven-api-core/src/main/java/org/apache/maven/api/DependencyCoordinate.java
similarity index 58%
copy from maven-toolchain-builder/src/main/java/org/apache/maven/toolchain/building/ToolchainsBuildingResult.java
copy to api/maven-api-core/src/main/java/org/apache/maven/api/DependencyCoordinate.java
index f7c5f7155..e5ea7a4cb 100644
--- a/maven-toolchain-builder/src/main/java/org/apache/maven/toolchain/building/ToolchainsBuildingResult.java
+++ b/api/maven-api-core/src/main/java/org/apache/maven/api/DependencyCoordinate.java
@@ -1,4 +1,4 @@
-package org.apache.maven.toolchain.building;
+package org.apache.maven.api;
/*
* Licensed to the Apache Software Foundation (ASF) under one
@@ -19,32 +19,36 @@ package org.apache.maven.toolchain.building;
* under the License.
*/
-import java.util.List;
+import org.apache.maven.api.annotations.Experimental;
+import org.apache.maven.api.annotations.Nonnull;
+import org.apache.maven.api.annotations.Nullable;
+import org.apache.maven.api.annotations.Immutable;
-import org.apache.maven.building.Problem;
-import org.apache.maven.toolchain.model.PersistedToolchains;
+import java.util.Collection;
/**
- * Collects the output of the toolchains builder.
*
- * @author Robert Scholte
- * @since 3.3.0
+ * @since 4.0
*/
-public interface ToolchainsBuildingResult
+@Experimental
+@Immutable
+public interface DependencyCoordinate extends ArtifactCoordinate
{
-
/**
- * Gets the assembled toolchains.
+ * The type of the artifact.
*
- * @return The assembled toolchains, never {@code null}.
+ * @return The type.
*/
- PersistedToolchains getEffectiveToolchains();
+ @Nonnull
+ Type getType();
- /**
- * Return a list of problems, if any.
- *
- * @return a list of problems, never {@code null}.
- */
- List<Problem> getProblems();
+ @Nonnull
+ Scope getScope();
+
+ @Nullable
+ Boolean getOptional();
+
+ @Nonnull
+ Collection<Exclusion> getExclusions();
}
diff --git a/api/maven-api-core/src/main/java/org/apache/maven/api/Event.java b/api/maven-api-core/src/main/java/org/apache/maven/api/Event.java
new file mode 100644
index 000000000..0a30dba8f
--- /dev/null
+++ b/api/maven-api-core/src/main/java/org/apache/maven/api/Event.java
@@ -0,0 +1,77 @@
+package org.apache.maven.api;
+
+/*
+ * 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.
+ */
+
+import org.apache.maven.api.annotations.Experimental;
+import org.apache.maven.api.annotations.Nonnull;
+
+import java.util.Optional;
+
+/**
+ * Event sent by maven during various phases of the build process.
+ * Such events can be listened to using {@link Listener}s objects
+ * registered in the {@link Session}.
+ *
+ * @since 4.0
+ */
+@Experimental
+public interface Event
+{
+
+ /**
+ * Gets the type of the event.
+ *
+ * @return The type of the event, never {@code null}.
+ */
+ @Nonnull
+ EventType getType();
+
+ /**
+ * Gets the session from which this event originates.
+ *
+ * @return The current session, never {@code null}.
+ */
+ @Nonnull
+ Session getSession();
+
+ /**
+ * Gets the current project (if any).
+ *
+ * @return The current project or {@code empty()} if not applicable.
+ */
+ @Nonnull
+ Optional<Project> getProject();
+
+ /**
+ * Gets the current mojo execution (if any).
+ *
+ * @return The current mojo execution or {@code empty()} if not applicable.
+ */
+ @Nonnull
+ Optional<MojoExecution> getMojoExecution();
+
+ /**
+ * Gets the exception that caused the event (if any).
+ *
+ * @return The exception or {@code empty()} if none.
+ */
+ Optional<Exception> getException();
+
+}
diff --git a/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/PluginsMetadataInfoProvider.java b/api/maven-api-core/src/main/java/org/apache/maven/api/EventType.java
similarity index 59%
copy from maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/PluginsMetadataInfoProvider.java
copy to api/maven-api-core/src/main/java/org/apache/maven/api/EventType.java
index 629a23f3b..0279d1222 100644
--- a/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/PluginsMetadataInfoProvider.java
+++ b/api/maven-api-core/src/main/java/org/apache/maven/api/EventType.java
@@ -1,4 +1,4 @@
-package org.apache.maven.repository.internal;
+package org.apache.maven.api;
/*
* Licensed to the Apache Software Foundation (ASF) under one
@@ -19,26 +19,31 @@ package org.apache.maven.repository.internal;
* under the License.
*/
-import org.eclipse.aether.artifact.Artifact;
+import org.apache.maven.api.annotations.Experimental;
/**
- * Plugin G level metadata provider.
+ * The possible types of execution events.
+ *
+ * @since 4.0
*/
-public interface PluginsMetadataInfoProvider
+@Experimental
+public enum EventType
{
- interface PluginInfo
- {
- String getPluginGroupId();
-
- String getPluginArtifactId();
-
- String getPluginPrefix();
-
- String getPluginName();
- }
-
- /**
- * Returns {@link PluginInfo} corresponding for passed in {@link Artifact}, or {@code null}.
- */
- PluginInfo getPluginInfo( Artifact artifact );
+ PROJECT_DISCOVERY_STARTED,
+ SESSION_STARTED,
+ SESSION_ENDED,
+ PROJECT_SKIPPED,
+ PROJECT_STARTED,
+ PROJECT_SUCCEEDED,
+ PROJECT_FAILED,
+ MOJO_SKIPPED,
+ MOJO_STARTED,
+ MOJO_SUCCEEDED,
+ MOJO_FAILED,
+ FORK_STARTED,
+ FORK_SUCCEEDED,
+ FORK_FAILED,
+ FORKED_PROJECT_STARTED,
+ FORKED_PROJECT_SUCCEEDED,
+ FORKED_PROJECT_FAILED,
}
diff --git a/maven-model/src/main/java/org/apache/maven/model/package-info.java b/api/maven-api-core/src/main/java/org/apache/maven/api/Exclusion.java
similarity index 69%
copy from maven-model/src/main/java/org/apache/maven/model/package-info.java
copy to api/maven-api-core/src/main/java/org/apache/maven/api/Exclusion.java
index 88d3fa070..143c6d257 100644
--- a/maven-model/src/main/java/org/apache/maven/model/package-info.java
+++ b/api/maven-api-core/src/main/java/org/apache/maven/api/Exclusion.java
@@ -1,9 +1,4 @@
-// CHECKSTYLE_OFF: RegexpHeader
-/**
- * Maven POM (Project Object Model) classes, generated from <code>maven.mdo</code> model.
- * The root class is {@link org.apache.maven.model.Model}.
- */
-package org.apache.maven.model;
+package org.apache.maven.api;
/*
* Licensed to the Apache Software Foundation (ASF) under one
@@ -22,4 +17,24 @@ package org.apache.maven.model;
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
- */
\ No newline at end of file
+ */
+
+import org.apache.maven.api.annotations.Experimental;
+import org.apache.maven.api.annotations.Nullable;
+
+/**
+ * A dependency exlusion.
+ *
+ * @since 4.0
+ * @see DependencyCoordinate#getExclusions()
+ */
+@Experimental
+public interface Exclusion
+{
+ @Nullable
+ String getGroupId();
+
+ @Nullable
+ String getArtifactId();
+
+}
diff --git a/maven-model/src/main/java/org/apache/maven/model/package-info.java b/api/maven-api-core/src/main/java/org/apache/maven/api/JavaToolchain.java
similarity index 71%
copy from maven-model/src/main/java/org/apache/maven/model/package-info.java
copy to api/maven-api-core/src/main/java/org/apache/maven/api/JavaToolchain.java
index 88d3fa070..21eefa490 100644
--- a/maven-model/src/main/java/org/apache/maven/model/package-info.java
+++ b/api/maven-api-core/src/main/java/org/apache/maven/api/JavaToolchain.java
@@ -1,9 +1,4 @@
-// CHECKSTYLE_OFF: RegexpHeader
-/**
- * Maven POM (Project Object Model) classes, generated from <code>maven.mdo</code> model.
- * The root class is {@link org.apache.maven.model.Model}.
- */
-package org.apache.maven.model;
+package org.apache.maven.api;
/*
* Licensed to the Apache Software Foundation (ASF) under one
@@ -14,7 +9,7 @@ package org.apache.maven.model;
* "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
+ * 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
@@ -22,4 +17,19 @@ package org.apache.maven.model;
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
- */
\ No newline at end of file
+ */
+
+import org.apache.maven.api.annotations.Experimental;
+
+/**
+ * A specific {@link Toolchain} dedicated for Java.
+ *
+ * @since 4.0
+ */
+@Experimental
+public interface JavaToolchain extends Toolchain
+{
+
+ String getJavaHome();
+
+}
diff --git a/maven-model/src/main/java/org/apache/maven/model/package-info.java b/api/maven-api-core/src/main/java/org/apache/maven/api/Listener.java
similarity index 65%
copy from maven-model/src/main/java/org/apache/maven/model/package-info.java
copy to api/maven-api-core/src/main/java/org/apache/maven/api/Listener.java
index 88d3fa070..924ddaeaa 100644
--- a/maven-model/src/main/java/org/apache/maven/model/package-info.java
+++ b/api/maven-api-core/src/main/java/org/apache/maven/api/Listener.java
@@ -1,9 +1,4 @@
-// CHECKSTYLE_OFF: RegexpHeader
-/**
- * Maven POM (Project Object Model) classes, generated from <code>maven.mdo</code> model.
- * The root class is {@link org.apache.maven.model.Model}.
- */
-package org.apache.maven.model;
+package org.apache.maven.api;
/*
* Licensed to the Apache Software Foundation (ASF) under one
@@ -14,7 +9,7 @@ package org.apache.maven.model;
* "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
+ * 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
@@ -22,4 +17,20 @@ package org.apache.maven.model;
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
- */
\ No newline at end of file
+ */
+
+import org.apache.maven.api.annotations.Consumer;
+import org.apache.maven.api.annotations.Experimental;
+import org.apache.maven.api.annotations.Nonnull;
+
+/**
+ * A listener for session events.
+ *
+ * @since 4.0
+ */
+@Experimental
+@FunctionalInterface @Consumer
+public interface Listener
+{
+ void onEvent( @Nonnull Event event );
+}
diff --git a/maven-model/src/main/java/org/apache/maven/model/package-info.java b/api/maven-api-core/src/main/java/org/apache/maven/api/LocalRepository.java
similarity index 62%
copy from maven-model/src/main/java/org/apache/maven/model/package-info.java
copy to api/maven-api-core/src/main/java/org/apache/maven/api/LocalRepository.java
index 88d3fa070..4d1101f76 100644
--- a/maven-model/src/main/java/org/apache/maven/model/package-info.java
+++ b/api/maven-api-core/src/main/java/org/apache/maven/api/LocalRepository.java
@@ -1,9 +1,4 @@
-// CHECKSTYLE_OFF: RegexpHeader
-/**
- * Maven POM (Project Object Model) classes, generated from <code>maven.mdo</code> model.
- * The root class is {@link org.apache.maven.model.Model}.
- */
-package org.apache.maven.model;
+package org.apache.maven.api;
/*
* Licensed to the Apache Software Foundation (ASF) under one
@@ -22,4 +17,26 @@ package org.apache.maven.model;
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
- */
\ No newline at end of file
+ */
+
+import java.nio.file.Path;
+
+import org.apache.maven.api.annotations.Experimental;
+import org.apache.maven.api.annotations.Immutable;
+import org.apache.maven.api.annotations.Nonnull;
+
+/**
+ * The local repository is used to cache artifacts downloaded from {@link RemoteRepository}
+ * and to hold artifacts that have been build locally.
+ *
+ * @since 4.0
+ */
+@Experimental
+@Immutable
+public interface LocalRepository extends Repository
+{
+
+ @Nonnull
+ Path getPath();
+
+}
diff --git a/maven-model/src/main/java/org/apache/maven/model/package-info.java b/api/maven-api-core/src/main/java/org/apache/maven/api/Metadata.java
similarity index 67%
copy from maven-model/src/main/java/org/apache/maven/model/package-info.java
copy to api/maven-api-core/src/main/java/org/apache/maven/api/Metadata.java
index 88d3fa070..d86aef648 100644
--- a/maven-model/src/main/java/org/apache/maven/model/package-info.java
+++ b/api/maven-api-core/src/main/java/org/apache/maven/api/Metadata.java
@@ -1,9 +1,4 @@
-// CHECKSTYLE_OFF: RegexpHeader
-/**
- * Maven POM (Project Object Model) classes, generated from <code>maven.mdo</code> model.
- * The root class is {@link org.apache.maven.model.Model}.
- */
-package org.apache.maven.model;
+package org.apache.maven.api;
/*
* Licensed to the Apache Software Foundation (ASF) under one
@@ -14,7 +9,7 @@ package org.apache.maven.model;
* "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
+ * 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
@@ -22,4 +17,25 @@ package org.apache.maven.model;
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
- */
\ No newline at end of file
+ */
+
+import org.apache.maven.api.annotations.Experimental;
+
+/**
+ * TODO: investigate removing the Metadata api completely
+ *
+ * @since 4.0
+ */
+@Experimental
+public interface Metadata
+{
+
+ String getGroupId();
+
+ String getArtifactId();
+
+ String getVersion();
+
+ MetadataStorage getStorage();
+
+}
diff --git a/maven-model/src/main/java/org/apache/maven/model/package-info.java b/api/maven-api-core/src/main/java/org/apache/maven/api/MetadataStorage.java
similarity index 78%
copy from maven-model/src/main/java/org/apache/maven/model/package-info.java
copy to api/maven-api-core/src/main/java/org/apache/maven/api/MetadataStorage.java
index 88d3fa070..1b988cfc7 100644
--- a/maven-model/src/main/java/org/apache/maven/model/package-info.java
+++ b/api/maven-api-core/src/main/java/org/apache/maven/api/MetadataStorage.java
@@ -1,9 +1,4 @@
-// CHECKSTYLE_OFF: RegexpHeader
-/**
- * Maven POM (Project Object Model) classes, generated from <code>maven.mdo</code> model.
- * The root class is {@link org.apache.maven.model.Model}.
- */
-package org.apache.maven.model;
+package org.apache.maven.api;
/*
* Licensed to the Apache Software Foundation (ASF) under one
@@ -22,4 +17,19 @@ package org.apache.maven.model;
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
- */
\ No newline at end of file
+ */
+
+import org.apache.maven.api.annotations.Experimental;
+
+/**
+ * Storage location for metadata
+ *
+ * @since 4.0
+ */
+@Experimental
+public enum MetadataStorage
+{
+ GROUP,
+ ARTIFACT,
+ VERSION
+}
diff --git a/maven-settings-builder/src/main/java/org/apache/maven/settings/validation/SettingsValidator.java b/api/maven-api-core/src/main/java/org/apache/maven/api/MojoExecution.java
similarity index 59%
copy from maven-settings-builder/src/main/java/org/apache/maven/settings/validation/SettingsValidator.java
copy to api/maven-api-core/src/main/java/org/apache/maven/api/MojoExecution.java
index 79745ecaf..0d7ffd1a3 100644
--- a/maven-settings-builder/src/main/java/org/apache/maven/settings/validation/SettingsValidator.java
+++ b/api/maven-api-core/src/main/java/org/apache/maven/api/MojoExecution.java
@@ -1,4 +1,4 @@
-package org.apache.maven.settings.validation;
+package org.apache.maven.api;
/*
* Licensed to the Apache Software Foundation (ASF) under one
@@ -19,23 +19,29 @@ package org.apache.maven.settings.validation;
* under the License.
*/
-import org.apache.maven.settings.Settings;
-import org.apache.maven.settings.building.SettingsProblemCollector;
+import java.util.Optional;
+
+import org.apache.maven.api.annotations.Experimental;
+import org.apache.maven.api.annotations.Nonnull;
+
+import org.apache.maven.api.model.Plugin;
+import org.apache.maven.api.xml.Dom;
/**
- * Validate a model settings
- *
- * @author Milos Kleint
+ * A {@code MojoExecution}
*/
-public interface SettingsValidator
+@Experimental
+public interface MojoExecution
{
+ @Nonnull
+ Plugin getPlugin();
+
+ @Nonnull
+ String getExecutionId();
- /**
- * Validate the specified settings.
- *
- * @param settings The settings to validate, must not be {@code null}.
- * @param problems The container used to collect problems that were encountered, must not be {@code null}.
- */
- void validate( Settings settings, SettingsProblemCollector problems );
+ @Nonnull
+ String getGoal();
+ @Nonnull
+ Optional<Dom> getConfiguration();
}
diff --git a/api/maven-api-core/src/main/java/org/apache/maven/api/Node.java b/api/maven-api-core/src/main/java/org/apache/maven/api/Node.java
new file mode 100644
index 000000000..f0bb78b17
--- /dev/null
+++ b/api/maven-api-core/src/main/java/org/apache/maven/api/Node.java
@@ -0,0 +1,103 @@
+package org.apache.maven.api;
+
+/*
+ * 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.
+ */
+
+import org.apache.maven.api.annotations.Experimental;
+import org.apache.maven.api.annotations.Immutable;
+import org.apache.maven.api.annotations.Nonnull;
+
+import java.util.List;
+import java.util.Optional;
+import java.util.function.Predicate;
+import java.util.stream.Stream;
+
+/**
+ * Represents a dependency node within a Maven project's dependency collector.
+ *
+ * @since 4.0
+ * @see org.apache.maven.api.services.DependencyCollectorResult#getRoot()
+ */
+@Experimental
+@Immutable
+public interface Node
+{
+
+ /**
+ * @return dependency for this node
+ */
+ Dependency getDependency();
+
+ /**
+ * Gets the child nodes of this node.
+ *
+ * @return the child nodes of this node, never {@code null}
+ */
+ @Nonnull
+ List<Node> getChildren();
+
+ /**
+ * @return repositories of this node
+ */
+ @Nonnull
+ List<RemoteRepository> getRemoteRepositories();
+
+ /**
+ * The repository where this artifact has been downloaded from.
+ */
+ @Nonnull
+ Optional<RemoteRepository> getRepository();
+
+ /**
+ * Traverses this node and potentially its children using the specified visitor.
+ *
+ * @param visitor The visitor to call back, must not be {@code null}.
+ * @return {@code true} to visit siblings nodes of this node as well, {@code false} to skip siblings.
+ */
+ boolean accept( @Nonnull NodeVisitor visitor );
+
+ /**
+ * Returns a new tree starting at this node, filtering the children.
+ * Note that this node will not be filtered and only the children
+ * and its descendant will be checked.
+ *
+ * @param filter the filter to apply
+ * @return a new filtered graph
+ */
+ Node filter( Predicate<Node> filter );
+
+ /**
+ * Returns a string representation of this dependency node.
+ *
+ * @return the string representation
+ */
+ String asString();
+
+ /**
+ * Obtain a Stream containing this node and all its descendant.
+ *
+ * @return a stream containing this node and its descendant
+ */
+ @Nonnull
+ default Stream<Node> stream()
+ {
+ return Stream.concat( Stream.of( this ), getChildren().stream().flatMap( Node::stream ) );
+ }
+
+}
diff --git a/api/maven-api-core/src/main/java/org/apache/maven/api/NodeVisitor.java b/api/maven-api-core/src/main/java/org/apache/maven/api/NodeVisitor.java
new file mode 100644
index 000000000..39ae803ea
--- /dev/null
+++ b/api/maven-api-core/src/main/java/org/apache/maven/api/NodeVisitor.java
@@ -0,0 +1,53 @@
+package org.apache.maven.api;
+
+/*
+ * 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.
+ */
+
+
+import org.apache.maven.api.annotations.Consumer;
+import org.apache.maven.api.annotations.Experimental;
+import org.apache.maven.api.annotations.Nonnull;
+
+/**
+ * Defines a hierarchical visitor for collecting dependency node trees.
+ *
+ * @since 4.0
+ */
+@Experimental
+@Consumer
+public interface NodeVisitor
+{
+ /**
+ * Starts the visit to the specified dependency node.
+ *
+ * @param node the dependency node to visit
+ * @return <code>true</code> to visit the specified dependency node's children, <code>false</code> to skip the
+ * specified dependency node's children and proceed to its next sibling
+ */
+ boolean enter( @Nonnull Node node );
+
+ /**
+ * Ends the visit to the specified dependency node.
+ *
+ * @param node the dependency node to visit
+ * @return <code>true</code> to visit the specified dependency node's next sibling, <code>false</code> to skip the
+ * specified dependency node's next siblings and proceed to its parent
+ */
+ boolean leave( @Nonnull Node node );
+}
diff --git a/api/maven-api-core/src/main/java/org/apache/maven/api/Project.java b/api/maven-api-core/src/main/java/org/apache/maven/api/Project.java
new file mode 100644
index 000000000..0531724b1
--- /dev/null
+++ b/api/maven-api-core/src/main/java/org/apache/maven/api/Project.java
@@ -0,0 +1,105 @@
+package org.apache.maven.api;
+
+/*
+ * 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.
+ */
+
+import java.nio.file.Path;
+import java.util.List;
+import java.util.Optional;
+
+import org.apache.maven.api.annotations.Experimental;
+import org.apache.maven.api.annotations.Nonnull;
+import org.apache.maven.api.model.Build;
+import org.apache.maven.api.model.Model;
+
+/**
+ * Interface representing a Maven project.
+ * Projects can be built using the {@link org.apache.maven.api.services.ProjectBuilder} service.
+ *
+ * @since 4.0
+ */
+@Experimental
+public interface Project
+{
+
+ @Nonnull
+ String getGroupId();
+
+ @Nonnull
+ String getArtifactId();
+
+ @Nonnull
+ String getVersion();
+
+ @Nonnull
+ String getPackaging();
+
+ @Nonnull
+ Artifact getArtifact();
+
+ @Nonnull
+ Model getModel();
+
+ @Nonnull
+ default Build getBuild()
+ {
+ Build build = getModel().getBuild();
+ return build != null ? build : Build.newInstance();
+ }
+
+ /**
+ * Returns the path to the pom file for this project.
+ * A project is usually read from the file system and this will point to
+ * the file. In some cases, a transient project can be created which
+ * will not point to an actual pom file.
+ * @return the path of the pom
+ */
+ @Nonnull
+ Optional<Path> getPomPath();
+
+ @Nonnull
+ default Optional<Path> getBasedir()
+ {
+ return getPomPath().map( Path::getParent );
+ }
+
+ @Nonnull
+ List<DependencyCoordinate> getDependencies();
+
+ @Nonnull
+ List<DependencyCoordinate> getManagedDependencies();
+
+ @Nonnull
+ default String getId()
+ {
+ return getModel().getId();
+ }
+
+ boolean isExecutionRoot();
+
+ @Nonnull
+ Optional<Project> getParent();
+
+ @Nonnull
+ List<RemoteRepository> getRemoteProjectRepositories();
+
+ @Nonnull
+ List<RemoteRepository> getRemotePluginRepositories();
+
+}
diff --git a/maven-model/src/main/java/org/apache/maven/model/package-info.java b/api/maven-api-core/src/main/java/org/apache/maven/api/RemoteRepository.java
similarity index 65%
copy from maven-model/src/main/java/org/apache/maven/model/package-info.java
copy to api/maven-api-core/src/main/java/org/apache/maven/api/RemoteRepository.java
index 88d3fa070..4dd629f2c 100644
--- a/maven-model/src/main/java/org/apache/maven/model/package-info.java
+++ b/api/maven-api-core/src/main/java/org/apache/maven/api/RemoteRepository.java
@@ -1,9 +1,4 @@
-// CHECKSTYLE_OFF: RegexpHeader
-/**
- * Maven POM (Project Object Model) classes, generated from <code>maven.mdo</code> model.
- * The root class is {@link org.apache.maven.model.Model}.
- */
-package org.apache.maven.model;
+package org.apache.maven.api;
/*
* Licensed to the Apache Software Foundation (ASF) under one
@@ -22,4 +17,24 @@ package org.apache.maven.model;
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
- */
\ No newline at end of file
+ */
+
+import org.apache.maven.api.annotations.Experimental;
+import org.apache.maven.api.annotations.Immutable;
+import org.apache.maven.api.annotations.Nonnull;
+
+/**
+ * A remote repository that can be used to download or upload artifacts.
+ */
+@Experimental
+@Immutable
+public interface RemoteRepository extends Repository
+{
+
+ @Nonnull
+ String getUrl();
+
+ @Nonnull
+ String getProtocol();
+
+}
diff --git a/maven-settings-builder/src/main/java/org/apache/maven/settings/validation/SettingsValidator.java b/api/maven-api-core/src/main/java/org/apache/maven/api/Repository.java
similarity index 55%
copy from maven-settings-builder/src/main/java/org/apache/maven/settings/validation/SettingsValidator.java
copy to api/maven-api-core/src/main/java/org/apache/maven/api/Repository.java
index 79745ecaf..10551d737 100644
--- a/maven-settings-builder/src/main/java/org/apache/maven/settings/validation/SettingsValidator.java
+++ b/api/maven-api-core/src/main/java/org/apache/maven/api/Repository.java
@@ -1,4 +1,4 @@
-package org.apache.maven.settings.validation;
+package org.apache.maven.api;
/*
* Licensed to the Apache Software Foundation (ASF) under one
@@ -19,23 +19,36 @@ package org.apache.maven.settings.validation;
* under the License.
*/
-import org.apache.maven.settings.Settings;
-import org.apache.maven.settings.building.SettingsProblemCollector;
+import org.apache.maven.api.annotations.Experimental;
+import org.apache.maven.api.annotations.Immutable;
+import org.apache.maven.api.annotations.Nonnull;
/**
- * Validate a model settings
+ * A repository holds artifacts.
*
- * @author Milos Kleint
+ * @since 4.0
+ * @see RemoteRepository
+ * @see LocalRepository
*/
-public interface SettingsValidator
+@Experimental
+@Immutable
+public interface Repository
{
/**
- * Validate the specified settings.
+ * Gets the identifier of this repository.
*
- * @param settings The settings to validate, must not be {@code null}.
- * @param problems The container used to collect problems that were encountered, must not be {@code null}.
+ * @return The (case-sensitive) identifier, never {@code null}.
*/
- void validate( Settings settings, SettingsProblemCollector problems );
+ @Nonnull
+ String getId();
+
+ /**
+ * Gets the type of the repository, for example "default".
+ *
+ * @return The (case-sensitive) type of the repository, never {@code null}.
+ */
+ @Nonnull
+ String getType();
}
diff --git a/maven-model/src/main/java/org/apache/maven/model/package-info.java b/api/maven-api-core/src/main/java/org/apache/maven/api/RepositoryMetadata.java
similarity index 74%
copy from maven-model/src/main/java/org/apache/maven/model/package-info.java
copy to api/maven-api-core/src/main/java/org/apache/maven/api/RepositoryMetadata.java
index 88d3fa070..a64879658 100644
--- a/maven-model/src/main/java/org/apache/maven/model/package-info.java
+++ b/api/maven-api-core/src/main/java/org/apache/maven/api/RepositoryMetadata.java
@@ -1,9 +1,4 @@
-// CHECKSTYLE_OFF: RegexpHeader
-/**
- * Maven POM (Project Object Model) classes, generated from <code>maven.mdo</code> model.
- * The root class is {@link org.apache.maven.model.Model}.
- */
-package org.apache.maven.model;
+package org.apache.maven.api;
/*
* Licensed to the Apache Software Foundation (ASF) under one
@@ -14,7 +9,7 @@ package org.apache.maven.model;
* "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
+ * 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
@@ -22,4 +17,15 @@ package org.apache.maven.model;
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
- */
\ No newline at end of file
+ */
+
+import org.apache.maven.api.annotations.Experimental;
+
+/**
+ *
+ * @since 4.0
+ */
+@Experimental
+public interface RepositoryMetadata extends Metadata
+{
+}
diff --git a/api/maven-api-core/src/main/java/org/apache/maven/api/ResolutionScope.java b/api/maven-api-core/src/main/java/org/apache/maven/api/ResolutionScope.java
new file mode 100644
index 000000000..a68dc5256
--- /dev/null
+++ b/api/maven-api-core/src/main/java/org/apache/maven/api/ResolutionScope.java
@@ -0,0 +1,104 @@
+package org.apache.maven.api;
+
+/*
+ * 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.
+ */
+
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Optional;
+import java.util.Set;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
+
+import org.apache.maven.api.annotations.Experimental;
+
+/**
+ * Dependencies resolution scopes available before
+ * <a href="/ref/current/maven-core/apidocs/org/apache/maven/lifecycle/internal/MojoExecutor.html">mojo execution</a>.
+ *
+ * Important note: The {@code id} values of this enum correspond to constants of
+ * {@code org.apache.maven.artifact.Artifact} class and MUST BE KEPT IN SYNC.
+ *
+ * @since 4.0
+ */
+@Experimental
+public enum ResolutionScope
+{
+ /**
+ * empty resolution scope
+ */
+ NONE( null ),
+ /**
+ * <code>compile</code> resolution scope
+ * = <code>compile</code> + <code>system</code> + <code>provided</code> dependencies
+ */
+ COMPILE( "compile", Scope.COMPILE, Scope.SYSTEM, Scope.PROVIDED ),
+ /**
+ * <code>compile+runtime</code> resolution scope (Maven 3 only)
+ * = <code>compile</code> + <code>system</code> + <code>provided</code> + <code>runtime</code> dependencies
+ */
+ COMPILE_PLUS_RUNTIME( "compile+runtime", Scope.COMPILE, Scope.SYSTEM, Scope.PROVIDED, Scope.RUNTIME ),
+ /**
+ * <code>runtime</code> resolution scope
+ * = <code>compile</code> + <code>runtime</code> dependencies
+ */
+ RUNTIME( "runtime", Scope.COMPILE, Scope.RUNTIME ),
+ /**
+ * <code>runtime+system</code> resolution scope (Maven 3 only)
+ * = <code>compile</code> + <code>system</code> + <code>runtime</code> dependencies
+ */
+ RUNTIME_PLUS_SYSTEM( "runtime+system", Scope.COMPILE, Scope.SYSTEM, Scope.RUNTIME ),
+ /**
+ * <code>test</code> resolution scope
+ * = <code>compile</code> + <code>system</code> + <code>provided</code> + <code>runtime</code> + <code>test</code>
+ * dependencies
+ */
+ TEST( "test", Scope.COMPILE, Scope.SYSTEM, Scope.PROVIDED, Scope.RUNTIME, Scope.TEST );
+
+ private static final Map<String, ResolutionScope> VALUES
+ = Stream.of( ResolutionScope.values() ).collect( Collectors.toMap( ResolutionScope::id, s -> s ) );
+
+ public static ResolutionScope fromString( String id )
+ {
+ return Optional.ofNullable( VALUES.get( id ) )
+ .orElseThrow( () -> new IllegalArgumentException( "Unknown resolution scope " + id ) );
+ }
+
+ private final String id;
+ private final Set<Scope> scopes;
+
+ ResolutionScope( String id, Scope... scopes )
+ {
+ this.id = id;
+ this.scopes = Collections.unmodifiableSet( new HashSet<>( Arrays.asList( scopes ) ) );
+ }
+
+ public String id()
+ {
+ return this.id;
+ }
+
+ public Set<Scope> scopes()
+ {
+ return scopes;
+ }
+
+}
diff --git a/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/PluginsMetadataInfoProvider.java b/api/maven-api-core/src/main/java/org/apache/maven/api/Scope.java
similarity index 58%
copy from maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/PluginsMetadataInfoProvider.java
copy to api/maven-api-core/src/main/java/org/apache/maven/api/Scope.java
index 629a23f3b..f246e9fd7 100644
--- a/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/PluginsMetadataInfoProvider.java
+++ b/api/maven-api-core/src/main/java/org/apache/maven/api/Scope.java
@@ -1,4 +1,4 @@
-package org.apache.maven.repository.internal;
+package org.apache.maven.api;
/*
* Licensed to the Apache Software Foundation (ASF) under one
@@ -19,26 +19,39 @@ package org.apache.maven.repository.internal;
* under the License.
*/
-import org.eclipse.aether.artifact.Artifact;
+import java.util.Locale;
+
+import org.apache.maven.api.annotations.Experimental;
/**
- * Plugin G level metadata provider.
+ * Scope for a dependency
+ *
+ * @since 4.0
*/
-public interface PluginsMetadataInfoProvider
+@Experimental
+public enum Scope
{
- interface PluginInfo
- {
- String getPluginGroupId();
+ COMPILE( "compile" ),
+ PROVIDED ( "provided" ),
+ SYSTEM( "system" ),
+ RUNTIME( "runtime" ),
+ TEST( "test" ),
+ IMPORT( "import" );
- String getPluginArtifactId();
+ private final String id;
- String getPluginPrefix();
+ Scope( String id )
+ {
+ this.id = id;
+ }
- String getPluginName();
+ public String id()
+ {
+ return this.id;
}
- /**
- * Returns {@link PluginInfo} corresponding for passed in {@link Artifact}, or {@code null}.
- */
- PluginInfo getPluginInfo( Artifact artifact );
+ public static Scope get( String scope )
+ {
+ return Enum.valueOf( Scope.class, scope.toUpperCase( Locale.ROOT ) );
+ }
}
diff --git a/maven-model/src/main/java/org/apache/maven/model/package-info.java b/api/maven-api-core/src/main/java/org/apache/maven/api/Service.java
similarity index 66%
copy from maven-model/src/main/java/org/apache/maven/model/package-info.java
copy to api/maven-api-core/src/main/java/org/apache/maven/api/Service.java
index 88d3fa070..a4cabcaa7 100644
--- a/maven-model/src/main/java/org/apache/maven/model/package-info.java
+++ b/api/maven-api-core/src/main/java/org/apache/maven/api/Service.java
@@ -1,9 +1,4 @@
-// CHECKSTYLE_OFF: RegexpHeader
-/**
- * Maven POM (Project Object Model) classes, generated from <code>maven.mdo</code> model.
- * The root class is {@link org.apache.maven.model.Model}.
- */
-package org.apache.maven.model;
+package org.apache.maven.api;
/*
* Licensed to the Apache Software Foundation (ASF) under one
@@ -22,4 +17,21 @@ package org.apache.maven.model;
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
- */
\ No newline at end of file
+ */
+
+import org.apache.maven.api.annotations.Experimental;
+import org.apache.maven.api.annotations.ThreadSafe;
+
+/**
+ * Marker interface for all services provided by the {@link Session}.
+ * <p>
+ * Services can be retrieved from the session using the
+ * {@link Session#getService(Class)} method.
+ *
+ * @see Session#getService(Class)
+ */
+@Experimental
+@ThreadSafe
+public interface Service
+{
+}
diff --git a/api/maven-api-core/src/main/java/org/apache/maven/api/Session.java b/api/maven-api-core/src/main/java/org/apache/maven/api/Session.java
new file mode 100644
index 000000000..0d0cf07f9
--- /dev/null
+++ b/api/maven-api-core/src/main/java/org/apache/maven/api/Session.java
@@ -0,0 +1,346 @@
+package org.apache.maven.api;
+
+/*
+ * 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.
+ */
+
+import java.nio.file.Path;
+import java.time.Instant;
+import java.util.Collection;
+import java.util.List;
+import java.util.Map;
+import java.util.NoSuchElementException;
+import java.util.Optional;
+import java.util.Properties;
+
+import org.apache.maven.api.annotations.Experimental;
+import org.apache.maven.api.annotations.Nonnull;
+import org.apache.maven.api.annotations.ThreadSafe;
+import org.apache.maven.api.model.Repository;
+import org.apache.maven.api.services.DependencyCoordinateFactory;
+import org.apache.maven.api.settings.Settings;
+
+/**
+ * The session to install / deploy / resolve artifacts and dependencies.
+ *
+ * @since 4.0
+ */
+@Experimental
+@ThreadSafe
+public interface Session
+{
+
+ @Nonnull
+ Settings getSettings();
+
+ @Nonnull
+ LocalRepository getLocalRepository();
+
+ @Nonnull
+ List<RemoteRepository> getRemoteRepositories();
+
+ @Nonnull
+ SessionData getData();
+
+ // TODO: investigate using Map<String, String> or Map<String, Object> for all properties in the new API
+ @Nonnull
+ Properties getUserProperties();
+
+ @Nonnull
+ Properties getSystemProperties();
+
+ /**
+ * Returns the current maven version
+ * @return the maven version, never {@code null}.
+ */
+ @Nonnull
+ String getMavenVersion();
+
+ int getDegreeOfConcurrency();
+
+ @Nonnull
+ Instant getStartTime();
+
+ @Nonnull
+ Path getMultiModuleProjectDirectory();
+
+ @Nonnull
+ Path getExecutionRootDirectory();
+
+ @Nonnull
+ List<Project> getProjects();
+
+ /**
+ * Returns the plugin context for mojo being executed and the specified
+ * {@link Project}, never returns {@code null} as if context not present, creates it.
+ *
+ * <strong>Implementation note:</strong> while this method return type is {@link Map}, the returned map instance
+ * implements {@link java.util.concurrent.ConcurrentMap} as well.
+ *
+ * @throws org.apache.maven.api.services.MavenException if not called from the within a mojo execution
+ */
+ @Nonnull
+ Map<String, Object> getPluginContext( @Nonnull Project project );
+
+ /**
+ * Retrieves the service for the interface
+ *
+ * @throws NoSuchElementException if the service could not be found
+ */
+ @Nonnull
+ <T extends Service> T getService( @Nonnull Class<T> clazz );
+
+ /**
+ * Creates a derived session using the given local repository.
+ *
+ * @param localRepository the new local repository
+ * @return the derived session
+ * @throws NullPointerException if {@code localRepository} is null
+ */
+ @Nonnull
+ Session withLocalRepository( @Nonnull LocalRepository localRepository );
+
+ /**
+ * Creates a derived session using the given remote repositories.
+ *
+ * @param repositories the new list of remote repositories
+ * @return the derived session
+ * @throws NullPointerException if {@code repositories} is null
+ */
+ @Nonnull
+ Session withRemoteRepositories( @Nonnull List<RemoteRepository> repositories );
+
+ /**
+ * Register the given listener which will receive all events.
+ *
+ * @param listener the listener to register
+ * @throws NullPointerException if {@code listener} is null
+ */
+ void registerListener( @Nonnull Listener listener );
+
+ /**
+ * Unregisters a previously registered listener.
+ *
+ * @param listener the listener to unregister
+ * @throws NullPointerException if {@code listener} is null
+ */
+ void unregisterListener( @Nonnull Listener listener );
+
+ /**
+ * Returns the list of registered listeners.
+ *
+ * @return an immutable collection of listeners, never {@code null}
+ */
+ @Nonnull
+ Collection<Listener> getListeners();
+
+ /**
+ * Shortcut for <code>getService(RepositoryFactory.class).createLocal(...)</code>
+ * @see org.apache.maven.api.services.RepositoryFactory#createLocal(Path)
+ */
+ LocalRepository createLocalRepository( Path path );
+
+ /**
+ * Shortcut for <code>getService(RepositoryFactory.class).createRemote(...)</code>
+ * @see org.apache.maven.api.services.RepositoryFactory#createRemote(String, String)
+ */
+ @Nonnull
+ RemoteRepository createRemoteRepository( @Nonnull String id, @Nonnull String url );
+
+ /**
+ * Shortcut for <code>getService(RepositoryFactory.class).createRemote(...)</code>
+ * @see org.apache.maven.api.services.RepositoryFactory#createRemote(Repository)
+ */
+ @Nonnull
+ RemoteRepository createRemoteRepository( @Nonnull Repository repository );
+
+ /**
+ * Shortcut for <code>getService(ArtifactFactory.class).create(...)</code>
+ * @see org.apache.maven.api.services.ArtifactFactory#create(Session, String, String, String, String)
+ */
+ ArtifactCoordinate createArtifactCoordinate( String groupId, String artifactId, String version, String extension );
+
+ /**
+ * Shortcut for <code>getService(ArtifactFactory.class).create(...)</code>
+ * @see org.apache.maven.api.services.ArtifactFactory#create(Session, String, String, String, String, String, String)
+ */
+ ArtifactCoordinate createArtifactCoordinate( String groupId, String artifactId, String version, String classifier,
+ String extension, String type );
+
+ /**
+ * Shortcut for <code>getService(ArtifactFactory.class).create(...)</code>
+ * @see org.apache.maven.api.services.ArtifactFactory#create(Session, String, String, String, String, String, String)
+ */
+ ArtifactCoordinate createArtifactCoordinate( Artifact artifact );
+
+ /**
+ * Shortcut for <code>getService(DependencyFactory.class).create(...)</code>
+ * @see DependencyCoordinateFactory#create(Session, ArtifactCoordinate)
+ */
+ @Nonnull
+ DependencyCoordinate createDependencyCoordinate( @Nonnull ArtifactCoordinate coordinate );
+
+ /**
+ * Shortcut for <code>getService(ArtifactFactory.class).create(...)</code>
+ * @see org.apache.maven.api.services.ArtifactFactory#create(Session, String, String, String, String)
+ */
+ Artifact createArtifact( String groupId, String artifactId, String version, String extension );
+
+ /**
+ * Shortcut for <code>getService(ArtifactFactory.class).create(...)</code>
+ * @see org.apache.maven.api.services.ArtifactFactory#create(Session, String, String, String, String, String, String)
+ */
+ Artifact createArtifact( String groupId, String artifactId, String version, String classifier,
+ String extension, String type );
+
+ /**
+ * Shortcut for <code>getService(ArtifactResolver.class).resolve(...)</code>
+ * @see org.apache.maven.api.services.ArtifactResolver#resolve(Session, Collection)
+ *
+ * @throws org.apache.maven.api.services.ArtifactResolverException if the artifact resolution failed
+ */
+ Artifact resolveArtifact( ArtifactCoordinate coordinate );
+
+ /**
+ * Shortcut for <code>getService(ArtifactResolver.class).resolve(...)</code>
+ * @see org.apache.maven.api.services.ArtifactResolver#resolve(Session, Collection)
+ *
+ * @throws org.apache.maven.api.services.ArtifactResolverException if the artifact resolution failed
+ */
+ Collection<Artifact> resolveArtifacts( ArtifactCoordinate... coordinates );
+
+ /**
+ * Shortcut for <code>getService(ArtifactResolver.class).resolve(...)</code>
+ * @see org.apache.maven.api.services.ArtifactResolver#resolve(Session, Collection)
+ *
+ * @throws org.apache.maven.api.services.ArtifactResolverException if the artifact resolution failed
+ */
+ Collection<Artifact> resolveArtifacts( Collection<? extends ArtifactCoordinate> coordinates );
+
+ /**
+ * Shortcut for <code>getService(ArtifactResolver.class).resolve(...)</code>
+ * @see org.apache.maven.api.services.ArtifactResolver#resolve(Session, Collection)
+ *
+ * @throws org.apache.maven.api.services.ArtifactResolverException if the artifact resolution failed
+ */
+ Artifact resolveArtifact( Artifact artifact );
+
+ /**
+ * Shortcut for <code>getService(ArtifactResolver.class).resolve(...)</code>
+ * @see org.apache.maven.api.services.ArtifactResolver#resolve(Session, Collection)
+ *
+ * @throws org.apache.maven.api.services.ArtifactResolverException if the artifact resolution failed
+ */
+ Collection<Artifact> resolveArtifacts( Artifact... artifacts );
+
+ /**
+ * Shortcut for {@code getService(ArtifactInstaller.class).install(...)}
+ * @see org.apache.maven.api.services.ArtifactInstaller#install(Session, Collection)
+ *
+ * @throws org.apache.maven.api.services.ArtifactInstallerException if the artifacts installation failed
+ */
+ void installArtifacts( Artifact... artifacts );
+
+ /**
+ * Shortcut for {@code getService(ArtifactInstaller.class).install(...)}
+ * @see org.apache.maven.api.services.ArtifactInstaller#install(Session, Collection)
+ *
+ * @throws org.apache.maven.api.services.ArtifactInstallerException if the artifacts installation failed
+ */
+ void installArtifacts( Collection<Artifact> artifacts );
+
+ /**
+ * Shortcut for <code>getService(ArtifactDeployer.class).deploy(...)</code>
+ * @see org.apache.maven.api.services.ArtifactDeployer#deploy(Session, RemoteRepository, Collection)
+ *
+ * @throws org.apache.maven.api.services.ArtifactDeployerException if the artifacts deployment failed
+ */
+ void deployArtifact( RemoteRepository repository, Artifact... artifacts );
+
+ /**
+ * Shortcut for <code>getService(ArtifactManager.class).setPath(...)</code>
+ * @see org.apache.maven.api.services.ArtifactManager#setPath(Artifact, Path)
+ */
+ void setArtifactPath( @Nonnull Artifact artifact, @Nonnull Path path );
+
+ /**
+ * Shortcut for <code>getService(ArtifactManager.class).getPath(...)</code>
+ * @see org.apache.maven.api.services.ArtifactManager#getPath(Artifact)
+ */
+ @Nonnull
+ Optional<Path> getArtifactPath( @Nonnull Artifact artifact );
+
+ /**
+ * Shortcut for <code>getService(ArtifactManager.class).isSnapshot(...)</code>
+ * @see org.apache.maven.api.services.VersionParser#isSnapshot(String)
+ */
+ boolean isVersionSnapshot( @Nonnull String version );
+
+ /**
+ * Shortcut for <code>getService(DependencyCollector.class).collect(...)</code>
+ * @see org.apache.maven.api.services.DependencyCollector#collect(Session, Artifact)
+ *
+ * @throws org.apache.maven.api.services.DependencyCollectorException if the dependency collection failed
+ */
+ @Nonnull
+ Node collectDependencies( @Nonnull Artifact artifact );
+
+ /**
+ * Shortcut for <code>getService(DependencyCollector.class).collect(...)</code>
+ * @see org.apache.maven.api.services.DependencyCollector#collect(Session, Project)
+ *
+ * @throws org.apache.maven.api.services.DependencyCollectorException if the dependency collection failed
+ */
+ @Nonnull
+ Node collectDependencies( @Nonnull Project project );
+
+ /**
+ * Shortcut for <code>getService(DependencyResolver.class).resolve(...)</code>
+ * @see org.apache.maven.api.services.DependencyCollector#collect(Session, DependencyCoordinate)
+ *
+ * @throws org.apache.maven.api.services.DependencyCollectorException if the dependency collection failed
+ */
+ @Nonnull
+ Node collectDependencies( @Nonnull DependencyCoordinate dependency );
+
+ Path getPathForLocalArtifact( @Nonnull Artifact artifact );
+
+ Path getPathForLocalMetadata( Metadata metadata );
+
+ Path getPathForRemoteArtifact( RemoteRepository remote, Artifact artifact );
+
+ Path getPathForRemoteMetadata( RemoteRepository remote, Metadata metadata );
+
+ /**
+ * Shortcut for <code>getService(VersionParser.class).parseVersion(...)</code>
+ * @see org.apache.maven.api.services.VersionParser#parseVersion(String)
+ *
+ * @throws org.apache.maven.api.services.VersionParserException if the parsing failed
+ */
+ @Nonnull
+ Version parseVersion( @Nonnull String version );
+
+ /**
+ * Shortcut for <code>getService(VersionParser.class).parseVersionRange(...)</code>
+ * @see org.apache.maven.api.services.VersionParser#parseVersionRange(String)
+ *
+ * @throws org.apache.maven.api.services.VersionParserException if the parsing failed
+ */
+ @Nonnull
+ VersionRange parseVersionRange( @Nonnull String versionRange );
+}
diff --git a/api/maven-api-core/src/main/java/org/apache/maven/api/SessionData.java b/api/maven-api-core/src/main/java/org/apache/maven/api/SessionData.java
new file mode 100644
index 000000000..8a8ef1940
--- /dev/null
+++ b/api/maven-api-core/src/main/java/org/apache/maven/api/SessionData.java
@@ -0,0 +1,86 @@
+package org.apache.maven.api;
+
+/*
+ * 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.
+ */
+
+import org.apache.maven.api.annotations.Experimental;
+import org.apache.maven.api.annotations.Nonnull;
+import org.apache.maven.api.annotations.Nullable;
+import org.apache.maven.api.annotations.Provider;
+import org.apache.maven.api.annotations.ThreadSafe;
+
+import java.util.function.Supplier;
+
+/**
+ * A container for data that is specific to a session.
+ * All components may use this storage to associate arbitrary data with a session.
+ * <p>
+ * Unlike a cache, this session data is not subject to purging. For this same reason, session data should also not be
+ * abused as a cache (i.e. for storing values that can be re-calculated) to avoid memory exhaustion.
+ * <p>
+ * <strong>Note:</strong> Actual implementations must be thread-safe.
+ *
+ * @see Session#getData()
+ * @since 4.0
+ */
+@Experimental
+@ThreadSafe @Provider
+public interface SessionData
+{
+
+ /**
+ * Associates the specified session data with the given key.
+ *
+ * @param key The key under which to store the session data, must not be {@code null}.
+ * @param value The data to associate with the key, may be {@code null} to remove the mapping.
+ */
+ void set( @Nonnull Object key, @Nullable Object value );
+
+ /**
+ * Associates the specified session data with the given key if the key is currently mapped to the given value. This
+ * method provides an atomic compare-and-update of some key's value.
+ *
+ * @param key The key under which to store the session data, must not be {@code null}.
+ * @param oldValue The expected data currently associated with the key, may be {@code null}.
+ * @param newValue The data to associate with the key, may be {@code null} to remove the mapping.
+ * @return {@code true} if the key mapping was successfully updated from the old value to the new value,
+ * {@code false} if the current key mapping didn't match the expected value and was not updated.
+ */
+ boolean set( @Nonnull Object key, @Nullable Object oldValue, @Nullable Object newValue );
+
+ /**
+ * Gets the session data associated with the specified key.
+ *
+ * @param key The key for which to retrieve the session data, must not be {@code null}.
+ * @return The session data associated with the key or {@code null} if none.
+ */
+ @Nullable
+ Object get( @Nonnull Object key );
+
+ /**
+ * Retrieve of compute the data associated with the specified key.
+ *
+ * @param key The key for which to retrieve the session data, must not be {@code null}.
+ * @param supplier The supplier will compute the new value.
+ * @return The session data associated with the key.
+ */
+ @Nullable
+ Object computeIfAbsent( @Nonnull Object key, @Nonnull Supplier<Object> supplier );
+
+}
diff --git a/api/maven-api-core/src/main/java/org/apache/maven/api/Toolchain.java b/api/maven-api-core/src/main/java/org/apache/maven/api/Toolchain.java
new file mode 100644
index 000000000..2f497194e
--- /dev/null
+++ b/api/maven-api-core/src/main/java/org/apache/maven/api/Toolchain.java
@@ -0,0 +1,56 @@
+package org.apache.maven.api;
+
+/*
+ * 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.
+ */
+
+import java.util.Map;
+
+import org.apache.maven.api.annotations.Experimental;
+
+/**
+ * Toolchain interface.
+ *
+ * @since 4.0
+ */
+@Experimental
+public interface Toolchain
+{
+ /**
+ * get the type of toolchain.
+ *
+ * @return the toolchain type
+ */
+ String getType();
+
+ /**
+ * Gets the platform tool executable.
+ *
+ * @param toolName the tool platform independent tool name.
+ * @return file representing the tool executable, or null if the tool can not be found
+ */
+ String findTool( String toolName );
+
+ /**
+ * Let the toolchain decide if it matches requirements defined
+ * in the toolchain plugin configuration.
+ * @param requirements Map<String, String> key value pair, may not be {@code null}
+ * @return {@code true} if the requirements match, otherwise {@code false}
+ */
+ boolean matchesRequirements( Map<String, String> requirements );
+}
\ No newline at end of file
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
new file mode 100644
index 000000000..71a94b2e2
--- /dev/null
+++ b/api/maven-api-core/src/main/java/org/apache/maven/api/Type.java
@@ -0,0 +1,72 @@
+package org.apache.maven.api;
+
+/*
+ * 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.
+ */
+
+import org.apache.maven.api.annotations.Experimental;
+import org.apache.maven.api.annotations.Immutable;
+
+/**
+ * An artifact's{@code Type} represents a known kind of artifacts.
+ * Such types are often associated to an extension and possibly
+ * a classifier, for example {@code java-source} has a {@code jar}
+ * extension and a {@code sources} classifier.
+ * It is also used to determine if a given dependency should be
+ * included in the classpath or if its transitive dependencies should.
+ *
+ * @since 4.0
+ */
+@Experimental
+@Immutable
+public interface Type
+{
+
+ String POM = "pom";
+ String JAR = "jar";
+ String JAVA_SOURCE = "java-source";
+ String JAVADOC = "javadoc";
+ String MAVEN_PLUGIN = "maven-plugin";
+ String TEST_JAR = "test-jar";
+
+ /**
+ * Returns the dependency type name.
+ *
+ * @return the type name
+ */
+ String getName();
+
+ /**
+ * Get the file extension associated to the file represented by the dependency type.
+ *
+ * @return the file extension
+ */
+ String getExtension();
+
+ /**
+ * Get the classifier associated to the dependency type.
+ *
+ * @return the classifier
+ */
+ String getClassifier();
+
+ boolean isIncludesDependencies();
+
+ boolean isAddedToClasspath();
+
+}
diff --git a/maven-settings-builder/src/main/java/org/apache/maven/settings/validation/SettingsValidator.java b/api/maven-api-core/src/main/java/org/apache/maven/api/Version.java
similarity index 56%
copy from maven-settings-builder/src/main/java/org/apache/maven/settings/validation/SettingsValidator.java
copy to api/maven-api-core/src/main/java/org/apache/maven/api/Version.java
index 79745ecaf..bf75f6c1d 100644
--- a/maven-settings-builder/src/main/java/org/apache/maven/settings/validation/SettingsValidator.java
+++ b/api/maven-api-core/src/main/java/org/apache/maven/api/Version.java
@@ -1,4 +1,4 @@
-package org.apache.maven.settings.validation;
+package org.apache.maven.api;
/*
* Licensed to the Apache Software Foundation (ASF) under one
@@ -19,23 +19,28 @@ package org.apache.maven.settings.validation;
* under the License.
*/
-import org.apache.maven.settings.Settings;
-import org.apache.maven.settings.building.SettingsProblemCollector;
+import org.apache.maven.api.annotations.Experimental;
+import org.apache.maven.api.annotations.Nonnull;
/**
- * Validate a model settings
+ * A version usually parsed using the {@link org.apache.maven.api.services.VersionParser} service.
*
- * @author Milos Kleint
+ * @since 4.0
+ * @see org.apache.maven.api.services.VersionParser#parseVersion(String)
+ * @see org.apache.maven.api.Session#parseVersion(String)
*/
-public interface SettingsValidator
+@Experimental
+public interface Version
+ extends Comparable<Version>
{
+ // TODO: add access to the version information
+
/**
- * Validate the specified settings.
- *
- * @param settings The settings to validate, must not be {@code null}.
- * @param problems The container used to collect problems that were encountered, must not be {@code null}.
+ * Returns a string representation of this version.
+ * @return the string representation of this version
*/
- void validate( Settings settings, SettingsProblemCollector problems );
+ @Nonnull
+ String asString();
}
diff --git a/maven-settings-builder/src/main/java/org/apache/maven/settings/validation/SettingsValidator.java b/api/maven-api-core/src/main/java/org/apache/maven/api/VersionRange.java
similarity index 53%
copy from maven-settings-builder/src/main/java/org/apache/maven/settings/validation/SettingsValidator.java
copy to api/maven-api-core/src/main/java/org/apache/maven/api/VersionRange.java
index 79745ecaf..fb3e39b2f 100644
--- a/maven-settings-builder/src/main/java/org/apache/maven/settings/validation/SettingsValidator.java
+++ b/api/maven-api-core/src/main/java/org/apache/maven/api/VersionRange.java
@@ -1,4 +1,4 @@
-package org.apache.maven.settings.validation;
+package org.apache.maven.api;
/*
* Licensed to the Apache Software Foundation (ASF) under one
@@ -19,23 +19,32 @@ package org.apache.maven.settings.validation;
* under the License.
*/
-import org.apache.maven.settings.Settings;
-import org.apache.maven.settings.building.SettingsProblemCollector;
+import org.apache.maven.api.annotations.Experimental;
+import org.apache.maven.api.annotations.Nonnull;
/**
- * Validate a model settings
+ * A range of versions.
*
- * @author Milos Kleint
+ * @since 4.0
*/
-public interface SettingsValidator
+@Experimental
+public interface VersionRange
{
+ // TODO: add access to the version information
+
/**
- * Validate the specified settings.
+ * Determines whether the specified version is contained within this range.
*
- * @param settings The settings to validate, must not be {@code null}.
- * @param problems The container used to collect problems that were encountered, must not be {@code null}.
+ * @param version The version to test, must not be {@code null}.
+ * @return {@code true} if this range contains the specified version, {@code false} otherwise.
*/
- void validate( Settings settings, SettingsProblemCollector problems );
+ boolean contains( @Nonnull Version version );
+ /**
+ * Returns a string representation of this version range
+ * @return the string representation of this version range
+ */
+ @Nonnull
+ String asString();
}
diff --git a/api/maven-api-core/src/main/java/org/apache/maven/api/plugin/Log.java b/api/maven-api-core/src/main/java/org/apache/maven/api/plugin/Log.java
new file mode 100644
index 000000000..f0eb2a660
--- /dev/null
+++ b/api/maven-api-core/src/main/java/org/apache/maven/api/plugin/Log.java
@@ -0,0 +1,168 @@
+package org.apache.maven.api.plugin;
+
+/*
+ * 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.
+ */
+
+import java.util.function.Supplier;
+
+/**
+ * This interface supplies the API for providing feedback to the user from the <code>Mojo</code>, using standard
+ * <code>Maven</code> channels.<br>
+ * There should be no big surprises here, although you may notice that the methods accept
+ * <code>java.lang.CharSequence</code> rather than <code>java.lang.String</code>. This is provided mainly as a
+ * convenience, to enable developers to pass things like <code>java.lang.StringBuffer</code> directly into the logger,
+ * rather than formatting first by calling <code>toString()</code>.
+ *
+ * @since 4.0
+ */
+public interface Log
+{
+ /**
+ * @return true if the <b>debug</b> error level is enabled
+ */
+ boolean isDebugEnabled();
+
+ /**
+ * Send a message to the user in the <b>debug</b> error level.
+ *
+ * @param content
+ */
+ void debug( CharSequence content );
+
+ /**
+ * Send a message (and accompanying exception) to the user in the <b>debug</b> error level.<br>
+ * The error's stacktrace will be output when this error level is enabled.
+ *
+ * @param content
+ * @param error
+ */
+ void debug( CharSequence content, Throwable error );
+
+ /**
+ * Send an exception to the user in the <b>debug</b> error level.<br>
+ * The stack trace for this exception will be output when this error level is enabled.
+ *
+ * @param error
+ */
+ void debug( Throwable error );
+
+ void debug( Supplier<String> content );
+
+ void debug( Supplier<String> content, Throwable error );
+
+ /**
+ * @return true if the <b>info</b> error level is enabled
+ */
+ boolean isInfoEnabled();
+
+ /**
+ * Send a message to the user in the <b>info</b> error level.
+ *
+ * @param content
+ */
+ void info( CharSequence content );
+
+ /**
+ * Send a message (and accompanying exception) to the user in the <b>info</b> error level.<br>
+ * The error's stacktrace will be output when this error level is enabled.
+ *
+ * @param content
+ * @param error
+ */
+ void info( CharSequence content, Throwable error );
+
+ /**
+ * Send an exception to the user in the <b>info</b> error level.<br>
+ * The stack trace for this exception will be output when this error level is enabled.
+ *
+ * @param error
+ */
+ void info( Throwable error );
+
+ void info( Supplier<String> content );
+
+ void info( Supplier<String> content, Throwable error );
+
+ /**
+ * @return true if the <b>warn</b> error level is enabled
+ */
+ boolean isWarnEnabled();
+
+ /**
+ * Send a message to the user in the <b>warn</b> error level.
+ *
+ * @param content
+ */
+ void warn( CharSequence content );
+
+ /**
+ * Send a message (and accompanying exception) to the user in the <b>warn</b> error level.<br>
+ * The error's stacktrace will be output when this error level is enabled.
+ *
+ * @param content
+ * @param error
+ */
+ void warn( CharSequence content, Throwable error );
+
+ /**
+ * Send an exception to the user in the <b>warn</b> error level.<br>
+ * The stack trace for this exception will be output when this error level is enabled.
+ *
+ * @param error
+ */
+ void warn( Throwable error );
+
+ void warn( Supplier<String> content );
+
+ void warn( Supplier<String> content, Throwable error );
+
+ /**
+ * @return true if the <b>error</b> error level is enabled
+ */
+ boolean isErrorEnabled();
+
+ /**
+ * Send a message to the user in the <b>error</b> error level.
+ *
+ * @param content
+ */
+ void error( CharSequence content );
+
+ /**
+ * Send a message (and accompanying exception) to the user in the <b>error</b> error level.<br>
+ * The error's stacktrace will be output when this error level is enabled.
+ *
+ * @param content
+ * @param error
+ */
+ void error( CharSequence content, Throwable error );
+
+ /**
+ * Send an exception to the user in the <b>error</b> error level.<br>
+ * The stack trace for this exception will be output when this error level is enabled.
+ *
+ * @param error
+ */
+ void error( Throwable error );
+
+ void error( Supplier<String> content );
+
+ void error( Supplier<String> content, Throwable error );
+
+}
diff --git a/maven-settings-builder/src/main/java/org/apache/maven/settings/validation/SettingsValidator.java b/api/maven-api-core/src/main/java/org/apache/maven/api/plugin/Mojo.java
similarity index 50%
copy from maven-settings-builder/src/main/java/org/apache/maven/settings/validation/SettingsValidator.java
copy to api/maven-api-core/src/main/java/org/apache/maven/api/plugin/Mojo.java
index 79745ecaf..a6217bff2 100644
--- a/maven-settings-builder/src/main/java/org/apache/maven/settings/validation/SettingsValidator.java
+++ b/api/maven-api-core/src/main/java/org/apache/maven/api/plugin/Mojo.java
@@ -1,4 +1,4 @@
-package org.apache.maven.settings.validation;
+package org.apache.maven.api.plugin;
/*
* Licensed to the Apache Software Foundation (ASF) under one
@@ -19,23 +19,28 @@ package org.apache.maven.settings.validation;
* under the License.
*/
-import org.apache.maven.settings.Settings;
-import org.apache.maven.settings.building.SettingsProblemCollector;
+import org.apache.maven.api.annotations.Consumer;
+import org.apache.maven.api.annotations.Experimental;
/**
- * Validate a model settings
+ * This interface forms the contract required for <code>Mojos</code> to interact with the <code>Maven</code>
+ * infrastructure.<br>
+ * It features an <code>execute()</code> method, which triggers the Mojo's build-process behavior, and can throw
+ * a MojoException if error conditions occur.<br>
*
- * @author Milos Kleint
+ * @since 4.0
*/
-public interface SettingsValidator
+@Experimental
+@FunctionalInterface @Consumer
+public interface Mojo
{
-
/**
- * Validate the specified settings.
+ * Perform whatever build-process behavior this <code>Mojo</code> implements.<br>
+ * This is the main trigger for the <code>Mojo</code> inside the <code>Maven</code> system, and allows
+ * the <code>Mojo</code> to communicate errors.
*
- * @param settings The settings to validate, must not be {@code null}.
- * @param problems The container used to collect problems that were encountered, must not be {@code null}.
+ * @throws MojoException if a problem occurs.
*/
- void validate( Settings settings, SettingsProblemCollector problems );
+ void execute();
}
diff --git a/api/maven-api-core/src/main/java/org/apache/maven/api/plugin/MojoException.java b/api/maven-api-core/src/main/java/org/apache/maven/api/plugin/MojoException.java
new file mode 100644
index 000000000..5e5b0c7ee
--- /dev/null
+++ b/api/maven-api-core/src/main/java/org/apache/maven/api/plugin/MojoException.java
@@ -0,0 +1,98 @@
+package org.apache.maven.api.plugin;
+
+/*
+ * 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.
+ */
+
+import org.apache.maven.api.annotations.Experimental;
+import org.apache.maven.api.services.MavenException;
+
+/**
+ * An exception occurring during the execution of a plugin.
+ *
+ * @since 4.0
+ */
+@Experimental
+public class MojoException
+ extends MavenException
+{
+
+ protected Object source;
+
+ protected String longMessage;
+
+ /**
+ * Construct a new <code>MojoExecutionException</code> exception providing the source and a short and long message:
+ * these messages are used to improve the message written at the end of Maven build.
+ */
+ public MojoException( Object source, String shortMessage, String longMessage )
+ {
+ super( shortMessage );
+ this.source = source;
+ this.longMessage = longMessage;
+ }
+
+ /**
+ * Construct a new <code>MojoExecutionException</code> exception wrapping an underlying <code>Exception</code>
+ * and providing a <code>message</code>.
+ */
+ public MojoException( String message, Exception cause )
+ {
+ super( message, cause );
+ }
+
+ /**
+ * Construct a new <code>MojoExecutionException</code> exception wrapping an underlying <code>Throwable</code>
+ * and providing a <code>message</code>.
+ */
+ public MojoException( String message, Throwable cause )
+ {
+ super( message, cause );
+ }
+
+ /**
+ * Construct a new <code>MojoExecutionException</code> exception providing a <code>message</code>.
+ */
+ public MojoException( String message )
+ {
+ super( message );
+ }
+
+ /**
+ * Constructs a new {@code MojoExecutionException} exception wrapping an underlying {@code Throwable}.
+ *
+ * @param cause the cause which is saved for later retrieval by the {@link #getCause()} method.
+ * A {@code null} value is permitted, and indicates that the cause is nonexistent or unknown.
+ * @since 3.8.3
+ */
+ public MojoException( Throwable cause )
+ {
+ super( cause );
+ }
+
+ public String getLongMessage()
+ {
+ return longMessage;
+ }
+
+ public Object getSource()
+ {
+ return source;
+ }
+
+}
diff --git a/api/maven-api-core/src/main/java/org/apache/maven/api/plugin/annotations/Component.java b/api/maven-api-core/src/main/java/org/apache/maven/api/plugin/annotations/Component.java
new file mode 100644
index 000000000..f963dfa98
--- /dev/null
+++ b/api/maven-api-core/src/main/java/org/apache/maven/api/plugin/annotations/Component.java
@@ -0,0 +1,56 @@
+package org.apache.maven.api.plugin.annotations;
+
+/*
+ * 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.
+ */
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Inherited;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+import org.apache.maven.api.annotations.Experimental;
+
+/**
+ * Used to configure injection of Plexus components by
+ * <a href="/ref/current/maven-core/apidocs/org/apache/maven/plugin/MavenPluginManager.html">
+ * <code>MavenPluginManager.getConfiguredMojo(...)</code></a>.
+ *
+ * @since 4.0
+ */
+@Experimental
+@Documented
+@Retention( RetentionPolicy.CLASS )
+@Target( { ElementType.FIELD, ElementType.METHOD, ElementType.PARAMETER } )
+@Inherited
+public @interface Component
+{
+ /**
+ * role of the component to inject.
+ * @return the role
+ */
+ Class<?> role() default Object.class;
+
+ /**
+ * hint of the component to inject.
+ * @return the hint
+ */
+ String hint() default "";
+}
diff --git a/api/maven-api-core/src/main/java/org/apache/maven/api/plugin/annotations/Execute.java b/api/maven-api-core/src/main/java/org/apache/maven/api/plugin/annotations/Execute.java
new file mode 100644
index 000000000..e4f870786
--- /dev/null
+++ b/api/maven-api-core/src/main/java/org/apache/maven/api/plugin/annotations/Execute.java
@@ -0,0 +1,64 @@
+package org.apache.maven.api.plugin.annotations;
+
+/*
+ * 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.
+ */
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Inherited;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+import org.apache.maven.api.annotations.Experimental;
+
+/**
+ * Used if your Mojo needs to fork a <a href="/ref/3.0.4/maven-core/lifecycles.html">lifecycle</a>.
+ *
+ * @since 4.0
+ */
+@Experimental
+@Documented
+@Retention( RetentionPolicy.CLASS )
+@Target( ElementType.TYPE )
+@Inherited
+public @interface Execute
+{
+ /**
+ * lifecycle phase to fork. Note that specifying a phase overrides specifying a goal.
+ * @return the phase
+ */
+ LifecyclePhase phase() default LifecyclePhase.NONE;
+
+ /**
+ * goal to fork. Note that specifying a phase overrides specifying a goal. The specified <code>goal</code> must be
+ * another goal of the same plugin.
+ * @return the goal
+ */
+ String goal() default "";
+
+ /**
+ * lifecycle id of the lifecycle that defines {@link #phase()}. Only valid in combination with {@link #phase()}. If
+ * not specified, Maven will use the lifecycle of the current build.
+ *
+ * @see <a href="https://maven.apache.org/maven-plugin-api/lifecycle-mappings.html">Lifecycle Mappings</a>
+ * @return the lifecycle id
+ */
+ String lifecycle() default "";
+}
diff --git a/maven-model-builder/src/test/java/org/apache/maven/model/interpolation/StringVisitorModelInterpolatorTest.java b/api/maven-api-core/src/main/java/org/apache/maven/api/plugin/annotations/InstantiationStrategy.java
similarity index 62%
copy from maven-model-builder/src/test/java/org/apache/maven/model/interpolation/StringVisitorModelInterpolatorTest.java
copy to api/maven-api-core/src/main/java/org/apache/maven/api/plugin/annotations/InstantiationStrategy.java
index 8fa92cecf..c5cfc75ec 100644
--- a/maven-model-builder/src/test/java/org/apache/maven/model/interpolation/StringVisitorModelInterpolatorTest.java
+++ b/api/maven-api-core/src/main/java/org/apache/maven/api/plugin/annotations/InstantiationStrategy.java
@@ -1,4 +1,4 @@
-package org.apache.maven.model.interpolation;
+package org.apache.maven.api.plugin.annotations;
/*
* Licensed to the Apache Software Foundation (ASF) under one
@@ -19,10 +19,30 @@ package org.apache.maven.model.interpolation;
* under the License.
*/
-public class StringVisitorModelInterpolatorTest extends AbstractModelInterpolatorTest
+import org.apache.maven.api.annotations.Experimental;
+
+/**
+ * Component instantiation strategy.
+ *
+ * @since 4.0
+ */
+@Experimental
+public enum InstantiationStrategy
{
- protected ModelInterpolator createInterpolator()
+ PER_LOOKUP( "per-lookup" ),
+ SINGLETON( "singleton" ),
+ KEEP_ALIVE( "keep-alive" ),
+ POOLABLE( "poolable" );
+
+ private final String id;
+
+ InstantiationStrategy( String id )
+ {
+ this.id = id;
+ }
+
+ public String id()
{
- return new StringVisitorModelInterpolator( null, null, new DefaultModelVersionProcessor() );
+ return this.id;
}
-}
\ No newline at end of file
+}
diff --git a/api/maven-api-core/src/main/java/org/apache/maven/api/plugin/annotations/LifecyclePhase.java b/api/maven-api-core/src/main/java/org/apache/maven/api/plugin/annotations/LifecyclePhase.java
new file mode 100644
index 000000000..84c567b4d
--- /dev/null
+++ b/api/maven-api-core/src/main/java/org/apache/maven/api/plugin/annotations/LifecyclePhase.java
@@ -0,0 +1,80 @@
+package org.apache.maven.api.plugin.annotations;
+
+/*
+ * 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.
+ */
+
+import org.apache.maven.api.annotations.Experimental;
+
+/**
+ * <a href="/ref/3.0.4/maven-core/lifecycles.html">Lifecycle phases</a>.
+ *
+ * @since 4.0
+ */
+@Experimental
+public enum LifecyclePhase
+{
+
+ VALIDATE( "validate" ),
+ INITIALIZE( "initialize" ),
+ GENERATE_SOURCES( "generate-sources" ),
+ PROCESS_SOURCES( "process-sources" ),
+ GENERATE_RESOURCES( "generate-resources" ),
+ PROCESS_RESOURCES( "process-resources" ),
+ COMPILE( "compile" ),
+ PROCESS_CLASSES( "process-classes" ),
+ GENERATE_TEST_SOURCES( "generate-test-sources" ),
+ PROCESS_TEST_SOURCES( "process-test-sources" ),
+ GENERATE_TEST_RESOURCES( "generate-test-resources" ),
+ PROCESS_TEST_RESOURCES( "process-test-resources" ),
+ TEST_COMPILE( "test-compile" ),
+ PROCESS_TEST_CLASSES( "process-test-classes" ),
+ TEST( "test" ),
+ PREPARE_PACKAGE( "prepare-package" ),
+ PACKAGE( "package" ),
+ PRE_INTEGRATION_TEST( "pre-integration-test" ),
+ INTEGRATION_TEST( "integration-test" ),
+ POST_INTEGRATION_TEST( "post-integration-test" ),
+ VERIFY( "verify" ),
+ INSTALL( "install" ),
+ DEPLOY( "deploy" ),
+
+ PRE_CLEAN( "pre-clean" ),
+ CLEAN( "clean" ),
+ POST_CLEAN( "post-clean" ),
+
+ PRE_SITE( "pre-site" ),
+ SITE( "site" ),
+ POST_SITE( "post-site" ),
+ SITE_DEPLOY( "site-deploy" ),
+
+ NONE( "" );
+
+ private final String id;
+
+ LifecyclePhase( String id )
+ {
+ this.id = id;
+ }
+
+ public String id()
+ {
+ return this.id;
+ }
+
+}
diff --git a/api/maven-api-core/src/main/java/org/apache/maven/api/plugin/annotations/Mojo.java b/api/maven-api-core/src/main/java/org/apache/maven/api/plugin/annotations/Mojo.java
new file mode 100644
index 000000000..e87341140
--- /dev/null
+++ b/api/maven-api-core/src/main/java/org/apache/maven/api/plugin/annotations/Mojo.java
@@ -0,0 +1,98 @@
+package org.apache.maven.api.plugin.annotations;
+
+/*
+ * 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.
+ */
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Inherited;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+import org.apache.maven.api.ResolutionScope;
+import org.apache.maven.api.annotations.Experimental;
+
+/**
+ * This annotation will mark your class as a Mojo (ie. goal in a Maven plugin).
+ *
+ * @since 4.0
+ */
+@Experimental
+@Documented
+@Retention( RetentionPolicy.CLASS )
+@Target( ElementType.TYPE )
+@Inherited
+public @interface Mojo
+{
+ /**
+ * goal name (required).
+ * @return the goal name
+ */
+ String name();
+
+ /**
+ * default phase to bind your mojo.
+ * @return the default phase
+ */
+ LifecyclePhase defaultPhase() default LifecyclePhase.NONE;
+
+ /**
+ * the required dependency resolution scope.
+ * @return the required dependency resolution scope
+ */
+ ResolutionScope requiresDependencyResolution() default ResolutionScope.NONE;
+
+ /**
+ * the required dependency collection scope.
+ * @return the required dependency collection scope
+ */
+ ResolutionScope requiresDependencyCollection() default ResolutionScope.NONE;
+
+ /**
+ * your Mojo instantiation strategy. (Only <code>per-lookup</code> and <code>singleton</code> are supported)
+ * @return the instantiation strategy
+ */
+ InstantiationStrategy instantiationStrategy() default InstantiationStrategy.PER_LOOKUP;
+
+ /**
+ * does your mojo requires a project to be executed?
+ * @return requires a project
+ */
+ boolean requiresProject() default true;
+
+ /**
+ * if the Mojo uses the Maven project and its child modules.
+ * @return uses the Maven project and its child modules
+ */
+ boolean aggregator() default false;
+
+ /**
+ * does this Mojo need to be online to be executed?
+ * @return need to be online
+ */
+ boolean requiresOnline() default false;
+
+ /**
+ * configurator bean name.
+ * @return the configurator bean name
+ */
+ String configurator() default "";
+
+}
diff --git a/api/maven-api-core/src/main/java/org/apache/maven/api/plugin/annotations/Parameter.java b/api/maven-api-core/src/main/java/org/apache/maven/api/plugin/annotations/Parameter.java
new file mode 100644
index 000000000..27ada3d2a
--- /dev/null
+++ b/api/maven-api-core/src/main/java/org/apache/maven/api/plugin/annotations/Parameter.java
@@ -0,0 +1,94 @@
+package org.apache.maven.api.plugin.annotations;
+
+/*
+ * 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.
+ */
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Inherited;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+import org.apache.maven.api.annotations.Experimental;
+
+/**
+ * Used to configure your Mojo parameters to be injected by
+ * <a href="/ref/current/maven-core/apidocs/org/apache/maven/plugin/MavenPluginManager.html">
+ * <code>MavenPluginManager.getConfiguredMojo(...)</code></a>.
+ * <p>
+ * Beans injected into Mojo parameters are prepared by <a href="https://www.eclipse.org/sisu/">Sisu</a> JSR330-based
+ * container: this annotation is only effective on fields of the Mojo class itself, nested bean injection
+ * requires Sisu or JSR330 annotations.
+ *
+ * @since 4.0
+ */
+@Experimental
+@Documented
+@Retention( RetentionPolicy.CLASS )
+@Target( { ElementType.FIELD, ElementType.METHOD } )
+@Inherited
+public @interface Parameter
+{
+ /**
+ * name of the bean property used to get/set the field: by default, field name is used.
+ * @return the name of the bean property
+ */
+ String name() default "";
+
+ /**
+ * alias supported to get parameter value.
+ * @return the alias
+ */
+ String alias() default "";
+
+ /**
+ * Property to use to retrieve a value. Can come from <code>-D</code> execution, setting properties or pom
+ * properties.
+ * @return property name
+ */
+ String property() default "";
+
+ /**
+ * parameter default value, may contain <code>${...}</code> expressions which will be interpreted at
+ * inject time: see
+ * <a href="/ref/current/maven-core/apidocs/org/apache/maven/plugin/PluginParameterExpressionEvaluator.html">
+ * PluginParameterExpressionEvaluator</a>.
+ * @return the default value
+ */
+ String defaultValue() default "";
+
+ /**
+ * is the parameter required?
+ * @return <code>true</code> if the Mojo should fail when the parameter cannot be injected
+ */
+ boolean required() default false;
+
+ /**
+ * Specifies that this parameter cannot be configured directly by the user (as in the case of POM-specified
+ * configuration). This is useful when you want to force the user to use common POM elements rather than plugin
+ * configurations, as in the case where you want to use the artifact's final name as a parameter. In this case, you
+ * want the user to modify <code><build><finalName/></build></code> rather than specifying a value
+ * for finalName directly in the plugin configuration section. It is also useful to ensure that - for example - a
+ * List-typed parameter which expects items of type Artifact doesn't get a List full of Strings.
+ *
+ * @return <code>true</code> if the user should not be allowed to configure the parameter directly
+ */
+ boolean readonly() default false;
+}
diff --git a/api/maven-api-core/src/main/java/org/apache/maven/api/services/ArtifactCoordinateFactory.java b/api/maven-api-core/src/main/java/org/apache/maven/api/services/ArtifactCoordinateFactory.java
new file mode 100644
index 000000000..a1da37134
--- /dev/null
+++ b/api/maven-api-core/src/main/java/org/apache/maven/api/services/ArtifactCoordinateFactory.java
@@ -0,0 +1,71 @@
+package org.apache.maven.api.services;
+
+/*
+ * 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.
+ */
+
+import org.apache.maven.api.Artifact;
+import org.apache.maven.api.ArtifactCoordinate;
+import org.apache.maven.api.Service;
+import org.apache.maven.api.Session;
+import org.apache.maven.api.annotations.Experimental;
+import org.apache.maven.api.annotations.Nonnull;
+
+/**
+ * Service used to create {@link ArtifactCoordinate} objects.
+ *
+ * @since 4.0
+ */
+@Experimental
+public interface ArtifactCoordinateFactory extends Service
+{
+
+ /**
+ * Creates a coordinate.
+ *
+ * @param request the request holding coordinate creation parameters
+ * @return an {@code Artifact}, never {@code null}
+ * @throws IllegalArgumentException if {@code request} is null or {@code request.session} is null or invalid
+ */
+ @Nonnull
+ ArtifactCoordinate create( @Nonnull ArtifactCoordinateFactoryRequest request );
+
+ @Nonnull
+ default ArtifactCoordinate create( @Nonnull Session session, String groupId,
+ String artifactId, String version, String extension )
+ {
+ return create( ArtifactCoordinateFactoryRequest.build( session, groupId, artifactId, version, extension ) );
+ }
+
+ @Nonnull
+ default ArtifactCoordinate create( @Nonnull Session session, String groupId, String artifactId, String version,
+ String classifier, String extension, String type )
+ {
+ return create( ArtifactCoordinateFactoryRequest.build( session, groupId, artifactId,
+ version, classifier, extension, type ) );
+ }
+
+ @Nonnull
+ default ArtifactCoordinate create( @Nonnull Session session, Artifact artifact )
+ {
+ return create( ArtifactCoordinateFactoryRequest.build( session,
+ artifact.getGroupId(), artifact.getArtifactId(), artifact.getVersion().asString(),
+ artifact.getClassifier(), artifact.getExtension(), null ) );
+ }
+
+}
diff --git a/api/maven-api-core/src/main/java/org/apache/maven/api/services/ArtifactCoordinateFactoryRequest.java b/api/maven-api-core/src/main/java/org/apache/maven/api/services/ArtifactCoordinateFactoryRequest.java
new file mode 100644
index 000000000..8c8b9af06
--- /dev/null
+++ b/api/maven-api-core/src/main/java/org/apache/maven/api/services/ArtifactCoordinateFactoryRequest.java
@@ -0,0 +1,222 @@
+package org.apache.maven.api.services;
+
+/*
+ * 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.
+ */
+
+import org.apache.maven.api.ArtifactCoordinate;
+import org.apache.maven.api.Session;
+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.NotThreadSafe;
+
+/**
+ * A request for creating a {@link ArtifactCoordinate} object.
+ *
+ * @since 4.0
+ */
+@Experimental
+@Immutable
+public interface ArtifactCoordinateFactoryRequest
+{
+
+ @Nonnull
+ Session getSession();
+
+ String getGroupId();
+
+ String getArtifactId();
+
+ String getVersion();
+
+ String getClassifier();
+
+ String getExtension();
+
+ String getType();
+
+ static ArtifactCoordinateFactoryRequest build( Session session, String groupId, String artifactId,
+ String version, String extension )
+ {
+ return ArtifactCoordinateFactoryRequest.builder()
+ .session( session )
+ .groupId( groupId )
+ .artifactId( artifactId )
+ .version( version )
+ .extension( extension )
+ .build();
+ }
+
+ static ArtifactCoordinateFactoryRequest build( Session session, String groupId, String artifactId,
+ String version, String classifier, String extension, String type )
+ {
+ return ArtifactCoordinateFactoryRequest.builder()
+ .session( session )
+ .groupId( groupId )
+ .artifactId( artifactId )
+ .version( version )
+ .classifier( classifier )
+ .extension( extension )
+ .type( type )
+ .build();
+ }
+
+ static ArtifactCoordinateFactoryRequest build( Session session, ArtifactCoordinate coordinate )
+ {
+ return ArtifactCoordinateFactoryRequest.builder()
+ .session( session )
+ .groupId( coordinate.getGroupId() )
+ .artifactId( coordinate.getArtifactId() )
+ .classifier( coordinate.getClassifier() )
+ .version( coordinate.getVersion().asString() )
+ .extension( coordinate.getExtension() )
+ .build();
+ }
+
+
+ static ArtifactFactoryRequestBuilder builder()
+ {
+ return new ArtifactFactoryRequestBuilder();
+ }
+
+ @NotThreadSafe
+ class ArtifactFactoryRequestBuilder
+ {
+ private Session session;
+ private String groupId;
+ private String artifactId;
+ private String version;
+ private String classifier;
+ private String extension;
+ private String type;
+
+ public ArtifactFactoryRequestBuilder session( Session session )
+ {
+ this.session = session;
+ return this;
+ }
+
+ public ArtifactFactoryRequestBuilder groupId( String groupId )
+ {
+ this.groupId = groupId;
+ return this;
+ }
+
+ public ArtifactFactoryRequestBuilder artifactId( String artifactId )
+ {
+ this.artifactId = artifactId;
+ return this;
+ }
+
+ public ArtifactFactoryRequestBuilder version( String version )
+ {
+ this.version = version;
+ return this;
+ }
+
+ public ArtifactFactoryRequestBuilder classifier( String classifier )
+ {
+ this.classifier = classifier;
+ return this;
+ }
+
+ public ArtifactFactoryRequestBuilder extension( String extension )
+ {
+ this.extension = extension;
+ return this;
+ }
+
+ public ArtifactFactoryRequestBuilder type( String type )
+ {
+ this.type = type;
+ return this;
+ }
+
+ public ArtifactCoordinateFactoryRequest build()
+ {
+ return new DefaultArtifactFactoryRequestArtifact( session, groupId, artifactId, version,
+ classifier, extension, type );
+ }
+
+ private static class DefaultArtifactFactoryRequestArtifact extends BaseRequest implements
+ ArtifactCoordinateFactoryRequest
+ {
+ private final String groupId;
+ private final String artifactId;
+ private final String version;
+ private final String classifier;
+ private final String extension;
+ private final String type;
+
+ DefaultArtifactFactoryRequestArtifact( @Nonnull Session session,
+ String groupId,
+ String artifactId,
+ String version,
+ String classifier,
+ String extension,
+ String type )
+ {
+ super( session );
+ this.groupId = groupId;
+ this.artifactId = artifactId;
+ this.version = version;
+ this.classifier = classifier;
+ this.extension = extension;
+ this.type = type;
+ }
+
+ @Override
+ public String getGroupId()
+ {
+ return groupId;
+ }
+
+ @Override
+ public String getArtifactId()
+ {
+ return artifactId;
+ }
+
+ @Override
+ public String getVersion()
+ {
+ return version;
+ }
+
+ @Override
+ public String getClassifier()
+ {
+ return classifier;
+ }
+
+ @Override
+ public String getExtension()
+ {
+ return extension;
+ }
+
+ @Override
+ public String getType()
+ {
+ return type;
+ }
+ }
+ }
+
+}
diff --git a/api/maven-api-core/src/main/java/org/apache/maven/api/services/ArtifactDeployer.java b/api/maven-api-core/src/main/java/org/apache/maven/api/services/ArtifactDeployer.java
new file mode 100644
index 000000000..38c243dbe
--- /dev/null
+++ b/api/maven-api-core/src/main/java/org/apache/maven/api/services/ArtifactDeployer.java
@@ -0,0 +1,61 @@
+package org.apache.maven.api.services;
+
+/*
+ * 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.
+ */
+
+import java.util.Collection;
+
+import org.apache.maven.api.Service;
+import org.apache.maven.api.Session;
+import org.apache.maven.api.Artifact;
+import org.apache.maven.api.RemoteRepository;
+import org.apache.maven.api.annotations.Experimental;
+import org.apache.maven.api.annotations.Nonnull;
+
+/**
+ * Deploys {@link Artifact}s to a {@link RemoteRepository}.
+ *
+ * @since 4.0
+ * @see Session#deployArtifact(RemoteRepository, Artifact...)
+ */
+@Experimental
+public interface ArtifactDeployer extends Service
+{
+
+ /**
+ * @param request {@link ArtifactDeployerRequest}
+ * @throws ArtifactDeployerException if the deployment failed
+ */
+ void deploy( @Nonnull ArtifactDeployerRequest request );
+
+ /**
+ * @param session the repository session
+ * @param repository the repository to deploy to
+ * @param artifacts the collection of artifacts to deploy
+ * @throws ArtifactDeployerException if the deployment failed
+ * @throws IllegalArgumentException if an argument is {@code null} or invalid
+ */
+ default void deploy( @Nonnull Session session,
+ @Nonnull RemoteRepository repository,
+ @Nonnull Collection<Artifact> artifacts )
+ {
+ deploy( ArtifactDeployerRequest.build( session, repository, artifacts ) );
+ }
+
+}
diff --git a/maven-settings-builder/src/main/java/org/apache/maven/settings/validation/SettingsValidator.java b/api/maven-api-core/src/main/java/org/apache/maven/api/services/ArtifactDeployerException.java
similarity index 60%
copy from maven-settings-builder/src/main/java/org/apache/maven/settings/validation/SettingsValidator.java
copy to api/maven-api-core/src/main/java/org/apache/maven/api/services/ArtifactDeployerException.java
index 79745ecaf..fbb206a53 100644
--- a/maven-settings-builder/src/main/java/org/apache/maven/settings/validation/SettingsValidator.java
+++ b/api/maven-api-core/src/main/java/org/apache/maven/api/services/ArtifactDeployerException.java
@@ -1,4 +1,4 @@
-package org.apache.maven.settings.validation;
+package org.apache.maven.api.services;
/*
* Licensed to the Apache Software Foundation (ASF) under one
@@ -19,23 +19,30 @@ package org.apache.maven.settings.validation;
* under the License.
*/
-import org.apache.maven.settings.Settings;
-import org.apache.maven.settings.building.SettingsProblemCollector;
+import org.apache.maven.api.annotations.Experimental;
/**
- * Validate a model settings
+ * An artifact could not correctly being deployed.
*
- * @author Milos Kleint
+ * @since 4.0
*/
-public interface SettingsValidator
+@Experimental
+public class ArtifactDeployerException
+ extends MavenException
{
/**
- * Validate the specified settings.
- *
- * @param settings The settings to validate, must not be {@code null}.
- * @param problems The container used to collect problems that were encountered, must not be {@code null}.
+ *
*/
- void validate( Settings settings, SettingsProblemCollector problems );
+ private static final long serialVersionUID = 7421964724059077698L;
+
+ /**
+ * @param message The message of the error.
+ * @param e {@link Exception}
+ */
+ public ArtifactDeployerException( String message, Exception e )
+ {
+ super( message, e );
+ }
}
diff --git a/api/maven-api-core/src/main/java/org/apache/maven/api/services/ArtifactDeployerRequest.java b/api/maven-api-core/src/main/java/org/apache/maven/api/services/ArtifactDeployerRequest.java
new file mode 100644
index 000000000..a87c0fbfc
--- /dev/null
+++ b/api/maven-api-core/src/main/java/org/apache/maven/api/services/ArtifactDeployerRequest.java
@@ -0,0 +1,153 @@
+package org.apache.maven.api.services;
+
+/*
+ * 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.
+ */
+
+import org.apache.maven.api.annotations.Experimental;
+import org.apache.maven.api.annotations.Immutable;
+import org.apache.maven.api.annotations.Nonnull;
+
+import java.util.Collection;
+
+import org.apache.maven.api.Session;
+import org.apache.maven.api.Artifact;
+import org.apache.maven.api.RemoteRepository;
+
+import static org.apache.maven.api.services.BaseRequest.nonNull;
+
+/**
+ * A request for deploying one or more artifacts to a remote repository.
+ *
+ * @since 4.0
+ */
+@Experimental
+@Immutable
+public interface ArtifactDeployerRequest
+{
+
+ @Nonnull
+ Session getSession();
+
+ @Nonnull
+ RemoteRepository getRepository();
+
+ @Nonnull
+ Collection<Artifact> getArtifacts();
+
+ int getRetryFailedDeploymentCount();
+
+ @Nonnull
+ static ArtifactDeployerRequestBuilder builder()
+ {
+ return new ArtifactDeployerRequestBuilder();
+ }
+
+ @Nonnull
+ static ArtifactDeployerRequest build( @Nonnull Session session,
+ @Nonnull RemoteRepository repository,
+ @Nonnull Collection<Artifact> artifacts )
+ {
+ return builder()
+ .session( nonNull( session, "session can not be null" ) )
+ .repository( repository )
+ .artifacts( artifacts )
+ .build();
+ }
+
+ class ArtifactDeployerRequestBuilder
+ {
+ Session session;
+ RemoteRepository repository;
+ Collection<Artifact> artifacts;
+ int retryFailedDeploymentCount;
+
+ @Nonnull
+ public ArtifactDeployerRequestBuilder session( Session session )
+ {
+ this.session = session;
+ return this;
+ }
+
+ @Nonnull
+ public ArtifactDeployerRequestBuilder repository( RemoteRepository repository )
+ {
+ this.repository = repository;
+ return this;
+ }
+
+ public ArtifactDeployerRequestBuilder artifacts( Collection<Artifact> artifacts )
+ {
+ this.artifacts = artifacts;
+ return this;
+ }
+
+ public ArtifactDeployerRequestBuilder retryFailedDeploymentCount( int retryFailedDeploymentCount )
+ {
+ this.retryFailedDeploymentCount = retryFailedDeploymentCount;
+ return this;
+ }
+
+ @Nonnull
+ public ArtifactDeployerRequest build()
+ {
+ return new DefaultArtifactDeployerRequest( session, repository, artifacts, retryFailedDeploymentCount );
+ }
+
+ private static class DefaultArtifactDeployerRequest extends BaseRequest
+ implements ArtifactDeployerRequest
+ {
+
+ private final RemoteRepository repository;
+ private final Collection<Artifact> artifacts;
+ private final int retryFailedDeploymentCount;
+
+ DefaultArtifactDeployerRequest( @Nonnull Session session,
+ @Nonnull RemoteRepository repository,
+ @Nonnull Collection<Artifact> artifacts,
+ int retryFailedDeploymentCount )
+ {
+ super( session );
+ this.repository = nonNull( repository, "repository can not be null" );
+ this.artifacts = nonNull( artifacts, "artifacts can not be null" );
+ this.retryFailedDeploymentCount = retryFailedDeploymentCount;
+ }
+
+ @Nonnull
+ @Override
+ public RemoteRepository getRepository()
+ {
+ return repository;
+ }
+
+ @Nonnull
+ @Override
+ public Collection<Artifact> getArtifacts()
+ {
+ return artifacts;
+ }
+
+ @Override
+ public int getRetryFailedDeploymentCount()
+ {
+ return retryFailedDeploymentCount;
+ }
+ }
+
+ }
+}
diff --git a/api/maven-api-core/src/main/java/org/apache/maven/api/services/ArtifactFactory.java b/api/maven-api-core/src/main/java/org/apache/maven/api/services/ArtifactFactory.java
new file mode 100644
index 000000000..c9f2095aa
--- /dev/null
+++ b/api/maven-api-core/src/main/java/org/apache/maven/api/services/ArtifactFactory.java
@@ -0,0 +1,61 @@
+package org.apache.maven.api.services;
+
+/*
+ * 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.
+ */
+
+import org.apache.maven.api.Service;
+import org.apache.maven.api.Session;
+import org.apache.maven.api.Artifact;
+import org.apache.maven.api.annotations.Experimental;
+import org.apache.maven.api.annotations.Nonnull;
+
+/**
+ * Service used to create {@link Artifact} objects.
+ *
+ * @since 4.0
+ */
+@Experimental
+public interface ArtifactFactory extends Service
+{
+
+ /**
+ * Creates an artifact.
+ *
+ * @param request the request holding artifact creation parameters
+ * @return an {@code Artifact}, never {@code null}
+ * @throws IllegalArgumentException if {@code request} is null or {@code request.session} is null or invalid
+ */
+ @Nonnull
+ Artifact create( @Nonnull ArtifactFactoryRequest request );
+
+ @Nonnull
+ default Artifact create( @Nonnull Session session, String groupId,
+ String artifactId, String version, String extension )
+ {
+ return create( ArtifactFactoryRequest.build( session, groupId, artifactId, version, extension ) );
+ }
+
+ @Nonnull
+ default Artifact create( @Nonnull Session session, String groupId, String artifactId, String version,
+ String classifier, String extension, String type )
+ {
+ return create( ArtifactFactoryRequest.build( session, groupId, artifactId,
+ version, classifier, extension, type ) );
+ }
+}
diff --git a/api/maven-api-core/src/main/java/org/apache/maven/api/services/ArtifactFactoryRequest.java b/api/maven-api-core/src/main/java/org/apache/maven/api/services/ArtifactFactoryRequest.java
new file mode 100644
index 000000000..eb7e3f96c
--- /dev/null
+++ b/api/maven-api-core/src/main/java/org/apache/maven/api/services/ArtifactFactoryRequest.java
@@ -0,0 +1,208 @@
+package org.apache.maven.api.services;
+
+/*
+ * 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.
+ */
+
+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.Session;
+import org.apache.maven.api.annotations.NotThreadSafe;
+
+/**
+ *
+ *
+ * @since 4.0
+ */
+@Experimental
+@Immutable
+public interface ArtifactFactoryRequest
+{
+
+ @Nonnull
+ Session getSession();
+
+ String getGroupId();
+
+ String getArtifactId();
+
+ String getVersion();
+
+ String getClassifier();
+
+ String getExtension();
+
+ String getType();
+
+ static ArtifactFactoryRequest build( Session session, String groupId, String artifactId,
+ String version, String extension )
+ {
+ return ArtifactFactoryRequest.builder()
+ .session( session )
+ .groupId( groupId )
+ .artifactId( artifactId )
+ .version( version )
+ .extension( extension )
+ .build();
+ }
+
+ static ArtifactFactoryRequest build( Session session, String groupId, String artifactId,
+ String version, String classifier, String extension, String type )
+ {
+ return ArtifactFactoryRequest.builder()
+ .session( session )
+ .groupId( groupId )
+ .artifactId( artifactId )
+ .version( version )
+ .classifier( classifier )
+ .extension( extension )
+ .type( type )
+ .build();
+ }
+
+ static ArtifactFactoryRequestBuilder builder()
+ {
+ return new ArtifactFactoryRequestBuilder();
+ }
+
+ @NotThreadSafe
+ class ArtifactFactoryRequestBuilder
+ {
+ private Session session;
+ private String groupId;
+ private String artifactId;
+ private String version;
+ private String classifier;
+ private String extension;
+ private String type;
+
+ public ArtifactFactoryRequestBuilder session( Session session )
+ {
+ this.session = session;
+ return this;
+ }
+
+ public ArtifactFactoryRequestBuilder groupId( String groupId )
+ {
+ this.groupId = groupId;
+ return this;
+ }
+
+ public ArtifactFactoryRequestBuilder artifactId( String artifactId )
+ {
+ this.artifactId = artifactId;
+ return this;
+ }
+
+ public ArtifactFactoryRequestBuilder version( String version )
+ {
+ this.version = version;
+ return this;
+ }
+
+ public ArtifactFactoryRequestBuilder classifier( String classifier )
+ {
+ this.classifier = classifier;
+ return this;
+ }
+
+ public ArtifactFactoryRequestBuilder extension( String extension )
+ {
+ this.extension = extension;
+ return this;
+ }
+
+ public ArtifactFactoryRequestBuilder type( String type )
+ {
+ this.type = type;
+ return this;
+ }
+
+ public ArtifactFactoryRequest build()
+ {
+ return new DefaultArtifactFactoryRequest( session, groupId, artifactId, version,
+ classifier, extension, type );
+ }
+
+ private static class DefaultArtifactFactoryRequest extends BaseRequest implements ArtifactFactoryRequest
+ {
+ private final String groupId;
+ private final String artifactId;
+ private final String version;
+ private final String classifier;
+ private final String extension;
+ private final String type;
+
+ DefaultArtifactFactoryRequest( @Nonnull Session session,
+ String groupId,
+ String artifactId,
+ String version,
+ String classifier,
+ String extension,
+ String type )
+ {
+ super( session );
+ this.groupId = groupId;
+ this.artifactId = artifactId;
+ this.version = version;
+ this.classifier = classifier;
+ this.extension = extension;
+ this.type = type;
+ }
+
+ @Override
+ public String getGroupId()
+ {
+ return groupId;
+ }
+
+ @Override
+ public String getArtifactId()
+ {
+ return artifactId;
+ }
+
+ @Override
+ public String getVersion()
+ {
+ return version;
+ }
+
+ @Override
+ public String getClassifier()
+ {
+ return classifier;
+ }
+
+ @Override
+ public String getExtension()
+ {
+ return extension;
+ }
+
+ @Override
+ public String getType()
+ {
+ return type;
+ }
+ }
+ }
+
+}
diff --git a/api/maven-api-core/src/main/java/org/apache/maven/api/services/ArtifactInstaller.java b/api/maven-api-core/src/main/java/org/apache/maven/api/services/ArtifactInstaller.java
new file mode 100644
index 000000000..5b07a88f8
--- /dev/null
+++ b/api/maven-api-core/src/main/java/org/apache/maven/api/services/ArtifactInstaller.java
@@ -0,0 +1,74 @@
+package org.apache.maven.api.services;
+
+/*
+ * 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.
+ */
+
+import java.util.Collection;
+import java.util.Collections;
+
+import org.apache.maven.api.Service;
+import org.apache.maven.api.Session;
+import org.apache.maven.api.Artifact;
+import org.apache.maven.api.annotations.Experimental;
+
+/**
+ * Installs {@link Artifact}s to the local repository.
+ *
+ * @since 4.0
+ * @see Session#withLocalRepository(org.apache.maven.api.LocalRepository)
+ */
+@Experimental
+public interface ArtifactInstaller extends Service
+{
+ /**
+ * @param request {@link ArtifactInstallerRequest}
+ * @throws ArtifactInstallerException in case of an error.
+ * @throws IllegalArgumentException in case {@code request} is {@code null}.
+ */
+ void install( ArtifactInstallerRequest request );
+
+ /**
+ * @param session the repository session
+ * @param artifact the {@link Artifact} to install
+ * @throws ArtifactInstallerException In case of an error which can be the a given artifact can not be found or the
+ * installation has failed.
+ * @throws IllegalArgumentException in case of parameter {@code session} is {@code null} or
+ * {@code artifact} is {@code null}.
+ */
+ default void install( Session session, Artifact artifact )
+ {
+ install( session, Collections.singletonList( artifact ) );
+ }
+
+ /**
+ * @param session the repository session
+ * @param artifacts Collection of {@link Artifact MavenArtifacts}
+ * @throws ArtifactInstallerException In case of an error which can be the a given artifact can not be found or the
+ * installation has failed.
+ * @throws IllegalArgumentException in case of parameter {@code request} is {@code null} or parameter
+ * {@code localRepository} is {@code null} or {@code localRepository} is not a directory
+ * or parameter {@code mavenArtifacts} is {@code null} or
+ * {@code mavenArtifacts.isEmpty()} is {@code true}.
+ */
+ default void install( Session session, Collection<Artifact> artifacts )
+ {
+ install( ArtifactInstallerRequest.build( session, artifacts ) );
+ }
+
+}
diff --git a/maven-settings-builder/src/main/java/org/apache/maven/settings/validation/SettingsValidator.java b/api/maven-api-core/src/main/java/org/apache/maven/api/services/ArtifactInstallerException.java
similarity index 60%
copy from maven-settings-builder/src/main/java/org/apache/maven/settings/validation/SettingsValidator.java
copy to api/maven-api-core/src/main/java/org/apache/maven/api/services/ArtifactInstallerException.java
index 79745ecaf..e6c6dc6ab 100644
--- a/maven-settings-builder/src/main/java/org/apache/maven/settings/validation/SettingsValidator.java
+++ b/api/maven-api-core/src/main/java/org/apache/maven/api/services/ArtifactInstallerException.java
@@ -1,4 +1,4 @@
-package org.apache.maven.settings.validation;
+package org.apache.maven.api.services;
/*
* Licensed to the Apache Software Foundation (ASF) under one
@@ -19,23 +19,28 @@ package org.apache.maven.settings.validation;
* under the License.
*/
-import org.apache.maven.settings.Settings;
-import org.apache.maven.settings.building.SettingsProblemCollector;
+import org.apache.maven.api.annotations.Experimental;
/**
- * Validate a model settings
- *
- * @author Milos Kleint
+ * @since 4.0
*/
-public interface SettingsValidator
+@Experimental
+public class ArtifactInstallerException
+ extends MavenException
{
/**
- * Validate the specified settings.
- *
- * @param settings The settings to validate, must not be {@code null}.
- * @param problems The container used to collect problems that were encountered, must not be {@code null}.
+ *
+ */
+ private static final long serialVersionUID = 3652561971360586373L;
+
+ /**
+ * @param message The message of the error.
+ * @param e {@link Exception}
*/
- void validate( Settings settings, SettingsProblemCollector problems );
+ public ArtifactInstallerException( String message, Exception e )
+ {
+ super( message, e );
+ }
}
diff --git a/api/maven-api-core/src/main/java/org/apache/maven/api/services/ArtifactInstallerRequest.java b/api/maven-api-core/src/main/java/org/apache/maven/api/services/ArtifactInstallerRequest.java
new file mode 100644
index 000000000..772203a85
--- /dev/null
+++ b/api/maven-api-core/src/main/java/org/apache/maven/api/services/ArtifactInstallerRequest.java
@@ -0,0 +1,113 @@
+package org.apache.maven.api.services;
+
+/*
+ * 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.
+ */
+
+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.NotThreadSafe;
+import org.apache.maven.api.annotations.Nullable;
+
+import java.util.Collection;
+import java.util.Collections;
+
+import org.apache.maven.api.Session;
+import org.apache.maven.api.Artifact;
+
+/**
+ * A request for installing one or more artifacts in the local repository.
+ *
+ * @since 4.0
+ */
+@Experimental
+@Immutable
+public interface ArtifactInstallerRequest
+{
+
+ @Nonnull
+ Session getSession();
+
+ @Nonnull
+ Collection<Artifact> getArtifacts();
+
+ @Nonnull
+ static ArtifactInstallerRequestBuilder builder()
+ {
+ return new ArtifactInstallerRequestBuilder();
+ }
+
+ @Nonnull
+ static ArtifactInstallerRequest build( Session session, Collection<Artifact> artifacts )
+ {
+ return builder()
+ .session( session )
+ .artifacts( artifacts )
+ .build();
+ }
+
+ @NotThreadSafe
+ class ArtifactInstallerRequestBuilder
+ {
+ Session session;
+ Collection<Artifact> artifacts = Collections.emptyList();
+
+ @Nonnull
+ public ArtifactInstallerRequestBuilder session( @Nonnull Session session )
+ {
+ this.session = session;
+ return this;
+ }
+
+ @Nonnull
+ public ArtifactInstallerRequestBuilder artifacts( @Nullable Collection<Artifact> artifacts )
+ {
+ this.artifacts = artifacts != null ? artifacts : Collections.emptyList();
+ return this;
+ }
+
+ @Nonnull
+ public ArtifactInstallerRequest build()
+ {
+ return new DefaultArtifactInstallerRequest( session, artifacts );
+ }
+
+ static class DefaultArtifactInstallerRequest extends BaseRequest
+ implements ArtifactInstallerRequest
+ {
+
+ private final Collection<Artifact> artifacts;
+
+ DefaultArtifactInstallerRequest( @Nonnull Session session,
+ @Nonnull Collection<Artifact> artifacts )
+ {
+ super( session );
+ this.artifacts = nonNull( artifacts, "artifacts can not be null" );
+ }
+
+ @Nonnull
+ @Override
+ public Collection<Artifact> getArtifacts()
+ {
+ return artifacts;
+ }
+ }
+ }
+
+}
diff --git a/api/maven-api-core/src/main/java/org/apache/maven/api/services/ArtifactManager.java b/api/maven-api-core/src/main/java/org/apache/maven/api/services/ArtifactManager.java
new file mode 100644
index 000000000..4fa771343
--- /dev/null
+++ b/api/maven-api-core/src/main/java/org/apache/maven/api/services/ArtifactManager.java
@@ -0,0 +1,64 @@
+package org.apache.maven.api.services;
+
+/*
+ * 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.
+ */
+
+import org.apache.maven.api.Service;
+import org.apache.maven.api.annotations.Experimental;
+import org.apache.maven.api.annotations.Nonnull;
+
+import java.nio.file.Path;
+import java.util.Collection;
+import java.util.Optional;
+
+import org.apache.maven.api.Artifact;
+import org.apache.maven.api.Metadata;
+
+/**
+ *
+ * @since 4.0
+ */
+@Experimental
+public interface ArtifactManager extends Service
+{
+
+ /**
+ * Returns the path of the file previously associated to this artifact
+ * or {@code Optional.empty()} if no path has been associated.
+ */
+ @Nonnull
+ Optional<Path> getPath( @Nonnull Artifact artifact );
+
+ /**
+ * Associates the given file path to the artifact.
+ */
+ void setPath( @Nonnull Artifact artifact, Path path );
+
+ /**
+ * TODO: investigate removing the Metadata api completely
+ */
+ @Nonnull
+ Collection<Metadata> getAttachedMetadatas( @Nonnull Artifact artifact );
+
+ /**
+ * TODO: investigate removing the Metadata api completely
+ */
+ void attachMetadata( @Nonnull Artifact artifact, @Nonnull Metadata metadata );
+
+}
diff --git a/api/maven-api-core/src/main/java/org/apache/maven/api/services/ArtifactResolver.java b/api/maven-api-core/src/main/java/org/apache/maven/api/services/ArtifactResolver.java
new file mode 100644
index 000000000..99f49d241
--- /dev/null
+++ b/api/maven-api-core/src/main/java/org/apache/maven/api/services/ArtifactResolver.java
@@ -0,0 +1,61 @@
+package org.apache.maven.api.services;
+
+/*
+ * 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.
+ */
+
+import java.util.Collection;
+
+import org.apache.maven.api.ArtifactCoordinate;
+import org.apache.maven.api.Service;
+import org.apache.maven.api.Session;
+import org.apache.maven.api.annotations.Experimental;
+
+/**
+ * Resolves the artifact, i.e download the file when required and attach it to the artifact
+ *
+ * @since 4.0
+ */
+@Experimental
+public interface ArtifactResolver extends Service
+{
+
+ /**
+ * @param request {@link ArtifactResolverRequest}
+ * @return {@link ArtifactResolverResult}
+ * @throws ArtifactResolverException in case of an error.
+ * @throws IllegalArgumentException in case of parameter {@code buildingRequest} is {@code null} or
+ * parameter {@code mavenArtifact} is {@code null} or invalid.
+ */
+ ArtifactResolverResult resolve( ArtifactResolverRequest request );
+
+ /**
+ * @param session {@link Session}
+ * @param coordinates array of {@link ArtifactCoordinate}
+ * @return {@link ArtifactResolverResult}
+ * @throws ArtifactResolverException in case of an error.
+ * @throws IllegalArgumentException in case of parameter {@code buildingRequest} is {@code null} or
+ * parameter {@code coordinate} is {@code null} or invalid.
+ */
+ default ArtifactResolverResult resolve( Session session,
+ Collection<? extends ArtifactCoordinate> coordinates )
+ {
+ return resolve( ArtifactResolverRequest.build( session, coordinates ) );
+ }
+
+}
diff --git a/maven-settings-builder/src/main/java/org/apache/maven/settings/validation/SettingsValidator.java b/api/maven-api-core/src/main/java/org/apache/maven/api/services/ArtifactResolverException.java
similarity index 60%
copy from maven-settings-builder/src/main/java/org/apache/maven/settings/validation/SettingsValidator.java
copy to api/maven-api-core/src/main/java/org/apache/maven/api/services/ArtifactResolverException.java
index 79745ecaf..ba6e5482c 100644
--- a/maven-settings-builder/src/main/java/org/apache/maven/settings/validation/SettingsValidator.java
+++ b/api/maven-api-core/src/main/java/org/apache/maven/api/services/ArtifactResolverException.java
@@ -1,4 +1,4 @@
-package org.apache.maven.settings.validation;
+package org.apache.maven.api.services;
/*
* Licensed to the Apache Software Foundation (ASF) under one
@@ -19,23 +19,27 @@ package org.apache.maven.settings.validation;
* under the License.
*/
-import org.apache.maven.settings.Settings;
-import org.apache.maven.settings.building.SettingsProblemCollector;
+import org.apache.maven.api.annotations.Experimental;
/**
- * Validate a model settings
*
- * @author Milos Kleint
+ *
+ * @since 4.0
*/
-public interface SettingsValidator
+@Experimental
+public class ArtifactResolverException
+ extends MavenException
{
+ private static final long serialVersionUID = 7252294837746943917L;
+
/**
- * Validate the specified settings.
- *
- * @param settings The settings to validate, must not be {@code null}.
- * @param problems The container used to collect problems that were encountered, must not be {@code null}.
+ * @param message The message for the exception.
+ * @param e The exception itself.
*/
- void validate( Settings settings, SettingsProblemCollector problems );
+ public ArtifactResolverException( String message, Exception e )
+ {
+ super( message, e );
+ }
}
diff --git a/api/maven-api-core/src/main/java/org/apache/maven/api/services/ArtifactResolverRequest.java b/api/maven-api-core/src/main/java/org/apache/maven/api/services/ArtifactResolverRequest.java
new file mode 100644
index 000000000..f35f326f1
--- /dev/null
+++ b/api/maven-api-core/src/main/java/org/apache/maven/api/services/ArtifactResolverRequest.java
@@ -0,0 +1,108 @@
+package org.apache.maven.api.services;
+
+/*
+ * 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.
+ */
+
+import java.util.Collection;
+
+import org.apache.maven.api.ArtifactCoordinate;
+import org.apache.maven.api.Session;
+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.NotThreadSafe;
+
+/**
+ * A request for resolving an artifact.
+ *
+ * @since 4.0
+ */
+@Experimental
+@Immutable
+public interface ArtifactResolverRequest
+{
+ @Nonnull
+ Session getSession();
+
+ @Nonnull
+ Collection<? extends ArtifactCoordinate> getCoordinates();
+
+ @Nonnull
+ static ArtifactResolverRequestBuilder builder()
+ {
+ return new ArtifactResolverRequestBuilder();
+ }
+
+ @Nonnull
+ static ArtifactResolverRequest build( Session session, Collection<? extends ArtifactCoordinate> coordinates )
+ {
+ return builder()
+ .session( session )
+ .coordinates( coordinates )
+ .build();
+ }
+
+ @NotThreadSafe
+ class ArtifactResolverRequestBuilder
+ {
+ Session session;
+ Collection<? extends ArtifactCoordinate> coordinates;
+
+ @Nonnull
+ public ArtifactResolverRequestBuilder session( Session session )
+ {
+ this.session = session;
+ return this;
+ }
+
+ @Nonnull
+ public ArtifactResolverRequestBuilder coordinates( Collection<? extends ArtifactCoordinate> coordinates )
+ {
+ this.coordinates = coordinates;
+ return this;
+ }
+
+ @Nonnull
+ public ArtifactResolverRequest build()
+ {
+ return new DefaultArtifactResolverRequest( session, coordinates );
+ }
+
+ private static class DefaultArtifactResolverRequest extends BaseRequest implements ArtifactResolverRequest
+ {
+ @Nonnull
+ private final Collection<? extends ArtifactCoordinate> coordinates;
+
+ DefaultArtifactResolverRequest( @Nonnull Session session,
+ @Nonnull Collection<? extends ArtifactCoordinate> coordinates )
+ {
+ super( session );
+ this.coordinates = nonNull( coordinates, "coordinates can not be null" );
+ }
+
+ @Nonnull
+ @Override
+ public Collection<? extends ArtifactCoordinate> getCoordinates()
+ {
+ return coordinates;
+ }
+ }
+ }
+
+}
diff --git a/maven-model/src/main/java/org/apache/maven/model/package-info.java b/api/maven-api-core/src/main/java/org/apache/maven/api/services/ArtifactResolverResult.java
similarity index 61%
copy from maven-model/src/main/java/org/apache/maven/model/package-info.java
copy to api/maven-api-core/src/main/java/org/apache/maven/api/services/ArtifactResolverResult.java
index 88d3fa070..74bd5a741 100644
--- a/maven-model/src/main/java/org/apache/maven/model/package-info.java
+++ b/api/maven-api-core/src/main/java/org/apache/maven/api/services/ArtifactResolverResult.java
@@ -1,9 +1,4 @@
-// CHECKSTYLE_OFF: RegexpHeader
-/**
- * Maven POM (Project Object Model) classes, generated from <code>maven.mdo</code> model.
- * The root class is {@link org.apache.maven.model.Model}.
- */
-package org.apache.maven.model;
+package org.apache.maven.api.services;
/*
* Licensed to the Apache Software Foundation (ASF) under one
@@ -14,7 +9,7 @@ package org.apache.maven.model;
* "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
+ * 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
@@ -22,4 +17,27 @@ package org.apache.maven.model;
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
- */
\ No newline at end of file
+ */
+
+import java.nio.file.Path;
+import java.util.Map;
+
+import org.apache.maven.api.Artifact;
+import org.apache.maven.api.annotations.Experimental;
+import org.apache.maven.api.annotations.Nonnull;
+
+/**
+ * The Artifact Result
+ *
+ * @since 4.0
+ */
+@Experimental
+public interface ArtifactResolverResult
+{
+ /**
+ * @return {@link Artifact}
+ */
+ @Nonnull
+ Map<Artifact, Path> getArtifacts();
+
+}
diff --git a/api/maven-api-core/src/main/java/org/apache/maven/api/services/BaseRequest.java b/api/maven-api-core/src/main/java/org/apache/maven/api/services/BaseRequest.java
new file mode 100644
index 000000000..86afa5a20
--- /dev/null
+++ b/api/maven-api-core/src/main/java/org/apache/maven/api/services/BaseRequest.java
@@ -0,0 +1,67 @@
+package org.apache.maven.api.services;
+
+/*
+ * 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.
+ */
+
+import org.apache.maven.api.annotations.Experimental;
+import org.apache.maven.api.annotations.Nonnull;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+
+import org.apache.maven.api.Session;
+
+/**
+ * Base class for requests.
+ *
+ * @since 4.0
+ */
+@Experimental
+abstract class BaseRequest
+{
+
+ private final Session session;
+
+ protected BaseRequest( @Nonnull Session session )
+ {
+ this.session = nonNull( session, "session can not be null" );
+ }
+
+ @Nonnull
+ public Session getSession()
+ {
+ return session;
+ }
+
+ public static <T> T nonNull( T obj, String message )
+ {
+ if ( obj == null )
+ {
+ throw new IllegalArgumentException( message );
+ }
+ return obj;
+ }
+
+ protected static <T> Collection<T> unmodifiable( Collection<T> obj )
+ {
+ return obj != null && !obj.isEmpty()
+ ? Collections.unmodifiableCollection( new ArrayList<>( obj ) ) : Collections.emptyList();
+ }
+}
diff --git a/api/maven-api-core/src/main/java/org/apache/maven/api/services/DependencyCollector.java b/api/maven-api-core/src/main/java/org/apache/maven/api/services/DependencyCollector.java
new file mode 100644
index 000000000..e21b2c469
--- /dev/null
+++ b/api/maven-api-core/src/main/java/org/apache/maven/api/services/DependencyCollector.java
@@ -0,0 +1,117 @@
+package org.apache.maven.api.services;
+
+/*
+ * 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.
+ */
+
+import org.apache.maven.api.Service;
+import org.apache.maven.api.annotations.Experimental;
+import org.apache.maven.api.annotations.Nonnull;
+
+import org.apache.maven.api.Session;
+import org.apache.maven.api.Artifact;
+import org.apache.maven.api.DependencyCoordinate;
+import org.apache.maven.api.Project;
+
+/**
+ * The DependencyCollector service can be used to collect dependencies
+ * for a given artifact and builds a graph of them.
+ * The dependencies collection mechanism will not download any artifacts,
+ * and only the pom files will be downloaded.
+ *
+ * @since 4.0
+ */
+@Experimental
+public interface DependencyCollector extends Service
+{
+
+ /**
+ * Collects the transitive dependencies and builds a dependency graph.
+ * Note that this operation is only concerned about determining the coordinates of the
+ * transitive dependencies and does not actually resolve the artifact files.
+ *
+ * @param request The dependency collection request, must not be {@code null}.
+ * @return The collection result, never {@code null}.
+ * @throws DependencyCollectorException If the dependency tree could not be built.
+ * @throws IllegalArgumentException if an argument is null or invalid
+ *
+ * @see DependencyCollector#collect(Session, Project)
+ * @see DependencyCollector#collect(Session, DependencyCoordinate)
+ * @see DependencyCollector#collect(Session, Artifact)
+ */
+ @Nonnull
+ DependencyCollectorResult collect( @Nonnull DependencyCollectorRequest request );
+
+ /**
+ * Collects the transitive dependencies of some artifacts and builds a dependency graph. Note that this operation is
+ * only concerned about determining the coordinates of the transitive dependencies and does not actually resolve the
+ * artifact files.
+ *
+ * @param session The {@link Session}, must not be {@code null}.
+ * @param root The Maven Dependency, must not be {@code null}.
+ * @return The collection result, never {@code null}.
+ * @throws DependencyCollectorException If the dependency tree could not be built.
+ * @throws IllegalArgumentException if an argument is null or invalid
+ * @see #collect(DependencyCollectorRequest)
+ */
+ @Nonnull
+ default DependencyCollectorResult collect( @Nonnull Session session,
+ @Nonnull DependencyCoordinate root )
+ {
+ return collect( DependencyCollectorRequest.build( session, root ) );
+ }
+
+ /**
+ * Collects the transitive dependencies of some artifacts and builds a dependency graph. Note that this operation is
+ * only concerned about determining the coordinates of the transitive dependencies and does not actually resolve the
+ * artifact files.
+ *
+ * @param session The {@link Session}, must not be {@code null}.
+ * @param project The {@link Project}, must not be {@code null}.
+ * @return The collection result, never {@code null}.
+ * @throws DependencyCollectorException If the dependency tree could not be built.
+ * @throws IllegalArgumentException if an argument is null or invalid
+ * @see #collect(DependencyCollectorRequest)
+ */
+ @Nonnull
+ default DependencyCollectorResult collect( @Nonnull Session session,
+ @Nonnull Project project )
+ {
+ return collect( DependencyCollectorRequest.build( session, project ) );
+ }
+
+ /**
+ * Collects the transitive dependencies of some artifacts and builds a dependency graph. Note that this operation is
+ * only concerned about determining the coordinates of the transitive dependencies and does not actually resolve the
+ * artifact files.
+ *
+ * @param session The {@link Session}, must not be {@code null}.
+ * @param artifact The {@link Artifact}, must not be {@code null}.
+ * @return The collection result, never {@code null}.
+ * @throws DependencyCollectorException If the dependency tree could not be built.
+ * @throws IllegalArgumentException if an argument is null or invalid
+ * @see #collect(DependencyCollectorRequest)
+ */
+ @Nonnull
+ default DependencyCollectorResult collect( @Nonnull Session session,
+ @Nonnull Artifact artifact )
+ {
+ return collect( DependencyCollectorRequest.build( session, artifact ) );
+ }
+
+}
diff --git a/maven-settings-builder/src/main/java/org/apache/maven/settings/validation/SettingsValidator.java b/api/maven-api-core/src/main/java/org/apache/maven/api/services/DependencyCollectorException.java
similarity index 56%
copy from maven-settings-builder/src/main/java/org/apache/maven/settings/validation/SettingsValidator.java
copy to api/maven-api-core/src/main/java/org/apache/maven/api/services/DependencyCollectorException.java
index 79745ecaf..019fedb6b 100644
--- a/maven-settings-builder/src/main/java/org/apache/maven/settings/validation/SettingsValidator.java
+++ b/api/maven-api-core/src/main/java/org/apache/maven/api/services/DependencyCollectorException.java
@@ -1,4 +1,4 @@
-package org.apache.maven.settings.validation;
+package org.apache.maven.api.services;
/*
* Licensed to the Apache Software Foundation (ASF) under one
@@ -19,23 +19,29 @@ package org.apache.maven.settings.validation;
* under the License.
*/
-import org.apache.maven.settings.Settings;
-import org.apache.maven.settings.building.SettingsProblemCollector;
+import org.apache.maven.api.annotations.Experimental;
/**
- * Validate a model settings
+ * Thrown in case of bad artifact descriptors, version ranges or other
+ * issues encountered during calculation of the dependency graph.
*
- * @author Milos Kleint
+ * @since 4.0
*/
-public interface SettingsValidator
+@Experimental
+public class DependencyCollectorException
+ extends MavenException
{
-
/**
- * Validate the specified settings.
*
- * @param settings The settings to validate, must not be {@code null}.
- * @param problems The container used to collect problems that were encountered, must not be {@code null}.
*/
- void validate( Settings settings, SettingsProblemCollector problems );
+ private static final long serialVersionUID = -3134726259840210686L;
+ /**
+ * @param message The message you would give for the exception.
+ * @param cause The cause which is related to the message.
+ */
+ public DependencyCollectorException( String message, Throwable cause )
+ {
+ super( message, cause );
+ }
}
diff --git a/api/maven-api-core/src/main/java/org/apache/maven/api/services/DependencyCollectorRequest.java b/api/maven-api-core/src/main/java/org/apache/maven/api/services/DependencyCollectorRequest.java
new file mode 100644
index 000000000..b0963205d
--- /dev/null
+++ b/api/maven-api-core/src/main/java/org/apache/maven/api/services/DependencyCollectorRequest.java
@@ -0,0 +1,331 @@
+package org.apache.maven.api.services;
+
+/*
+ * 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.
+ */
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
+import java.util.Optional;
+
+import org.apache.maven.api.Artifact;
+import org.apache.maven.api.DependencyCoordinate;
+import org.apache.maven.api.Project;
+import org.apache.maven.api.Session;
+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.NotThreadSafe;
+import org.apache.maven.api.annotations.Nullable;
+
+import static org.apache.maven.api.services.BaseRequest.nonNull;
+
+/**
+ * A request to collect the transitive dependencies and to build a dependency graph from them. There are three ways to
+ * create a dependency graph. First, only the root dependency can be given. Second, a root dependency and direct
+ * dependencies can be specified in which case the specified direct dependencies are merged with the direct dependencies
+ * retrieved from the artifact descriptor of the root dependency. And last, only direct dependencies can be specified in
+ * which case the root node of the resulting graph has no associated dependency.
+ *
+ * @since 4.0
+ * @see DependencyCollector#collect(DependencyCollectorRequest)
+ */
+@Experimental
+@Immutable
+public interface DependencyCollectorRequest
+{
+
+ @Nonnull
+ Session getSession();
+
+ @Nonnull
+ Optional<Artifact> getRootArtifact();
+
+ @Nonnull
+ Optional<DependencyCoordinate> getRoot();
+
+ @Nonnull
+ Collection<DependencyCoordinate> getDependencies();
+
+ @Nonnull
+ Collection<DependencyCoordinate> getManagedDependencies();
+
+ boolean getVerbose();
+
+ @Nonnull
+ static DependencyCollectorRequest build( @Nonnull Session session, Artifact root )
+ {
+ return builder()
+ .session( nonNull( session, "session can not be null" ) )
+ .rootArtifact( nonNull( root, "root can not be null" ) )
+ .build();
+ }
+
+ @Nonnull
+ static DependencyCollectorRequest build( @Nonnull Session session, @Nonnull DependencyCoordinate root )
+ {
+ return builder()
+ .session( nonNull( session, "session can not be null" ) )
+ .root( nonNull( root, "root can not be null" ) )
+ .build();
+ }
+
+ @Nonnull
+ static DependencyCollectorRequest build( @Nonnull Session session, @Nonnull Project project )
+ {
+ nonNull( session, "session can not be null" );
+ nonNull( project, "project can not be null" );
+ return builder()
+ .session( session )
+ .rootArtifact( project.getArtifact() )
+ .dependencies( project.getDependencies() )
+ .managedDependencies( project.getManagedDependencies() )
+ .build();
+ }
+
+ @Nonnull
+ static DependencyCollectorRequestBuilder builder()
+ {
+ return new DependencyCollectorRequestBuilder();
+ }
+
+ @NotThreadSafe
+ class DependencyCollectorRequestBuilder
+ {
+
+ Session session;
+ Artifact rootArtifact;
+ DependencyCoordinate root;
+ List<DependencyCoordinate> dependencies = Collections.emptyList();
+ List<DependencyCoordinate> managedDependencies = Collections.emptyList();
+ boolean verbose;
+
+ @Nonnull
+ public DependencyCollectorRequestBuilder session( @Nonnull Session session )
+ {
+ this.session = session;
+ return this;
+ }
+
+ /**
+ * Sets the root artifact for the dependency graph.
+ * This must not be confused with {@link #root(DependencyCoordinate)}: The root <em>dependency</em>, like any
+ * other specified dependency, will be subject to dependency collection/resolution, i.e. should have an artifact
+ * descriptor and a corresponding artifact file. The root <em>artifact</em> on the other hand is only used
+ * as a label for the root node of the graph in case no root dependency was specified. As such, the configured
+ * root artifact is ignored if {@link #root(DependencyCoordinate)} has been set.
+ *
+ * @param rootArtifact The root artifact for the dependency graph, may be {@code null}.
+ * @return This request for chaining, never {@code null}.
+ */
+ @Nonnull
+ public DependencyCollectorRequestBuilder rootArtifact( @Nullable Artifact rootArtifact )
+ {
+ this.rootArtifact = rootArtifact;
+ return this;
+ }
+
+ /**
+ * @param root The root dependency
+ * @return This request for chaining, never {@code null}.
+ */
+ @Nonnull
+ public DependencyCollectorRequestBuilder root( @Nonnull DependencyCoordinate root )
+ {
+ this.root = root;
+ return this;
+ }
+
+ /**
+ * Sets the direct dependencies. If both a root dependency and direct dependencies are given in the request, the
+ * direct dependencies from the request will be merged with the direct dependencies from the root dependency's
+ * artifact descriptor, giving higher priority to the dependencies from the request.
+ *
+ * @param dependencies The direct dependencies, may be {@code null}.
+ * @return This request for chaining, never {@code null}.
+ */
+ @Nonnull
+ public DependencyCollectorRequestBuilder dependencies( @Nullable List<DependencyCoordinate> dependencies )
+ {
+ this.dependencies = ( dependencies != null ) ? dependencies : Collections.emptyList();
+ return this;
+ }
+
+ /**
+ * Adds the specified direct dependency.
+ *
+ * @param dependency The dependency to add, may be {@code null}.
+ * @return This request for chaining, never {@code null}.
+ */
+ @Nonnull
+ public DependencyCollectorRequestBuilder dependency( @Nullable DependencyCoordinate dependency )
+ {
+ if ( dependency != null )
+ {
+ if ( this.dependencies.isEmpty() )
+ {
+ this.dependencies = new ArrayList<>();
+ }
+ this.dependencies.add( dependency );
+ }
+ return this;
+ }
+
+
+ /**
+ * Sets the dependency management to apply to transitive dependencies. To clarify, this management does not
+ * apply to
+ * the direct dependencies of the root node.
+ *
+ * @param managedDependencies The dependency management, may be {@code null}.
+ * @return This request for chaining, never {@code null}.
+ */
+ @Nonnull
+ public DependencyCollectorRequestBuilder managedDependencies(
+ @Nullable List<DependencyCoordinate> managedDependencies )
+ {
+ this.managedDependencies = ( managedDependencies != null ) ? managedDependencies : Collections.emptyList();
+ return this;
+ }
+
+ /**
+ * Adds the specified managed dependency.
+ *
+ * @param managedDependency The managed dependency to add, may be {@code null} in which case the call
+ * will have no effect.
+ * @return This request for chaining, never {@code null}.
+ */
+ @Nonnull
+ public DependencyCollectorRequestBuilder managedDependency( @Nullable DependencyCoordinate managedDependency )
+ {
+ if ( managedDependency != null )
+ {
+ if ( this.managedDependencies.isEmpty() )
+ {
+ this.managedDependencies = new ArrayList<>();
+ }
+ this.managedDependencies.add( managedDependency );
+ }
+ return this;
+ }
+
+ /**
+ * Specifies that the collection should be verbose.
+ *
+ * @param verbose whether the collection should be verbose or not.
+ * @return This request for chaining, never {@code null}.
+ */
+ @Nonnull
+ public DependencyCollectorRequestBuilder verbose( boolean verbose )
+ {
+ this.verbose = verbose;
+ return this;
+ }
+
+ @Nonnull
+ public DependencyCollectorRequest build()
+ {
+ return new DefaultDependencyCollectorRequest(
+ session,
+ rootArtifact,
+ root,
+ dependencies,
+ managedDependencies,
+ verbose );
+ }
+
+ static class DefaultDependencyCollectorRequest extends BaseRequest
+ implements DependencyCollectorRequest
+ {
+ private final Artifact rootArtifact;
+ private final DependencyCoordinate root;
+ private final Collection<DependencyCoordinate> dependencies;
+ private final Collection<DependencyCoordinate> managedDependencies;
+ private final boolean verbose;
+
+
+ /**
+ * Creates a request with the specified properties.
+ *
+ * @param session {@link Session}
+ * @param rootArtifact The root dependency whose transitive dependencies should be collected, may be {@code
+ * null}.
+ */
+ DefaultDependencyCollectorRequest(
+ @Nonnull Session session,
+ @Nullable Artifact rootArtifact,
+ @Nullable DependencyCoordinate root,
+ @Nonnull Collection<DependencyCoordinate> dependencies,
+ @Nonnull Collection<DependencyCoordinate> managedDependencies,
+ boolean verbose )
+ {
+ super( session );
+ this.rootArtifact = rootArtifact;
+ this.root = root;
+ this.dependencies = unmodifiable( dependencies );
+ this.managedDependencies = unmodifiable( managedDependencies );
+ this.verbose = verbose;
+ }
+
+ @Nonnull
+ @Override
+ public Optional<Artifact> getRootArtifact()
+ {
+ return Optional.ofNullable( rootArtifact );
+ }
+
+ @Nonnull
+ @Override
+ public Optional<DependencyCoordinate> getRoot()
+ {
+ return Optional.ofNullable( root );
+ }
+
+ @Nonnull
+ @Override
+ public Collection<DependencyCoordinate> getDependencies()
+ {
+ return dependencies;
+ }
+
+ @Nonnull
+ @Override
+ public Collection<DependencyCoordinate> getManagedDependencies()
+ {
+ return managedDependencies;
+ }
+
+ @Override
+ public boolean getVerbose()
+ {
+ return verbose;
+ }
+
+ @Nonnull
+ @Override
+ public String toString()
+ {
+ return getRoot() + " -> " + getDependencies();
+ }
+
+ }
+ }
+
+}
diff --git a/maven-settings-builder/src/main/java/org/apache/maven/settings/validation/SettingsValidator.java b/api/maven-api-core/src/main/java/org/apache/maven/api/services/DependencyCollectorResult.java
similarity index 54%
copy from maven-settings-builder/src/main/java/org/apache/maven/settings/validation/SettingsValidator.java
copy to api/maven-api-core/src/main/java/org/apache/maven/api/services/DependencyCollectorResult.java
index 79745ecaf..09388cca7 100644
--- a/maven-settings-builder/src/main/java/org/apache/maven/settings/validation/SettingsValidator.java
+++ b/api/maven-api-core/src/main/java/org/apache/maven/api/services/DependencyCollectorResult.java
@@ -1,4 +1,4 @@
-package org.apache.maven.settings.validation;
+package org.apache.maven.api.services;
/*
* Licensed to the Apache Software Foundation (ASF) under one
@@ -19,23 +19,32 @@ package org.apache.maven.settings.validation;
* under the License.
*/
-import org.apache.maven.settings.Settings;
-import org.apache.maven.settings.building.SettingsProblemCollector;
+import java.util.List;
+
+import org.apache.maven.api.Node;
+import org.apache.maven.api.annotations.Experimental;
/**
- * Validate a model settings
+ * The result of a dependency collection request.
*
- * @author Milos Kleint
+ * @since 4.0
+ * @see DependencyCollector#collect(DependencyCollectorRequest)
*/
-public interface SettingsValidator
+@Experimental
+public interface DependencyCollectorResult
{
+ /**
+ * Gets the exceptions that occurred while building the dependency graph.
+ *
+ * @return The exceptions that occurred, never {@code null}.
+ */
+ List<Exception> getExceptions();
- /**
- * Validate the specified settings.
- *
- * @param settings The settings to validate, must not be {@code null}.
- * @param problems The container used to collect problems that were encountered, must not be {@code null}.
- */
- void validate( Settings settings, SettingsProblemCollector problems );
+ /**
+ * Gets the root node of the dependency graph.
+ *
+ * @return The root node of the dependency graph or {@code null} if none.
+ */
+ Node getRoot();
}
diff --git a/api/maven-api-core/src/main/java/org/apache/maven/api/services/DependencyCoordinateFactory.java b/api/maven-api-core/src/main/java/org/apache/maven/api/services/DependencyCoordinateFactory.java
new file mode 100644
index 000000000..d3c7a6ffd
--- /dev/null
+++ b/api/maven-api-core/src/main/java/org/apache/maven/api/services/DependencyCoordinateFactory.java
@@ -0,0 +1,89 @@
+package org.apache.maven.api.services;
+
+/*
+ * 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.
+ */
+
+import org.apache.maven.api.ArtifactCoordinate;
+import org.apache.maven.api.DependencyCoordinate;
+import org.apache.maven.api.Service;
+import org.apache.maven.api.Session;
+import org.apache.maven.api.annotations.Experimental;
+import org.apache.maven.api.annotations.Nonnull;
+import org.apache.maven.api.model.Dependency;
+import org.apache.maven.api.model.Plugin;
+import org.apache.maven.api.model.ReportPlugin;
+
+/**
+ *
+ * @since 4.0
+ */
+@Experimental
+public interface DependencyCoordinateFactory extends Service
+{
+
+ /**
+ * Creates a new {@link DependencyCoordinate} object from the request.
+ *
+ * @param request the request containing the various data
+ * @return a new {@link DependencyCoordinate} object.
+ *
+ * @throws IllegalArgumentException if {@code request} is null or
+ * if {@code request.getSession()} is null or invalid
+ */
+ @Nonnull
+ DependencyCoordinate create( @Nonnull DependencyCoordinateFactoryRequest request );
+
+ @Nonnull
+ default DependencyCoordinate create( @Nonnull Session session, @Nonnull ArtifactCoordinate coordinate )
+ {
+ return create( DependencyCoordinateFactoryRequest.build( session, coordinate ) );
+ }
+
+ @Nonnull
+ default DependencyCoordinate create( @Nonnull Session session, @Nonnull org.apache.maven.api.Dependency dependency )
+ {
+ return create( DependencyCoordinateFactoryRequest.build( session, dependency ) );
+ }
+
+ @Nonnull
+ default DependencyCoordinate create( @Nonnull Session session, Dependency dependency )
+ {
+ return create( DependencyCoordinateFactoryRequest.build( session,
+ dependency.getGroupId(), dependency.getArtifactId(), dependency.getVersion(),
+ dependency.getClassifier(), null, dependency.getType() ) );
+ }
+
+ @Nonnull
+ default DependencyCoordinate create( @Nonnull Session session, Plugin plugin )
+ {
+ // TODO: hard coded string
+ return create( DependencyCoordinateFactoryRequest.build( session,
+ plugin.getGroupId(), plugin.getArtifactId(), plugin.getVersion(),
+ null, null, "maven-plugin" ) );
+ }
+
+ @Nonnull
+ default DependencyCoordinate create( @Nonnull Session session, ReportPlugin reportPlugin )
+ {
+ // TODO: hard coded string
+ return create( DependencyCoordinateFactoryRequest.build( session,
+ reportPlugin.getGroupId(), reportPlugin.getArtifactId(), reportPlugin.getVersion(),
+ null, null, "maven-plugin" ) );
+ }
+}
diff --git a/api/maven-api-core/src/main/java/org/apache/maven/api/services/DependencyCoordinateFactoryRequest.java b/api/maven-api-core/src/main/java/org/apache/maven/api/services/DependencyCoordinateFactoryRequest.java
new file mode 100644
index 000000000..b42853cd5
--- /dev/null
+++ b/api/maven-api-core/src/main/java/org/apache/maven/api/services/DependencyCoordinateFactoryRequest.java
@@ -0,0 +1,292 @@
+package org.apache.maven.api.services;
+
+/*
+ * 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.
+ */
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+
+import org.apache.maven.api.ArtifactCoordinate;
+import org.apache.maven.api.Dependency;
+import org.apache.maven.api.Exclusion;
+import org.apache.maven.api.Session;
+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.NotThreadSafe;
+
+/**
+ *
+ * @since 4.0
+ */
+@Experimental
+@Immutable
+public interface DependencyCoordinateFactoryRequest extends ArtifactCoordinateFactoryRequest
+{
+
+ String getScope();
+
+ boolean isOptional();
+
+ @Nonnull
+ Collection<Exclusion> getExclusions();
+
+ static DependencyCoordinateFactoryRequest build( Session session, String groupId, String artifactId,
+ String version, String classifier, String extension, String type )
+ {
+ return DependencyCoordinateFactoryRequest.builder()
+ .session( session )
+ .groupId( groupId )
+ .artifactId( artifactId )
+ .version( version )
+ .classifier( classifier )
+ .extension( extension )
+ .type( type )
+ .build();
+ }
+
+ static DependencyCoordinateFactoryRequest build( Session session, ArtifactCoordinate coordinate )
+ {
+ return builder()
+ .session( session )
+ .groupId( coordinate.getGroupId() )
+ .artifactId( coordinate.getArtifactId() )
+ .version( coordinate.getVersion().asString() )
+ .classifier( coordinate.getClassifier() )
+ .extension( coordinate.getExtension() )
+ .build();
+ }
+
+ static DependencyCoordinateFactoryRequest build( Session session, Dependency dependency )
+ {
+ return builder()
+ .session( session )
+ .groupId( dependency.getGroupId() )
+ .artifactId( dependency.getArtifactId() )
+ .version( dependency.getVersion().asString() )
+ .classifier( dependency.getClassifier() )
+ .extension( dependency.getExtension() )
+ .type( dependency.getType().getName() )
+ .scope( dependency.getScope().id() )
+ .optional( dependency.isOptional() )
+ .build();
+ }
+
+ static DependencyCoordinateFactoryRequestBuilder builder()
+ {
+ return new DependencyCoordinateFactoryRequestBuilder();
+ }
+
+ @NotThreadSafe
+ class DependencyCoordinateFactoryRequestBuilder
+ {
+ private Session session;
+ private String groupId;
+ private String artifactId;
+ private String version;
+ private String classifier;
+ private String extension;
+ private String type;
+ private String scope;
+ private boolean optional;
+ private Collection<Exclusion> exclusions = Collections.emptyList();
+
+ public DependencyCoordinateFactoryRequestBuilder session( Session session )
+ {
+ this.session = session;
+ return this;
+ }
+
+ public DependencyCoordinateFactoryRequestBuilder groupId( String groupId )
+ {
+ this.groupId = groupId;
+ return this;
+ }
+
+ public DependencyCoordinateFactoryRequestBuilder artifactId( String artifactId )
+ {
+ this.artifactId = artifactId;
+ return this;
+ }
+
+ public DependencyCoordinateFactoryRequestBuilder version( String version )
+ {
+ this.version = version;
+ return this;
+ }
+
+ public DependencyCoordinateFactoryRequestBuilder classifier( String classifier )
+ {
+ this.classifier = classifier;
+ return this;
+ }
+
+ public DependencyCoordinateFactoryRequestBuilder extension( String extension )
+ {
+ this.extension = extension;
+ return this;
+ }
+
+ public DependencyCoordinateFactoryRequestBuilder type( String type )
+ {
+ this.type = type;
+ return this;
+ }
+
+ public DependencyCoordinateFactoryRequestBuilder scope( String scope )
+ {
+ this.scope = scope;
+ return this;
+ }
+
+ public DependencyCoordinateFactoryRequestBuilder optional( boolean optional )
+ {
+ this.optional = optional;
+ return this;
+ }
+
+ public DependencyCoordinateFactoryRequestBuilder exclusions( Collection<Exclusion> exclusions )
+ {
+ if ( exclusions != null )
+ {
+ if ( this.exclusions.isEmpty() )
+ {
+ this.exclusions = new ArrayList<>();
+ }
+ this.exclusions.addAll( exclusions );
+ }
+ return this;
+ }
+
+ public DependencyCoordinateFactoryRequestBuilder exclusion( Exclusion exclusion )
+ {
+ if ( exclusion != null )
+ {
+ if ( this.exclusions.isEmpty() )
+ {
+ this.exclusions = new ArrayList<>();
+ }
+ this.exclusions.add( exclusion );
+ }
+ return this;
+ }
+
+ public DependencyCoordinateFactoryRequest build()
+ {
+ return new DefaultDependencyCoordinateFactoryRequest( session, groupId, artifactId, version,
+ classifier, extension, type, scope, optional, exclusions );
+ }
+
+ private static class DefaultDependencyCoordinateFactoryRequest
+ extends BaseRequest
+ implements DependencyCoordinateFactoryRequest
+ {
+ private final String groupId;
+ private final String artifactId;
+ private final String version;
+ private final String classifier;
+ private final String extension;
+ private final String type;
+ private final String scope;
+ private final boolean optional;
+ private final Collection<Exclusion> exclusions;
+
+ @SuppressWarnings( "checkstyle:ParameterNumber" )
+ private DefaultDependencyCoordinateFactoryRequest(
+ @Nonnull Session session, String groupId,
+ String artifactId,
+ String version,
+ String classifier,
+ String extension,
+ String type,
+ String scope,
+ boolean optional,
+ Collection<Exclusion> exclusions )
+ {
+ super( session );
+ this.groupId = groupId;
+ this.artifactId = artifactId;
+ this.version = version;
+ this.classifier = classifier;
+ this.extension = extension;
+ this.type = type;
+ this.scope = scope;
+ this.optional = optional;
+ this.exclusions = exclusions;
+ }
+
+ @Override
+ public String getGroupId()
+ {
+ return groupId;
+ }
+
+ @Override
+ public String getArtifactId()
+ {
+ return artifactId;
+ }
+
+ @Override
+ public String getVersion()
+ {
+ return version;
+ }
+
+ @Override
+ public String getClassifier()
+ {
+ return classifier;
+ }
+
+ @Override
+ public String getExtension()
+ {
+ return extension;
+ }
+
+ @Override
+ public String getType()
+ {
+ return type;
+ }
+
+ @Override
+ public String getScope()
+ {
+ return scope;
+ }
+
+ @Override
+ public boolean isOptional()
+ {
+ return optional;
+ }
+
+ @Nonnull
+ @Override
+ public Collection<Exclusion> getExclusions()
+ {
+ return exclusions;
+ }
+ }
+ }
+
+}
diff --git a/api/maven-api-core/src/main/java/org/apache/maven/api/services/LocalRepositoryManager.java b/api/maven-api-core/src/main/java/org/apache/maven/api/services/LocalRepositoryManager.java
new file mode 100644
index 000000000..5e40ac83f
--- /dev/null
+++ b/api/maven-api-core/src/main/java/org/apache/maven/api/services/LocalRepositoryManager.java
@@ -0,0 +1,48 @@
+package org.apache.maven.api.services;
+
+/*
+ * 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.
+ */
+
+import java.nio.file.Path;
+
+import org.apache.maven.api.Artifact;
+import org.apache.maven.api.LocalRepository;
+import org.apache.maven.api.Metadata;
+import org.apache.maven.api.RemoteRepository;
+import org.apache.maven.api.Service;
+import org.apache.maven.api.Session;
+import org.apache.maven.api.annotations.Experimental;
+
+/**
+ *
+ * @since 4.0
+ */
+@Experimental
+public interface LocalRepositoryManager extends Service
+{
+
+ Path getPathForLocalArtifact( Session session, LocalRepository local, Artifact artifact );
+
+ Path getPathForLocalMetadata( Session session, LocalRepository local, Metadata metadata );
+
+ Path getPathForRemoteArtifact( Session session, LocalRepository local, RemoteRepository remote, Artifact artifact );
+
+ Path getPathForRemoteMetadata( Session session, LocalRepository local, RemoteRepository remote, Metadata metadata );
+
+}
diff --git a/maven-model-builder/src/test/java/org/apache/maven/model/interpolation/StringVisitorModelInterpolatorTest.java b/api/maven-api-core/src/main/java/org/apache/maven/api/services/Lookup.java
similarity index 69%
copy from maven-model-builder/src/test/java/org/apache/maven/model/interpolation/StringVisitorModelInterpolatorTest.java
copy to api/maven-api-core/src/main/java/org/apache/maven/api/services/Lookup.java
index 8fa92cecf..93e24994e 100644
--- a/maven-model-builder/src/test/java/org/apache/maven/model/interpolation/StringVisitorModelInterpolatorTest.java
+++ b/api/maven-api-core/src/main/java/org/apache/maven/api/services/Lookup.java
@@ -1,4 +1,4 @@
-package org.apache.maven.model.interpolation;
+package org.apache.maven.api.services;
/*
* Licensed to the Apache Software Foundation (ASF) under one
@@ -19,10 +19,20 @@ package org.apache.maven.model.interpolation;
* under the License.
*/
-public class StringVisitorModelInterpolatorTest extends AbstractModelInterpolatorTest
+import java.util.List;
+import java.util.Map;
+
+import org.apache.maven.api.Service;
+
+public interface Lookup extends Service
{
- protected ModelInterpolator createInterpolator()
- {
- return new StringVisitorModelInterpolator( null, null, new DefaultModelVersionProcessor() );
- }
-}
\ No newline at end of file
+
+ <T> T lookup( Class<T> type );
+
+ <T> T lookup( Class<T> type, String name );
+
+ <T> List<T> lookupList( Class<T> type );
+
+ <T> Map<String, T> lookupMap( Class<T> type );
+
+}
diff --git a/maven-settings-builder/src/main/java/org/apache/maven/settings/validation/SettingsValidator.java b/api/maven-api-core/src/main/java/org/apache/maven/api/services/LookupException.java
similarity index 60%
copy from maven-settings-builder/src/main/java/org/apache/maven/settings/validation/SettingsValidator.java
copy to api/maven-api-core/src/main/java/org/apache/maven/api/services/LookupException.java
index 79745ecaf..d88549112 100644
--- a/maven-settings-builder/src/main/java/org/apache/maven/settings/validation/SettingsValidator.java
+++ b/api/maven-api-core/src/main/java/org/apache/maven/api/services/LookupException.java
@@ -1,4 +1,4 @@
-package org.apache.maven.settings.validation;
+package org.apache.maven.api.services;
/*
* Licensed to the Apache Software Foundation (ASF) under one
@@ -19,23 +19,32 @@ package org.apache.maven.settings.validation;
* under the License.
*/
-import org.apache.maven.settings.Settings;
-import org.apache.maven.settings.building.SettingsProblemCollector;
+import org.apache.maven.api.annotations.Experimental;
/**
- * Validate a model settings
+ * The Exception class throw by the {@link Lookup} service.
*
- * @author Milos Kleint
+ * @since 4.0
*/
-public interface SettingsValidator
+@Experimental
+public class LookupException
+ extends MavenException
{
+ /**
+ * @param message The message to give.
+ * @param e The {@link Exception}.
+ */
+ public LookupException( String message, Exception e )
+ {
+ super( message, e );
+ }
/**
- * Validate the specified settings.
- *
- * @param settings The settings to validate, must not be {@code null}.
- * @param problems The container used to collect problems that were encountered, must not be {@code null}.
+ * @param e The {@link Exception}.
*/
- void validate( Settings settings, SettingsProblemCollector problems );
+ public LookupException( Exception e )
+ {
+ super( e );
+ }
}
diff --git a/maven-settings-builder/src/main/java/org/apache/maven/settings/validation/SettingsValidator.java b/api/maven-api-core/src/main/java/org/apache/maven/api/services/MavenException.java
similarity index 59%
copy from maven-settings-builder/src/main/java/org/apache/maven/settings/validation/SettingsValidator.java
copy to api/maven-api-core/src/main/java/org/apache/maven/api/services/MavenException.java
index 79745ecaf..aba7dd721 100644
--- a/maven-settings-builder/src/main/java/org/apache/maven/settings/validation/SettingsValidator.java
+++ b/api/maven-api-core/src/main/java/org/apache/maven/api/services/MavenException.java
@@ -1,4 +1,4 @@
-package org.apache.maven.settings.validation;
+package org.apache.maven.api.services;
/*
* Licensed to the Apache Software Foundation (ASF) under one
@@ -19,23 +19,33 @@ package org.apache.maven.settings.validation;
* under the License.
*/
-import org.apache.maven.settings.Settings;
-import org.apache.maven.settings.building.SettingsProblemCollector;
+import org.apache.maven.api.annotations.Experimental;
/**
- * Validate a model settings
+ * Base class for all maven exceptions.
*
- * @author Milos Kleint
+ * @since 4.0
*/
-public interface SettingsValidator
+@Experimental
+public class MavenException extends RuntimeException
{
+ public MavenException()
+ {
+ }
- /**
- * Validate the specified settings.
- *
- * @param settings The settings to validate, must not be {@code null}.
- * @param problems The container used to collect problems that were encountered, must not be {@code null}.
- */
- void validate( Settings settings, SettingsProblemCollector problems );
+ public MavenException( String message )
+ {
+ super( message );
+ }
+
+ public MavenException( String message, Throwable cause )
+ {
+ super( message, cause );
+ }
+
+ public MavenException( Throwable cause )
+ {
+ super( cause );
+ }
}
diff --git a/api/maven-api-core/src/main/java/org/apache/maven/api/services/MessageBuilder.java b/api/maven-api-core/src/main/java/org/apache/maven/api/services/MessageBuilder.java
new file mode 100644
index 000000000..1d8691199
--- /dev/null
+++ b/api/maven-api-core/src/main/java/org/apache/maven/api/services/MessageBuilder.java
@@ -0,0 +1,157 @@
+package org.apache.maven.api.services;
+
+/*
+ * 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.
+ */
+
+import org.apache.maven.api.annotations.Nonnull;
+
+/**
+ * Message builder that supports configurable styling.
+ *
+ * @since 4.0
+ * @see MessageBuilderFactory
+ */
+public interface MessageBuilder
+{
+ /**
+ * Append message content in success style.
+ * By default, bold green
+ * @param message the message to append
+ * @return the current builder
+ */
+ @Nonnull
+ MessageBuilder success( Object message );
+
+ /**
+ * Append message content in warning style.
+ * By default, bold yellow
+ * @param message the message to append
+ * @return the current builder
+ */
+ @Nonnull
+ MessageBuilder warning( Object message );
+
+ /**
+ * Append message content in failure style.
+ * By default, bold red
+ * @param message the message to append
+ * @return the current builder
+ */
+ @Nonnull
+ MessageBuilder failure( Object message );
+
+ /**
+ * Append message content in strong style.
+ * By default, bold
+ * @param message the message to append
+ * @return the current builder
+ */
+ @Nonnull
+ MessageBuilder strong( Object message );
+
+ /**
+ * Append message content in mojo style.
+ * By default, green
+ * @param message the message to append
+ * @return the current builder
+ */
+ @Nonnull
+ MessageBuilder mojo( Object message );
+
+ /**
+ * Append message content in project style.
+ * By default, cyan
+ * @param message the message to append
+ * @return the current builder
+ */
+ @Nonnull
+ MessageBuilder project( Object message );
+
+ //
+ // message building methods modelled after Ansi methods
+ //
+ /**
+ * Append content to the message buffer.
+ * @param value the content to append
+ * @param offset the index of the first {@code char} to append
+ * @param len the number of {@code char}s to append
+ * @return the current builder
+ */
+ @Nonnull
+ MessageBuilder a( char[] value, int offset, int len );
+
+ /**
+ * Append content to the message buffer.
+ * @param value the content to append
+ * @return the current builder
+ */
+ @Nonnull
+ MessageBuilder a( char[] value );
+
+ /**
+ * Append content to the message buffer.
+ * @param value the content to append
+ * @param start the starting index of the subsequence to be appended
+ * @param end the end index of the subsequence to be appended
+ * @return the current builder
+ */
+ @Nonnull
+ MessageBuilder a( CharSequence value, int start, int end );
+
+ /**
+ * Append content to the message buffer.
+ * @param value the content to append
+ * @return the current builder
+ */
+ @Nonnull
+ MessageBuilder a( CharSequence value );
+
+ /**
+ * Append content to the message buffer.
+ * @param value the content to append
+ * @return the current builder
+ */
+ @Nonnull
+ MessageBuilder a( Object value );
+
+ /**
+ * Append newline to the message buffer.
+ * @return the current builder
+ */
+ @Nonnull
+ MessageBuilder newline();
+
+ /**
+ * Append formatted content to the buffer.
+ * @see String#format(String, Object...)
+ * @param pattern a <a href="../util/Formatter.html#syntax">format string</a>
+ * @param args arguments referenced by the format specifiers in the format string.
+ * @return the current builder
+ */
+ @Nonnull
+ MessageBuilder format( String pattern, Object... args );
+
+ /**
+ * Return the built message.
+ * @return the message
+ */
+ @Nonnull
+ String build();
+
+}
diff --git a/api/maven-api-core/src/main/java/org/apache/maven/api/services/MessageBuilderFactory.java b/api/maven-api-core/src/main/java/org/apache/maven/api/services/MessageBuilderFactory.java
new file mode 100644
index 000000000..5290dab14
--- /dev/null
+++ b/api/maven-api-core/src/main/java/org/apache/maven/api/services/MessageBuilderFactory.java
@@ -0,0 +1,71 @@
+package org.apache.maven.api.services;
+
+/*
+ * 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.
+ */
+
+import org.apache.maven.api.Service;
+import org.apache.maven.api.annotations.Experimental;
+import org.apache.maven.api.annotations.Nonnull;
+
+/**
+ * A factory for {@link MessageBuilder}.
+ *
+ * @since 4.0
+ */
+@Experimental
+public interface MessageBuilderFactory extends Service
+{
+ /**
+ * Checks if the underlying output does support styling or not.
+ * @return whether color styling is supported or not
+ */
+ boolean isColorEnabled();
+
+ /**
+ * Returns the terminal width or <code>-1</code> if not supported.
+ * @return the terminal width
+ */
+ int getTerminalWidth();
+
+ /**
+ * Creates a new message builder.
+ * @return a new message builder
+ */
+ @Nonnull
+ MessageBuilder builder();
+
+ /**
+ * Creates a new message builder backed by the given string builder.
+ * @param stringBuilder a string builder
+ * @return a new message builder
+ */
+ @Nonnull
+ MessageBuilder builder( @Nonnull StringBuilder stringBuilder );
+
+ /**
+ * Creates a new message builder of the specified size.
+ * @param size the initial size of the message builder buffer
+ * @return a new message builder
+ */
+ @Nonnull
+ default MessageBuilder builder( int size )
+ {
+ return builder( new StringBuilder( size ) );
+ }
+}
diff --git a/api/maven-api-core/src/main/java/org/apache/maven/api/services/ProjectBuilder.java b/api/maven-api-core/src/main/java/org/apache/maven/api/services/ProjectBuilder.java
new file mode 100644
index 000000000..d7829752f
--- /dev/null
+++ b/api/maven-api-core/src/main/java/org/apache/maven/api/services/ProjectBuilder.java
@@ -0,0 +1,110 @@
+package org.apache.maven.api.services;
+
+/*
+ * 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.
+ */
+
+import org.apache.maven.api.ArtifactCoordinate;
+import org.apache.maven.api.Service;
+import org.apache.maven.api.annotations.Experimental;
+import org.apache.maven.api.annotations.Nonnull;
+
+import java.nio.file.Path;
+
+import org.apache.maven.api.Session;
+import org.apache.maven.api.Artifact;
+
+/**
+ * @since 4.0
+ */
+@Experimental
+public interface ProjectBuilder extends Service
+{
+
+ /**
+ * Creates a {@link org.apache.maven.api.Project} from a POM file.
+ *
+ * @param request {@link ProjectBuilderRequest}
+ * @return the {@link ProjectBuilderResult} containing the built project and possible errors
+ * @throws ProjectBuilderException if the project can not be created
+ * @throws IllegalArgumentException if an argument is {@code null} or invalid
+ */
+ @Nonnull
+ ProjectBuilderResult build( ProjectBuilderRequest request );
+
+ /**
+ * Creates a {@link org.apache.maven.api.Project} from a POM file.
+ *
+ * @param session The {@link Session}, must not be {@code null}.
+ * @param source The {@link ProjectBuilderSource}, must not be {@code null}.
+ * @throws ProjectBuilderException if the project can not be created
+ * @throws IllegalArgumentException if an argument is {@code null} or invalid
+ * @see #build(ProjectBuilderRequest)
+ */
+ @Nonnull
+ default ProjectBuilderResult build( @Nonnull Session session, @Nonnull ProjectBuilderSource source )
+ {
+ return build( ProjectBuilderRequest.build( session, source ) );
+ }
+
+ /**
+ * Creates a {@link org.apache.maven.api.Project} from a POM file.
+ *
+ * @param session The {@link Session}, must not be {@code null}.
+ * @param path The {@link Path}, must not be {@code null}.
+ * @throws ProjectBuilderException if the project can not be created
+ * @throws IllegalArgumentException if an argument is {@code null} or invalid
+ * @see #build(ProjectBuilderRequest)
+ */
+ @Nonnull
+ default ProjectBuilderResult build( @Nonnull Session session, @Nonnull Path path )
+ {
+ return build( ProjectBuilderRequest.build( session, path ) );
+ }
+
+ /**
+ * Creates a {@link org.apache.maven.api.Project} from an artifact.
+ *
+ * @param session The {@link Session}, must not be {@code null}.
+ * @param artifact The {@link Artifact}, must not be {@code null}.
+ * @throws ProjectBuilderException if the project can not be created
+ * @throws IllegalArgumentException if an argument is {@code null} or invalid
+ * @see #build(ProjectBuilderRequest)
+ */
+ @Nonnull
+ default ProjectBuilderResult build( @Nonnull Session session, @Nonnull Artifact artifact )
+ {
+ return build( ProjectBuilderRequest.build( session, artifact ) );
+ }
+
+ /**
+ * Creates a {@link org.apache.maven.api.Project} from a coordinate.
+ *
+ * @param session The {@link Session}, must not be {@code null}.
+ * @param coordinate The {@link ArtifactCoordinate}, must not be {@code null}.
+ * @throws ProjectBuilderException if the project can not be created
+ * @throws IllegalArgumentException if an argument is {@code null} or invalid
+ * @see #build(ProjectBuilderRequest)
+ */
+ @Nonnull
+ default ProjectBuilderResult build( @Nonnull Session session, @Nonnull ArtifactCoordinate coordinate )
+ {
+ return build( ProjectBuilderRequest.build( session, coordinate ) );
+ }
+
+}
diff --git a/maven-model-builder/src/test/java/org/apache/maven/model/interpolation/StringVisitorModelInterpolatorTest.java b/api/maven-api-core/src/main/java/org/apache/maven/api/services/ProjectBuilderException.java
similarity index 60%
copy from maven-model-builder/src/test/java/org/apache/maven/model/interpolation/StringVisitorModelInterpolatorTest.java
copy to api/maven-api-core/src/main/java/org/apache/maven/api/services/ProjectBuilderException.java
index 8fa92cecf..2256bd144 100644
--- a/maven-model-builder/src/test/java/org/apache/maven/model/interpolation/StringVisitorModelInterpolatorTest.java
+++ b/api/maven-api-core/src/main/java/org/apache/maven/api/services/ProjectBuilderException.java
@@ -1,4 +1,4 @@
-package org.apache.maven.model.interpolation;
+package org.apache.maven.api.services;
/*
* Licensed to the Apache Software Foundation (ASF) under one
@@ -9,7 +9,7 @@ package org.apache.maven.model.interpolation;
* "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
+ * 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
@@ -19,10 +19,24 @@ package org.apache.maven.model.interpolation;
* under the License.
*/
-public class StringVisitorModelInterpolatorTest extends AbstractModelInterpolatorTest
+import org.apache.maven.api.annotations.Experimental;
+
+/**
+ * The Exception class throw by the {@link ProjectBuilder} service.
+ *
+ * @since 4.0
+ */
+@Experimental
+public class ProjectBuilderException
+ extends MavenException
{
- protected ModelInterpolator createInterpolator()
+ /**
+ * @param message The message to give.
+ * @param e The {@link Exception}.
+ */
+ public ProjectBuilderException( String message, Exception e )
{
- return new StringVisitorModelInterpolator( null, null, new DefaultModelVersionProcessor() );
+ super( message, e );
}
-}
\ No newline at end of file
+
+}
diff --git a/api/maven-api-core/src/main/java/org/apache/maven/api/services/ProjectBuilderProblem.java b/api/maven-api-core/src/main/java/org/apache/maven/api/services/ProjectBuilderProblem.java
new file mode 100644
index 000000000..fef6ceae0
--- /dev/null
+++ b/api/maven-api-core/src/main/java/org/apache/maven/api/services/ProjectBuilderProblem.java
@@ -0,0 +1,90 @@
+package org.apache.maven.api.services;
+
+/*
+ * 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.
+ */
+
+import org.apache.maven.api.annotations.Experimental;
+
+/**
+ * Describes a problem that was encountered during project building. A problem can either be an exception that was
+ * thrown or a simple string message. In addition, a problem carries a hint about its source.
+ *
+ * @since 4.0
+ */
+@Experimental
+public interface ProjectBuilderProblem
+{
+
+ /**
+ * Gets the hint about the source of the problem. While the syntax of this hint is unspecified and depends on the
+ * creator of the problem, the general expectation is that the hint provides sufficient information to the user to
+ * track the problem back to its origin. A concrete example for such a source hint can be the file path or URL from
+ * which the settings were read.
+ *
+ * @return The hint about the source of the problem or an empty string if unknown, never {@code null}.
+ */
+ String getSource();
+
+ /**
+ * Gets the one-based index of the line containing the problem. The line number should refer to some text file that
+ * is given by {@link #getSource()}.
+ *
+ * @return The one-based index of the line containing the problem or a non-positive value if unknown.
+ */
+ int getLineNumber();
+
+ /**
+ * Gets the one-based index of the column containing the problem. The column number should refer to some text file
+ * that is given by {@link #getSource()}.
+ *
+ * @return The one-based index of the column containing the problem or non-positive value if unknown.
+ */
+ int getColumnNumber();
+
+ /**
+ * Gets the location of the problem. The location is a user-friendly combination of the values from
+ * {@link #getSource()}, {@link #getLineNumber()} and {@link #getColumnNumber()}. The exact syntax of the returned
+ * value is undefined.
+ *
+ * @return The location of the problem, never {@code null}.
+ */
+ String getLocation();
+
+ /**
+ * Gets the exception that caused this problem (if any).
+ *
+ * @return The exception that caused this problem or {@code null} if not applicable.
+ */
+ Exception getException();
+
+ /**
+ * Gets the message that describes this problem.
+ *
+ * @return The message describing this problem, never {@code null}.
+ */
+ String getMessage();
+
+ /**
+ * Gets the severity level of this problem.
+ *
+ * @return The severity level of this problem, never {@code null}.
+ */
+ ProjectBuilderProblemSeverity getSeverity();
+
+}
diff --git a/maven-model/src/main/java/org/apache/maven/model/package-info.java b/api/maven-api-core/src/main/java/org/apache/maven/api/services/ProjectBuilderProblemSeverity.java
similarity index 73%
copy from maven-model/src/main/java/org/apache/maven/model/package-info.java
copy to api/maven-api-core/src/main/java/org/apache/maven/api/services/ProjectBuilderProblemSeverity.java
index 88d3fa070..6af025709 100644
--- a/maven-model/src/main/java/org/apache/maven/model/package-info.java
+++ b/api/maven-api-core/src/main/java/org/apache/maven/api/services/ProjectBuilderProblemSeverity.java
@@ -1,9 +1,4 @@
-// CHECKSTYLE_OFF: RegexpHeader
-/**
- * Maven POM (Project Object Model) classes, generated from <code>maven.mdo</code> model.
- * The root class is {@link org.apache.maven.model.Model}.
- */
-package org.apache.maven.model;
+package org.apache.maven.api.services;
/*
* Licensed to the Apache Software Foundation (ASF) under one
@@ -22,4 +17,21 @@ package org.apache.maven.model;
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
- */
\ No newline at end of file
+ */
+
+import org.apache.maven.api.annotations.Experimental;
+
+/**
+ * The different severity levels for a problem, in decreasing order.
+ *
+ * @since 4.0
+ */
+@Experimental
+public enum ProjectBuilderProblemSeverity
+{
+
+ FATAL, //
+ ERROR, //
+ WARNING //
+
+}
diff --git a/api/maven-api-core/src/main/java/org/apache/maven/api/services/ProjectBuilderRequest.java b/api/maven-api-core/src/main/java/org/apache/maven/api/services/ProjectBuilderRequest.java
new file mode 100644
index 000000000..4b90e8bfd
--- /dev/null
+++ b/api/maven-api-core/src/main/java/org/apache/maven/api/services/ProjectBuilderRequest.java
@@ -0,0 +1,262 @@
+package org.apache.maven.api.services;
+
+/*
+ * 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.
+ */
+
+import org.apache.maven.api.ArtifactCoordinate;
+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.NotThreadSafe;
+import org.apache.maven.api.annotations.Nullable;
+
+import java.nio.file.Path;
+import java.util.Optional;
+
+import org.apache.maven.api.Session;
+import org.apache.maven.api.Artifact;
+
+import static org.apache.maven.api.services.BaseRequest.nonNull;
+
+/**
+ * Request used to build a {@link org.apache.maven.api.Project} using
+ * the {@link ProjectBuilder} service.
+ *
+ * @since 4.0
+ */
+@Experimental
+@Immutable
+public interface ProjectBuilderRequest
+{
+
+ @Nonnull
+ Session getSession();
+
+ @Nonnull
+ Optional<Path> getPath();
+
+ @Nonnull
+ Optional<ProjectBuilderSource> getSource();
+
+ @Nonnull
+ Optional<Artifact> getArtifact();
+
+ @Nonnull
+ Optional<ArtifactCoordinate> getCoordinate();
+
+ boolean isAllowStubModel();
+
+ boolean isRecursive();
+
+ boolean isProcessPlugins();
+
+ boolean isResolveDependencies();
+
+ @Nonnull
+ static ProjectBuilderRequest build( @Nonnull Session session, @Nonnull ProjectBuilderSource source )
+ {
+ return builder()
+ .session( nonNull( session, "session can not be null" ) )
+ .source( nonNull( source, "source can not be null" ) )
+ .build();
+ }
+
+ @Nonnull
+ static ProjectBuilderRequest build( @Nonnull Session session, @Nonnull Path path )
+ {
+ return builder()
+ .session( nonNull( session, "session can not be null" ) )
+ .path( nonNull( path, "path can not be null" ) )
+ .build();
+ }
+
+ @Nonnull
+ static ProjectBuilderRequest build( @Nonnull Session session, @Nonnull Artifact artifact )
+ {
+ return builder()
+ .session( nonNull( session, "session can not be null" ) )
+ .artifact( nonNull( artifact, "artifact can not be null" ) )
+ .build();
+ }
+
+ @Nonnull
+ static ProjectBuilderRequest build( @Nonnull Session session, @Nonnull ArtifactCoordinate coordinate )
+ {
+ return builder()
+ .session( nonNull( session, "session can not be null" ) )
+ .coordinate( nonNull( coordinate, "coordinate can not be null" ) )
+ .build();
+ }
+
+ @Nonnull
+ static ProjectBuilderRequestBuilder builder()
+ {
+ return new ProjectBuilderRequestBuilder();
+ }
+
+ @NotThreadSafe
+ class ProjectBuilderRequestBuilder
+ {
+ Session session;
+ Path path;
+ ProjectBuilderSource source;
+ Artifact artifact;
+ ArtifactCoordinate coordinate;
+ boolean allowStubModel;
+ boolean recursive;
+ boolean processPlugins = true;
+ boolean resolveDependencies = true;
+
+ public ProjectBuilderRequestBuilder session( Session session )
+ {
+ this.session = session;
+ return this;
+ }
+
+ public ProjectBuilderRequestBuilder path( Path path )
+ {
+ this.path = path;
+ return this;
+ }
+
+ public ProjectBuilderRequestBuilder source( ProjectBuilderSource source )
+ {
+ this.source = source;
+ return this;
+ }
+
+ public ProjectBuilderRequestBuilder artifact( Artifact artifact )
+ {
+ this.artifact = artifact;
+ return this;
+ }
+
+ public ProjectBuilderRequestBuilder coordinate( ArtifactCoordinate coordinate )
+ {
+ this.coordinate = coordinate;
+ return this;
+ }
+
+ public ProjectBuilderRequestBuilder processPlugins( boolean processPlugins )
+ {
+ this.processPlugins = processPlugins;
+ return this;
+ }
+
+ public ProjectBuilderRequestBuilder resolveDependencies( boolean resolveDependencies )
+ {
+ this.resolveDependencies = resolveDependencies;
+ return this;
+ }
+
+ public ProjectBuilderRequest build()
+ {
+ return new DefaultProjectBuilderRequest( session, path, source, artifact, coordinate,
+ allowStubModel, recursive, processPlugins, resolveDependencies );
+ }
+
+ private static class DefaultProjectBuilderRequest extends BaseRequest
+ implements ProjectBuilderRequest
+ {
+ private final Path path;
+ private final ProjectBuilderSource source;
+ private final Artifact artifact;
+ private final ArtifactCoordinate coordinate;
+ private final boolean allowStubModel;
+ private final boolean recursive;
+ private final boolean processPlugins;
+ private final boolean resolveDependencies;
+
+ @SuppressWarnings( "checkstyle:ParameterNumber" )
+ DefaultProjectBuilderRequest( @Nonnull Session session,
+ @Nullable Path path,
+ @Nullable ProjectBuilderSource source,
+ @Nullable Artifact artifact,
+ @Nullable ArtifactCoordinate coordinate,
+ boolean allowStubModel,
+ boolean recursive,
+ boolean processPlugins,
+ boolean resolveDependencies )
+ {
+ super( session );
+ this.path = path;
+ this.source = source;
+ this.artifact = artifact;
+ this.coordinate = coordinate;
+ this.allowStubModel = allowStubModel;
+ this.recursive = recursive;
+ this.processPlugins = processPlugins;
+ this.resolveDependencies = resolveDependencies;
+ }
+
+ @Nonnull
+ @Override
+ public Optional<Path> getPath()
+ {
+ return Optional.ofNullable( path );
+ }
+
+ @Nonnull
+ @Override
+ public Optional<ProjectBuilderSource> getSource()
+ {
+ return Optional.ofNullable( source );
+ }
+
+ @Nonnull
+ @Override
+ public Optional<Artifact> getArtifact()
+ {
+ return Optional.ofNullable( artifact );
+ }
+
+ @Nonnull
+ @Override
+ public Optional<ArtifactCoordinate> getCoordinate()
+ {
+ return Optional.ofNullable( coordinate );
+ }
+
+ @Override
+ public boolean isAllowStubModel()
+ {
+ return allowStubModel;
+ }
+
+ @Override
+ public boolean isRecursive()
+ {
+ return recursive;
+ }
+
+ @Override
+ public boolean isProcessPlugins()
+ {
+ return processPlugins;
+ }
+
+ @Override
+ public boolean isResolveDependencies()
+ {
+ return resolveDependencies;
+ }
+ }
+
+ }
+}
diff --git a/api/maven-api-core/src/main/java/org/apache/maven/api/services/ProjectBuilderResult.java b/api/maven-api-core/src/main/java/org/apache/maven/api/services/ProjectBuilderResult.java
new file mode 100644
index 000000000..a76b6cab2
--- /dev/null
+++ b/api/maven-api-core/src/main/java/org/apache/maven/api/services/ProjectBuilderResult.java
@@ -0,0 +1,83 @@
+package org.apache.maven.api.services;
+
+/*
+ * 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.
+ */
+
+import org.apache.maven.api.annotations.Experimental;
+import org.apache.maven.api.annotations.Nonnull;
+
+import java.nio.file.Path;
+import java.util.Collection;
+import java.util.Optional;
+
+import org.apache.maven.api.Project;
+
+/**
+ * Result of a project build call.
+ *
+ * @since 4.0
+ */
+@Experimental
+public interface ProjectBuilderResult
+{
+
+ /**
+ * Gets the identifier of the project that could not be built. The general format of the identifier is {@code
+ * <groupId>:<artifactId>:<version>} but some of these coordinates may still be unknown at the point the exception
+ * is thrown so this information is merely meant to assist the user.
+ *
+ * @return The identifier of the project or an empty string if not known, never {@code null}.
+ */
+ @Nonnull
+ String getProjectId();
+
+ /**
+ * Gets the POM file from which the project was built.
+ *
+ * @return The optional POM file.
+ */
+ @Nonnull
+ Optional<Path> getPomFile();
+
+ /**
+ * Gets the project that was built.
+ *
+ * @return The project that was built or {@code null} if an error occurred and this result accompanies a
+ * {@link ProjectBuilderException}.
+ */
+ @Nonnull
+ Optional<Project> getProject();
+
+ /**
+ * Gets the problems that were encountered during the project building.
+ *
+ * @return The problems that were encountered during the project building, can be empty but never {@code null}.
+ */
+ @Nonnull
+ Collection<ProjectBuilderProblem> getProblems();
+
+ /**
+ * Gets the result of the dependency resolution for the project.
+ *
+ * @return The result of the dependency resolution for the project.
+ */
+ @Nonnull
+ Optional<DependencyCollectorResult> getDependencyResolverResult();
+
+}
diff --git a/maven-model/src/main/java/org/apache/maven/model/package-info.java b/api/maven-api-core/src/main/java/org/apache/maven/api/services/ProjectBuilderSource.java
similarity index 69%
copy from maven-model/src/main/java/org/apache/maven/model/package-info.java
copy to api/maven-api-core/src/main/java/org/apache/maven/api/services/ProjectBuilderSource.java
index 88d3fa070..1add18cb1 100644
--- a/maven-model/src/main/java/org/apache/maven/model/package-info.java
+++ b/api/maven-api-core/src/main/java/org/apache/maven/api/services/ProjectBuilderSource.java
@@ -1,9 +1,4 @@
-// CHECKSTYLE_OFF: RegexpHeader
-/**
- * Maven POM (Project Object Model) classes, generated from <code>maven.mdo</code> model.
- * The root class is {@link org.apache.maven.model.Model}.
- */
-package org.apache.maven.model;
+package org.apache.maven.api.services;
/*
* Licensed to the Apache Software Foundation (ASF) under one
@@ -22,4 +17,22 @@ package org.apache.maven.model;
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
- */
\ No newline at end of file
+ */
+
+import java.io.IOException;
+import java.io.InputStream;
+
+import org.apache.maven.api.annotations.Experimental;
+
+/**
+ * The source for a project's XML model.
+ *
+ * @since 4.0
+ */
+@Experimental
+public interface ProjectBuilderSource
+{
+ InputStream getInputStream() throws IOException;
+
+ String getLocation();
+}
diff --git a/api/maven-api-core/src/main/java/org/apache/maven/api/services/ProjectManager.java b/api/maven-api-core/src/main/java/org/apache/maven/api/services/ProjectManager.java
new file mode 100644
index 000000000..a908bf19a
--- /dev/null
+++ b/api/maven-api-core/src/main/java/org/apache/maven/api/services/ProjectManager.java
@@ -0,0 +1,93 @@
+package org.apache.maven.api.services;
+
+/*
+ * 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.
+ */
+
+import org.apache.maven.api.Service;
+import org.apache.maven.api.annotations.Experimental;
+import org.apache.maven.api.annotations.Nonnull;
+
+import java.nio.file.Path;
+import java.util.Collection;
+import java.util.List;
+import java.util.Optional;
+
+import org.apache.maven.api.Artifact;
+import org.apache.maven.api.Node;
+import org.apache.maven.api.Project;
+import org.apache.maven.api.RemoteRepository;
+import org.apache.maven.api.ResolutionScope;
+import org.apache.maven.api.Session;
+
+/**
+ * Interface to manage the project during its lifecycle.
+ *
+ * @since 4.0
+ */
+@Experimental
+public interface ProjectManager extends Service
+{
+ /**
+ * Returns the path to the resolved file in the local repository
+ * if the artifact has been resolved.
+ *
+ * @return the path of the resolved artifact
+ */
+ @Nonnull
+ Optional<Path> getPath( Project project );
+
+ @Nonnull
+ Collection<Artifact> getAttachedArtifacts( Project project );
+
+ default void attachArtifact( Session session, Project project, Path path )
+ {
+ String name = path.getFileName().toString();
+ int dot = name.lastIndexOf( '.' );
+ String ext = dot >= 1 ? name.substring( dot + 1 ) : "";
+ Artifact artifact = session.createArtifact( project.getGroupId(), project.getArtifactId(),
+ project.getVersion(), ext );
+ attachArtifact( project, artifact, path );
+ }
+
+ default void attachArtifact( Session session, Project project, String type, Path path )
+ {
+ Artifact artifact = session.createArtifact( project.getGroupId(), project.getArtifactId(),
+ project.getVersion(), null, null, type );
+ attachArtifact( project, artifact, path );
+ }
+
+ void attachArtifact( Project project, Artifact artifact, Path path );
+
+ List<String> getCompileSourceRoots( Project project );
+
+ void addCompileSourceRoot( Project project, String sourceRoot );
+
+ List<String> getTestCompileSourceRoots( Project project );
+
+ void addTestCompileSourceRoot( Project project, String sourceRoot );
+
+ List<RemoteRepository> getRepositories( Project project );
+
+ List<Artifact> getResolvedDependencies( Project project, ResolutionScope scope );
+
+ Node getCollectedDependencies( Project project, ResolutionScope scope );
+
+ void setProperty( Project project, String key, String value );
+
+}
diff --git a/api/maven-api-core/src/main/java/org/apache/maven/api/services/Prompter.java b/api/maven-api-core/src/main/java/org/apache/maven/api/services/Prompter.java
new file mode 100644
index 000000000..a5229f4b4
--- /dev/null
+++ b/api/maven-api-core/src/main/java/org/apache/maven/api/services/Prompter.java
@@ -0,0 +1,106 @@
+package org.apache.maven.api.services;
+
+/*
+ * 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.
+ */
+
+import java.util.List;
+
+import org.apache.maven.api.Service;
+import org.apache.maven.api.annotations.Experimental;
+
+/**
+ * Service used to interact with the end user.
+ *
+ * @since 4.0
+ */
+@Experimental
+public interface Prompter extends Service
+{
+ /**
+ * Prompts the user for a string.
+ *
+ * @param message the message to display to the user
+ * @return the string entered by the user
+ * @throws PrompterException if an exception occurs
+ */
+ default String prompt( String message )
+ throws PrompterException
+ {
+ return prompt( message, null, null );
+ }
+
+ /**
+ * Prompts the user for a string using a default value.
+ *
+ * @param message the message to display
+ * @param defaultReply the default reply value
+ * @return the string entered by the user
+ * @throws PrompterException if an exception occurs
+ */
+ default String prompt( String message, String defaultReply )
+ throws PrompterException
+ {
+ return prompt( message, null, defaultReply );
+ }
+
+ /**
+ * Prompts the user for a string using a list of possible values.
+ *
+ * @param message the message to display
+ * @param possibleValues the list of possible values
+ * @return the string entered by the user
+ * @throws PrompterException if an exception occurs
+ */
+ default String prompt( String message, List<String> possibleValues )
+ throws PrompterException
+ {
+ return prompt( message, possibleValues, null );
+ }
+
+ /**
+ * Prompts the user for a string using a list of possible values and a default reply.
+ *
+ * @param message the message to display
+ * @param possibleValues the list of possible values
+ * @param defaultReply the default reply value
+ * @return the string entered by the user
+ * @throws PrompterException if an exception occurs
+ */
+ String prompt( String message, List<String> possibleValues, String defaultReply )
+ throws PrompterException;
+
+ /**
+ * Prompts the user for a password.
+ *
+ * @param message the message to display
+ * @return the password entered by the user
+ * @throws PrompterException if an exception occurs
+ */
+ String promptForPassword( String message )
+ throws PrompterException;
+
+ /**
+ * Displays a message to the user.
+ *
+ * @param message the message to display
+ * @throws PrompterException if an exception occurs
+ */
+ void showMessage( String message )
+ throws PrompterException;
+}
diff --git a/maven-model-builder/src/test/java/org/apache/maven/model/interpolation/StringVisitorModelInterpolatorTest.java b/api/maven-api-core/src/main/java/org/apache/maven/api/services/PrompterException.java
similarity index 61%
copy from maven-model-builder/src/test/java/org/apache/maven/model/interpolation/StringVisitorModelInterpolatorTest.java
copy to api/maven-api-core/src/main/java/org/apache/maven/api/services/PrompterException.java
index 8fa92cecf..4f892c749 100644
--- a/maven-model-builder/src/test/java/org/apache/maven/model/interpolation/StringVisitorModelInterpolatorTest.java
+++ b/api/maven-api-core/src/main/java/org/apache/maven/api/services/PrompterException.java
@@ -1,4 +1,4 @@
-package org.apache.maven.model.interpolation;
+package org.apache.maven.api.services;
/*
* Licensed to the Apache Software Foundation (ASF) under one
@@ -9,7 +9,7 @@ package org.apache.maven.model.interpolation;
* "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
+ * 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
@@ -19,10 +19,24 @@ package org.apache.maven.model.interpolation;
* under the License.
*/
-public class StringVisitorModelInterpolatorTest extends AbstractModelInterpolatorTest
+import org.apache.maven.api.annotations.Experimental;
+
+/**
+ * The Exception class throw by the {@link Prompter} service.
+ *
+ * @since 4.0
+ */
+@Experimental
+public class PrompterException
+ extends MavenException
{
- protected ModelInterpolator createInterpolator()
+ /**
+ * @param message The message to give.
+ * @param e The {@link Exception}.
+ */
+ public PrompterException( String message, Exception e )
{
- return new StringVisitorModelInterpolator( null, null, new DefaultModelVersionProcessor() );
+ super( message, e );
}
-}
\ No newline at end of file
+
+}
diff --git a/maven-core/src/main/java/org/apache/maven/plugin/CycleDetectedInPluginGraphException.java b/api/maven-api-core/src/main/java/org/apache/maven/api/services/RepositoryFactory.java
similarity index 52%
copy from maven-core/src/main/java/org/apache/maven/plugin/CycleDetectedInPluginGraphException.java
copy to api/maven-api-core/src/main/java/org/apache/maven/api/services/RepositoryFactory.java
index f77461fe3..727a3e485 100644
--- a/maven-core/src/main/java/org/apache/maven/plugin/CycleDetectedInPluginGraphException.java
+++ b/api/maven-api-core/src/main/java/org/apache/maven/api/services/RepositoryFactory.java
@@ -1,4 +1,4 @@
-package org.apache.maven.plugin;
+package org.apache.maven.api.services;
/*
* Licensed to the Apache Software Foundation (ASF) under one
@@ -19,28 +19,31 @@ package org.apache.maven.plugin;
* under the License.
*/
-import org.apache.maven.model.Plugin;
-import org.codehaus.plexus.component.composition.CycleDetectedInComponentGraphException;
+import java.nio.file.Path;
+
+import org.apache.maven.api.LocalRepository;
+import org.apache.maven.api.RemoteRepository;
+import org.apache.maven.api.Service;
+import org.apache.maven.api.annotations.Experimental;
+import org.apache.maven.api.annotations.Nonnull;
+import org.apache.maven.api.model.Repository;
/**
- * Exception occurring trying to resolve a plugin.
+ * Factory service to create {@link LocalRepository} or {@link RemoteRepository} objects.
*
- * @author <a href="mailto:brett@apache.org">Brett Porter</a>
+ * @since 4.0
*/
-public class CycleDetectedInPluginGraphException
- extends Exception
+@Experimental
+public interface RepositoryFactory extends Service
{
- private final Plugin plugin;
- public CycleDetectedInPluginGraphException( Plugin plugin, CycleDetectedInComponentGraphException e )
- {
- super( "A cycle was detected in the component graph of the plugin: " + plugin.getArtifactId() );
+ @Nonnull
+ LocalRepository createLocal( @Nonnull Path path );
+
+ @Nonnull
+ RemoteRepository createRemote( @Nonnull String id, @Nonnull String url );
- this.plugin = plugin;
- }
+ @Nonnull
+ RemoteRepository createRemote( @Nonnull Repository repository );
- public Plugin getPlugin()
- {
- return plugin;
- }
}
diff --git a/maven-model/src/main/java/org/apache/maven/model/package-info.java b/api/maven-api-core/src/main/java/org/apache/maven/api/services/ToolchainFactory.java
similarity index 71%
copy from maven-model/src/main/java/org/apache/maven/model/package-info.java
copy to api/maven-api-core/src/main/java/org/apache/maven/api/services/ToolchainFactory.java
index 88d3fa070..9b0c54d55 100644
--- a/maven-model/src/main/java/org/apache/maven/model/package-info.java
+++ b/api/maven-api-core/src/main/java/org/apache/maven/api/services/ToolchainFactory.java
@@ -1,9 +1,4 @@
-// CHECKSTYLE_OFF: RegexpHeader
-/**
- * Maven POM (Project Object Model) classes, generated from <code>maven.mdo</code> model.
- * The root class is {@link org.apache.maven.model.Model}.
- */
-package org.apache.maven.model;
+package org.apache.maven.api.services;
/*
* Licensed to the Apache Software Foundation (ASF) under one
@@ -14,7 +9,7 @@ package org.apache.maven.model;
* "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
+ * 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
@@ -22,4 +17,17 @@ package org.apache.maven.model;
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
- */
\ No newline at end of file
+ */
+
+import org.apache.maven.api.annotations.Consumer;
+import org.apache.maven.api.annotations.Experimental;
+
+/**
+ * @since 4.0
+ */
+@Experimental
+@Consumer
+public interface ToolchainFactory
+{
+ // TODO: implement ToolchainFactory
+}
diff --git a/api/maven-api-core/src/main/java/org/apache/maven/api/services/ToolchainManager.java b/api/maven-api-core/src/main/java/org/apache/maven/api/services/ToolchainManager.java
new file mode 100644
index 000000000..d5c6c5779
--- /dev/null
+++ b/api/maven-api-core/src/main/java/org/apache/maven/api/services/ToolchainManager.java
@@ -0,0 +1,82 @@
+package org.apache.maven.api.services;
+
+/*
+ * 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.
+ */
+
+import java.util.List;
+import java.util.Map;
+import java.util.Optional;
+
+import org.apache.maven.api.Service;
+import org.apache.maven.api.Session;
+import org.apache.maven.api.Toolchain;
+import org.apache.maven.api.annotations.Experimental;
+import org.apache.maven.api.annotations.Nonnull;
+
+/**
+ * Service to manage {@link Toolchain}s.
+ *
+ * @since 4.0
+ */
+@Experimental
+public interface ToolchainManager extends Service
+{
+
+ /**
+ *
+ * @param session
+ * @param type
+ * @param requirements
+ * @return the selected {@link Toolchain}s
+ * @throws ToolchainManagerException if an exception occurs
+ */
+ @Nonnull
+ List<Toolchain> getToolchains( @Nonnull Session session, String type, Map<String, String> requirements );
+
+ /**
+ *
+ * @param session
+ * @param type
+ * @return the selected {@link Toolchain}
+ * @throws ToolchainManagerException if an exception occurs
+ */
+ @Nonnull
+ Optional<Toolchain> getToolchainFromBuildContext( @Nonnull Session session, String type )
+ throws ToolchainManagerException;
+
+ /**
+ *
+ * @param session
+ * @param type
+ * @return the selected {@link Toolchain}s
+ * @throws ToolchainManagerException if an exception occurs
+ */
+ @Nonnull
+ List<Toolchain> getToolchainsForType( @Nonnull Session session, String type )
+ throws ToolchainManagerException;
+
+ /**
+ *
+ * @param session
+ * @param toolchain
+ * @throws ToolchainManagerException if an exception occurs
+ */
+ void storeToolchainToBuildContext( @Nonnull Session session, Toolchain toolchain )
+ throws ToolchainManagerException;
+}
diff --git a/maven-model-builder/src/test/java/org/apache/maven/model/interpolation/StringVisitorModelInterpolatorTest.java b/api/maven-api-core/src/main/java/org/apache/maven/api/services/ToolchainManagerException.java
similarity index 60%
copy from maven-model-builder/src/test/java/org/apache/maven/model/interpolation/StringVisitorModelInterpolatorTest.java
copy to api/maven-api-core/src/main/java/org/apache/maven/api/services/ToolchainManagerException.java
index 8fa92cecf..2c8a2bd8f 100644
--- a/maven-model-builder/src/test/java/org/apache/maven/model/interpolation/StringVisitorModelInterpolatorTest.java
+++ b/api/maven-api-core/src/main/java/org/apache/maven/api/services/ToolchainManagerException.java
@@ -1,4 +1,4 @@
-package org.apache.maven.model.interpolation;
+package org.apache.maven.api.services;
/*
* Licensed to the Apache Software Foundation (ASF) under one
@@ -9,7 +9,7 @@ package org.apache.maven.model.interpolation;
* "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
+ * 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
@@ -19,10 +19,24 @@ package org.apache.maven.model.interpolation;
* under the License.
*/
-public class StringVisitorModelInterpolatorTest extends AbstractModelInterpolatorTest
+import org.apache.maven.api.annotations.Experimental;
+
+/**
+ * The Exception class throw by the {@link ToolchainManager}.
+ *
+ * @since 4.0
+ */
+@Experimental
+public class ToolchainManagerException
+ extends MavenException
{
- protected ModelInterpolator createInterpolator()
+ /**
+ * @param message The message to give.
+ * @param e The {@link Exception}.
+ */
+ public ToolchainManagerException( String message, Exception e )
{
- return new StringVisitorModelInterpolator( null, null, new DefaultModelVersionProcessor() );
+ super( message, e );
}
-}
\ No newline at end of file
+
+}
diff --git a/maven-settings-builder/src/main/java/org/apache/maven/settings/validation/SettingsValidator.java b/api/maven-api-core/src/main/java/org/apache/maven/api/services/TypeRegistry.java
similarity index 58%
copy from maven-settings-builder/src/main/java/org/apache/maven/settings/validation/SettingsValidator.java
copy to api/maven-api-core/src/main/java/org/apache/maven/api/services/TypeRegistry.java
index 79745ecaf..21482ba40 100644
--- a/maven-settings-builder/src/main/java/org/apache/maven/settings/validation/SettingsValidator.java
+++ b/api/maven-api-core/src/main/java/org/apache/maven/api/services/TypeRegistry.java
@@ -1,4 +1,4 @@
-package org.apache.maven.settings.validation;
+package org.apache.maven.api.services;
/*
* Licensed to the Apache Software Foundation (ASF) under one
@@ -19,23 +19,29 @@ package org.apache.maven.settings.validation;
* under the License.
*/
-import org.apache.maven.settings.Settings;
-import org.apache.maven.settings.building.SettingsProblemCollector;
+import org.apache.maven.api.Service;
+import org.apache.maven.api.Type;
+import org.apache.maven.api.annotations.Experimental;
+import org.apache.maven.api.annotations.Nonnull;
/**
- * Validate a model settings
+ * Access to {@link Type} registry.
*
- * @author Milos Kleint
+ * @since 4.0
*/
-public interface SettingsValidator
+@Experimental
+public interface TypeRegistry extends Service
{
/**
- * Validate the specified settings.
+ * Obtain the {@link Type} from the specified {@code id}.
+ * If no type is known for {@code id}, the registry will
+ * create a custom {@code Type} for it.
*
- * @param settings The settings to validate, must not be {@code null}.
- * @param problems The container used to collect problems that were encountered, must not be {@code null}.
+ * @param id the id of the type to retrieve
+ * @return the type
*/
- void validate( Settings settings, SettingsProblemCollector problems );
+ @Nonnull
+ Type getType( @Nonnull String id );
}
diff --git a/api/maven-api-core/src/main/java/org/apache/maven/api/services/VersionParser.java b/api/maven-api-core/src/main/java/org/apache/maven/api/services/VersionParser.java
new file mode 100644
index 000000000..ed5e69ba7
--- /dev/null
+++ b/api/maven-api-core/src/main/java/org/apache/maven/api/services/VersionParser.java
@@ -0,0 +1,62 @@
+package org.apache.maven.api.services;
+
+/*
+ * 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.
+ */
+
+import org.apache.maven.api.Service;
+import org.apache.maven.api.Version;
+import org.apache.maven.api.VersionRange;
+import org.apache.maven.api.annotations.Experimental;
+import org.apache.maven.api.annotations.Nonnull;
+
+/**
+ * Service interface to parse {@link Version} and {@link VersionRange}.
+ *
+ * @since 4.0
+ */
+@Experimental
+public interface VersionParser extends Service
+{
+ /**
+ * Parses the specified version string, for example "1.0".
+ *
+ * @param version The version string to parse, must not be {@code null}.
+ * @return The parsed version, never {@code null}.
+ * @throws VersionParserException If the string violates the syntax rules of this scheme.
+ * @see org.apache.maven.api.Session#parseVersion(String)
+ */
+ @Nonnull
+ Version parseVersion( @Nonnull String version );
+
+ /**
+ * Parses the specified version range specification, for example "[1.0,2.0)".
+ *
+ * @param range The range specification to parse, must not be {@code null}.
+ * @return The parsed version range, never {@code null}.
+ * @throws VersionParserException If the range specification violates the syntax rules of this scheme.
+ */
+ @Nonnull
+ VersionRange parseVersionRange( @Nonnull String range );
+
+ /**
+ * Checks whether a given artifact version is considered a {@code SNAPSHOT} or not.
+ */
+ boolean isSnapshot( @Nonnull String version );
+
+}
diff --git a/maven-model-builder/src/test/java/org/apache/maven/model/interpolation/StringVisitorModelInterpolatorTest.java b/api/maven-api-core/src/main/java/org/apache/maven/api/services/VersionParserException.java
similarity index 61%
copy from maven-model-builder/src/test/java/org/apache/maven/model/interpolation/StringVisitorModelInterpolatorTest.java
copy to api/maven-api-core/src/main/java/org/apache/maven/api/services/VersionParserException.java
index 8fa92cecf..f0c448113 100644
--- a/maven-model-builder/src/test/java/org/apache/maven/model/interpolation/StringVisitorModelInterpolatorTest.java
+++ b/api/maven-api-core/src/main/java/org/apache/maven/api/services/VersionParserException.java
@@ -1,4 +1,4 @@
-package org.apache.maven.model.interpolation;
+package org.apache.maven.api.services;
/*
* Licensed to the Apache Software Foundation (ASF) under one
@@ -9,7 +9,7 @@ package org.apache.maven.model.interpolation;
* "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
+ * 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
@@ -19,10 +19,24 @@ package org.apache.maven.model.interpolation;
* under the License.
*/
-public class StringVisitorModelInterpolatorTest extends AbstractModelInterpolatorTest
+import org.apache.maven.api.annotations.Experimental;
+
+/**
+ * The Exception class thrown by {@link VersionParser}.
+ *
+ * @since 4.0
+ */
+@Experimental
+public class VersionParserException
+ extends MavenException
{
- protected ModelInterpolator createInterpolator()
+ /**
+ * @param message The message to give.
+ * @param e The {@link Exception}.
+ */
+ public VersionParserException( String message, Exception e )
{
- return new StringVisitorModelInterpolator( null, null, new DefaultModelVersionProcessor() );
+ super( message, e );
}
-}
\ No newline at end of file
+
+}
diff --git a/maven-model/src/main/java/org/apache/maven/model/package-info.java b/api/maven-api-core/src/main/java/org/apache/maven/api/services/xml/ModelXmlFactory.java
similarity index 69%
copy from maven-model/src/main/java/org/apache/maven/model/package-info.java
copy to api/maven-api-core/src/main/java/org/apache/maven/api/services/xml/ModelXmlFactory.java
index 88d3fa070..8de030ff7 100644
--- a/maven-model/src/main/java/org/apache/maven/model/package-info.java
+++ b/api/maven-api-core/src/main/java/org/apache/maven/api/services/xml/ModelXmlFactory.java
@@ -1,9 +1,4 @@
-// CHECKSTYLE_OFF: RegexpHeader
-/**
- * Maven POM (Project Object Model) classes, generated from <code>maven.mdo</code> model.
- * The root class is {@link org.apache.maven.model.Model}.
- */
-package org.apache.maven.model;
+package org.apache.maven.api.services.xml;
/*
* Licensed to the Apache Software Foundation (ASF) under one
@@ -14,7 +9,7 @@ package org.apache.maven.model;
* "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
+ * 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
@@ -22,4 +17,18 @@ package org.apache.maven.model;
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
- */
\ No newline at end of file
+ */
+
+import org.apache.maven.api.annotations.Experimental;
+import org.apache.maven.api.model.Model;
+
+/**
+ * Reads or writes a {@link Model} using XML.
+ *
+ * @since 4.0
+ */
+@Experimental
+public interface ModelXmlFactory extends XmlFactory<Model>
+{
+
+}
diff --git a/maven-model/src/main/java/org/apache/maven/model/package-info.java b/api/maven-api-core/src/main/java/org/apache/maven/api/services/xml/SettingsXmlFactory.java
similarity index 68%
copy from maven-model/src/main/java/org/apache/maven/model/package-info.java
copy to api/maven-api-core/src/main/java/org/apache/maven/api/services/xml/SettingsXmlFactory.java
index 88d3fa070..0d6672ae9 100644
--- a/maven-model/src/main/java/org/apache/maven/model/package-info.java
+++ b/api/maven-api-core/src/main/java/org/apache/maven/api/services/xml/SettingsXmlFactory.java
@@ -1,9 +1,4 @@
-// CHECKSTYLE_OFF: RegexpHeader
-/**
- * Maven POM (Project Object Model) classes, generated from <code>maven.mdo</code> model.
- * The root class is {@link org.apache.maven.model.Model}.
- */
-package org.apache.maven.model;
+package org.apache.maven.api.services.xml;
/*
* Licensed to the Apache Software Foundation (ASF) under one
@@ -14,7 +9,7 @@ package org.apache.maven.model;
* "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
+ * 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
@@ -22,4 +17,18 @@ package org.apache.maven.model;
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
- */
\ No newline at end of file
+ */
+
+import org.apache.maven.api.annotations.Experimental;
+import org.apache.maven.api.settings.Settings;
+
+/**
+ * Reads and writes a {@link Settings} object to/from XML.
+ *
+ * @since 4.0
+ */
+@Experimental
+public interface SettingsXmlFactory extends XmlFactory<Settings>
+{
+
+}
diff --git a/maven-model/src/main/java/org/apache/maven/model/package-info.java b/api/maven-api-core/src/main/java/org/apache/maven/api/services/xml/ToolchainsXmlFactory.java
similarity index 66%
copy from maven-model/src/main/java/org/apache/maven/model/package-info.java
copy to api/maven-api-core/src/main/java/org/apache/maven/api/services/xml/ToolchainsXmlFactory.java
index 88d3fa070..854cb9791 100644
--- a/maven-model/src/main/java/org/apache/maven/model/package-info.java
+++ b/api/maven-api-core/src/main/java/org/apache/maven/api/services/xml/ToolchainsXmlFactory.java
@@ -1,9 +1,4 @@
-// CHECKSTYLE_OFF: RegexpHeader
-/**
- * Maven POM (Project Object Model) classes, generated from <code>maven.mdo</code> model.
- * The root class is {@link org.apache.maven.model.Model}.
- */
-package org.apache.maven.model;
+package org.apache.maven.api.services.xml;
/*
* Licensed to the Apache Software Foundation (ASF) under one
@@ -14,7 +9,7 @@ package org.apache.maven.model;
* "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
+ * 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
@@ -22,4 +17,18 @@ package org.apache.maven.model;
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
- */
\ No newline at end of file
+ */
+
+import org.apache.maven.api.annotations.Experimental;
+import org.apache.maven.api.toolchain.PersistedToolchains;
+
+/**
+ * Reads and writes a {@link PersistedToolchains} object to/from XML.
+ *
+ * @since 4.0
+ */
+@Experimental
+public interface ToolchainsXmlFactory extends XmlFactory<PersistedToolchains>
+{
+
+}
diff --git a/api/maven-api-core/src/main/java/org/apache/maven/api/services/xml/XmlFactory.java b/api/maven-api-core/src/main/java/org/apache/maven/api/services/xml/XmlFactory.java
new file mode 100644
index 000000000..651b1a5fe
--- /dev/null
+++ b/api/maven-api-core/src/main/java/org/apache/maven/api/services/xml/XmlFactory.java
@@ -0,0 +1,98 @@
+package org.apache.maven.api.services.xml;
+
+/*
+ * 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.
+ */
+
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.io.Reader;
+import java.io.Writer;
+import java.nio.file.Path;
+
+import org.apache.maven.api.annotations.Experimental;
+import org.apache.maven.api.annotations.Nonnull;
+import org.apache.maven.api.Service;
+
+/**
+ * Generic interface to read/write objects to/from XML.
+ *
+ * @param <T> the object type to read/write
+ * @since 4.0
+ */
+@Experimental
+public interface XmlFactory<T> extends Service
+{
+
+ @Nonnull
+ default T read( @Nonnull Path path ) throws XmlReaderException
+ {
+ return read( path, true );
+ }
+
+ @Nonnull
+ default T read( @Nonnull Path path, boolean strict ) throws XmlReaderException
+ {
+ return read( XmlReaderRequest.builder().path( path ).strict( strict ).build() );
+ }
+
+ @Nonnull
+ default T read( @Nonnull InputStream input ) throws XmlReaderException
+ {
+ return read( input, true );
+ }
+
+ @Nonnull
+ default T read( @Nonnull InputStream input, boolean strict ) throws XmlReaderException
+ {
+ return read( XmlReaderRequest.builder().inputStream( input ).strict( strict ).build() );
+ }
+
+ @Nonnull
+ default T read( @Nonnull Reader reader ) throws XmlReaderException
+ {
+ return read( reader, true );
+ }
+
+ @Nonnull
+ default T read( @Nonnull Reader reader, boolean strict ) throws XmlReaderException
+ {
+ return read( XmlReaderRequest.builder().reader( reader ).strict( strict ).build() );
+ }
+
+ @Nonnull
+ T read( @Nonnull XmlReaderRequest request ) throws XmlReaderException;
+
+ default void write( @Nonnull T content, @Nonnull Path path ) throws XmlWriterException
+ {
+ write( XmlWriterRequest.<T>builder().content( content ).path( path ).build() );
+ }
+
+ default void write( @Nonnull T content, @Nonnull OutputStream outputStream ) throws XmlWriterException
+ {
+ write( XmlWriterRequest.<T>builder().content( content ).outputStream( outputStream ).build() );
+ }
+
+ default void write( @Nonnull T content, @Nonnull Writer writer ) throws XmlWriterException
+ {
+ write( XmlWriterRequest.<T>builder().content( content ).writer( writer ).build() );
+ }
+
+ void write( @Nonnull XmlWriterRequest<T> request ) throws XmlWriterException;
+
+}
diff --git a/maven-settings-builder/src/main/java/org/apache/maven/settings/validation/SettingsValidator.java b/api/maven-api-core/src/main/java/org/apache/maven/api/services/xml/XmlReaderException.java
similarity index 60%
copy from maven-settings-builder/src/main/java/org/apache/maven/settings/validation/SettingsValidator.java
copy to api/maven-api-core/src/main/java/org/apache/maven/api/services/xml/XmlReaderException.java
index 79745ecaf..2cc30c0c2 100644
--- a/maven-settings-builder/src/main/java/org/apache/maven/settings/validation/SettingsValidator.java
+++ b/api/maven-api-core/src/main/java/org/apache/maven/api/services/xml/XmlReaderException.java
@@ -1,4 +1,4 @@
-package org.apache.maven.settings.validation;
+package org.apache.maven.api.services.xml;
/*
* Licensed to the Apache Software Foundation (ASF) under one
@@ -19,23 +19,26 @@ package org.apache.maven.settings.validation;
* under the License.
*/
-import org.apache.maven.settings.Settings;
-import org.apache.maven.settings.building.SettingsProblemCollector;
+import org.apache.maven.api.annotations.Experimental;
+import org.apache.maven.api.services.MavenException;
/**
- * Validate a model settings
+ * An exception thrown during the reading of an xml file.
*
- * @author Milos Kleint
+ * @since 4.0
*/
-public interface SettingsValidator
+@Experimental
+public class XmlReaderException
+ extends MavenException
{
/**
- * Validate the specified settings.
- *
- * @param settings The settings to validate, must not be {@code null}.
- * @param problems The container used to collect problems that were encountered, must not be {@code null}.
+ * @param message The message for the exception.
+ * @param e The exception itself.
*/
- void validate( Settings settings, SettingsProblemCollector problems );
+ public XmlReaderException( String message, Exception e )
+ {
+ super( message, e );
+ }
}
diff --git a/api/maven-api-core/src/main/java/org/apache/maven/api/services/xml/XmlReaderRequest.java b/api/maven-api-core/src/main/java/org/apache/maven/api/services/xml/XmlReaderRequest.java
new file mode 100644
index 000000000..05e442303
--- /dev/null
+++ b/api/maven-api-core/src/main/java/org/apache/maven/api/services/xml/XmlReaderRequest.java
@@ -0,0 +1,236 @@
+package org.apache.maven.api.services.xml;
+
+/*
+ * 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.
+ */
+
+import java.io.InputStream;
+import java.io.Reader;
+import java.net.URL;
+import java.nio.file.Path;
+
+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.NotThreadSafe;
+
+/**
+ * An XML reader request.
+ *
+ * @since 4.0
+ */
+@Experimental
+@Immutable
+public interface XmlReaderRequest
+{
+
+ Path getPath();
+
+ URL getURL();
+
+ InputStream getInputStream();
+
+ Reader getReader();
+
+ Transformer getTransformer();
+
+ boolean isStrict();
+
+ String getModelId();
+
+ String getLocation();
+
+ boolean isAddDefaultEntities();
+
+ interface Transformer
+ {
+ /**
+ * Interpolate the value read from the xml document
+ *
+ * @param source The source value
+ * @param fieldName A description of the field being interpolated. The implementation may use this to
+ * log stuff.
+ * @return The interpolated value.
+ */
+ String transform( String source, String fieldName );
+ }
+
+ @Nonnull
+ static XmlReaderRequestBuilder builder()
+ {
+ return new XmlReaderRequestBuilder();
+ }
+
+ @NotThreadSafe
+ class XmlReaderRequestBuilder
+ {
+ Path path;
+ URL url;
+ InputStream inputStream;
+ Reader reader;
+ Transformer transformer;
+ boolean strict;
+ String modelId;
+ String location;
+ boolean addDefaultEntities = true;
+
+ public XmlReaderRequestBuilder path( Path path )
+ {
+ this.path = path;
+ return this;
+ }
+
+ public XmlReaderRequestBuilder url( URL url )
+ {
+ this.url = url;
+ return this;
+ }
+
+ public XmlReaderRequestBuilder inputStream( InputStream inputStream )
+ {
+ this.inputStream = inputStream;
+ return this;
+ }
+
+ public XmlReaderRequestBuilder reader( Reader reader )
+ {
+ this.reader = reader;
+ return this;
+ }
+
+ public XmlReaderRequestBuilder transformer( Transformer transformer )
+ {
+ this.transformer = transformer;
+ return this;
+ }
+
+ public XmlReaderRequestBuilder strict( boolean strict )
+ {
+ this.strict = strict;
+ return this;
+ }
+
+ public XmlReaderRequestBuilder modelId( String modelId )
+ {
+ this.modelId = modelId;
+ return this;
+ }
+
+ public XmlReaderRequestBuilder location( String location )
+ {
+ this.location = location;
+ return this;
+ }
+
+ public XmlReaderRequestBuilder addDefaultEntities( boolean addDefaultEntities )
+ {
+ this.addDefaultEntities = addDefaultEntities;
+ return this;
+ }
+
+ public XmlReaderRequest build()
+ {
+ return new DefaultXmlReaderRequest( path, url, inputStream, reader, transformer, strict,
+ modelId, location, addDefaultEntities );
+ }
+
+ private static class DefaultXmlReaderRequest implements XmlReaderRequest
+ {
+ final Path path;
+ final URL url;
+ final InputStream inputStream;
+ final Reader reader;
+ final Transformer transformer;
+ final boolean strict;
+ final String modelId;
+ final String location;
+ final boolean addDefaultEntities;
+
+ @SuppressWarnings( "checkstyle:ParameterNumber" )
+ DefaultXmlReaderRequest( Path path, URL url, InputStream inputStream, Reader reader,
+ Transformer transformer, boolean strict,
+ String modelId, String location,
+ boolean addDefaultEntities )
+ {
+ this.path = path;
+ this.url = url;
+ this.inputStream = inputStream;
+ this.reader = reader;
+ this.transformer = transformer;
+ this.strict = strict;
+ this.modelId = modelId;
+ this.location = location;
+ this.addDefaultEntities = addDefaultEntities;
+ }
+
+ @Override
+ public Path getPath()
+ {
+ return path;
+ }
+
+ @Override
+ public URL getURL()
+ {
+ return null;
+ }
+
+ @Override
+ public InputStream getInputStream()
+ {
+ return inputStream;
+ }
+
+ public Reader getReader()
+ {
+ return reader;
+ }
+
+ @Override
+ public Transformer getTransformer()
+ {
+ return transformer;
+ }
+
+ @Override
+ public boolean isStrict()
+ {
+ return strict;
+ }
+
+ @Override
+ public String getModelId()
+ {
+ return modelId;
+ }
+
+ @Override
+ public String getLocation()
+ {
+ return location;
+ }
+
+ @Override
+ public boolean isAddDefaultEntities()
+ {
+ return addDefaultEntities;
+ }
+ }
+ }
+
+}
diff --git a/maven-settings-builder/src/main/java/org/apache/maven/settings/validation/SettingsValidator.java b/api/maven-api-core/src/main/java/org/apache/maven/api/services/xml/XmlWriterException.java
similarity index 60%
copy from maven-settings-builder/src/main/java/org/apache/maven/settings/validation/SettingsValidator.java
copy to api/maven-api-core/src/main/java/org/apache/maven/api/services/xml/XmlWriterException.java
index 79745ecaf..099b6ea12 100644
--- a/maven-settings-builder/src/main/java/org/apache/maven/settings/validation/SettingsValidator.java
+++ b/api/maven-api-core/src/main/java/org/apache/maven/api/services/xml/XmlWriterException.java
@@ -1,4 +1,4 @@
-package org.apache.maven.settings.validation;
+package org.apache.maven.api.services.xml;
/*
* Licensed to the Apache Software Foundation (ASF) under one
@@ -19,23 +19,26 @@ package org.apache.maven.settings.validation;
* under the License.
*/
-import org.apache.maven.settings.Settings;
-import org.apache.maven.settings.building.SettingsProblemCollector;
+import org.apache.maven.api.annotations.Experimental;
+import org.apache.maven.api.services.MavenException;
/**
- * Validate a model settings
+ * An exception thrown during the writing of an xml file.
*
- * @author Milos Kleint
+ * @since 4.0
*/
-public interface SettingsValidator
+@Experimental
+public class XmlWriterException
+ extends MavenException
{
/**
- * Validate the specified settings.
- *
- * @param settings The settings to validate, must not be {@code null}.
- * @param problems The container used to collect problems that were encountered, must not be {@code null}.
+ * @param message The message for the exception.
+ * @param e The exception itself.
*/
- void validate( Settings settings, SettingsProblemCollector problems );
+ public XmlWriterException( String message, Exception e )
+ {
+ super( message, e );
+ }
}
diff --git a/api/maven-api-core/src/main/java/org/apache/maven/api/services/xml/XmlWriterRequest.java b/api/maven-api-core/src/main/java/org/apache/maven/api/services/xml/XmlWriterRequest.java
new file mode 100644
index 000000000..15f0319dd
--- /dev/null
+++ b/api/maven-api-core/src/main/java/org/apache/maven/api/services/xml/XmlWriterRequest.java
@@ -0,0 +1,127 @@
+package org.apache.maven.api.services.xml;
+
+/*
+ * 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.
+ */
+
+import java.io.OutputStream;
+import java.io.Writer;
+import java.nio.file.Path;
+
+import org.apache.maven.api.annotations.Experimental;
+
+/**
+ * An XML writer request.
+ *
+ * @since 4.0
+ * @param <T> the object type to read
+ */
+@Experimental
+public interface XmlWriterRequest<T>
+{
+
+ Path getPath();
+
+ OutputStream getOutputStream();
+
+ Writer getWriter();
+
+ T getContent();
+
+ static <T> XmlWriterRequestBuilder<T> builder()
+ {
+ return new XmlWriterRequestBuilder<>();
+ }
+
+ class XmlWriterRequestBuilder<T>
+ {
+ Path path;
+ OutputStream outputStream;
+ Writer writer;
+ T content;
+
+ public XmlWriterRequestBuilder<T> path( Path path )
+ {
+ this.path = path;
+ return this;
+ }
+
+ public XmlWriterRequestBuilder<T> outputStream( OutputStream outputStream )
+ {
+ this.outputStream = outputStream;
+ return this;
+ }
+
+ public XmlWriterRequestBuilder<T> writer( Writer writer )
+ {
+ this.writer = writer;
+ return this;
+ }
+
+ public XmlWriterRequestBuilder<T> content( T content )
+ {
+ this.content = content;
+ return this;
+ }
+
+ public XmlWriterRequest<T> build()
+ {
+ return new DefaultXmlWriterRequest<>( path, outputStream, writer, content );
+ }
+
+ private static class DefaultXmlWriterRequest<T> implements XmlWriterRequest<T>
+ {
+ final Path path;
+ final OutputStream outputStream;
+ final Writer writer;
+ final T content;
+
+ DefaultXmlWriterRequest( Path path, OutputStream outputStream, Writer writer, T content )
+ {
+ this.path = path;
+ this.outputStream = outputStream;
+ this.writer = writer;
+ this.content = content;
+ }
+
+ @Override
+ public Path getPath()
+ {
+ return path;
+ }
+
+ @Override
+ public OutputStream getOutputStream()
+ {
+ return outputStream;
+ }
+
+ @Override
+ public Writer getWriter()
+ {
+ return writer;
+ }
+
+ @Override
+ public T getContent()
+ {
+ return content;
+ }
+ }
+ }
+}
diff --git a/api/maven-api-meta/pom.xml b/api/maven-api-meta/pom.xml
new file mode 100644
index 000000000..8c4d392ad
--- /dev/null
+++ b/api/maven-api-meta/pom.xml
@@ -0,0 +1,32 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<!--
+ 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.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.apache.maven</groupId>
+ <artifactId>maven-api</artifactId>
+ <version>4.0.0-alpha-1-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>maven-api-meta</artifactId>
+ <name>Maven API Meta annotations</name>
+
+</project>
diff --git a/api/maven-api-meta/src/main/java/org/apache/maven/api/annotations/Consumer.java b/api/maven-api-meta/src/main/java/org/apache/maven/api/annotations/Consumer.java
new file mode 100644
index 000000000..f8de92bb3
--- /dev/null
+++ b/api/maven-api-meta/src/main/java/org/apache/maven/api/annotations/Consumer.java
@@ -0,0 +1,47 @@
+package org.apache.maven.api.annotations;
+
+/*
+ * 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.
+ */
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * A type implemented by, or extended by maven plugins or extensions.
+ * Maven plugins or extensions may provide implementations of those types which will be used by maven.
+ * <p>
+ * A type can be marked {@link Consumer} or {@link Provider} but not both. A type is assumed to be
+ * {@link Consumer} if it is not marked either {@link Consumer} or {@link Provider}.
+ * <p>
+ * A package can be marked {@link Provider}. In this case, all types in the package are considered
+ * to be a provider type regardless of whether they are marked {@link Consumer} or {@link Provider}.
+ *
+ * @see Provider
+ * @since 4.0
+ */
+@Experimental
+@Documented
+@Retention( RetentionPolicy.CLASS )
+@Target( { ElementType.TYPE, ElementType.PACKAGE } )
+public @interface Consumer
+{
+}
diff --git a/maven-model/src/main/java/org/apache/maven/model/package-info.java b/api/maven-api-meta/src/main/java/org/apache/maven/api/annotations/Experimental.java
similarity index 60%
copy from maven-model/src/main/java/org/apache/maven/model/package-info.java
copy to api/maven-api-meta/src/main/java/org/apache/maven/api/annotations/Experimental.java
index 88d3fa070..bb706d893 100644
--- a/maven-model/src/main/java/org/apache/maven/model/package-info.java
+++ b/api/maven-api-meta/src/main/java/org/apache/maven/api/annotations/Experimental.java
@@ -1,9 +1,4 @@
-// CHECKSTYLE_OFF: RegexpHeader
-/**
- * Maven POM (Project Object Model) classes, generated from <code>maven.mdo</code> model.
- * The root class is {@link org.apache.maven.model.Model}.
- */
-package org.apache.maven.model;
+package org.apache.maven.api.annotations;
/*
* Licensed to the Apache Software Foundation (ASF) under one
@@ -14,7 +9,7 @@ package org.apache.maven.model;
* "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
+ * 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
@@ -22,4 +17,21 @@ package org.apache.maven.model;
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
- */
\ No newline at end of file
+ */
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+
+/**
+ * This annotation tags types that are part of an experimental API.
+ * Classes or methods annotated with this annotation may be changed / removed without notice.
+ *
+ * @since 4.0
+ */
+@Experimental
+@Documented
+@Retention( RetentionPolicy.CLASS )
+public @interface Experimental
+{
+}
diff --git a/maven-model/src/main/java/org/apache/maven/model/package-info.java b/api/maven-api-meta/src/main/java/org/apache/maven/api/annotations/Generated.java
similarity index 60%
copy from maven-model/src/main/java/org/apache/maven/model/package-info.java
copy to api/maven-api-meta/src/main/java/org/apache/maven/api/annotations/Generated.java
index 88d3fa070..9813f69d5 100644
--- a/maven-model/src/main/java/org/apache/maven/model/package-info.java
+++ b/api/maven-api-meta/src/main/java/org/apache/maven/api/annotations/Generated.java
@@ -1,9 +1,4 @@
-// CHECKSTYLE_OFF: RegexpHeader
-/**
- * Maven POM (Project Object Model) classes, generated from <code>maven.mdo</code> model.
- * The root class is {@link org.apache.maven.model.Model}.
- */
-package org.apache.maven.model;
+package org.apache.maven.api.annotations;
/*
* Licensed to the Apache Software Foundation (ASF) under one
@@ -14,7 +9,7 @@ package org.apache.maven.model;
* "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
+ * 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
@@ -22,4 +17,23 @@ package org.apache.maven.model;
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
- */
\ No newline at end of file
+ */
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * This annotation indicates that a type is automatically generated.
+ *
+ * @since 4.0
+ */
+@Experimental
+@Documented
+@Retention( RetentionPolicy.CLASS )
+@Target( ElementType.TYPE )
+public @interface Generated
+{
+}
diff --git a/maven-settings-builder/src/main/java/org/apache/maven/settings/validation/SettingsValidator.java b/api/maven-api-meta/src/main/java/org/apache/maven/api/annotations/Immutable.java
similarity index 58%
copy from maven-settings-builder/src/main/java/org/apache/maven/settings/validation/SettingsValidator.java
copy to api/maven-api-meta/src/main/java/org/apache/maven/api/annotations/Immutable.java
index 79745ecaf..ea8df9a06 100644
--- a/maven-settings-builder/src/main/java/org/apache/maven/settings/validation/SettingsValidator.java
+++ b/api/maven-api-meta/src/main/java/org/apache/maven/api/annotations/Immutable.java
@@ -1,4 +1,4 @@
-package org.apache.maven.settings.validation;
+package org.apache.maven.api.annotations;
/*
* Licensed to the Apache Software Foundation (ASF) under one
@@ -19,23 +19,25 @@ package org.apache.maven.settings.validation;
* under the License.
*/
-import org.apache.maven.settings.Settings;
-import org.apache.maven.settings.building.SettingsProblemCollector;
+import java.lang.annotation.Documented;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
/**
- * Validate a model settings
+ * The {@code Immutable} annotation indicates that the object is immutable, i.e.
+ * none of its field can be changed. This also ensures that the type is
+ * {@link ThreadSafe}.
*
- * @author Milos Kleint
+ * @see ThreadSafe
+ * @since 4.0
*/
-public interface SettingsValidator
+@Experimental
+@Documented
+@Retention( RetentionPolicy.CLASS )
+@ThreadSafe
+@Target( ElementType.TYPE )
+public @interface Immutable
{
-
- /**
- * Validate the specified settings.
- *
- * @param settings The settings to validate, must not be {@code null}.
- * @param problems The container used to collect problems that were encountered, must not be {@code null}.
- */
- void validate( Settings settings, SettingsProblemCollector problems );
-
}
diff --git a/maven-settings-builder/src/main/java/org/apache/maven/settings/validation/SettingsValidator.java b/api/maven-api-meta/src/main/java/org/apache/maven/api/annotations/Nonnull.java
similarity index 55%
copy from maven-settings-builder/src/main/java/org/apache/maven/settings/validation/SettingsValidator.java
copy to api/maven-api-meta/src/main/java/org/apache/maven/api/annotations/Nonnull.java
index 79745ecaf..0668a3bc8 100644
--- a/maven-settings-builder/src/main/java/org/apache/maven/settings/validation/SettingsValidator.java
+++ b/api/maven-api-meta/src/main/java/org/apache/maven/api/annotations/Nonnull.java
@@ -1,4 +1,4 @@
-package org.apache.maven.settings.validation;
+package org.apache.maven.api.annotations;
/*
* Licensed to the Apache Software Foundation (ASF) under one
@@ -19,23 +19,26 @@ package org.apache.maven.settings.validation;
* under the License.
*/
-import org.apache.maven.settings.Settings;
-import org.apache.maven.settings.building.SettingsProblemCollector;
+import java.lang.annotation.Documented;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
/**
- * Validate a model settings
+ * The annotated element must not be null.
+ * <p>
+ * Annotated fields must not be null after construction has completed.
+ * <p>
+ * When this annotation is applied to a method it applies to the method return value.
*
- * @author Milos Kleint
+ * @see Nullable
+ * @since 4.0
*/
-public interface SettingsValidator
+@Experimental
+@Documented
+@Retention( RetentionPolicy.CLASS )
+@Target( { ElementType.FIELD, ElementType.PARAMETER, ElementType.METHOD } )
+public @interface Nonnull
{
-
- /**
- * Validate the specified settings.
- *
- * @param settings The settings to validate, must not be {@code null}.
- * @param problems The container used to collect problems that were encountered, must not be {@code null}.
- */
- void validate( Settings settings, SettingsProblemCollector problems );
-
}
diff --git a/maven-settings-builder/src/main/java/org/apache/maven/settings/validation/SettingsValidator.java b/api/maven-api-meta/src/main/java/org/apache/maven/api/annotations/NotThreadSafe.java
similarity index 59%
copy from maven-settings-builder/src/main/java/org/apache/maven/settings/validation/SettingsValidator.java
copy to api/maven-api-meta/src/main/java/org/apache/maven/api/annotations/NotThreadSafe.java
index 79745ecaf..ae4a6286f 100644
--- a/maven-settings-builder/src/main/java/org/apache/maven/settings/validation/SettingsValidator.java
+++ b/api/maven-api-meta/src/main/java/org/apache/maven/api/annotations/NotThreadSafe.java
@@ -1,4 +1,4 @@
-package org.apache.maven.settings.validation;
+package org.apache.maven.api.annotations;
/*
* Licensed to the Apache Software Foundation (ASF) under one
@@ -19,23 +19,23 @@ package org.apache.maven.settings.validation;
* under the License.
*/
-import org.apache.maven.settings.Settings;
-import org.apache.maven.settings.building.SettingsProblemCollector;
+import java.lang.annotation.Documented;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
/**
- * Validate a model settings
+ * This annotation indicates that the annotated type is <bold>not</bold> threadsafe
+ * and should only be used by a single thread.
*
- * @author Milos Kleint
+ * @see ThreadSafe
+ * @since 4.0
*/
-public interface SettingsValidator
+@Experimental
+@Documented
+@Retention( RetentionPolicy.CLASS )
+@Target( ElementType.TYPE )
+public @interface NotThreadSafe
{
-
- /**
- * Validate the specified settings.
- *
- * @param settings The settings to validate, must not be {@code null}.
- * @param problems The container used to collect problems that were encountered, must not be {@code null}.
- */
- void validate( Settings settings, SettingsProblemCollector problems );
-
}
diff --git a/maven-model/src/main/java/org/apache/maven/model/package-info.java b/api/maven-api-meta/src/main/java/org/apache/maven/api/annotations/Nullable.java
similarity index 66%
copy from maven-model/src/main/java/org/apache/maven/model/package-info.java
copy to api/maven-api-meta/src/main/java/org/apache/maven/api/annotations/Nullable.java
index 88d3fa070..e21a6de6a 100644
--- a/maven-model/src/main/java/org/apache/maven/model/package-info.java
+++ b/api/maven-api-meta/src/main/java/org/apache/maven/api/annotations/Nullable.java
@@ -1,9 +1,4 @@
-// CHECKSTYLE_OFF: RegexpHeader
-/**
- * Maven POM (Project Object Model) classes, generated from <code>maven.mdo</code> model.
- * The root class is {@link org.apache.maven.model.Model}.
- */
-package org.apache.maven.model;
+package org.apache.maven.api.annotations;
/*
* Licensed to the Apache Software Foundation (ASF) under one
@@ -14,7 +9,7 @@ package org.apache.maven.model;
* "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
+ * 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
@@ -22,4 +17,21 @@ package org.apache.maven.model;
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
- */
\ No newline at end of file
+ */
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+
+/**
+ * The annotated element can be {@code null}.
+ *
+ * @see Nonnull
+ * @since 4.0
+ */
+@Experimental
+@Documented
+@Retention( RetentionPolicy.CLASS )
+public @interface Nullable
+{
+}
diff --git a/api/maven-api-meta/src/main/java/org/apache/maven/api/annotations/Provider.java b/api/maven-api-meta/src/main/java/org/apache/maven/api/annotations/Provider.java
new file mode 100644
index 000000000..ea5174def
--- /dev/null
+++ b/api/maven-api-meta/src/main/java/org/apache/maven/api/annotations/Provider.java
@@ -0,0 +1,47 @@
+package org.apache.maven.api.annotations;
+
+/*
+ * 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.
+ */
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * A type implemented by, or extended by maven itself.
+ * Maven provides implementations of those types and may inject them in plugins.
+ * <p>
+ * A type can be marked {@link Consumer} or {@link Provider} but not both. A type is assumed to be
+ * {@link Consumer} if it is not marked either {@link Consumer} or {@link Provider}.
+ * <p>
+ * A package can be marked {@link Provider}. In this case, all types in the package are considered
+ * to be a provider type regardless of whether they are marked {@link Consumer} or {@link Provider}.
+ *
+ * @see Consumer
+ * @since 4.0
+ */
+@Experimental
+@Documented
+@Retention( RetentionPolicy.CLASS )
+@Target( { ElementType.TYPE, ElementType.PACKAGE } )
+public @interface Provider
+{
+}
diff --git a/maven-settings-builder/src/main/java/org/apache/maven/settings/validation/SettingsValidator.java b/api/maven-api-meta/src/main/java/org/apache/maven/api/annotations/ThreadSafe.java
similarity index 59%
copy from maven-settings-builder/src/main/java/org/apache/maven/settings/validation/SettingsValidator.java
copy to api/maven-api-meta/src/main/java/org/apache/maven/api/annotations/ThreadSafe.java
index 79745ecaf..82d7b8463 100644
--- a/maven-settings-builder/src/main/java/org/apache/maven/settings/validation/SettingsValidator.java
+++ b/api/maven-api-meta/src/main/java/org/apache/maven/api/annotations/ThreadSafe.java
@@ -1,4 +1,4 @@
-package org.apache.maven.settings.validation;
+package org.apache.maven.api.annotations;
/*
* Licensed to the Apache Software Foundation (ASF) under one
@@ -19,23 +19,24 @@ package org.apache.maven.settings.validation;
* under the License.
*/
-import org.apache.maven.settings.Settings;
-import org.apache.maven.settings.building.SettingsProblemCollector;
+import java.lang.annotation.Documented;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
/**
- * Validate a model settings
+ * The {@code ThreadSafe} annotation can be used to indicate a given type
+ * is thread safe. {@link Immutable} objects are automatically thread safe.
*
- * @author Milos Kleint
+ * @see Immutable
+ * @see NotThreadSafe
+ * @since 4.0
*/
-public interface SettingsValidator
+@Experimental
+@Documented
+@Retention( RetentionPolicy.CLASS )
+@Target( ElementType.TYPE )
+public @interface ThreadSafe
{
-
- /**
- * Validate the specified settings.
- *
- * @param settings The settings to validate, must not be {@code null}.
- * @param problems The container used to collect problems that were encountered, must not be {@code null}.
- */
- void validate( Settings settings, SettingsProblemCollector problems );
-
}
diff --git a/maven-model/src/main/java/org/apache/maven/model/package-info.java b/api/maven-api-meta/src/main/java/org/apache/maven/api/annotations/package-info.java
similarity index 73%
copy from maven-model/src/main/java/org/apache/maven/model/package-info.java
copy to api/maven-api-meta/src/main/java/org/apache/maven/api/annotations/package-info.java
index 88d3fa070..2a0d276c7 100644
--- a/maven-model/src/main/java/org/apache/maven/model/package-info.java
+++ b/api/maven-api-meta/src/main/java/org/apache/maven/api/annotations/package-info.java
@@ -1,9 +1,13 @@
// CHECKSTYLE_OFF: RegexpHeader
/**
- * Maven POM (Project Object Model) classes, generated from <code>maven.mdo</code> model.
- * The root class is {@link org.apache.maven.model.Model}.
+ * This package contains non-functional annotations which are
+ * used to tag various elements and help users understanding
+ * how those types should be used.
+ *
+ * @since 4.0
*/
-package org.apache.maven.model;
+@Experimental
+package org.apache.maven.api.annotations;
/*
* Licensed to the Apache Software Foundation (ASF) under one
@@ -14,7 +18,7 @@ package org.apache.maven.model;
* "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
+ * 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
@@ -22,4 +26,5 @@ package org.apache.maven.model;
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
- */
\ No newline at end of file
+ */
+
diff --git a/api/maven-api-model/pom.xml b/api/maven-api-model/pom.xml
new file mode 100644
index 000000000..a62c6c72b
--- /dev/null
+++ b/api/maven-api-model/pom.xml
@@ -0,0 +1,104 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+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.
+-->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.apache.maven</groupId>
+ <artifactId>maven-api</artifactId>
+ <version>4.0.0-alpha-1-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>maven-api-model</artifactId>
+
+ <name>Maven API Model</name>
+ <description>Maven API Model for Maven POM (Project Object Model)</description>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.maven</groupId>
+ <artifactId>maven-api-xml</artifactId>
+ <version>4.0.0-alpha-1-SNAPSHOT</version>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>build-helper-maven-plugin</artifactId>
+ <version>3.2.0</version>
+ <executions>
+ <execution>
+ <id>attach-mdo</id>
+ <goals>
+ <goal>attach-artifact</goal>
+ </goals>
+ <configuration>
+ <artifacts>
+ <artifact>
+ <file>src/main/mdo/maven.mdo</file>
+ <type>mdo</type>
+ </artifact>
+ </artifacts>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven</groupId>
+ <artifactId>modello-plugin-velocity</artifactId>
+ <version>4.0.0-alpha-1-SNAPSHOT</version>
+ <configuration>
+ <version>5.0.0</version>
+ <models>
+ <model>src/main/mdo/maven.mdo</model>
+ </models>
+ <templates>
+ <template>src/main/mdo/model.vm</template>
+ </templates>
+ <params>
+ <param>packageModelV4=org.apache.maven.api.model</param>
+ </params>
+ </configuration>
+ <executions>
+ <execution>
+ <id>modello</id>
+ <goals>
+ <goal>velocity</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <configuration>
+ <excludes>
+ <exclude>**/package-info.java</exclude>
+ </excludes>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
diff --git a/api/maven-api-model/src/main/java/org/apache/maven/api/model/ImmutableCollections.java b/api/maven-api-model/src/main/java/org/apache/maven/api/model/ImmutableCollections.java
new file mode 100644
index 000000000..35c98d6e7
--- /dev/null
+++ b/api/maven-api-model/src/main/java/org/apache/maven/api/model/ImmutableCollections.java
@@ -0,0 +1,738 @@
+package org.apache.maven.api.model;
+
+/*
+ * 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.
+ */
+
+import java.util.AbstractList;
+import java.util.AbstractMap;
+import java.util.AbstractSet;
+import java.util.Collection;
+import java.util.Comparator;
+import java.util.Iterator;
+import java.util.List;
+import java.util.ListIterator;
+import java.util.Map;
+import java.util.NoSuchElementException;
+import java.util.Properties;
+import java.util.RandomAccess;
+import java.util.Set;
+import java.util.function.BiFunction;
+import java.util.function.Function;
+import java.util.function.Predicate;
+import java.util.function.UnaryOperator;
+
+class ImmutableCollections
+{
+
+ private static final List<?> EMPTY_LIST = new AbstractImmutableList<Object>()
+ {
+ @Override
+ public Object get( int index )
+ {
+ throw new IndexOutOfBoundsException();
+ }
+ @Override
+ public int size()
+ {
+ return 0;
+ }
+ };
+
+ private static final Map<?, ?> EMPTY_MAP = new AbstractImmutableMap<Object, Object>()
+ {
+ @Override
+ public Set<Entry<Object, Object>> entrySet()
+ {
+ return new AbstractImmutableSet<Entry<Object, Object>>()
+ {
+ @Override
+ public Iterator<Entry<Object, Object>> iterator()
+ {
+ return new Iterator<Entry<Object, Object>>()
+ {
+ @Override
+ public boolean hasNext()
+ {
+ return false;
+ }
+ @Override
+ public Entry<Object, Object> next()
+ {
+ throw new NoSuchElementException();
+ }
+ };
+ }
+ @Override
+ public int size()
+ {
+ return 0;
+ }
+ };
+ }
+ };
+
+ static <E> List<E> copy( Collection<E> collection )
+ {
+ if ( collection == null )
+ {
+ return emptyList();
+ }
+ else if ( collection instanceof AbstractImmutableList )
+ {
+ return ( List<E> ) collection;
+ }
+ else
+ {
+ switch ( collection.size() )
+ {
+ case 0:
+ return emptyList();
+ case 1:
+ return singletonList( collection.iterator().next() );
+ case 2:
+ Iterator<E> it = collection.iterator();
+ return new List2<>( it.next(), it.next() );
+ default:
+ return new ListN<>( collection );
+ }
+ }
+ }
+
+ @SuppressWarnings( "unchecked" )
+ static <E> List<E> emptyList()
+ {
+ return ( List<E> ) EMPTY_LIST;
+ }
+
+ static <E> List<E> singletonList( E element )
+ {
+ return new List1<>( element );
+ }
+
+ static <K, V> Map<K, V> copy( Map<K, V> map )
+ {
+ if ( map == null )
+ {
+ return emptyMap();
+ }
+ else if ( map instanceof AbstractImmutableMap )
+ {
+ return map;
+ }
+ else
+ {
+ switch ( map.size() )
+ {
+ case 0:
+ return emptyMap();
+ case 1:
+ Map.Entry<K, V> entry = map.entrySet().iterator().next();
+ return singletonMap( entry.getKey(), entry.getValue() );
+ default:
+ return new MapN<>( map );
+ }
+ }
+ }
+
+ @SuppressWarnings( "unchecked" )
+ static <K, V> Map<K, V> emptyMap()
+ {
+ return ( Map<K, V> ) EMPTY_MAP;
+ }
+
+ static <K, V> Map<K, V> singletonMap( K key, V value )
+ {
+ return new Map1<>( key, value );
+ }
+
+ static Properties copy( Properties properties )
+ {
+ if ( properties instanceof ROProperties )
+ {
+ return properties;
+ }
+ return new ROProperties( properties );
+ }
+
+ private static class List1<E> extends AbstractImmutableList<E>
+ {
+ private final E element;
+
+ private List1( E element )
+ {
+ this.element = element;
+ }
+
+ @Override
+ public E get( int index )
+ {
+ if ( index == 0 )
+ {
+ return element;
+ }
+ throw outOfBounds( index );
+ }
+
+ @Override
+ public int size()
+ {
+ return 1;
+ }
+ }
+
+ private static class List2<E> extends AbstractImmutableList<E>
+ {
+ private final E element1;
+ private final E element2;
+
+ private List2( E element1, E element2 )
+ {
+ this.element1 = element1;
+ this.element2 = element2;
+ }
+
+ @Override
+ public E get( int index )
+ {
+ if ( index == 0 )
+ {
+ return element1;
+ }
+ else if ( index == 1 )
+ {
+ return element2;
+ }
+ throw outOfBounds( index );
+ }
+
+ @Override
+ public int size()
+ {
+ return 2;
+ }
+ }
+
+ private static class ListN<E> extends AbstractImmutableList<E>
+ {
+ private final Object[] elements;
+
+ private ListN( Collection<E> elements )
+ {
+ this.elements = elements.toArray();
+ }
+
+ @SuppressWarnings( "unchecked" )
+ @Override
+ public E get( int index )
+ {
+ return ( E ) elements[ index ];
+ }
+
+ @Override
+ public int size()
+ {
+ return elements.length;
+ }
+ }
+
+ private abstract static class AbstractImmutableList<E> extends AbstractList<E> implements RandomAccess
+ {
+ @Override
+ public boolean add( E e )
+ {
+ throw uoe();
+ }
+
+ @Override
+ public boolean remove( Object o )
+ {
+ throw uoe();
+ }
+
+ @Override
+ public boolean addAll( Collection<? extends E> c )
+ {
+ throw uoe();
+ }
+
+ @Override
+ public boolean removeAll( Collection<?> c )
+ {
+ throw uoe();
+ }
+
+ @Override
+ public boolean retainAll( Collection<?> c )
+ {
+ throw uoe();
+ }
+
+ @Override
+ public void clear()
+ {
+ throw uoe();
+ }
+
+ @Override
+ public boolean removeIf( Predicate<? super E> filter )
+ {
+ throw uoe();
+ }
+
+ @Override
+ public void replaceAll( UnaryOperator<E> operator )
+ {
+ throw uoe();
+ }
+
+ @Override
+ public void sort( Comparator<? super E> c )
+ {
+ throw uoe();
+ }
+
+ @Override
+ public Iterator<E> iterator()
+ {
+ return new Itr( 0 );
+ }
+
+ @Override
+ public ListIterator<E> listIterator()
+ {
+ return new Itr( 0 );
+ }
+
+ @Override
+ public ListIterator<E> listIterator( int index )
+ {
+ if ( index < 0 || index > size() )
+ {
+ throw outOfBounds( index );
+ }
+ return new Itr( index );
+ }
+
+ @Override
+ public List<E> subList( int fromIndex, int toIndex )
+ {
+ if ( fromIndex < 0 )
+ {
+ throw new IndexOutOfBoundsException( "fromIndex = " + fromIndex );
+ }
+ if ( toIndex > size() )
+ {
+ throw new IndexOutOfBoundsException( "toIndex = " + toIndex );
+ }
+ if ( fromIndex > toIndex )
+ {
+ throw new IllegalArgumentException( "fromIndex(" + fromIndex + ") > toIndex(" + toIndex + ")" );
+ }
+ return new SubList( fromIndex, toIndex );
+ }
+
+ protected IndexOutOfBoundsException outOfBounds( int index )
+ {
+ return new IndexOutOfBoundsException( "Index: " + index + ", Size: " + size() );
+ }
+
+ private class SubList extends AbstractImmutableList<E>
+ {
+ private final int fromIndex;
+ private final int toIndex;
+
+ private SubList( int fromIndex, int toIndex )
+ {
+ this.fromIndex = fromIndex;
+ this.toIndex = toIndex;
+ }
+
+ @Override
+ public E get( int index )
+ {
+ if ( index < 0 || index > size() )
+ {
+ throw outOfBounds( index );
+ }
+ return AbstractImmutableList.this.get( fromIndex + index );
+ }
+
+ @Override
+ public int size()
+ {
+ return toIndex - fromIndex;
+ }
+ }
+
+ private class Itr implements ListIterator<E>
+ {
+ int index;
+
+ private Itr( int index )
+ {
+ this.index = index;
+ }
+
+ @Override
+ public boolean hasNext()
+ {
+ return index < size();
+ }
+
+ @Override
+ public E next()
+ {
+ return get( index++ );
+ }
+
+ @Override
+ public boolean hasPrevious()
+ {
+ return index > 0;
+ }
+
+ @Override
+ public E previous()
+ {
+ return get( --index );
+ }
+
+ @Override
+ public int nextIndex()
+ {
+ return index;
+ }
+
+ @Override
+ public int previousIndex()
+ {
+ return index - 1;
+ }
+
+ @Override
+ public void remove()
+ {
+ throw uoe();
+ }
+
+ @Override
+ public void set( E e )
+ {
+ throw uoe();
+ }
+
+ @Override
+ public void add( E e )
+ {
+ throw uoe();
+ }
+ }
+ }
+
+ private static class ROProperties extends Properties
+ {
+ private ROProperties( Properties props )
+ {
+ super();
+ if ( props != null )
+ {
+ // Do not use super.putAll, as it may delegate to put which throws an UnsupportedOperationException
+ for ( Map.Entry<Object, Object> e : props.entrySet() )
+ {
+ super.put( e.getKey(), e.getValue() );
+ }
+ }
+ }
+
+ @Override
+ public Object put( Object key, Object value )
+ {
+ throw uoe();
+ }
+
+ @Override
+ public Object remove( Object key )
+ {
+ throw uoe();
+ }
+
+ @Override
+ public void putAll( Map<?, ?> t )
+ {
+ throw uoe();
+ }
+
+ @Override
+ public void clear()
+ {
+ throw uoe();
+ }
+
+ @Override
+ public void replaceAll( BiFunction<? super Object, ? super Object, ?> function )
+ {
+ throw uoe();
+ }
+
+ @Override
+ public Object putIfAbsent( Object key, Object value )
+ {
+ throw uoe();
+ }
+
+ @Override
+ public boolean remove( Object key, Object value )
+ {
+ throw uoe();
+ }
+
+ @Override
+ public boolean replace( Object key, Object oldValue, Object newValue )
+ {
+ throw uoe();
+ }
+
+ @Override
+ public Object replace( Object key, Object value )
+ {
+ throw uoe();
+ }
+
+ @Override
+ public Object computeIfAbsent( Object key, Function<? super Object, ?> mappingFunction )
+ {
+ throw uoe();
+ }
+
+ @Override
+ public Object computeIfPresent( Object key, BiFunction<? super Object, ? super Object, ?> remappingFunction )
+ {
+ throw uoe();
+ }
+
+ @Override
+ public Object compute( Object key, BiFunction<? super Object, ? super Object, ?> remappingFunction )
+ {
+ throw uoe();
+ }
+
+ @Override
+ public Object merge( Object key, Object value, BiFunction<? super Object, ? super Object, ?> remappingFunction )
+ {
+ throw uoe();
+ }
+ }
+
+ private static class Map1<K, V> extends AbstractImmutableMap<K, V>
+ {
+ private final Map.Entry<K, V> entry;
+
+ private Map1( K key, V value )
+ {
+ this.entry = new SimpleImmutableEntry<>( key, value );
+ }
+
+ @Override
+ public Set<Entry<K, V>> entrySet()
+ {
+ return new AbstractImmutableSet<Entry<K, V>>()
+ {
+ @Override
+ public Iterator<Entry<K, V>> iterator()
+ {
+ return new Iterator<Entry<K, V>>()
+ {
+ int index = 0;
+ @Override
+ public boolean hasNext()
+ {
+ return index == 0;
+ }
+
+ @Override
+ public Entry<K, V> next()
+ {
+ if ( index++ == 0 )
+ {
+ return entry;
+ }
+ throw new NoSuchElementException();
+ }
+ };
+ }
+
+ @Override
+ public int size()
+ {
+ return 1;
+ }
+ };
+ }
+ }
+
+ private static class MapN<K, V> extends AbstractImmutableMap<K, V>
+ {
+ private final Object[] entries;
+
+ private MapN( Map<K, V> map )
+ {
+ entries = map != null ? map.entrySet().toArray() : new Object[0];
+ }
+
+ @Override
+ public Set<Entry<K, V>> entrySet()
+ {
+ return new AbstractImmutableSet<Entry<K, V>>()
+ {
+ @Override
+ public Iterator<Entry<K, V>> iterator()
+ {
+ return new Iterator<Entry<K, V>>()
+ {
+ int index = 0;
+ @Override
+ public boolean hasNext()
+ {
+ return index < entries.length;
+ }
+
+ @SuppressWarnings( "unchecked" )
+ @Override
+ public Entry<K, V> next()
+ {
+ if ( index < entries.length )
+ {
+ return ( Map.Entry<K, V> ) entries[index++];
+ }
+ throw new NoSuchElementException();
+ }
+ };
+ }
+
+ @Override
+ public int size()
+ {
+ return entries.length;
+ }
+ };
+ }
+ }
+
+ private abstract static class AbstractImmutableMap<K, V> extends AbstractMap<K, V>
+ {
+ @Override
+ public void replaceAll( BiFunction<? super K, ? super V, ? extends V> function )
+ {
+ throw uoe();
+ }
+
+ @Override
+ public V putIfAbsent( K key, V value )
+ {
+ throw uoe();
+ }
+
+ @Override
+ public boolean remove( Object key, Object value )
+ {
+ throw uoe();
+ }
+
+ @Override
+ public boolean replace( K key, V oldValue, V newValue )
+ {
+ throw uoe();
+ }
... 50722 lines suppressed ...