You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by sj...@apache.org on 2025/10/13 17:09:34 UTC
(maven-plugin-testing) branch master updated: Freeze and cleanups master branch
This is an automated email from the ASF dual-hosted git repository.
sjaranowski pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/maven-plugin-testing.git
The following commit(s) were added to refs/heads/master by this push:
new f29ea13 Freeze and cleanups master branch
f29ea13 is described below
commit f29ea133c25119ece72b383d0f6d1348025d4864
Author: Slawomir Jaranowski <s....@gmail.com>
AuthorDate: Sun Oct 12 16:52:22 2025 +0200
Freeze and cleanups master branch
fix #217
reference:
- https://github.com/apache/maven/pull/2193
---
.github/dependabot.yml | 6 +-
.github/release-drafter.yml | 28 -
.github/workflows/maven-verify.yml | 32 -
.github/workflows/pr-automation.yml | 2 -
.github/workflows/release-drafter.yml | 29 -
Jenkinsfile | 20 -
README.md | 68 +-
deploySite.sh | 23 -
maven-plugin-testing-harness/pom.xml | 118 ---
.../maven/api/di/testing/MavenDIExtension.java | 150 ---
.../apache/maven/api/di/testing/MavenDITest.java | 34 -
.../apache/maven/api/plugin/testing/Basedir.java | 32 -
.../maven/api/plugin/testing/InjectMojo.java | 35 -
.../maven/api/plugin/testing/MojoExtension.java | 730 -------------
.../maven/api/plugin/testing/MojoParameter.java | 36 -
.../maven/api/plugin/testing/MojoParameters.java | 32 -
.../apache/maven/api/plugin/testing/MojoTest.java | 34 -
.../testing/ResolverExpressionEvaluatorStub.java | 118 ---
.../api/plugin/testing/stubs/ArtifactStub.java | 188 ----
.../maven/api/plugin/testing/stubs/LookupStub.java | 68 --
.../plugin/testing/stubs/MojoExecutionStub.java | 113 --
.../maven/api/plugin/testing/stubs/PluginStub.java | 102 --
.../plugin/testing/stubs/ProducedArtifactStub.java | 33 -
.../api/plugin/testing/stubs/ProjectStub.java | 301 ------
.../testing/stubs/RepositorySystemSupplier.java | 1115 --------------------
.../api/plugin/testing/stubs/SessionMock.java | 448 --------
.../api/plugin/testing/stubs/SessionStub.java | 458 --------
.../src/site/apt/examples/artifact.apt | 215 ----
.../site/apt/examples/complex-mojo-parameters.apt | 177 ----
.../src/site/apt/examples/multiproject.apt | 138 ---
.../src/site/apt/examples/repositories.apt | 133 ---
.../src/site/apt/getting-started/index.apt | 249 -----
.../src/site/apt/index.apt | 46 -
maven-plugin-testing-harness/src/site/fml/faq.fml | 72 --
maven-plugin-testing-harness/src/site/site.xml | 41 -
.../apache/maven/api/di/testing/SimpleDITest.java | 50 -
.../plugin/testing/ExpressionEvaluatorTest.java | 139 ---
.../META-INF/maven/org.apache.maven.api.di.Inject | 19 -
.../src/test/resources/META-INF/maven/plugin.xml | 95 --
pom.xml | 76 --
src/site/apt/index.apt | 40 -
src/site/resources/download.cgi | 22 -
src/site/site.xml | 35 -
src/site/xdoc/download.xml.vm | 75 --
44 files changed, 4 insertions(+), 5971 deletions(-)
diff --git a/.github/dependabot.yml b/.github/dependabot.yml
index 576788a..a094845 100644
--- a/.github/dependabot.yml
+++ b/.github/dependabot.yml
@@ -17,15 +17,11 @@
version: 2
updates:
- - package-ecosystem: "maven"
- directory: "/"
- schedule:
- interval: "daily"
-
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "daily"
+ target-branch: "maven-plugin-testing-3.x"
- package-ecosystem: "maven"
directory: "/"
diff --git a/.github/release-drafter.yml b/.github/release-drafter.yml
deleted file mode 100644
index f829205..0000000
--- a/.github/release-drafter.yml
+++ /dev/null
@@ -1,28 +0,0 @@
-
-
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied. See the License for the
-# specific language governing permissions and limitations
-# under the License.
-
-_extends: maven-gh-actions-shared
-tag-template: maven-plugin-testing-$RESOLVED_VERSION
-
-include-pre-releases: true
-prerelease: true
-
-header: |
- > [!WARNING]
- > This plugin is a Maven 4 plugin and requires Maven 4.0.0-rc-3 to run.
diff --git a/.github/workflows/maven-verify.yml b/.github/workflows/maven-verify.yml
deleted file mode 100644
index 7e8c831..0000000
--- a/.github/workflows/maven-verify.yml
+++ /dev/null
@@ -1,32 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied. See the License for the
-# specific language governing permissions and limitations
-# under the License.
-
-name: Verify
-
-on:
- push:
- pull_request:
-
-jobs:
- build:
- name: Verify
- uses: apache/maven-gh-actions-shared/.github/workflows/maven-verify.yml@v4
- with:
- jdk-matrix: '[ "17", "21" ]'
- maven4-enabled: true
- ff-goal: "verify"
- verify-goal: "verify"
diff --git a/.github/workflows/pr-automation.yml b/.github/workflows/pr-automation.yml
index e9d6698..5307595 100644
--- a/.github/workflows/pr-automation.yml
+++ b/.github/workflows/pr-automation.yml
@@ -20,8 +20,6 @@ on:
pull_request_target:
types:
- closed
- - unlabeled
- - review_requested
jobs:
pr-automation:
diff --git a/.github/workflows/release-drafter.yml b/.github/workflows/release-drafter.yml
deleted file mode 100644
index 17de384..0000000
--- a/.github/workflows/release-drafter.yml
+++ /dev/null
@@ -1,29 +0,0 @@
-
-
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied. See the License for the
-# specific language governing permissions and limitations
-# under the License.
-
-name: Release Drafter
-on:
- push:
- branches:
- - master
- workflow_dispatch:
-
-jobs:
- update_release_draft:
- uses: apache/maven-gh-actions-shared/.github/workflows/release-drafter.yml@v4
\ No newline at end of file
diff --git a/Jenkinsfile b/Jenkinsfile
deleted file mode 100644
index 9119b5c..0000000
--- a/Jenkinsfile
+++ /dev/null
@@ -1,20 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-asfMavenTlpStdBuild(jdks:[ "17", "21" ])
diff --git a/README.md b/README.md
index 9b0f062..32f81bb 100644
--- a/README.md
+++ b/README.md
@@ -18,72 +18,10 @@ Contributing to [Apache Maven Plugin Testing](https://maven.apache.org/plugin-te
======================
[][license]
-[](https://search.maven.org/artifact/org.apache.maven.plugin-testing/maven-plugin-testing)
-[](https://github.com/jvm-repo-rebuild/reproducible-central/blob/master/content/org/apache/maven/parent/README.md)
-[][build]
-[][test-results]
-[](https://github.com/apache/maven-parent/actions/workflows/maven-verify.yml)
-You have found a bug or you have an idea for a cool new feature? Contributing
-code is a great way to give something back to the open source community. Before
-you dig right into the code, there are a few guidelines that we need
-contributors to follow so that we can have a chance of keeping on top of
-things.
+Maven Plugin Testing has been merged into Maven core repository.
-Getting Started
----------------
-
-+ Make sure you have a [GitHub account](https://github.com/signup/free).
-+ If you're planning to implement a new feature, it makes sense to discuss your changes
- on the [dev list][ml-list] first.
- This way you can make sure you're not wasting your time on something that isn't
- considered to be in Apache Maven's scope.
-+ Submit a ticket for your issue, assuming one does not already exist.
- + Clearly describe the issue, including steps to reproduce when it is a bug.
- + Make sure you fill in the earliest version that you know has the issue.
-+ Fork the repository on GitHub.
-
-Making and Submitting Changes
---------------
-
-We accept Pull Requests via GitHub. The [developer mailing list][ml-list] is the
-main channel of communication for contributors.
-There are some guidelines which will make applying PRs easier for us:
-+ Create a topic branch from where you want to base your work (this is usually the master branch).
- Push your changes to a topic branch in your fork of the repository.
-+ Make commits of logical units.
-+ Respect the original code style: by using the same [codestyle][code-style],
- patches should only highlight the actual difference, not being disturbed by any formatting issues:
- + Only use spaces for indentation.
- + Create minimal diffs - disable on save actions like reformat source code or organize imports.
- If you feel the source code should be reformatted, create a separate PR for this change.
- + Check for unnecessary whitespace with `git diff --check` before committing.
-+ Make sure your commit messages are in the proper format.
-+ Make sure you have added the necessary tests (JUnit/IT) for your changes.
-+ Run all the tests with `mvn -Prun-its verify` to assure nothing else was accidentally broken.
-+ Submit a pull request to the repository in the Apache organization.
-
-If you plan to contribute on a regular basis, please consider filing a [contributor license agreement][cla].
-
-Making Trivial Changes
-----------------------
-
-For changes of a trivial nature to comments and documentation, or other simple changes
-it is not always necessary to create a new issue.
-In this case, it is appropriate to skip the issue from a commit message.
-
-Additional Resources
---------------------
-
-+ [Contributing patches](https://maven.apache.org/guides/development/guide-maven-development.html#Creating_and_submitting_a_patch)
-+ [Contributor License Agreement][cla]
-+ [General GitHub documentation](https://docs.github.com/)
-+ [GitHub pull request documentation](https://docs.github.com/pull-requests)
-+ [Apache Maven Twitter Account](https://twitter.com/ASFMavenProject)
+Branches are still available:
+* [maven-plugin-testing-3.x](https://github.com/apache/maven-plugin-testing/tree/maven-plugin-testing-3.x) for Maven 3.x
[license]: https://www.apache.org/licenses/LICENSE-2.0
-[ml-list]: https://maven.apache.org/mailing-lists.html
-[code-style]: https://maven.apache.org/developers/conventions/code.html
-[cla]: https://www.apache.org/licenses/#clas
-[test-results]: https://ci-maven.apache.org/job/Maven/job/maven-box/job/maven-plugin-testing/job/master/lastCompletedBuild/testReport/
-[build]: https://ci-maven.apache.org/job/Maven/job/maven-box/job/maven-plugin-testing/job/master/
diff --git a/deploySite.sh b/deploySite.sh
deleted file mode 100644
index f6c265d..0000000
--- a/deploySite.sh
+++ /dev/null
@@ -1,23 +0,0 @@
-#!/bin/sh
-
-#
-# 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.
-#
-
-mvn -Preporting site site:stage $@
-mvn scm-publish:publish-scm $@
diff --git a/maven-plugin-testing-harness/pom.xml b/maven-plugin-testing-harness/pom.xml
deleted file mode 100644
index 454e2bf..0000000
--- a/maven-plugin-testing-harness/pom.xml
+++ /dev/null
@@ -1,118 +0,0 @@
-<?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.plugin-testing</groupId>
- <artifactId>maven-plugin-testing</artifactId>
- <version>4.0.0-beta-5-SNAPSHOT</version>
- </parent>
-
- <artifactId>maven-plugin-testing-harness</artifactId>
- <name>Maven Plugin Testing Mechanism</name>
- <description>The Maven Plugin Testing Harness provides mechanisms to manage tests on Mojo.</description>
-
- <dependencyManagement>
- <dependencies>
- <dependency>
- <groupId>org.junit</groupId>
- <artifactId>junit-bom</artifactId>
- <version>6.0.0</version>
- <type>pom</type>
- <scope>import</scope>
- </dependency>
- </dependencies>
- </dependencyManagement>
-
- <dependencies>
- <!-- maven -->
- <dependency>
- <groupId>org.apache.maven</groupId>
- <artifactId>maven-api-core</artifactId>
- <version>${mavenVersion}</version>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.maven</groupId>
- <artifactId>maven-core</artifactId>
- <version>${mavenVersion}</version>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.maven</groupId>
- <artifactId>maven-model</artifactId>
- <version>${mavenVersion}</version>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.maven</groupId>
- <artifactId>maven-xml</artifactId>
- <version>${mavenVersion}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.maven</groupId>
- <artifactId>maven-resolver-provider</artifactId>
- <version>${mavenVersion}</version>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>org.eclipse.sisu</groupId>
- <artifactId>org.eclipse.sisu.plexus</artifactId>
- </dependency>
-
- <!-- plexus -->
- <dependency>
- <groupId>org.codehaus.plexus</groupId>
- <artifactId>plexus-utils</artifactId>
- <version>4.0.2</version>
- </dependency>
- <dependency>
- <!-- correct version must be provided by project depends on Maven version -->
- <groupId>org.codehaus.plexus</groupId>
- <artifactId>plexus-xml</artifactId>
- <version>4.1.0</version>
- <optional>true</optional>
- </dependency>
-
- <dependency>
- <groupId>org.junit.jupiter</groupId>
- <artifactId>junit-jupiter-api</artifactId>
- <optional>true</optional>
- </dependency>
- <dependency>
- <groupId>org.mockito</groupId>
- <artifactId>mockito-core</artifactId>
- <version>5.20.0</version>
- </dependency>
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-api</artifactId>
- <version>2.0.17</version>
- </dependency>
-
- <dependency>
- <groupId>com.google.inject</groupId>
- <artifactId>guice</artifactId>
- <version>6.0.0</version>
- <scope>test</scope>
- </dependency>
- </dependencies>
-</project>
diff --git a/maven-plugin-testing-harness/src/main/java/org/apache/maven/api/di/testing/MavenDIExtension.java b/maven-plugin-testing-harness/src/main/java/org/apache/maven/api/di/testing/MavenDIExtension.java
deleted file mode 100644
index 82802bc..0000000
--- a/maven-plugin-testing-harness/src/main/java/org/apache/maven/api/di/testing/MavenDIExtension.java
+++ /dev/null
@@ -1,150 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.maven.api.di.testing;
-
-import java.io.File;
-
-import org.apache.maven.di.Injector;
-import org.apache.maven.di.Key;
-import org.apache.maven.di.impl.DIException;
-import org.junit.jupiter.api.extension.AfterEachCallback;
-import org.junit.jupiter.api.extension.BeforeEachCallback;
-import org.junit.jupiter.api.extension.ExtensionContext;
-
-/**
- * This is a slightly modified version of the original plexus class
- * available at https://raw.githubusercontent.com/codehaus-plexus/plexus-containers/master/plexus-container-default/
- * src/main/java/org/codehaus/plexus/PlexusTestCase.java
- * in order to migrate the tests to JUnit 4.
- *
- * @author Jason van Zyl
- * @author <a href="mailto:trygvis@inamo.no">Trygve Laugstøl</a>
- * @author <a href="mailto:michal@codehaus.org">Michal Maczka</a>
- * @author Guillaume Nodet
- */
-public class MavenDIExtension implements BeforeEachCallback, AfterEachCallback {
- protected static ExtensionContext context;
- protected Injector injector;
- protected static String basedir;
-
- @Override
- public void beforeEach(ExtensionContext context) throws Exception {
- basedir = getBasedir();
-
- setContext(context);
-
- getInjector().bindInstance((Class<Object>) context.getRequiredTestClass(), context.getRequiredTestInstance());
- getInjector().injectInstance(context.getRequiredTestInstance());
- }
-
- protected void setContext(ExtensionContext context) {
- this.context = context;
- }
-
- @SuppressWarnings("unchecked")
- protected void setupContainer() {
- try {
- injector = Injector.create();
- injector.bindInstance(ExtensionContext.class, this.context);
- injector.discover(this.context.getRequiredTestClass().getClassLoader());
- injector.bindInstance(Injector.class, injector);
- injector.bindInstance((Class) this.context.getRequiredTestClass(), this.context.getRequiredTestInstance());
- } catch (Exception e) {
- throw new IllegalArgumentException("Failed to create DI injector.", e);
- }
- }
-
- @Override
- public void afterEach(ExtensionContext context) throws Exception {
- if (injector != null) {
- // TODO: implement
- // injector.dispose();
- injector = null;
- }
- }
-
- public Injector getInjector() {
- if (injector == null) {
- setupContainer();
- }
-
- return injector;
- }
-
- // ----------------------------------------------------------------------
- // Container access
- // ----------------------------------------------------------------------
-
- protected <T> T lookup(Class<T> componentClass) throws DIException {
- return getInjector().getInstance(componentClass);
- }
-
- protected <T> T lookup(Class<T> componentClass, String roleHint) throws DIException {
- return getInjector().getInstance(Key.ofType(componentClass, roleHint));
- }
-
- protected <T> T lookup(Class<T> componentClass, Object qualifier) throws DIException {
- return getInjector().getInstance(Key.ofType(componentClass, qualifier));
- }
-
- protected void release(Object component) throws DIException {
- // TODO: implement
- // getInjector().release(component);
- }
-
- // ----------------------------------------------------------------------
- // Helper methods for sub classes
- // ----------------------------------------------------------------------
-
- public static File getTestFile(String path) {
- return new File(getBasedir(), path);
- }
-
- public static File getTestFile(String basedir, String path) {
- File basedirFile = new File(basedir);
-
- if (!basedirFile.isAbsolute()) {
- basedirFile = getTestFile(basedir);
- }
-
- return new File(basedirFile, path);
- }
-
- public static String getTestPath(String path) {
- return getTestFile(path).getAbsolutePath();
- }
-
- public static String getTestPath(String basedir, String path) {
- return getTestFile(basedir, path).getAbsolutePath();
- }
-
- public static String getBasedir() {
- if (basedir != null) {
- return basedir;
- }
-
- basedir = System.getProperty("basedir");
-
- if (basedir == null) {
- basedir = new File("").getAbsolutePath();
- }
-
- return basedir;
- }
-}
diff --git a/maven-plugin-testing-harness/src/main/java/org/apache/maven/api/di/testing/MavenDITest.java b/maven-plugin-testing-harness/src/main/java/org/apache/maven/api/di/testing/MavenDITest.java
deleted file mode 100644
index ddc6d2f..0000000
--- a/maven-plugin-testing-harness/src/main/java/org/apache/maven/api/di/testing/MavenDITest.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.maven.api.di.testing;
-
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-import org.junit.jupiter.api.extension.ExtendWith;
-
-/**
- * Plexus test
- */
-@Retention(RetentionPolicy.RUNTIME)
-@ExtendWith(MavenDIExtension.class)
-@Target(ElementType.TYPE)
-public @interface MavenDITest {}
diff --git a/maven-plugin-testing-harness/src/main/java/org/apache/maven/api/plugin/testing/Basedir.java b/maven-plugin-testing-harness/src/main/java/org/apache/maven/api/plugin/testing/Basedir.java
deleted file mode 100644
index 69eaba2..0000000
--- a/maven-plugin-testing-harness/src/main/java/org/apache/maven/api/plugin/testing/Basedir.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.maven.api.plugin.testing;
-
-import java.lang.annotation.Inherited;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-
-/**
- * Mojo parameters container
- */
-@Retention(RetentionPolicy.RUNTIME)
-@Inherited
-public @interface Basedir {
- String value() default "";
-}
diff --git a/maven-plugin-testing-harness/src/main/java/org/apache/maven/api/plugin/testing/InjectMojo.java b/maven-plugin-testing-harness/src/main/java/org/apache/maven/api/plugin/testing/InjectMojo.java
deleted file mode 100644
index 272eb9b..0000000
--- a/maven-plugin-testing-harness/src/main/java/org/apache/maven/api/plugin/testing/InjectMojo.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.maven.api.plugin.testing;
-
-import java.lang.annotation.Inherited;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-
-/**
- *
- */
-@Retention(RetentionPolicy.RUNTIME)
-@Inherited
-public @interface InjectMojo {
-
- String goal();
-
- String pom() default "";
-}
diff --git a/maven-plugin-testing-harness/src/main/java/org/apache/maven/api/plugin/testing/MojoExtension.java b/maven-plugin-testing-harness/src/main/java/org/apache/maven/api/plugin/testing/MojoExtension.java
deleted file mode 100644
index e300672..0000000
--- a/maven-plugin-testing-harness/src/main/java/org/apache/maven/api/plugin/testing/MojoExtension.java
+++ /dev/null
@@ -1,730 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.maven.api.plugin.testing;
-
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.Reader;
-import java.io.StringReader;
-import java.lang.reflect.AccessibleObject;
-import java.lang.reflect.AnnotatedElement;
-import java.lang.reflect.Field;
-import java.net.URL;
-import java.nio.file.Files;
-import java.nio.file.Path;
-import java.nio.file.Paths;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.LinkedHashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Objects;
-import java.util.Optional;
-import java.util.Set;
-import java.util.stream.Collectors;
-import java.util.stream.Stream;
-
-import org.apache.maven.api.MojoExecution;
-import org.apache.maven.api.Project;
-import org.apache.maven.api.Session;
-import org.apache.maven.api.di.Named;
-import org.apache.maven.api.di.Priority;
-import org.apache.maven.api.di.Provides;
-import org.apache.maven.api.di.Singleton;
-import org.apache.maven.api.di.testing.MavenDIExtension;
-import org.apache.maven.api.model.Build;
-import org.apache.maven.api.model.ConfigurationContainer;
-import org.apache.maven.api.model.Model;
-import org.apache.maven.api.plugin.Log;
-import org.apache.maven.api.plugin.Mojo;
-import org.apache.maven.api.plugin.descriptor.MojoDescriptor;
-import org.apache.maven.api.plugin.descriptor.Parameter;
-import org.apache.maven.api.plugin.descriptor.PluginDescriptor;
-import org.apache.maven.api.plugin.testing.stubs.MojoExecutionStub;
-import org.apache.maven.api.plugin.testing.stubs.PluginStub;
-import org.apache.maven.api.plugin.testing.stubs.ProducedArtifactStub;
-import org.apache.maven.api.plugin.testing.stubs.ProjectStub;
-import org.apache.maven.api.plugin.testing.stubs.RepositorySystemSupplier;
-import org.apache.maven.api.plugin.testing.stubs.SessionMock;
-import org.apache.maven.api.services.ArtifactDeployer;
-import org.apache.maven.api.services.ArtifactFactory;
-import org.apache.maven.api.services.ArtifactInstaller;
-import org.apache.maven.api.services.ArtifactManager;
-import org.apache.maven.api.services.LocalRepositoryManager;
-import org.apache.maven.api.services.ProjectBuilder;
-import org.apache.maven.api.services.ProjectManager;
-import org.apache.maven.api.services.RepositoryFactory;
-import org.apache.maven.api.services.VersionParser;
-import org.apache.maven.api.services.xml.ModelXmlFactory;
-import org.apache.maven.api.xml.XmlNode;
-import org.apache.maven.configuration.internal.EnhancedComponentConfigurator;
-import org.apache.maven.di.Injector;
-import org.apache.maven.di.Key;
-import org.apache.maven.di.impl.DIException;
-import org.apache.maven.impl.InternalSession;
-import org.apache.maven.impl.model.DefaultModelPathTranslator;
-import org.apache.maven.impl.model.DefaultPathTranslator;
-import org.apache.maven.internal.impl.DefaultLog;
-import org.apache.maven.internal.xml.XmlNodeImpl;
-import org.apache.maven.internal.xml.XmlPlexusConfiguration;
-import org.apache.maven.lifecycle.internal.MojoDescriptorCreator;
-import org.apache.maven.model.v4.MavenMerger;
-import org.apache.maven.model.v4.MavenStaxReader;
-import org.apache.maven.plugin.PluginParameterExpressionEvaluatorV4;
-import org.apache.maven.plugin.descriptor.io.PluginDescriptorStaxReader;
-import org.codehaus.plexus.component.configurator.expression.ExpressionEvaluationException;
-import org.codehaus.plexus.component.configurator.expression.ExpressionEvaluator;
-import org.codehaus.plexus.component.configurator.expression.TypeAwareExpressionEvaluator;
-import org.codehaus.plexus.util.ReflectionUtils;
-import org.codehaus.plexus.util.xml.XmlStreamReader;
-import org.codehaus.plexus.util.xml.Xpp3Dom;
-import org.codehaus.plexus.util.xml.Xpp3DomBuilder;
-import org.eclipse.aether.RepositorySystem;
-import org.junit.jupiter.api.extension.BeforeEachCallback;
-import org.junit.jupiter.api.extension.ExtensionContext;
-import org.junit.jupiter.api.extension.ParameterContext;
-import org.junit.jupiter.api.extension.ParameterResolutionException;
-import org.junit.jupiter.api.extension.ParameterResolver;
-import org.junit.platform.commons.support.AnnotationSupport;
-import org.slf4j.LoggerFactory;
-
-import static java.util.Objects.requireNonNull;
-
-/**
- * JUnit extension to help testing Mojos. The extension should be automatically registered
- * by adding the {@link MojoTest} annotation on the test class.
- *
- * @see MojoTest
- * @see InjectMojo
- * @see MojoParameter
- * @see Basedir
- */
-public class MojoExtension extends MavenDIExtension implements ParameterResolver, BeforeEachCallback {
-
- protected static String pluginBasedir;
- protected static String basedir;
-
- public static String getTestId() {
- return context.getRequiredTestClass().getSimpleName() + "-"
- + context.getRequiredTestMethod().getName();
- }
-
- public static String getBasedir() {
- return requireNonNull(basedir != null ? basedir : MavenDIExtension.basedir);
- }
-
- public static String getPluginBasedir() {
- return requireNonNull(pluginBasedir);
- }
-
- @Override
- public boolean supportsParameter(ParameterContext parameterContext, ExtensionContext extensionContext)
- throws ParameterResolutionException {
- return parameterContext.isAnnotated(InjectMojo.class)
- || parameterContext.getDeclaringExecutable().isAnnotationPresent(InjectMojo.class);
- }
-
- @Override
- public Object resolveParameter(ParameterContext parameterContext, ExtensionContext extensionContext)
- throws ParameterResolutionException {
- try {
- Class<?> holder = parameterContext.getTarget().get().getClass();
- PluginDescriptor descriptor = extensionContext
- .getStore(ExtensionContext.Namespace.GLOBAL)
- .get(PluginDescriptor.class, PluginDescriptor.class);
- Model model =
- extensionContext.getStore(ExtensionContext.Namespace.GLOBAL).get(Model.class, Model.class);
- InjectMojo parameterInjectMojo =
- parameterContext.getAnnotatedElement().getAnnotation(InjectMojo.class);
- String goal;
- if (parameterInjectMojo != null) {
- String pom = parameterInjectMojo.pom();
- if (pom != null && !pom.isEmpty()) {
- try (Reader r = openPomUrl(holder, pom, new Path[1])) {
- Model localModel = new MavenStaxReader().read(r);
- model = new MavenMerger().merge(localModel, model, false, null);
- model = new DefaultModelPathTranslator(new DefaultPathTranslator())
- .alignToBaseDirectory(model, Paths.get(getBasedir()), null);
- }
- }
- goal = parameterInjectMojo.goal();
- } else {
- InjectMojo methodInjectMojo = AnnotationSupport.findAnnotation(
- parameterContext.getDeclaringExecutable(), InjectMojo.class)
- .orElse(null);
- if (methodInjectMojo != null) {
- goal = methodInjectMojo.goal();
- } else {
- goal = getGoalFromMojoImplementationClass(
- parameterContext.getParameter().getType());
- }
- }
-
- Set<MojoParameter> mojoParameters = new LinkedHashSet<>();
- for (AnnotatedElement ae :
- Arrays.asList(parameterContext.getDeclaringExecutable(), parameterContext.getAnnotatedElement())) {
- mojoParameters.addAll(AnnotationSupport.findRepeatableAnnotations(ae, MojoParameter.class));
- }
- String[] coord = mojoCoordinates(goal);
-
- XmlNode pluginConfiguration = model.getBuild().getPlugins().stream()
- .filter(p ->
- Objects.equals(p.getGroupId(), coord[0]) && Objects.equals(p.getArtifactId(), coord[1]))
- .map(ConfigurationContainer::getConfiguration)
- .findFirst()
- .orElseGet(() -> new XmlNodeImpl("config"));
- List<XmlNode> children = mojoParameters.stream()
- .map(mp -> new XmlNodeImpl(mp.name(), mp.value()))
- .collect(Collectors.toList());
- XmlNode config = new XmlNodeImpl("configuration", null, null, children, null);
- pluginConfiguration = XmlNode.merge(config, pluginConfiguration);
-
- // load default config
- // pluginkey = groupId : artifactId : version : goal
- Mojo mojo = lookup(Mojo.class, coord[0] + ":" + coord[1] + ":" + coord[2] + ":" + coord[3]);
- for (MojoDescriptor mojoDescriptor : descriptor.getMojos()) {
- if (Objects.equals(mojoDescriptor.getGoal(), coord[3])) {
- if (pluginConfiguration != null) {
- pluginConfiguration = finalizeConfig(pluginConfiguration, mojoDescriptor);
- }
- }
- }
-
- Session session = getInjector().getInstance(Session.class);
- Project project = getInjector().getInstance(Project.class);
- MojoExecution mojoExecution = getInjector().getInstance(MojoExecution.class);
- ExpressionEvaluator evaluator = new WrapEvaluator(
- getInjector(), new PluginParameterExpressionEvaluatorV4(session, project, mojoExecution));
-
- EnhancedComponentConfigurator configurator = new EnhancedComponentConfigurator();
- configurator.configureComponent(
- mojo, new XmlPlexusConfiguration(pluginConfiguration), evaluator, null, null);
- return mojo;
- } catch (Exception e) {
- throw new ParameterResolutionException("Unable to resolve mojo", e);
- }
- }
-
- /**
- * The @Mojo annotation is only retained in the class file, not at runtime,
- * so we need to actually read the class file with ASM to find the annotation and
- * the goal.
- */
- private static String getGoalFromMojoImplementationClass(Class<?> cl) throws IOException {
- return cl.getAnnotation(Named.class).value();
- }
-
- @Override
- @SuppressWarnings("checkstyle:MethodLength")
- public void beforeEach(ExtensionContext context) throws Exception {
- if (pluginBasedir == null) {
- pluginBasedir = MavenDIExtension.getBasedir();
- }
- basedir = AnnotationSupport.findAnnotation(context.getElement().get(), Basedir.class)
- .map(Basedir::value)
- .orElse(pluginBasedir);
- if (basedir != null) {
- if (basedir.isEmpty()) {
- basedir = pluginBasedir + "/target/tests/"
- + context.getRequiredTestClass().getSimpleName() + "/"
- + context.getRequiredTestMethod().getName();
- } else {
- basedir = basedir.replace("${basedir}", pluginBasedir);
- }
- }
-
- setContext(context);
-
- /*
- binder.install(ProviderMethodsModule.forObject(context.getRequiredTestInstance()));
- binder.requestInjection(context.getRequiredTestInstance());
- binder.bind(Log.class).toInstance(new DefaultLog(LoggerFactory.getLogger("anonymous")));
- binder.bind(ExtensionContext.class).toInstance(context);
- // Load maven 4 api Services interfaces and try to bind them to the (possible) mock instances
- // returned by the (possibly) mock InternalSession
- try {
- for (ClassPath.ClassInfo clazz :
- ClassPath.from(getClassLoader()).getAllClasses()) {
- if ("org.apache.maven.api.services".equals(clazz.getPackageName())) {
- Class<?> load = clazz.load();
- if (Service.class.isAssignableFrom(load)) {
- Class<Service> svc = (Class) load;
- binder.bind(svc).toProvider(() -> {
- try {
- return getContainer()
- .lookup(InternalSession.class)
- .getService(svc);
- } catch (ComponentLookupException e) {
- throw new RuntimeException("Unable to lookup service " + svc.getName());
- }
- });
- }
- }
- }
- } catch (Exception e) {
- throw new RuntimeException("Unable to bind session services", e);
- }
-
- */
-
- Path basedirPath = Paths.get(getBasedir());
-
- InjectMojo mojo = AnnotationSupport.findAnnotation(context.getElement().get(), InjectMojo.class)
- .orElse(null);
- Model defaultModel = Model.newBuilder()
- .groupId("myGroupId")
- .artifactId("myArtifactId")
- .version("1.0-SNAPSHOT")
- .packaging("jar")
- .build(Build.newBuilder()
- .directory(basedirPath.resolve("target").toString())
- .outputDirectory(basedirPath.resolve("target/classes").toString())
- .sourceDirectory(basedirPath.resolve("src/main/java").toString())
- .testSourceDirectory(
- basedirPath.resolve("src/test/java").toString())
- .testOutputDirectory(
- basedirPath.resolve("target/test-classes").toString())
- .build())
- .build();
- Path[] modelPath = new Path[] {null};
- Model tmodel = null;
- if (mojo != null) {
- String pom = mojo.pom();
- if (pom != null && !pom.isEmpty()) {
- try (Reader r = openPomUrl(context.getRequiredTestClass(), pom, modelPath)) {
- tmodel = new MavenStaxReader().read(r);
- }
- } else {
- Path pomPath = basedirPath.resolve("pom.xml");
- if (Files.exists(pomPath)) {
- try (Reader r = Files.newBufferedReader(pomPath)) {
- tmodel = new MavenStaxReader().read(r);
- modelPath[0] = pomPath;
- }
- }
- }
- }
- Model model;
- if (tmodel == null) {
- model = defaultModel;
- } else {
- model = new MavenMerger().merge(tmodel, defaultModel, false, null);
- }
- tmodel = new DefaultModelPathTranslator(new DefaultPathTranslator())
- .alignToBaseDirectory(tmodel, Paths.get(getBasedir()), null);
- context.getStore(ExtensionContext.Namespace.GLOBAL).put(Model.class, tmodel);
-
- // mojo execution
- // Map<Object, Object> map = getInjector().getContext().getContextData();
- PluginDescriptor pluginDescriptor;
- ClassLoader classLoader = context.getRequiredTestClass().getClassLoader();
- try (InputStream is = requireNonNull(
- classLoader.getResourceAsStream(getPluginDescriptorLocation()),
- "Unable to find plugin descriptor: " + getPluginDescriptorLocation());
- Reader reader = new BufferedReader(new XmlStreamReader(is))) {
- // new InterpolationFilterReader(reader, map, "${", "}");
- pluginDescriptor = new PluginDescriptorStaxReader().read(reader);
- }
- context.getStore(ExtensionContext.Namespace.GLOBAL).put(PluginDescriptor.class, pluginDescriptor);
- // for (ComponentDescriptor<?> desc : pluginDescriptor.getComponents()) {
- // getContainer().addComponentDescriptor(desc);
- // }
-
- @SuppressWarnings({"unused", "MagicNumber"})
- class Foo {
-
- @Provides
- @Singleton
- @Priority(-10)
- private InternalSession createSession() {
- return SessionMock.getMockSession(getBasedir());
- }
-
- @Provides
- @Singleton
- @Priority(-10)
- private Project createProject(InternalSession s) {
- ProjectStub stub = new ProjectStub();
- if (!"pom".equals(model.getPackaging())) {
- ProducedArtifactStub artifact = new ProducedArtifactStub(
- model.getGroupId(), model.getArtifactId(), "", model.getVersion(), model.getPackaging());
- stub.setMainArtifact(artifact);
- }
- stub.setModel(model);
- stub.setBasedir(Paths.get(MojoExtension.getBasedir()));
- stub.setPomPath(modelPath[0]);
- s.getService(ArtifactManager.class).setPath(stub.getPomArtifact(), modelPath[0]);
- return stub;
- }
-
- @Provides
- @Singleton
- @Priority(-10)
- private MojoExecution createMojoExecution() {
- MojoExecutionStub mes = new MojoExecutionStub("executionId", null);
- if (mojo != null) {
- String goal = mojo.goal();
- int idx = goal.lastIndexOf(':');
- if (idx >= 0) {
- goal = goal.substring(idx + 1);
- }
- mes.setGoal(goal);
- for (MojoDescriptor md : pluginDescriptor.getMojos()) {
- if (goal.equals(md.getGoal())) {
- mes.setDescriptor(md);
- }
- }
- requireNonNull(mes.getDescriptor());
- }
- PluginStub plugin = new PluginStub();
- plugin.setDescriptor(pluginDescriptor);
- mes.setPlugin(plugin);
- return mes;
- }
-
- @Provides
- @Singleton
- @Priority(-10)
- private Log createLog() {
- return new DefaultLog(LoggerFactory.getLogger("anonymous"));
- }
-
- @Provides
- static RepositorySystemSupplier newRepositorySystemSupplier() {
- return new RepositorySystemSupplier();
- }
-
- @Provides
- static RepositorySystem newRepositorySystem(RepositorySystemSupplier repositorySystemSupplier) {
- return repositorySystemSupplier.getRepositorySystem();
- }
-
- @Provides
- @Priority(10)
- static RepositoryFactory newRepositoryFactory(Session session) {
- return session.getService(RepositoryFactory.class);
- }
-
- @Provides
- @Priority(10)
- static VersionParser newVersionParser(Session session) {
- return session.getService(VersionParser.class);
- }
-
- @Provides
- @Priority(10)
- static LocalRepositoryManager newLocalRepositoryManager(Session session) {
- return session.getService(LocalRepositoryManager.class);
- }
-
- @Provides
- @Priority(10)
- static ArtifactInstaller newArtifactInstaller(Session session) {
- return session.getService(ArtifactInstaller.class);
- }
-
- @Provides
- @Priority(10)
- static ArtifactDeployer newArtifactDeployer(Session session) {
- return session.getService(ArtifactDeployer.class);
- }
-
- @Provides
- @Priority(10)
- static ArtifactManager newArtifactManager(Session session) {
- return session.getService(ArtifactManager.class);
- }
-
- @Provides
- @Priority(10)
- static ProjectManager newProjectManager(Session session) {
- return session.getService(ProjectManager.class);
- }
-
- @Provides
- @Priority(10)
- static ArtifactFactory newArtifactFactory(Session session) {
- return session.getService(ArtifactFactory.class);
- }
-
- @Provides
- @Priority(10)
- static ProjectBuilder newProjectBuilder(Session session) {
- return session.getService(ProjectBuilder.class);
- }
-
- @Provides
- @Priority(10)
- static ModelXmlFactory newModelXmlFactory(Session session) {
- return session.getService(ModelXmlFactory.class);
- }
- }
-
- getInjector().bindInstance(Foo.class, new Foo());
-
- getInjector().injectInstance(context.getRequiredTestInstance());
-
- // SessionScope sessionScope = getInjector().getInstance(SessionScope.class);
- // sessionScope.enter();
- // sessionScope.seed(Session.class, s);
- // sessionScope.seed(InternalSession.class, s);
-
- // MojoExecutionScope mojoExecutionScope = getInjector().getInstance(MojoExecutionScope.class);
- // mojoExecutionScope.enter();
- // mojoExecutionScope.seed(Project.class, p);
- // mojoExecutionScope.seed(MojoExecution.class, me);
- }
-
- private Reader openPomUrl(Class<?> holder, String pom, Path[] modelPath) throws IOException {
- if (pom.startsWith("file:")) {
- Path path = Paths.get(getBasedir()).resolve(pom.substring("file:".length()));
- modelPath[0] = path;
- return Files.newBufferedReader(path);
- } else if (pom.startsWith("classpath:")) {
- URL url = holder.getResource(pom.substring("classpath:".length()));
- if (url == null) {
- throw new IllegalStateException("Unable to find pom on classpath: " + pom);
- }
- return new XmlStreamReader(url.openStream());
- } else if (pom.contains("<project>")) {
- return new StringReader(pom);
- } else {
- Path path = Paths.get(getBasedir()).resolve(pom);
- modelPath[0] = path;
- return Files.newBufferedReader(path);
- }
- }
-
- protected String getPluginDescriptorLocation() {
- return "META-INF/maven/plugin.xml";
- }
-
- protected String[] mojoCoordinates(String goal) throws Exception {
- if (goal.matches(".*:.*:.*:.*")) {
- return goal.split(":");
- } else {
- Path pluginPom = Paths.get(getPluginBasedir(), "pom.xml");
- Xpp3Dom pluginPomDom = Xpp3DomBuilder.build(Files.newBufferedReader(pluginPom));
- String artifactId = pluginPomDom.getChild("artifactId").getValue();
- String groupId = resolveFromRootThenParent(pluginPomDom, "groupId");
- String version = resolveFromRootThenParent(pluginPomDom, "version");
- return new String[] {groupId, artifactId, version, goal};
- }
- }
-
- private XmlNode finalizeConfig(XmlNode config, MojoDescriptor mojoDescriptor) {
- List<XmlNode> children = new ArrayList<>();
- if (mojoDescriptor != null && mojoDescriptor.getParameters() != null) {
- XmlNode defaultConfiguration;
- defaultConfiguration = MojoDescriptorCreator.convert(mojoDescriptor);
- for (Parameter parameter : mojoDescriptor.getParameters()) {
- XmlNode parameterConfiguration = config.getChild(parameter.getName());
- if (parameterConfiguration == null) {
- parameterConfiguration = config.getChild(parameter.getAlias());
- }
- XmlNode parameterDefaults = defaultConfiguration.getChild(parameter.getName());
- parameterConfiguration = XmlNode.merge(parameterConfiguration, parameterDefaults, Boolean.TRUE);
- if (parameterConfiguration != null) {
- Map<String, String> attributes = new HashMap<>(parameterConfiguration.getAttributes());
- // if (isEmpty(parameterConfiguration.getAttribute("implementation"))
- // && !isEmpty(parameter.getImplementation())) {
- // attributes.put("implementation", parameter.getImplementation());
- // }
- parameterConfiguration = new XmlNodeImpl(
- parameter.getName(),
- parameterConfiguration.getValue(),
- attributes,
- parameterConfiguration.getChildren(),
- parameterConfiguration.getInputLocation());
-
- children.add(parameterConfiguration);
- }
- }
- }
- return new XmlNodeImpl("configuration", null, null, children, null);
- }
-
- private boolean isEmpty(String str) {
- return str == null || str.isEmpty();
- }
-
- private static Optional<Xpp3Dom> child(Xpp3Dom element, String name) {
- return Optional.ofNullable(element.getChild(name));
- }
-
- private static Stream<Xpp3Dom> children(Xpp3Dom element) {
- return Stream.of(element.getChildren());
- }
-
- public static XmlNode extractPluginConfiguration(String artifactId, Xpp3Dom pomDom) throws Exception {
- Xpp3Dom pluginConfigurationElement = child(pomDom, "build")
- .flatMap(buildElement -> child(buildElement, "plugins"))
- .map(MojoExtension::children)
- .orElseGet(Stream::empty)
- .filter(e -> e.getChild("artifactId").getValue().equals(artifactId))
- .findFirst()
- .flatMap(buildElement -> child(buildElement, "configuration"))
- .orElse(Xpp3DomBuilder.build(new StringReader("<configuration/>")));
- return pluginConfigurationElement.getDom();
- }
-
- /**
- * sometimes the parent element might contain the correct value so generalize that access
- *
- * TODO find out where this is probably done elsewhere
- */
- private static String resolveFromRootThenParent(Xpp3Dom pluginPomDom, String element) throws Exception {
- return Optional.ofNullable(child(pluginPomDom, element).orElseGet(() -> child(pluginPomDom, "parent")
- .flatMap(e -> child(e, element))
- .orElse(null)))
- .map(Xpp3Dom::getValue)
- .orElseThrow(() -> new Exception("unable to determine " + element));
- }
-
- /**
- * Convenience method to obtain the value of a variable on a mojo that might not have a getter.
- * <br>
- * NOTE: the caller is responsible for casting to what the desired type is.
- */
- public static Object getVariableValueFromObject(Object object, String variable) throws IllegalAccessException {
- Field field = ReflectionUtils.getFieldByNameIncludingSuperclasses(variable, object.getClass());
- field.setAccessible(true);
- return field.get(object);
- }
-
- /**
- * Convenience method to obtain all variables and values from the mojo (including its superclasses)
- * <br>
- * Note: the values in the map are of type Object so the caller is responsible for casting to desired types.
- */
- public static Map<String, Object> getVariablesAndValuesFromObject(Object object) throws IllegalAccessException {
- return getVariablesAndValuesFromObject(object.getClass(), object);
- }
-
- /**
- * Convenience method to obtain all variables and values from the mojo (including its superclasses)
- * <br>
- * Note: the values in the map are of type Object so the caller is responsible for casting to desired types.
- *
- * @return map of variable names and values
- */
- public static Map<String, Object> getVariablesAndValuesFromObject(Class<?> clazz, Object object)
- throws IllegalAccessException {
- Map<String, Object> map = new HashMap<>();
- Field[] fields = clazz.getDeclaredFields();
- AccessibleObject.setAccessible(fields, true);
- for (Field field : fields) {
- map.put(field.getName(), field.get(object));
- }
- Class<?> superclass = clazz.getSuperclass();
- if (!Object.class.equals(superclass)) {
- map.putAll(getVariablesAndValuesFromObject(superclass, object));
- }
- return map;
- }
-
- /**
- * Convenience method to set values to variables in objects that don't have setters
- */
- public static void setVariableValueToObject(Object object, String variable, Object value)
- throws IllegalAccessException {
- Field field = ReflectionUtils.getFieldByNameIncludingSuperclasses(variable, object.getClass());
- requireNonNull(field, "Field " + variable + " not found");
- field.setAccessible(true);
- field.set(object, value);
- }
-
- static class WrapEvaluator implements TypeAwareExpressionEvaluator {
-
- private final Injector injector;
- private final TypeAwareExpressionEvaluator evaluator;
-
- WrapEvaluator(Injector injector, TypeAwareExpressionEvaluator evaluator) {
- this.injector = injector;
- this.evaluator = evaluator;
- }
-
- @Override
- public Object evaluate(String expression) throws ExpressionEvaluationException {
- return evaluate(expression, null);
- }
-
- @Override
- public Object evaluate(String expression, Class<?> type) throws ExpressionEvaluationException {
- Object value = evaluator.evaluate(expression, type);
- if (value == null) {
- String expr = stripTokens(expression);
- if (expr != null) {
- try {
- value = injector.getInstance(Key.of(type, expr));
- } catch (DIException e) {
- // nothing
- }
- }
- }
- return value;
- }
-
- private String stripTokens(String expr) {
- if (expr.startsWith("${") && expr.endsWith("}")) {
- return expr.substring(2, expr.length() - 1);
- }
- return null;
- }
-
- @Override
- public File alignToBaseDirectory(File path) {
- return evaluator.alignToBaseDirectory(path);
- }
- }
-
- /*
- private Scope getScopeInstanceOrNull(final Injector injector, final Binding<?> binding) {
- return binding.acceptScopingVisitor(new DefaultBindingScopingVisitor<Scope>() {
-
- @Override
- public Scope visitScopeAnnotation(Class<? extends Annotation> scopeAnnotation) {
- throw new RuntimeException(String.format(
- "I don't know how to handle the scopeAnnotation: %s", scopeAnnotation.getCanonicalName()));
- }
-
- @Override
- public Scope visitNoScoping() {
- if (binding instanceof LinkedKeyBinding) {
- Binding<?> childBinding = injector.getBinding(((LinkedKeyBinding) binding).getLinkedKey());
- return getScopeInstanceOrNull(injector, childBinding);
- }
- return null;
- }
-
- @Override
- public Scope visitEagerSingleton() {
- return Scopes.SINGLETON;
- }
-
- public Scope visitScope(Scope scope) {
- return scope;
- }
- });
- }*/
-
-}
diff --git a/maven-plugin-testing-harness/src/main/java/org/apache/maven/api/plugin/testing/MojoParameter.java b/maven-plugin-testing-harness/src/main/java/org/apache/maven/api/plugin/testing/MojoParameter.java
deleted file mode 100644
index 8c37804..0000000
--- a/maven-plugin-testing-harness/src/main/java/org/apache/maven/api/plugin/testing/MojoParameter.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.maven.api.plugin.testing;
-
-import java.lang.annotation.Inherited;
-import java.lang.annotation.Repeatable;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-
-/**
- * Mojo parameter
- */
-@Retention(RetentionPolicy.RUNTIME)
-@Repeatable(MojoParameters.class)
-@Inherited
-public @interface MojoParameter {
- String name();
-
- String value();
-}
diff --git a/maven-plugin-testing-harness/src/main/java/org/apache/maven/api/plugin/testing/MojoParameters.java b/maven-plugin-testing-harness/src/main/java/org/apache/maven/api/plugin/testing/MojoParameters.java
deleted file mode 100644
index 373c926..0000000
--- a/maven-plugin-testing-harness/src/main/java/org/apache/maven/api/plugin/testing/MojoParameters.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.maven.api.plugin.testing;
-
-import java.lang.annotation.Inherited;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-
-/**
- * Mojo parameters container
- */
-@Retention(RetentionPolicy.RUNTIME)
-@Inherited
-public @interface MojoParameters {
- MojoParameter[] value();
-}
diff --git a/maven-plugin-testing-harness/src/main/java/org/apache/maven/api/plugin/testing/MojoTest.java b/maven-plugin-testing-harness/src/main/java/org/apache/maven/api/plugin/testing/MojoTest.java
deleted file mode 100644
index eb94c09..0000000
--- a/maven-plugin-testing-harness/src/main/java/org/apache/maven/api/plugin/testing/MojoTest.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.maven.api.plugin.testing;
-
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-import org.junit.jupiter.api.extension.ExtendWith;
-
-/**
- *
- */
-@Retention(RetentionPolicy.RUNTIME)
-@ExtendWith(MojoExtension.class)
-@Target(ElementType.TYPE)
-public @interface MojoTest {}
diff --git a/maven-plugin-testing-harness/src/main/java/org/apache/maven/api/plugin/testing/ResolverExpressionEvaluatorStub.java b/maven-plugin-testing-harness/src/main/java/org/apache/maven/api/plugin/testing/ResolverExpressionEvaluatorStub.java
deleted file mode 100644
index 1ca785d..0000000
--- a/maven-plugin-testing-harness/src/main/java/org/apache/maven/api/plugin/testing/ResolverExpressionEvaluatorStub.java
+++ /dev/null
@@ -1,118 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.maven.api.plugin.testing;
-
-import java.io.File;
-import java.util.Map;
-
-import org.codehaus.plexus.component.configurator.expression.ExpressionEvaluationException;
-import org.codehaus.plexus.component.configurator.expression.ExpressionEvaluator;
-import org.codehaus.plexus.component.configurator.expression.TypeAwareExpressionEvaluator;
-import org.eclipse.aether.repository.LocalRepository;
-
-/**
- * Stub for {@link ExpressionEvaluator}
- *
- * @author jesse
- */
-public class ResolverExpressionEvaluatorStub implements TypeAwareExpressionEvaluator {
-
- private final Map<String, Object> properties;
-
- public ResolverExpressionEvaluatorStub(Map<String, Object> properties) {
- this.properties = properties;
- }
-
- /** {@inheritDoc} */
- @Override
- public Object evaluate(String expr) throws ExpressionEvaluationException {
- return evaluate(expr, null);
- }
-
- /** {@inheritDoc} */
- @Override
- public Object evaluate(String expr, Class<?> type) throws ExpressionEvaluationException {
-
- Object value = null;
-
- if (expr == null) {
- return null;
- }
-
- String expression = stripTokens(expr);
-
- if (expression.equals(expr)) {
- int index = expr.indexOf("${");
- if (index >= 0) {
- int lastIndex = expr.indexOf("}", index);
- if (lastIndex >= 0) {
- String retVal = expr.substring(0, index);
-
- if (index > 0 && expr.charAt(index - 1) == '$') {
- retVal += expr.substring(index + 1, lastIndex + 1);
- } else {
- retVal += evaluate(expr.substring(index, lastIndex + 1));
- }
-
- retVal += evaluate(expr.substring(lastIndex + 1));
- return retVal;
- }
- }
-
- // Was not an expression
- return expression.contains("$$") ? expression.replaceAll("\\$\\$", "\\$") : expression;
- } else {
- if ("basedir".equals(expression) || "project.basedir".equals(expression)) {
- value = MojoExtension.getBasedir();
- } else if (expression.startsWith("basedir") || expression.startsWith("project.basedir")) {
- int pathSeparator = expression.indexOf("/");
- if (pathSeparator > 0) {
- value = MojoExtension.getBasedir() + expression.substring(pathSeparator);
- }
- } else if ("localRepository".equals(expression)) {
- File localRepo = new File(MojoExtension.getBasedir(), "target/local-repo");
- return new LocalRepository("file://" + localRepo.getAbsolutePath());
- }
- if (value == null && properties != null && properties.containsKey(expression)) {
- value = properties.get(expression);
- }
- return value;
- }
- }
-
- private String stripTokens(String expr) {
- if (expr.startsWith("${") && expr.indexOf("}") == expr.length() - 1) {
- expr = expr.substring(2, expr.length() - 1);
- }
-
- return expr;
- }
-
- /** {@inheritDoc} */
- @Override
- public File alignToBaseDirectory(File file) {
- if (file.getAbsolutePath().startsWith(MojoExtension.getBasedir())) {
- return file;
- } else if (file.isAbsolute()) {
- return file;
- } else {
- return new File(MojoExtension.getBasedir(), file.getPath());
- }
- }
-}
diff --git a/maven-plugin-testing-harness/src/main/java/org/apache/maven/api/plugin/testing/stubs/ArtifactStub.java b/maven-plugin-testing-harness/src/main/java/org/apache/maven/api/plugin/testing/stubs/ArtifactStub.java
deleted file mode 100644
index b1689d4..0000000
--- a/maven-plugin-testing-harness/src/main/java/org/apache/maven/api/plugin/testing/stubs/ArtifactStub.java
+++ /dev/null
@@ -1,188 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.maven.api.plugin.testing.stubs;
-
-import java.util.Objects;
-
-import org.apache.maven.api.Artifact;
-import org.apache.maven.api.ArtifactCoordinates;
-import org.apache.maven.api.Version;
-import org.apache.maven.api.VersionConstraint;
-import org.apache.maven.api.annotations.Nonnull;
-import org.apache.maven.impl.DefaultModelVersionParser;
-import org.apache.maven.impl.DefaultVersionParser;
-import org.eclipse.aether.util.version.GenericVersionScheme;
-
-/**
- *
- */
-public class ArtifactStub implements Artifact {
- private String groupId;
- private String artifactId;
- private String classifier;
- private String version;
- private String baseVersion;
- private String extension;
-
- public ArtifactStub() {
- groupId = "";
- artifactId = "";
- version = "";
- classifier = "";
- extension = "";
- }
-
- public ArtifactStub(String groupId, String artifactId, String classifier, String version, String extension) {
- this.groupId = groupId;
- this.artifactId = artifactId;
- this.classifier = classifier;
- this.version = version;
- this.extension = extension;
- }
-
- @Nonnull
- @Override
- public String getGroupId() {
- return groupId;
- }
-
- public void setGroupId(String groupId) {
- this.groupId = groupId;
- }
-
- @Nonnull
- @Override
- public String getArtifactId() {
- return artifactId;
- }
-
- public void setArtifactId(String artifactId) {
- this.artifactId = artifactId;
- }
-
- @Nonnull
- @Override
- public String getClassifier() {
- return classifier;
- }
-
- public void setClassifier(String classifier) {
- this.classifier = classifier;
- }
-
- @Nonnull
- @Override
- public Version getVersion() {
- return getParser().parseVersion(version);
- }
-
- public void setVersion(String version) {
- this.version = version;
- }
-
- @Override
- public Version getBaseVersion() {
- return getParser().parseVersion(baseVersion != null ? baseVersion : version);
- }
-
- public void setBaseVersion(String baseVersion) {
- this.baseVersion = baseVersion;
- }
-
- @Nonnull
- @Override
- public String getExtension() {
- return extension;
- }
-
- public void setExtension(String extension) {
- this.extension = extension;
- }
-
- @Override
- public boolean isSnapshot() {
- return false;
- }
-
- @Override
- public ArtifactCoordinates toCoordinates() {
- return new ArtifactCoordinates() {
- @Override
- public String getGroupId() {
- return groupId;
- }
-
- @Override
- public String getArtifactId() {
- return artifactId;
- }
-
- @Override
- public String getClassifier() {
- return classifier;
- }
-
- @Override
- public VersionConstraint getVersionConstraint() {
- return getParser().parseVersionConstraint(version);
- }
-
- @Override
- public String getExtension() {
- return extension;
- }
- };
- }
-
- @Override
- public String toString() {
- return "ArtifactStub["
- + "groupId='" + groupId + '\''
- + ", artifactId='" + artifactId + '\''
- + ", classifier='" + classifier + '\''
- + ", version='" + version + '\''
- + ", extension='" + extension + '\''
- + ']';
- }
-
- @Override
- public boolean equals(Object o) {
- if (this == o) {
- return true;
- }
- if (!(o instanceof ArtifactStub)) {
- return false;
- }
- ArtifactStub that = (ArtifactStub) o;
- return Objects.equals(groupId, that.groupId)
- && Objects.equals(artifactId, that.artifactId)
- && Objects.equals(classifier, that.classifier)
- && Objects.equals(version, that.version)
- && Objects.equals(extension, that.extension);
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(groupId, artifactId, classifier, version, extension);
- }
-
- private static DefaultVersionParser getParser() {
- return new DefaultVersionParser(new DefaultModelVersionParser(new GenericVersionScheme()));
- }
-}
diff --git a/maven-plugin-testing-harness/src/main/java/org/apache/maven/api/plugin/testing/stubs/LookupStub.java b/maven-plugin-testing-harness/src/main/java/org/apache/maven/api/plugin/testing/stubs/LookupStub.java
deleted file mode 100644
index 15f4e91..0000000
--- a/maven-plugin-testing-harness/src/main/java/org/apache/maven/api/plugin/testing/stubs/LookupStub.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.maven.api.plugin.testing.stubs;
-
-import java.util.List;
-import java.util.Map;
-import java.util.Optional;
-
-import org.apache.maven.api.services.Lookup;
-import org.apache.maven.api.services.LookupException;
-
-public class LookupStub implements Lookup {
- /**
- * A stub where all methods return an empty value when possible, or throw an exception otherwise.
- */
- public static final Lookup EMPTY = new LookupStub();
-
- /**
- * For sub-class constructors.
- */
- protected LookupStub() {}
-
- @Override
- public <T> T lookup(Class<T> type) {
- throw new LookupException("This is only a stub.");
- }
-
- @Override
- public <T> T lookup(Class<T> type, String string) {
- throw new LookupException("This is only a stub.");
- }
-
- @Override
- public <T> Optional<T> lookupOptional(Class<T> type) {
- return Optional.empty();
- }
-
- @Override
- public <T> Optional<T> lookupOptional(Class<T> type, String string) {
- return Optional.empty();
- }
-
- @Override
- public <T> List<T> lookupList(Class<T> type) {
- return List.of();
- }
-
- @Override
- public <T> Map<String, T> lookupMap(Class<T> type) {
- return Map.of();
- }
-}
diff --git a/maven-plugin-testing-harness/src/main/java/org/apache/maven/api/plugin/testing/stubs/MojoExecutionStub.java b/maven-plugin-testing-harness/src/main/java/org/apache/maven/api/plugin/testing/stubs/MojoExecutionStub.java
deleted file mode 100644
index 2619b75..0000000
--- a/maven-plugin-testing-harness/src/main/java/org/apache/maven/api/plugin/testing/stubs/MojoExecutionStub.java
+++ /dev/null
@@ -1,113 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.maven.api.plugin.testing.stubs;
-
-import java.util.Optional;
-
-import org.apache.maven.api.MojoExecution;
-import org.apache.maven.api.Plugin;
-import org.apache.maven.api.model.PluginExecution;
-import org.apache.maven.api.plugin.descriptor.MojoDescriptor;
-import org.apache.maven.api.xml.XmlNode;
-
-/**
- * Stub for {@link MojoExecution}.
- */
-public class MojoExecutionStub implements MojoExecution {
- private String executionId;
- private String goal;
- private XmlNode dom;
- private Plugin plugin = new PluginStub();
- private PluginExecution model;
- private MojoDescriptor descriptor;
- private String lifecyclePhase;
-
- public MojoExecutionStub(String executionId, String goal) {
- this(executionId, goal, null);
- }
-
- public MojoExecutionStub(String executionId, String goal, XmlNode dom) {
- this.executionId = executionId;
- this.goal = goal;
- this.dom = dom;
- }
-
- @Override
- public Plugin getPlugin() {
- return plugin;
- }
-
- @Override
- public PluginExecution getModel() {
- return model;
- }
-
- @Override
- public MojoDescriptor getDescriptor() {
- return descriptor;
- }
-
- @Override
- public String getLifecyclePhase() {
- return lifecyclePhase;
- }
-
- @Override
- public String getExecutionId() {
- return executionId;
- }
-
- @Override
- public String getGoal() {
- return goal;
- }
-
- @Override
- public Optional<XmlNode> getConfiguration() {
- return Optional.ofNullable(dom);
- }
-
- public void setExecutionId(String executionId) {
- this.executionId = executionId;
- }
-
- public void setGoal(String goal) {
- this.goal = goal;
- }
-
- public void setDom(XmlNode dom) {
- this.dom = dom;
- }
-
- public void setPlugin(Plugin plugin) {
- this.plugin = plugin;
- }
-
- public void setModel(PluginExecution model) {
- this.model = model;
- }
-
- public void setDescriptor(MojoDescriptor descriptor) {
- this.descriptor = descriptor;
- }
-
- public void setLifecyclePhase(String lifecyclePhase) {
- this.lifecyclePhase = lifecyclePhase;
- }
-}
diff --git a/maven-plugin-testing-harness/src/main/java/org/apache/maven/api/plugin/testing/stubs/PluginStub.java b/maven-plugin-testing-harness/src/main/java/org/apache/maven/api/plugin/testing/stubs/PluginStub.java
deleted file mode 100644
index b7b4cfc..0000000
--- a/maven-plugin-testing-harness/src/main/java/org/apache/maven/api/plugin/testing/stubs/PluginStub.java
+++ /dev/null
@@ -1,102 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.maven.api.plugin.testing.stubs;
-
-import java.util.Collections;
-import java.util.List;
-import java.util.Map;
-
-import org.apache.maven.api.Artifact;
-import org.apache.maven.api.Dependency;
-import org.apache.maven.api.Plugin;
-import org.apache.maven.api.plugin.descriptor.PluginDescriptor;
-import org.apache.maven.api.plugin.descriptor.lifecycle.Lifecycle;
-
-public class PluginStub implements Plugin {
-
- org.apache.maven.api.model.Plugin model;
- PluginDescriptor descriptor;
- List<Lifecycle> lifecycles = Collections.emptyList();
- ClassLoader classLoader;
- Artifact artifact;
- List<Dependency> dependencies = Collections.emptyList();
- Map<String, Dependency> dependenciesMap = Collections.emptyMap();
-
- @Override
- public org.apache.maven.api.model.Plugin getModel() {
- return model;
- }
-
- public void setModel(org.apache.maven.api.model.Plugin model) {
- this.model = model;
- }
-
- @Override
- public PluginDescriptor getDescriptor() {
- return descriptor;
- }
-
- public void setDescriptor(PluginDescriptor descriptor) {
- this.descriptor = descriptor;
- }
-
- @Override
- public List<Lifecycle> getLifecycles() {
- return lifecycles;
- }
-
- public void setLifecycles(List<Lifecycle> lifecycles) {
- this.lifecycles = lifecycles;
- }
-
- @Override
- public ClassLoader getClassLoader() {
- return classLoader;
- }
-
- public void setClassLoader(ClassLoader classLoader) {
- this.classLoader = classLoader;
- }
-
- @Override
- public Artifact getArtifact() {
- return artifact;
- }
-
- public void setArtifact(Artifact artifact) {
- this.artifact = artifact;
- }
-
- @Override
- public List<Dependency> getDependencies() {
- return dependencies;
- }
-
- public void setDependencies(List<Dependency> dependencies) {
- this.dependencies = dependencies;
- }
-
- public Map<String, Dependency> getDependenciesMap() {
- return dependenciesMap;
- }
-
- public void setDependenciesMap(Map<String, Dependency> dependenciesMap) {
- this.dependenciesMap = dependenciesMap;
- }
-}
diff --git a/maven-plugin-testing-harness/src/main/java/org/apache/maven/api/plugin/testing/stubs/ProducedArtifactStub.java b/maven-plugin-testing-harness/src/main/java/org/apache/maven/api/plugin/testing/stubs/ProducedArtifactStub.java
deleted file mode 100644
index 9575225..0000000
--- a/maven-plugin-testing-harness/src/main/java/org/apache/maven/api/plugin/testing/stubs/ProducedArtifactStub.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.maven.api.plugin.testing.stubs;
-
-import org.apache.maven.api.ProducedArtifact;
-
-/**
- *
- */
-public class ProducedArtifactStub extends ArtifactStub implements ProducedArtifact {
- public ProducedArtifactStub() {}
-
- public ProducedArtifactStub(
- String groupId, String artifactId, String classifier, String version, String extension) {
- super(groupId, artifactId, classifier, version, extension);
- }
-}
diff --git a/maven-plugin-testing-harness/src/main/java/org/apache/maven/api/plugin/testing/stubs/ProjectStub.java b/maven-plugin-testing-harness/src/main/java/org/apache/maven/api/plugin/testing/stubs/ProjectStub.java
deleted file mode 100644
index e08d32c..0000000
--- a/maven-plugin-testing-harness/src/main/java/org/apache/maven/api/plugin/testing/stubs/ProjectStub.java
+++ /dev/null
@@ -1,301 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.maven.api.plugin.testing.stubs;
-
-import java.nio.file.Path;
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Optional;
-import java.util.Set;
-
-import org.apache.maven.api.DependencyCoordinates;
-import org.apache.maven.api.Language;
-import org.apache.maven.api.Packaging;
-import org.apache.maven.api.PathType;
-import org.apache.maven.api.ProducedArtifact;
-import org.apache.maven.api.Project;
-import org.apache.maven.api.Type;
-import org.apache.maven.api.annotations.Nonnull;
-import org.apache.maven.api.model.Model;
-import org.apache.maven.api.model.PluginContainer;
-import org.apache.maven.api.model.Profile;
-
-/**
- * @author Olivier Lamy
- * @since 1.0-beta-1
- *
- */
-public class ProjectStub implements Project {
-
- private Model model = Model.newInstance();
- private Path basedir;
- private Path pomPath;
- private boolean topProject;
- private Path rootDirectory;
- private ProducedArtifact mainArtifact;
- private List<Profile> declaredProfiles = List.of();
- private List<Profile> effectiveProfiles = List.of();
- private List<Profile> declaredActiveProfiles = List.of();
- private List<Profile> effectiveActiveProfiles = List.of();
-
- public void setModel(Model model) {
- this.model = model;
- }
-
- @Nonnull
- @Override
- public String getGroupId() {
- return model.getGroupId();
- }
-
- @Nonnull
- @Override
- public String getArtifactId() {
- return model.getArtifactId();
- }
-
- @Nonnull
- @Override
- public String getVersion() {
- return model.getVersion();
- }
-
- public String getName() {
- return model.getName();
- }
-
- @Nonnull
- @Override
- public Packaging getPackaging() {
- return new Packaging() {
- @Override
- public String id() {
- return model.getPackaging();
- }
-
- @Override
- public Type type() {
- return new Type() {
- @Override
- public String id() {
- return model.getPackaging();
- }
-
- @Override
- public Language getLanguage() {
- return null;
- }
-
- @Override
- public String getExtension() {
- return model.getPackaging();
- }
-
- @Override
- public String getClassifier() {
- return "";
- }
-
- @Override
- public boolean isIncludesDependencies() {
- return false;
- }
-
- @Override
- public Set<PathType> getPathTypes() {
- return Set.of();
- }
- };
- }
-
- @Override
- public Map<String, PluginContainer> plugins() {
- return Map.of();
- }
- };
- }
-
- @Override
- public List<ProducedArtifact> getArtifacts() {
- ProducedArtifact pomArtifact = new ProducedArtifactStub(getGroupId(), getArtifactId(), "", getVersion(), "pom");
- return mainArtifact != null ? Arrays.asList(pomArtifact, mainArtifact) : Arrays.asList(pomArtifact);
- }
-
- @Nonnull
- @Override
- public Model getModel() {
- return model;
- }
-
- @Nonnull
- @Override
- public Path getPomPath() {
- return pomPath;
- }
-
- @Nonnull
- @Override
- public List<DependencyCoordinates> getDependencies() {
- return null;
- }
-
- @Nonnull
- @Override
- public List<DependencyCoordinates> getManagedDependencies() {
- return null;
- }
-
- @Override
- public Path getBasedir() {
- return basedir;
- }
-
- @Override
- public Optional<Project> getParent() {
- return Optional.empty();
- }
-
- @Override
- public boolean isTopProject() {
- return topProject;
- }
-
- @Override
- public boolean isRootProject() {
- return model.isRoot();
- }
-
- @Override
- public Path getRootDirectory() {
- return rootDirectory;
- }
-
- //
- // Setters
- //
-
- public ProjectStub setBasedir(Path basedir) {
- this.basedir = basedir;
- return this;
- }
-
- public ProjectStub setGroupId(String groupId) {
- model = model.withGroupId(groupId);
- return this;
- }
-
- public ProjectStub setArtifactId(String artifactId) {
- model = model.withArtifactId(artifactId);
- return this;
- }
-
- public ProjectStub setVersion(String version) {
- model = model.withVersion(version);
- return this;
- }
-
- public ProjectStub setName(String name) {
- model = model.withName(name);
- return this;
- }
-
- public ProjectStub setDescription(String desc) {
- model = model.withDescription(desc);
- return this;
- }
-
- public ProjectStub setPackaging(String packaging) {
- model = model.withPackaging(packaging);
- return this;
- }
-
- public ProjectStub setMainArtifact(ProducedArtifact mainArtifact) {
- this.mainArtifact = mainArtifact;
- return this;
- }
-
- public ProjectStub setPomPath(Path pomPath) {
- this.pomPath = pomPath;
- return this;
- }
-
- public ProjectStub setTopProject(boolean topProject) {
- this.topProject = topProject;
- return this;
- }
-
- public ProjectStub setMavenModel(org.apache.maven.model.Model model) {
- this.model = model.getDelegate();
- return this;
- }
-
- public ProjectStub setRootDirectory(Path rootDirectory) {
- this.rootDirectory = rootDirectory;
- return this;
- }
-
- public ProjectStub addProperty(String key, String value) {
- Map<String, String> props = new HashMap<>(model.getProperties());
- props.put(key, value);
- model = model.withProperties(props);
- return this;
- }
-
- @Override
- @SuppressWarnings("ReturnOfCollectionOrArrayField") // Safe because list is unmodifiable.
- public List<Profile> getDeclaredProfiles() {
- return declaredProfiles;
- }
-
- public void setDeclaredProfiles(List<Profile> values) {
- declaredProfiles = List.copyOf(values);
- }
-
- @Override
- @SuppressWarnings("ReturnOfCollectionOrArrayField") // Safe because list is unmodifiable.
- public List<Profile> getEffectiveProfiles() {
- return effectiveProfiles;
- }
-
- public void setEffectiveProfiles(List<Profile> values) {
- effectiveProfiles = List.copyOf(values);
- }
-
- @Override
- @SuppressWarnings("ReturnOfCollectionOrArrayField") // Safe because list is unmodifiable.
- public List<Profile> getDeclaredActiveProfiles() {
- return declaredActiveProfiles;
- }
-
- public void setDeclaredActiveProfiles(List<Profile> values) {
- declaredActiveProfiles = List.copyOf(values);
- }
-
- @Override
- @SuppressWarnings("ReturnOfCollectionOrArrayField") // Safe because list is unmodifiable.
- public List<Profile> getEffectiveActiveProfiles() {
- return effectiveActiveProfiles;
- }
-
- public void setEffectiveActiveProfiles(List<Profile> values) {
- effectiveActiveProfiles = List.copyOf(values);
- }
-}
diff --git a/maven-plugin-testing-harness/src/main/java/org/apache/maven/api/plugin/testing/stubs/RepositorySystemSupplier.java b/maven-plugin-testing-harness/src/main/java/org/apache/maven/api/plugin/testing/stubs/RepositorySystemSupplier.java
deleted file mode 100644
index 5f7246d..0000000
--- a/maven-plugin-testing-harness/src/main/java/org/apache/maven/api/plugin/testing/stubs/RepositorySystemSupplier.java
+++ /dev/null
@@ -1,1115 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.maven.api.plugin.testing.stubs;
-
-import java.util.HashMap;
-import java.util.LinkedHashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.concurrent.atomic.AtomicBoolean;
-import java.util.function.Supplier;
-
-import org.apache.maven.api.services.ModelBuilder;
-import org.apache.maven.impl.DefaultModelUrlNormalizer;
-import org.apache.maven.impl.DefaultModelVersionParser;
-import org.apache.maven.impl.DefaultModelXmlFactory;
-import org.apache.maven.impl.DefaultPluginConfigurationExpander;
-import org.apache.maven.impl.DefaultSuperPomProvider;
-import org.apache.maven.impl.DefaultUrlNormalizer;
-import org.apache.maven.impl.model.DefaultDependencyManagementImporter;
-import org.apache.maven.impl.model.DefaultDependencyManagementInjector;
-import org.apache.maven.impl.model.DefaultInheritanceAssembler;
-import org.apache.maven.impl.model.DefaultInterpolator;
-import org.apache.maven.impl.model.DefaultModelBuilder;
-import org.apache.maven.impl.model.DefaultModelInterpolator;
-import org.apache.maven.impl.model.DefaultModelNormalizer;
-import org.apache.maven.impl.model.DefaultModelPathTranslator;
-import org.apache.maven.impl.model.DefaultModelProcessor;
-import org.apache.maven.impl.model.DefaultModelValidator;
-import org.apache.maven.impl.model.DefaultPathTranslator;
-import org.apache.maven.impl.model.DefaultPluginManagementInjector;
-import org.apache.maven.impl.model.DefaultProfileInjector;
-import org.apache.maven.impl.model.DefaultProfileSelector;
-import org.apache.maven.impl.model.rootlocator.DefaultRootLocator;
-import org.apache.maven.impl.resolver.DefaultArtifactDescriptorReader;
-import org.apache.maven.impl.resolver.DefaultModelResolver;
-import org.apache.maven.impl.resolver.DefaultVersionRangeResolver;
-import org.apache.maven.impl.resolver.DefaultVersionResolver;
-import org.apache.maven.impl.resolver.MavenArtifactRelocationSource;
-import org.apache.maven.impl.resolver.PluginsMetadataGeneratorFactory;
-import org.apache.maven.impl.resolver.SnapshotMetadataGeneratorFactory;
-import org.apache.maven.impl.resolver.VersionsMetadataGeneratorFactory;
-import org.apache.maven.impl.resolver.relocation.DistributionManagementArtifactRelocationSource;
-import org.apache.maven.impl.resolver.relocation.UserPropertiesArtifactRelocationSource;
-import org.eclipse.aether.RepositoryListener;
-import org.eclipse.aether.RepositorySystem;
-import org.eclipse.aether.connector.basic.BasicRepositoryConnectorFactory;
-import org.eclipse.aether.impl.ArtifactDescriptorReader;
-import org.eclipse.aether.impl.ArtifactResolver;
-import org.eclipse.aether.impl.DependencyCollector;
-import org.eclipse.aether.impl.Deployer;
-import org.eclipse.aether.impl.Installer;
-import org.eclipse.aether.impl.LocalRepositoryProvider;
-import org.eclipse.aether.impl.MetadataGeneratorFactory;
-import org.eclipse.aether.impl.MetadataResolver;
-import org.eclipse.aether.impl.OfflineController;
-import org.eclipse.aether.impl.RemoteRepositoryFilterManager;
-import org.eclipse.aether.impl.RemoteRepositoryManager;
-import org.eclipse.aether.impl.RepositoryConnectorProvider;
-import org.eclipse.aether.impl.RepositoryEventDispatcher;
-import org.eclipse.aether.impl.RepositorySystemLifecycle;
-import org.eclipse.aether.impl.UpdateCheckManager;
-import org.eclipse.aether.impl.UpdatePolicyAnalyzer;
-import org.eclipse.aether.impl.VersionRangeResolver;
-import org.eclipse.aether.impl.VersionResolver;
-import org.eclipse.aether.internal.impl.DefaultArtifactPredicateFactory;
-import org.eclipse.aether.internal.impl.DefaultArtifactResolver;
-import org.eclipse.aether.internal.impl.DefaultChecksumPolicyProvider;
-import org.eclipse.aether.internal.impl.DefaultChecksumProcessor;
-import org.eclipse.aether.internal.impl.DefaultDeployer;
-import org.eclipse.aether.internal.impl.DefaultInstaller;
-import org.eclipse.aether.internal.impl.DefaultLocalPathComposer;
-import org.eclipse.aether.internal.impl.DefaultLocalPathPrefixComposerFactory;
-import org.eclipse.aether.internal.impl.DefaultLocalRepositoryProvider;
-import org.eclipse.aether.internal.impl.DefaultMetadataResolver;
-import org.eclipse.aether.internal.impl.DefaultOfflineController;
-import org.eclipse.aether.internal.impl.DefaultPathProcessor;
-import org.eclipse.aether.internal.impl.DefaultRemoteRepositoryManager;
-import org.eclipse.aether.internal.impl.DefaultRepositoryConnectorProvider;
-import org.eclipse.aether.internal.impl.DefaultRepositoryEventDispatcher;
-import org.eclipse.aether.internal.impl.DefaultRepositoryLayoutProvider;
-import org.eclipse.aether.internal.impl.DefaultRepositorySystem;
-import org.eclipse.aether.internal.impl.DefaultRepositorySystemLifecycle;
-import org.eclipse.aether.internal.impl.DefaultTrackingFileManager;
-import org.eclipse.aether.internal.impl.DefaultTransporterProvider;
-import org.eclipse.aether.internal.impl.DefaultUpdateCheckManager;
-import org.eclipse.aether.internal.impl.DefaultUpdatePolicyAnalyzer;
-import org.eclipse.aether.internal.impl.EnhancedLocalRepositoryManagerFactory;
-import org.eclipse.aether.internal.impl.LocalPathComposer;
-import org.eclipse.aether.internal.impl.LocalPathPrefixComposerFactory;
-import org.eclipse.aether.internal.impl.Maven2RepositoryLayoutFactory;
-import org.eclipse.aether.internal.impl.SimpleLocalRepositoryManagerFactory;
-import org.eclipse.aether.internal.impl.TrackingFileManager;
-import org.eclipse.aether.internal.impl.checksum.DefaultChecksumAlgorithmFactorySelector;
-import org.eclipse.aether.internal.impl.checksum.Md5ChecksumAlgorithmFactory;
-import org.eclipse.aether.internal.impl.checksum.Sha1ChecksumAlgorithmFactory;
-import org.eclipse.aether.internal.impl.checksum.Sha256ChecksumAlgorithmFactory;
-import org.eclipse.aether.internal.impl.checksum.Sha512ChecksumAlgorithmFactory;
-import org.eclipse.aether.internal.impl.checksum.SparseDirectoryTrustedChecksumsSource;
-import org.eclipse.aether.internal.impl.checksum.SummaryFileTrustedChecksumsSource;
-import org.eclipse.aether.internal.impl.checksum.TrustedToProvidedChecksumsSourceAdapter;
-import org.eclipse.aether.internal.impl.collect.DefaultDependencyCollector;
-import org.eclipse.aether.internal.impl.collect.DependencyCollectorDelegate;
-import org.eclipse.aether.internal.impl.collect.bf.BfDependencyCollector;
-import org.eclipse.aether.internal.impl.collect.df.DfDependencyCollector;
-import org.eclipse.aether.internal.impl.filter.DefaultRemoteRepositoryFilterManager;
-import org.eclipse.aether.internal.impl.filter.GroupIdRemoteRepositoryFilterSource;
-import org.eclipse.aether.internal.impl.filter.PrefixesRemoteRepositoryFilterSource;
-import org.eclipse.aether.internal.impl.resolution.TrustedChecksumsArtifactResolverPostProcessor;
-import org.eclipse.aether.internal.impl.synccontext.DefaultSyncContextFactory;
-import org.eclipse.aether.internal.impl.synccontext.named.NameMapper;
-import org.eclipse.aether.internal.impl.synccontext.named.NameMappers;
-import org.eclipse.aether.internal.impl.synccontext.named.NamedLockFactoryAdapterFactory;
-import org.eclipse.aether.internal.impl.synccontext.named.NamedLockFactoryAdapterFactoryImpl;
-import org.eclipse.aether.internal.impl.transport.http.DefaultChecksumExtractor;
-import org.eclipse.aether.internal.impl.transport.http.Nx2ChecksumExtractor;
-import org.eclipse.aether.internal.impl.transport.http.XChecksumExtractor;
-import org.eclipse.aether.named.NamedLockFactory;
-import org.eclipse.aether.named.providers.FileLockNamedLockFactory;
-import org.eclipse.aether.named.providers.LocalReadWriteLockNamedLockFactory;
-import org.eclipse.aether.named.providers.LocalSemaphoreNamedLockFactory;
-import org.eclipse.aether.named.providers.NoopNamedLockFactory;
-import org.eclipse.aether.spi.artifact.ArtifactPredicateFactory;
-import org.eclipse.aether.spi.artifact.decorator.ArtifactDecoratorFactory;
-import org.eclipse.aether.spi.artifact.generator.ArtifactGeneratorFactory;
-import org.eclipse.aether.spi.artifact.transformer.ArtifactTransformer;
-import org.eclipse.aether.spi.checksums.ProvidedChecksumsSource;
-import org.eclipse.aether.spi.checksums.TrustedChecksumsSource;
-import org.eclipse.aether.spi.connector.RepositoryConnectorFactory;
-import org.eclipse.aether.spi.connector.checksum.ChecksumAlgorithmFactory;
-import org.eclipse.aether.spi.connector.checksum.ChecksumAlgorithmFactorySelector;
-import org.eclipse.aether.spi.connector.checksum.ChecksumPolicyProvider;
-import org.eclipse.aether.spi.connector.filter.RemoteRepositoryFilterSource;
-import org.eclipse.aether.spi.connector.layout.RepositoryLayoutFactory;
-import org.eclipse.aether.spi.connector.layout.RepositoryLayoutProvider;
-import org.eclipse.aether.spi.connector.transport.TransporterFactory;
-import org.eclipse.aether.spi.connector.transport.TransporterProvider;
-import org.eclipse.aether.spi.connector.transport.http.ChecksumExtractor;
-import org.eclipse.aether.spi.connector.transport.http.ChecksumExtractorStrategy;
-import org.eclipse.aether.spi.io.ChecksumProcessor;
-import org.eclipse.aether.spi.io.PathProcessor;
-import org.eclipse.aether.spi.localrepo.LocalRepositoryManagerFactory;
-import org.eclipse.aether.spi.resolution.ArtifactResolverPostProcessor;
-import org.eclipse.aether.spi.synccontext.SyncContextFactory;
-import org.eclipse.aether.transport.apache.ApacheTransporterFactory;
-import org.eclipse.aether.transport.file.FileTransporterFactory;
-import org.eclipse.aether.util.version.GenericVersionScheme;
-import org.eclipse.aether.version.VersionScheme;
-
-/**
- * A simple memorizing {@link Supplier} of {@link RepositorySystem} instance, that on first call
- * supplies lazily constructed instance, and on each subsequent call same instance. Hence, this instance should be
- * thrown away immediately once repository system was created and there is no need for more instances. If new
- * repository system instance needed, new instance of this class must be created. For proper shut down of returned
- * repository system instance(s) use {@link RepositorySystem#shutdown()} method on supplied instance(s).
- * <p>
- * Since Resolver 2.0 this class offers access to various components via public getters, and allows even partial object
- * graph construction.
- * <p>
- * Extend this class {@code createXXX()} methods and override to customize, if needed. The contract of this class makes
- * sure that these (potentially overridden) methods are invoked only once, and instance created by those methods are
- * memorized and kept as long as supplier instance is kept open.
- * <p>
- * This class is not thread safe and must be used from one thread only, while the constructed {@link RepositorySystem}
- * is thread safe.
- * <p>
- * Important: Given the instance of supplier memorizes the supplier {@link RepositorySystem} instance it supplies,
- * their lifecycle is shared as well: once supplied repository system is shut-down, this instance becomes closed as
- * well. Any subsequent {@code getXXX} method invocation attempt will fail with {@link IllegalStateException}.
- */
-public class RepositorySystemSupplier implements Supplier<RepositorySystem> {
- private final AtomicBoolean closed = new AtomicBoolean(false);
-
- public RepositorySystemSupplier() {}
-
- private void checkClosed() {
- if (closed.get()) {
- throw new IllegalStateException("Supplier is closed");
- }
- }
-
- private PathProcessor pathProcessor;
-
- public final PathProcessor getPathProcessor() {
- checkClosed();
- if (pathProcessor == null) {
- pathProcessor = createPathProcessor();
- }
- return pathProcessor;
- }
-
- protected PathProcessor createPathProcessor() {
- return new DefaultPathProcessor();
- }
-
- private ChecksumProcessor checksumProcessor;
-
- public final ChecksumProcessor getChecksumProcessor() {
- checkClosed();
- if (checksumProcessor == null) {
- checksumProcessor = createChecksumProcessor();
- }
- return checksumProcessor;
- }
-
- protected ChecksumProcessor createChecksumProcessor() {
- return new DefaultChecksumProcessor(getPathProcessor());
- }
-
- private TrackingFileManager trackingFileManager;
-
- public final TrackingFileManager getTrackingFileManager() {
- checkClosed();
- if (trackingFileManager == null) {
- trackingFileManager = createTrackingFileManager();
- }
- return trackingFileManager;
- }
-
- protected TrackingFileManager createTrackingFileManager() {
- return new DefaultTrackingFileManager();
- }
-
- private LocalPathComposer localPathComposer;
-
- public final LocalPathComposer getLocalPathComposer() {
- checkClosed();
- if (localPathComposer == null) {
- localPathComposer = createLocalPathComposer();
- }
- return localPathComposer;
- }
-
- protected LocalPathComposer createLocalPathComposer() {
- return new DefaultLocalPathComposer();
- }
-
- private LocalPathPrefixComposerFactory localPathPrefixComposerFactory;
-
- public final LocalPathPrefixComposerFactory getLocalPathPrefixComposerFactory() {
- checkClosed();
- if (localPathPrefixComposerFactory == null) {
- localPathPrefixComposerFactory = createLocalPathPrefixComposerFactory();
- }
- return localPathPrefixComposerFactory;
- }
-
- protected LocalPathPrefixComposerFactory createLocalPathPrefixComposerFactory() {
- return new DefaultLocalPathPrefixComposerFactory();
- }
-
- private RepositorySystemLifecycle repositorySystemLifecycle;
-
- public final RepositorySystemLifecycle getRepositorySystemLifecycle() {
- checkClosed();
- if (repositorySystemLifecycle == null) {
- repositorySystemLifecycle = createRepositorySystemLifecycle();
- repositorySystemLifecycle.addOnSystemEndedHandler(() -> closed.set(true));
- }
- return repositorySystemLifecycle;
- }
-
- protected RepositorySystemLifecycle createRepositorySystemLifecycle() {
- return new DefaultRepositorySystemLifecycle();
- }
-
- private OfflineController offlineController;
-
- public final OfflineController getOfflineController() {
- checkClosed();
- if (offlineController == null) {
- offlineController = createOfflineController();
- }
- return offlineController;
- }
-
- protected OfflineController createOfflineController() {
- return new DefaultOfflineController();
- }
-
- private UpdatePolicyAnalyzer updatePolicyAnalyzer;
-
- public final UpdatePolicyAnalyzer getUpdatePolicyAnalyzer() {
- checkClosed();
- if (updatePolicyAnalyzer == null) {
- updatePolicyAnalyzer = createUpdatePolicyAnalyzer();
- }
- return updatePolicyAnalyzer;
- }
-
- protected UpdatePolicyAnalyzer createUpdatePolicyAnalyzer() {
- return new DefaultUpdatePolicyAnalyzer();
- }
-
- private ChecksumPolicyProvider checksumPolicyProvider;
-
- public final ChecksumPolicyProvider getChecksumPolicyProvider() {
- checkClosed();
- if (checksumPolicyProvider == null) {
- checksumPolicyProvider = createChecksumPolicyProvider();
- }
- return checksumPolicyProvider;
- }
-
- protected ChecksumPolicyProvider createChecksumPolicyProvider() {
- return new DefaultChecksumPolicyProvider();
- }
-
- private UpdateCheckManager updateCheckManager;
-
- public final UpdateCheckManager getUpdateCheckManager() {
- checkClosed();
- if (updateCheckManager == null) {
- updateCheckManager = createUpdateCheckManager();
- }
- return updateCheckManager;
- }
-
- protected UpdateCheckManager createUpdateCheckManager() {
- return new DefaultUpdateCheckManager(getTrackingFileManager(), getUpdatePolicyAnalyzer(), getPathProcessor());
- }
-
- private Map<String, NamedLockFactory> namedLockFactories;
-
- public final Map<String, NamedLockFactory> getNamedLockFactories() {
- checkClosed();
- if (namedLockFactories == null) {
- namedLockFactories = createNamedLockFactories();
- }
- return namedLockFactories;
- }
-
- protected Map<String, NamedLockFactory> createNamedLockFactories() {
- HashMap<String, NamedLockFactory> result = new HashMap<>();
- result.put(NoopNamedLockFactory.NAME, new NoopNamedLockFactory());
- result.put(LocalReadWriteLockNamedLockFactory.NAME, new LocalReadWriteLockNamedLockFactory());
- result.put(LocalSemaphoreNamedLockFactory.NAME, new LocalSemaphoreNamedLockFactory());
- result.put(FileLockNamedLockFactory.NAME, new FileLockNamedLockFactory());
- return result;
- }
-
- private Map<String, NameMapper> nameMappers;
-
- public final Map<String, NameMapper> getNameMappers() {
- checkClosed();
- if (nameMappers == null) {
- nameMappers = createNameMappers();
- }
- return nameMappers;
- }
-
- protected Map<String, NameMapper> createNameMappers() {
- HashMap<String, NameMapper> result = new HashMap<>();
- result.put(NameMappers.STATIC_NAME, NameMappers.staticNameMapper());
- result.put(NameMappers.GAV_NAME, NameMappers.gavNameMapper());
- result.put(NameMappers.DISCRIMINATING_NAME, NameMappers.discriminatingNameMapper());
- result.put(NameMappers.FILE_GAV_NAME, NameMappers.fileGavNameMapper());
- result.put(NameMappers.FILE_HGAV_NAME, NameMappers.fileHashingGavNameMapper());
- return result;
- }
-
- private NamedLockFactoryAdapterFactory namedLockFactoryAdapterFactory;
-
- public final NamedLockFactoryAdapterFactory getNamedLockFactoryAdapterFactory() {
- checkClosed();
- if (namedLockFactoryAdapterFactory == null) {
- namedLockFactoryAdapterFactory = createNamedLockFactoryAdapterFactory();
- }
- return namedLockFactoryAdapterFactory;
- }
-
- protected NamedLockFactoryAdapterFactory createNamedLockFactoryAdapterFactory() {
- return new NamedLockFactoryAdapterFactoryImpl(
- getNamedLockFactories(), getNameMappers(), getRepositorySystemLifecycle());
- }
-
- private SyncContextFactory syncContextFactory;
-
- public final SyncContextFactory getSyncContextFactory() {
- checkClosed();
- if (syncContextFactory == null) {
- syncContextFactory = createSyncContextFactory();
- }
- return syncContextFactory;
- }
-
- protected SyncContextFactory createSyncContextFactory() {
- return new DefaultSyncContextFactory(getNamedLockFactoryAdapterFactory());
- }
-
- private Map<String, ChecksumAlgorithmFactory> checksumAlgorithmFactories;
-
- public final Map<String, ChecksumAlgorithmFactory> getChecksumAlgorithmFactories() {
- checkClosed();
- if (checksumAlgorithmFactories == null) {
- checksumAlgorithmFactories = createChecksumAlgorithmFactories();
- }
- return checksumAlgorithmFactories;
- }
-
- protected Map<String, ChecksumAlgorithmFactory> createChecksumAlgorithmFactories() {
- HashMap<String, ChecksumAlgorithmFactory> result = new HashMap<>();
- result.put(Sha512ChecksumAlgorithmFactory.NAME, new Sha512ChecksumAlgorithmFactory());
- result.put(Sha256ChecksumAlgorithmFactory.NAME, new Sha256ChecksumAlgorithmFactory());
- result.put(Sha1ChecksumAlgorithmFactory.NAME, new Sha1ChecksumAlgorithmFactory());
- result.put(Md5ChecksumAlgorithmFactory.NAME, new Md5ChecksumAlgorithmFactory());
- return result;
- }
-
- private ChecksumAlgorithmFactorySelector checksumAlgorithmFactorySelector;
-
- public final ChecksumAlgorithmFactorySelector getChecksumAlgorithmFactorySelector() {
- checkClosed();
- if (checksumAlgorithmFactorySelector == null) {
- checksumAlgorithmFactorySelector = createChecksumAlgorithmFactorySelector();
- }
- return checksumAlgorithmFactorySelector;
- }
-
- protected ChecksumAlgorithmFactorySelector createChecksumAlgorithmFactorySelector() {
- return new DefaultChecksumAlgorithmFactorySelector(getChecksumAlgorithmFactories());
- }
-
- private ArtifactPredicateFactory artifactPredicateFactory;
-
- public final ArtifactPredicateFactory getArtifactPredicateFactory() {
- checkClosed();
- if (artifactPredicateFactory == null) {
- artifactPredicateFactory = createArtifactPredicateFactory();
- }
- return artifactPredicateFactory;
- }
-
- protected ArtifactPredicateFactory createArtifactPredicateFactory() {
- return new DefaultArtifactPredicateFactory(getChecksumAlgorithmFactorySelector());
- }
-
- private Map<String, RepositoryLayoutFactory> repositoryLayoutFactories;
-
- public final Map<String, RepositoryLayoutFactory> getRepositoryLayoutFactories() {
- checkClosed();
- if (repositoryLayoutFactories == null) {
- repositoryLayoutFactories = createRepositoryLayoutFactories();
- }
- return repositoryLayoutFactories;
- }
-
- protected Map<String, RepositoryLayoutFactory> createRepositoryLayoutFactories() {
- HashMap<String, RepositoryLayoutFactory> result = new HashMap<>();
- result.put(
- Maven2RepositoryLayoutFactory.NAME,
- new Maven2RepositoryLayoutFactory(
- getChecksumAlgorithmFactorySelector(), getArtifactPredicateFactory()));
- return result;
- }
-
- private RepositoryLayoutProvider repositoryLayoutProvider;
-
- public final RepositoryLayoutProvider getRepositoryLayoutProvider() {
- checkClosed();
- if (repositoryLayoutProvider == null) {
- repositoryLayoutProvider = createRepositoryLayoutProvider();
- }
- return repositoryLayoutProvider;
- }
-
- protected RepositoryLayoutProvider createRepositoryLayoutProvider() {
- return new DefaultRepositoryLayoutProvider(getRepositoryLayoutFactories());
- }
-
- private LocalRepositoryProvider localRepositoryProvider;
-
- public final LocalRepositoryProvider getLocalRepositoryProvider() {
- checkClosed();
- if (localRepositoryProvider == null) {
- localRepositoryProvider = createLocalRepositoryProvider();
- }
- return localRepositoryProvider;
- }
-
- protected LocalRepositoryProvider createLocalRepositoryProvider() {
- LocalPathComposer localPathComposer = getLocalPathComposer();
- HashMap<String, LocalRepositoryManagerFactory> localRepositoryProviders = new HashMap<>(2);
- localRepositoryProviders.put(
- SimpleLocalRepositoryManagerFactory.NAME, new SimpleLocalRepositoryManagerFactory(localPathComposer));
- localRepositoryProviders.put(
- EnhancedLocalRepositoryManagerFactory.NAME,
- new EnhancedLocalRepositoryManagerFactory(
- localPathComposer, getTrackingFileManager(), getLocalPathPrefixComposerFactory()));
- return new DefaultLocalRepositoryProvider(localRepositoryProviders);
- }
-
- private RemoteRepositoryManager remoteRepositoryManager;
-
- public final RemoteRepositoryManager getRemoteRepositoryManager() {
- checkClosed();
- if (remoteRepositoryManager == null) {
- remoteRepositoryManager = createRemoteRepositoryManager();
- }
- return remoteRepositoryManager;
- }
-
- protected RemoteRepositoryManager createRemoteRepositoryManager() {
- return new DefaultRemoteRepositoryManager(getUpdatePolicyAnalyzer(), getChecksumPolicyProvider());
- }
-
- private Map<String, RemoteRepositoryFilterSource> remoteRepositoryFilterSources;
-
- public final Map<String, RemoteRepositoryFilterSource> getRemoteRepositoryFilterSources() {
- checkClosed();
- if (remoteRepositoryFilterSources == null) {
- remoteRepositoryFilterSources = createRemoteRepositoryFilterSources();
- }
- return remoteRepositoryFilterSources;
- }
-
- protected Map<String, RemoteRepositoryFilterSource> createRemoteRepositoryFilterSources() {
- HashMap<String, RemoteRepositoryFilterSource> result = new HashMap<>();
- result.put(
- GroupIdRemoteRepositoryFilterSource.NAME,
- new GroupIdRemoteRepositoryFilterSource(getRepositorySystemLifecycle()));
- result.put(
- PrefixesRemoteRepositoryFilterSource.NAME,
- new PrefixesRemoteRepositoryFilterSource(getRepositoryLayoutProvider()));
- return result;
- }
-
- private RemoteRepositoryFilterManager remoteRepositoryFilterManager;
-
- public final RemoteRepositoryFilterManager getRemoteRepositoryFilterManager() {
- checkClosed();
- if (remoteRepositoryFilterManager == null) {
- remoteRepositoryFilterManager = createRemoteRepositoryFilterManager();
- }
- return remoteRepositoryFilterManager;
- }
-
- protected RemoteRepositoryFilterManager createRemoteRepositoryFilterManager() {
- return new DefaultRemoteRepositoryFilterManager(getRemoteRepositoryFilterSources());
- }
-
- private Map<String, RepositoryListener> repositoryListeners;
-
- public final Map<String, RepositoryListener> getRepositoryListeners() {
- checkClosed();
- if (repositoryListeners == null) {
- repositoryListeners = createRepositoryListeners();
- }
- return repositoryListeners;
- }
-
- protected Map<String, RepositoryListener> createRepositoryListeners() {
- return new HashMap<>();
- }
-
- private RepositoryEventDispatcher repositoryEventDispatcher;
-
- public final RepositoryEventDispatcher getRepositoryEventDispatcher() {
- checkClosed();
- if (repositoryEventDispatcher == null) {
- repositoryEventDispatcher = createRepositoryEventDispatcher();
- }
- return repositoryEventDispatcher;
- }
-
- protected RepositoryEventDispatcher createRepositoryEventDispatcher() {
- return new DefaultRepositoryEventDispatcher(getRepositoryListeners());
- }
-
- private Map<String, TrustedChecksumsSource> trustedChecksumsSources;
-
- public final Map<String, TrustedChecksumsSource> getTrustedChecksumsSources() {
- checkClosed();
- if (trustedChecksumsSources == null) {
- trustedChecksumsSources = createTrustedChecksumsSources();
- }
- return trustedChecksumsSources;
- }
-
- protected Map<String, TrustedChecksumsSource> createTrustedChecksumsSources() {
- HashMap<String, TrustedChecksumsSource> result = new HashMap<>();
- result.put(
- SparseDirectoryTrustedChecksumsSource.NAME,
- new SparseDirectoryTrustedChecksumsSource(getChecksumProcessor(), getLocalPathComposer()));
- result.put(
- SummaryFileTrustedChecksumsSource.NAME,
- new SummaryFileTrustedChecksumsSource(getLocalPathComposer(), getRepositorySystemLifecycle()));
- return result;
- }
-
- private Map<String, ProvidedChecksumsSource> providedChecksumsSources;
-
- public final Map<String, ProvidedChecksumsSource> getProvidedChecksumsSources() {
- checkClosed();
- if (providedChecksumsSources == null) {
- providedChecksumsSources = createProvidedChecksumsSources();
- }
- return providedChecksumsSources;
- }
-
- protected Map<String, ProvidedChecksumsSource> createProvidedChecksumsSources() {
- HashMap<String, ProvidedChecksumsSource> result = new HashMap<>();
- result.put(
- TrustedToProvidedChecksumsSourceAdapter.NAME,
- new TrustedToProvidedChecksumsSourceAdapter(getTrustedChecksumsSources()));
- return result;
- }
-
- private Map<String, ChecksumExtractorStrategy> checksumExtractorStrategies;
-
- public final Map<String, ChecksumExtractorStrategy> getChecksumExtractorStrategies() {
- checkClosed();
- if (checksumExtractorStrategies == null) {
- checksumExtractorStrategies = createChecksumExtractorStrategies();
- }
- return checksumExtractorStrategies;
- }
-
- protected Map<String, ChecksumExtractorStrategy> createChecksumExtractorStrategies() {
- HashMap<String, ChecksumExtractorStrategy> result = new HashMap<>();
- result.put(XChecksumExtractor.NAME, new XChecksumExtractor());
- result.put(Nx2ChecksumExtractor.NAME, new Nx2ChecksumExtractor());
- return result;
- }
-
- private ChecksumExtractor checksumExtractor;
-
- public final ChecksumExtractor getChecksumExtractor() {
- checkClosed();
- if (checksumExtractor == null) {
- checksumExtractor = createChecksumExtractor();
- }
- return checksumExtractor;
- }
-
- protected ChecksumExtractor createChecksumExtractor() {
- return new DefaultChecksumExtractor(getChecksumExtractorStrategies());
- }
-
- private Map<String, TransporterFactory> transporterFactories;
-
- public final Map<String, TransporterFactory> getTransporterFactories() {
- checkClosed();
- if (transporterFactories == null) {
- transporterFactories = createTransporterFactories();
- }
- return transporterFactories;
- }
-
- protected Map<String, TransporterFactory> createTransporterFactories() {
- HashMap<String, TransporterFactory> result = new HashMap<>();
- result.put(FileTransporterFactory.NAME, new FileTransporterFactory());
- result.put(
- ApacheTransporterFactory.NAME,
- new ApacheTransporterFactory(getChecksumExtractor(), getPathProcessor()));
- return result;
- }
-
- private TransporterProvider transporterProvider;
-
- public final TransporterProvider getTransporterProvider() {
- checkClosed();
- if (transporterProvider == null) {
- transporterProvider = createTransporterProvider();
- }
- return transporterProvider;
- }
-
- protected TransporterProvider createTransporterProvider() {
- return new DefaultTransporterProvider(getTransporterFactories());
- }
-
- private BasicRepositoryConnectorFactory basicRepositoryConnectorFactory;
-
- public final BasicRepositoryConnectorFactory getBasicRepositoryConnectorFactory() {
- checkClosed();
- if (basicRepositoryConnectorFactory == null) {
- basicRepositoryConnectorFactory = createBasicRepositoryConnectorFactory();
- }
- return basicRepositoryConnectorFactory;
- }
-
- protected BasicRepositoryConnectorFactory createBasicRepositoryConnectorFactory() {
- return new BasicRepositoryConnectorFactory(
- getTransporterProvider(),
- getRepositoryLayoutProvider(),
- getChecksumPolicyProvider(),
- getChecksumProcessor(),
- getProvidedChecksumsSources());
- }
-
- private Map<String, RepositoryConnectorFactory> repositoryConnectorFactories;
-
- public final Map<String, RepositoryConnectorFactory> getRepositoryConnectorFactories() {
- checkClosed();
- if (repositoryConnectorFactories == null) {
- repositoryConnectorFactories = createRepositoryConnectorFactories();
- }
- return repositoryConnectorFactories;
- }
-
- protected Map<String, RepositoryConnectorFactory> createRepositoryConnectorFactories() {
- HashMap<String, RepositoryConnectorFactory> result = new HashMap<>();
- result.put(BasicRepositoryConnectorFactory.NAME, getBasicRepositoryConnectorFactory());
- return result;
- }
-
- private RepositoryConnectorProvider repositoryConnectorProvider;
-
- public final RepositoryConnectorProvider getRepositoryConnectorProvider() {
- checkClosed();
- if (repositoryConnectorProvider == null) {
- repositoryConnectorProvider = createRepositoryConnectorProvider();
- }
- return repositoryConnectorProvider;
- }
-
- protected RepositoryConnectorProvider createRepositoryConnectorProvider() {
- return new DefaultRepositoryConnectorProvider(
- getRepositoryConnectorFactories(), getRemoteRepositoryFilterManager());
- }
-
- private Installer installer;
-
- public final Installer getInstaller() {
- checkClosed();
- if (installer == null) {
- installer = createInstaller();
- }
- return installer;
- }
-
- protected Installer createInstaller() {
- return new DefaultInstaller(
- getPathProcessor(),
- getRepositoryEventDispatcher(),
- getArtifactGeneratorFactories(),
- getMetadataGeneratorFactories(),
- getArtifactTransformers(),
- getSyncContextFactory());
- }
-
- private Deployer deployer;
-
- public final Deployer getDeployer() {
- checkClosed();
- if (deployer == null) {
- deployer = createDeployer();
- }
- return deployer;
- }
-
- protected Deployer createDeployer() {
- return new DefaultDeployer(
- getPathProcessor(),
- getRepositoryEventDispatcher(),
- getRepositoryConnectorProvider(),
- getRemoteRepositoryManager(),
- getUpdateCheckManager(),
- getArtifactGeneratorFactories(),
- getMetadataGeneratorFactories(),
- getArtifactTransformers(),
- getSyncContextFactory(),
- getOfflineController());
- }
-
- private Map<String, DependencyCollectorDelegate> dependencyCollectorDelegates;
-
- public final Map<String, DependencyCollectorDelegate> getDependencyCollectorDelegates() {
- checkClosed();
- if (dependencyCollectorDelegates == null) {
- dependencyCollectorDelegates = createDependencyCollectorDelegates();
- }
- return dependencyCollectorDelegates;
- }
-
- protected Map<String, DependencyCollectorDelegate> createDependencyCollectorDelegates() {
- RemoteRepositoryManager remoteRepositoryManager = getRemoteRepositoryManager();
- ArtifactDescriptorReader artifactDescriptorReader = getArtifactDescriptorReader();
- VersionRangeResolver versionRangeResolver = getVersionRangeResolver();
- HashMap<String, DependencyCollectorDelegate> result = new HashMap<>();
- result.put(
- DfDependencyCollector.NAME,
- new DfDependencyCollector(
- remoteRepositoryManager,
- artifactDescriptorReader,
- versionRangeResolver,
- getArtifactDecoratorFactories()));
- result.put(
- BfDependencyCollector.NAME,
- new BfDependencyCollector(
- remoteRepositoryManager,
- artifactDescriptorReader,
- versionRangeResolver,
- getArtifactDecoratorFactories()));
- return result;
- }
-
- private DependencyCollector dependencyCollector;
-
- public final DependencyCollector getDependencyCollector() {
- checkClosed();
- if (dependencyCollector == null) {
- dependencyCollector = createDependencyCollector();
- }
- return dependencyCollector;
- }
-
- protected DependencyCollector createDependencyCollector() {
- return new DefaultDependencyCollector(getDependencyCollectorDelegates());
- }
-
- private Map<String, ArtifactResolverPostProcessor> artifactResolverPostProcessors;
-
- public final Map<String, ArtifactResolverPostProcessor> getArtifactResolverPostProcessors() {
- checkClosed();
- if (artifactResolverPostProcessors == null) {
- artifactResolverPostProcessors = createArtifactResolverPostProcessors();
- }
- return artifactResolverPostProcessors;
- }
-
- protected Map<String, ArtifactResolverPostProcessor> createArtifactResolverPostProcessors() {
- HashMap<String, ArtifactResolverPostProcessor> result = new HashMap<>();
- result.put(
- TrustedChecksumsArtifactResolverPostProcessor.NAME,
- new TrustedChecksumsArtifactResolverPostProcessor(
- getChecksumAlgorithmFactorySelector(), getTrustedChecksumsSources()));
- return result;
- }
-
- private ArtifactResolver artifactResolver;
-
- public final ArtifactResolver getArtifactResolver() {
- checkClosed();
- if (artifactResolver == null) {
- artifactResolver = createArtifactResolver();
- }
- return artifactResolver;
- }
-
- protected ArtifactResolver createArtifactResolver() {
- return new DefaultArtifactResolver(
- getPathProcessor(),
- getRepositoryEventDispatcher(),
- getVersionResolver(),
- getUpdateCheckManager(),
- getRepositoryConnectorProvider(),
- getRemoteRepositoryManager(),
- getSyncContextFactory(),
- getOfflineController(),
- getArtifactResolverPostProcessors(),
- getRemoteRepositoryFilterManager());
- }
-
- private MetadataResolver metadataResolver;
-
- public final MetadataResolver getMetadataResolver() {
- checkClosed();
- if (metadataResolver == null) {
- metadataResolver = createMetadataResolver();
- }
- return metadataResolver;
- }
-
- protected MetadataResolver createMetadataResolver() {
- return new DefaultMetadataResolver(
- getRepositoryEventDispatcher(),
- getUpdateCheckManager(),
- getRepositoryConnectorProvider(),
- getRemoteRepositoryManager(),
- getSyncContextFactory(),
- getOfflineController(),
- getRemoteRepositoryFilterManager(),
- getPathProcessor());
- }
-
- private VersionScheme versionScheme;
-
- public final VersionScheme getVersionScheme() {
- checkClosed();
- if (versionScheme == null) {
- versionScheme = createVersionScheme();
- }
- return versionScheme;
- }
-
- protected VersionScheme createVersionScheme() {
- return new GenericVersionScheme();
- }
-
- private Map<String, ArtifactGeneratorFactory> artifactGeneratorFactories;
-
- public final Map<String, ArtifactGeneratorFactory> getArtifactGeneratorFactories() {
- checkClosed();
- if (artifactGeneratorFactories == null) {
- artifactGeneratorFactories = createArtifactGeneratorFactories();
- }
- return artifactGeneratorFactories;
- }
-
- protected Map<String, ArtifactGeneratorFactory> createArtifactGeneratorFactories() {
- // by default none, this is extension point
- return new HashMap<>();
- }
-
- private Map<String, ArtifactDecoratorFactory> artifactDecoratorFactories;
-
- public final Map<String, ArtifactDecoratorFactory> getArtifactDecoratorFactories() {
- checkClosed();
- if (artifactDecoratorFactories == null) {
- artifactDecoratorFactories = createArtifactDecoratorFactories();
- }
- return artifactDecoratorFactories;
- }
-
- protected Map<String, ArtifactDecoratorFactory> createArtifactDecoratorFactories() {
- // by default none, this is extension point
- return new HashMap<>();
- }
-
- protected Map<String, ArtifactTransformer> artifactTransformers;
-
- public final Map<String, ArtifactTransformer> getArtifactTransformers() {
- checkClosed();
- if (artifactTransformers == null) {
- artifactTransformers = createArtifactTransformers();
- }
- return artifactTransformers;
- }
-
- protected Map<String, ArtifactTransformer> createArtifactTransformers() {
- return new HashMap<>();
- }
-
- // Maven provided
-
- private Map<String, MetadataGeneratorFactory> metadataGeneratorFactories;
-
- public final Map<String, MetadataGeneratorFactory> getMetadataGeneratorFactories() {
- checkClosed();
- if (metadataGeneratorFactories == null) {
- metadataGeneratorFactories = createMetadataGeneratorFactories();
- }
- return metadataGeneratorFactories;
- }
-
- protected Map<String, MetadataGeneratorFactory> createMetadataGeneratorFactories() {
- // from maven-resolver-provider
- HashMap<String, MetadataGeneratorFactory> result = new HashMap<>();
- result.put(PluginsMetadataGeneratorFactory.NAME, new PluginsMetadataGeneratorFactory());
- result.put(VersionsMetadataGeneratorFactory.NAME, new VersionsMetadataGeneratorFactory());
- result.put(SnapshotMetadataGeneratorFactory.NAME, new SnapshotMetadataGeneratorFactory());
- return result;
- }
-
- private LinkedHashMap<String, MavenArtifactRelocationSource> artifactRelocationSources;
-
- public final LinkedHashMap<String, MavenArtifactRelocationSource> getMavenArtifactRelocationSources() {
- checkClosed();
- if (artifactRelocationSources == null) {
- artifactRelocationSources = createMavenArtifactRelocationSources();
- }
- return artifactRelocationSources;
- }
-
- protected LinkedHashMap<String, MavenArtifactRelocationSource> createMavenArtifactRelocationSources() {
- // from maven-resolver-provider
- LinkedHashMap<String, MavenArtifactRelocationSource> result = new LinkedHashMap<>();
- result.put(UserPropertiesArtifactRelocationSource.NAME, new UserPropertiesArtifactRelocationSource());
- result.put(
- DistributionManagementArtifactRelocationSource.NAME,
- new DistributionManagementArtifactRelocationSource());
- return result;
- }
-
- private ArtifactDescriptorReader artifactDescriptorReader;
-
- public final ArtifactDescriptorReader getArtifactDescriptorReader() {
- checkClosed();
- if (artifactDescriptorReader == null) {
- artifactDescriptorReader = createArtifactDescriptorReader();
- }
- return artifactDescriptorReader;
- }
-
- protected ArtifactDescriptorReader createArtifactDescriptorReader() {
- // from maven-resolver-provider
- return new DefaultArtifactDescriptorReader(
- getVersionResolver(),
- getArtifactResolver(),
- getModelBuilder(),
- getRepositoryEventDispatcher(),
- getMavenArtifactRelocationSources());
- }
-
- private VersionResolver versionResolver;
-
- public final VersionResolver getVersionResolver() {
- checkClosed();
- if (versionResolver == null) {
- versionResolver = createVersionResolver();
- }
- return versionResolver;
- }
-
- protected VersionResolver createVersionResolver() {
- // from maven-resolver-provider
- return new DefaultVersionResolver(
- getMetadataResolver(), getSyncContextFactory(), getRepositoryEventDispatcher());
- }
-
- private VersionRangeResolver versionRangeResolver;
-
- public final VersionRangeResolver getVersionRangeResolver() {
- checkClosed();
- if (versionRangeResolver == null) {
- versionRangeResolver = createVersionRangeResolver();
- }
- return versionRangeResolver;
- }
-
- protected VersionRangeResolver createVersionRangeResolver() {
- // from maven-resolver-provider
- return new DefaultVersionRangeResolver(
- getMetadataResolver(), getSyncContextFactory(), getRepositoryEventDispatcher(), getVersionScheme());
- }
-
- private ModelBuilder modelBuilder;
-
- public final ModelBuilder getModelBuilder() {
- checkClosed();
- if (modelBuilder == null) {
- modelBuilder = createModelBuilder();
- }
- return modelBuilder;
- }
-
- protected ModelBuilder createModelBuilder() {
- // from maven-model-builder
- DefaultModelProcessor modelProcessor = new DefaultModelProcessor(new DefaultModelXmlFactory(), List.of());
- return new DefaultModelBuilder(
- modelProcessor,
- new DefaultModelValidator(),
- new DefaultModelNormalizer(),
- new DefaultModelInterpolator(
- new DefaultPathTranslator(),
- new DefaultUrlNormalizer(),
- new DefaultRootLocator(),
- new DefaultInterpolator()),
- new DefaultModelPathTranslator(new DefaultPathTranslator()),
- new DefaultModelUrlNormalizer(new DefaultUrlNormalizer()),
- new DefaultSuperPomProvider(modelProcessor),
- new DefaultInheritanceAssembler(),
- new DefaultProfileSelector(),
- new DefaultProfileInjector(),
- new DefaultPluginManagementInjector(),
- new DefaultDependencyManagementInjector(),
- new DefaultDependencyManagementImporter(),
- new DefaultPluginConfigurationExpander(),
- new DefaultModelVersionParser(getVersionScheme()),
- List.of(),
- new DefaultModelResolver(),
- new DefaultInterpolator(),
- new DefaultPathTranslator(),
- new DefaultRootLocator());
- }
-
- private RepositorySystem repositorySystem;
-
- public final RepositorySystem getRepositorySystem() {
- checkClosed();
- if (repositorySystem == null) {
- repositorySystem = createRepositorySystem();
- }
- return repositorySystem;
- }
-
- protected RepositorySystem createRepositorySystem() {
- return new DefaultRepositorySystem(
- getVersionResolver(),
- getVersionRangeResolver(),
- getArtifactResolver(),
- getMetadataResolver(),
- getArtifactDescriptorReader(),
- getDependencyCollector(),
- getInstaller(),
- getDeployer(),
- getLocalRepositoryProvider(),
- getSyncContextFactory(),
- getRemoteRepositoryManager(),
- getRepositorySystemLifecycle(),
- getArtifactDecoratorFactories());
- }
-
- @Override
- public RepositorySystem get() {
- return getRepositorySystem();
- }
-}
diff --git a/maven-plugin-testing-harness/src/main/java/org/apache/maven/api/plugin/testing/stubs/SessionMock.java b/maven-plugin-testing-harness/src/main/java/org/apache/maven/api/plugin/testing/stubs/SessionMock.java
deleted file mode 100644
index 77d66d5..0000000
--- a/maven-plugin-testing-harness/src/main/java/org/apache/maven/api/plugin/testing/stubs/SessionMock.java
+++ /dev/null
@@ -1,448 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.maven.api.plugin.testing.stubs;
-
-import java.net.URI;
-import java.nio.file.Path;
-import java.nio.file.Paths;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Optional;
-import java.util.Properties;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.function.Supplier;
-
-import org.apache.maven.api.Artifact;
-import org.apache.maven.api.LocalRepository;
-import org.apache.maven.api.ProducedArtifact;
-import org.apache.maven.api.Project;
-import org.apache.maven.api.RemoteRepository;
-import org.apache.maven.api.Session;
-import org.apache.maven.api.SessionData;
-import org.apache.maven.api.model.Model;
-import org.apache.maven.api.model.Repository;
-import org.apache.maven.api.services.ArtifactDeployer;
-import org.apache.maven.api.services.ArtifactDeployerRequest;
-import org.apache.maven.api.services.ArtifactFactory;
-import org.apache.maven.api.services.ArtifactFactoryRequest;
-import org.apache.maven.api.services.ArtifactInstaller;
-import org.apache.maven.api.services.ArtifactInstallerRequest;
-import org.apache.maven.api.services.ArtifactManager;
-import org.apache.maven.api.services.LocalRepositoryManager;
-import org.apache.maven.api.services.Lookup;
-import org.apache.maven.api.services.ProjectBuilder;
-import org.apache.maven.api.services.ProjectBuilderRequest;
-import org.apache.maven.api.services.ProjectBuilderResult;
-import org.apache.maven.api.services.ProjectManager;
-import org.apache.maven.api.services.RepositoryFactory;
-import org.apache.maven.api.services.VersionParser;
-import org.apache.maven.api.services.xml.ModelXmlFactory;
-import org.apache.maven.impl.DefaultModelVersionParser;
-import org.apache.maven.impl.DefaultModelXmlFactory;
-import org.apache.maven.impl.DefaultVersionParser;
-import org.apache.maven.impl.InternalSession;
-import org.apache.maven.model.v4.MavenStaxReader;
-import org.eclipse.aether.util.version.GenericVersionScheme;
-import org.mockito.ArgumentMatchers;
-
-import static org.mockito.ArgumentMatchers.any;
-import static org.mockito.ArgumentMatchers.anyString;
-import static org.mockito.ArgumentMatchers.same;
-import static org.mockito.Mockito.doAnswer;
-import static org.mockito.Mockito.doReturn;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-import static org.mockito.Mockito.withSettings;
-
-/**
- *
- */
-public class SessionMock {
-
- public static InternalSession getMockSession(String localRepo) {
- LocalRepository localRepository = mock(LocalRepository.class);
- when(localRepository.getId()).thenReturn("local");
- when(localRepository.getPath()).thenReturn(Paths.get(localRepo));
- return getMockSession(localRepository);
- }
-
- @SuppressWarnings("checkstyle:MethodLength")
- public static InternalSession getMockSession(LocalRepository localRepository) {
- InternalSession session = mock(InternalSession.class);
-
- //
- // RepositoryFactory
- //
- RepositoryFactory repositoryFactory = mock(RepositoryFactory.class);
- when(session.createRemoteRepository(anyString(), anyString())).thenAnswer(iom -> {
- String id = iom.getArgument(0, String.class);
- String url = iom.getArgument(1, String.class);
- return session.getService(RepositoryFactory.class).createRemote(id, url);
- });
- when(session.createRemoteRepository(any()))
- .thenAnswer(iom -> repositoryFactory.createRemote(iom.getArgument(0, Repository.class)));
- when(repositoryFactory.createRemote(any(Repository.class))).thenAnswer(iom -> {
- Repository repository = iom.getArgument(0, Repository.class);
- return repositoryFactory.createRemote(repository.getId(), repository.getUrl());
- });
- when(repositoryFactory.createRemote(anyString(), anyString())).thenAnswer(iom -> {
- String id = iom.getArgument(0, String.class);
- String url = iom.getArgument(1, String.class);
- RemoteRepository remoteRepository =
- mock(RemoteRepository.class, withSettings().lenient());
- when(remoteRepository.getId()).thenReturn(id);
- when(remoteRepository.getUrl()).thenReturn(url);
- when(remoteRepository.getProtocol()).thenReturn(URI.create(url).getScheme());
- return remoteRepository;
- });
- when(session.getService(RepositoryFactory.class)).thenReturn(repositoryFactory);
-
- //
- // VersionParser
- //
- VersionParser versionParser =
- new DefaultVersionParser(new DefaultModelVersionParser(new GenericVersionScheme()));
- when(session.parseVersion(any()))
- .thenAnswer(iom -> versionParser.parseVersion(iom.getArgument(0, String.class)));
- when(session.getService(VersionParser.class)).thenReturn(versionParser);
-
- //
- // LocalRepositoryManager
- //
- LocalRepositoryManager localRepositoryManager = mock(LocalRepositoryManager.class);
- when(session.getPathForLocalArtifact(any(Artifact.class)))
- .then(iom -> localRepositoryManager.getPathForLocalArtifact(
- session, session.getLocalRepository(), iom.getArgument(0, Artifact.class)));
- when(session.getPathForRemoteArtifact(any(), any()))
- .thenAnswer(iom -> localRepositoryManager.getPathForRemoteArtifact(
- session,
- session.getLocalRepository(),
- iom.getArgument(0, RemoteRepository.class),
- iom.getArgument(1, Artifact.class)));
- when(localRepositoryManager.getPathForLocalArtifact(any(), any(), any()))
- .thenAnswer(iom -> {
- LocalRepository localRepo = iom.getArgument(1, LocalRepository.class);
- Artifact artifact = iom.getArgument(2, Artifact.class);
- return localRepo.getPath().resolve(getPathForArtifact(artifact, true));
- });
- when(session.getService(LocalRepositoryManager.class)).thenReturn(localRepositoryManager);
-
- //
- // ArtifactInstaller
- //
- ArtifactInstaller artifactInstaller = mock(ArtifactInstaller.class);
- doAnswer(iom -> {
- artifactInstaller.install(
- ArtifactInstallerRequest.build(session, iom.getArgument(0, Collection.class)));
- return null;
- })
- .when(session)
- .installArtifacts(any(Collection.class));
- doAnswer(iom -> {
- artifactInstaller.install(ArtifactInstallerRequest.build(
- session, Arrays.asList(iom.getArgument(0, ProducedArtifact[].class))));
- return null;
- })
- .when(session)
- .installArtifacts(any(ProducedArtifact[].class));
- doAnswer(iom -> {
- artifactInstaller.install(ArtifactInstallerRequest.build(
- iom.getArgument(0, Session.class), iom.getArgument(1, Collection.class)));
- return null;
- })
- .when(artifactInstaller)
- .install(any(Session.class), ArgumentMatchers.<Collection<ProducedArtifact>>any());
- when(session.getService(ArtifactInstaller.class)).thenReturn(artifactInstaller);
-
- //
- // ArtifactDeployer
- //
- ArtifactDeployer artifactDeployer = mock(ArtifactDeployer.class);
- doAnswer(iom -> {
- artifactDeployer.deploy(ArtifactDeployerRequest.build(
- iom.getArgument(0, Session.class),
- iom.getArgument(1, RemoteRepository.class),
- Arrays.asList(iom.getArgument(2, ProducedArtifact[].class))));
- return null;
- })
- .when(session)
- .deployArtifact(any(), any());
- doAnswer(iom -> {
- artifactDeployer.deploy(ArtifactDeployerRequest.build(
- iom.getArgument(0, Session.class),
- iom.getArgument(1, RemoteRepository.class),
- iom.getArgument(2, Collection.class)));
- return null;
- })
- .when(artifactDeployer)
- .deploy(any(), any(), any());
- when(session.getService(ArtifactDeployer.class)).thenReturn(artifactDeployer);
-
- //
- // ArtifactManager
- //
- ArtifactManager artifactManager = mock(ArtifactManager.class);
- Map<Artifact, Path> paths = new HashMap<>();
- doAnswer(iom -> {
- paths.put(iom.getArgument(0), iom.getArgument(1));
- return null;
- })
- .when(artifactManager)
- .setPath(any(), any());
- doAnswer(iom -> Optional.ofNullable(paths.get(iom.getArgument(0, Artifact.class))))
- .when(artifactManager)
- .getPath(any());
- doAnswer(iom -> artifactManager.getPath(iom.getArgument(0, Artifact.class)))
- .when(session)
- .getArtifactPath(any());
- when(session.getService(ArtifactManager.class)).thenReturn(artifactManager);
-
- //
- // ProjectManager
- //
- ProjectManager projectManager = mock(ProjectManager.class);
- Map<Project, Collection<Artifact>> attachedArtifacts = new HashMap<>();
- doAnswer(iom -> {
- Project project = iom.getArgument(1, Project.class);
- String type = iom.getArgument(2, String.class);
- Path path = iom.getArgument(3, Path.class);
- ProducedArtifact artifact = session.createProducedArtifact(
- project.getGroupId(), project.getArtifactId(), project.getVersion(), null, null, type);
- artifactManager.setPath(artifact, path);
- attachedArtifacts
- .computeIfAbsent(project, p -> new ArrayList<>())
- .add(artifact);
- return null;
- })
- .when(projectManager)
- .attachArtifact(same(session), any(Project.class), any(), any());
- doAnswer(iom -> {
- Project project = iom.getArgument(0, Project.class);
- ProducedArtifact artifact = iom.getArgument(1, ProducedArtifact.class);
- Path path = iom.getArgument(2, Path.class);
- artifactManager.setPath(artifact, path);
- attachedArtifacts
- .computeIfAbsent(project, p -> new ArrayList<>())
- .add(artifact);
- return null;
- })
- .when(projectManager)
- .attachArtifact(any(Project.class), any(ProducedArtifact.class), any(Path.class));
- when(projectManager.getAttachedArtifacts(any()))
- .then(iom ->
- attachedArtifacts.computeIfAbsent(iom.getArgument(0, Project.class), p -> new ArrayList<>()));
- when(projectManager.getAllArtifacts(any())).then(iom -> {
- Project project = iom.getArgument(0, Project.class);
- List<Artifact> result = new ArrayList<>();
- result.addAll(project.getArtifacts());
- result.addAll(attachedArtifacts.computeIfAbsent(project, p -> new ArrayList<>()));
- return result;
- });
- when(session.getService(ProjectManager.class)).thenReturn(projectManager);
-
- //
- // ArtifactFactory
- //
- ArtifactFactory artifactFactory = mock(ArtifactFactory.class);
- when(artifactFactory.create(any())).then(iom -> {
- ArtifactFactoryRequest request = iom.getArgument(0, ArtifactFactoryRequest.class);
- String classifier = request.getClassifier();
- String extension = request.getExtension();
- String type = request.getType();
- if (classifier == null) {
- classifier = "";
- }
- if (extension == null) {
- extension = type != null ? type : "";
- }
- return new ArtifactStub(
- request.getGroupId(), request.getArtifactId(), classifier, request.getVersion(), extension);
- });
- when(artifactFactory.createProduced(any())).then(iom -> {
- ArtifactFactoryRequest request = iom.getArgument(0, ArtifactFactoryRequest.class);
- String classifier = request.getClassifier();
- String extension = request.getExtension();
- String type = request.getType();
- if (classifier == null) {
- classifier = "";
- }
- if (extension == null) {
- extension = type != null ? type : "";
- }
- return new ProducedArtifactStub(
- request.getGroupId(), request.getArtifactId(), classifier, request.getVersion(), extension);
- });
- when(session.createArtifact(any(), any(), any(), any(), any(), any())).thenAnswer(iom -> {
- String groupId = iom.getArgument(0, String.class);
- String artifactId = iom.getArgument(1, String.class);
- String version = iom.getArgument(2, String.class);
- String classifier = iom.getArgument(3, String.class);
- String extension = iom.getArgument(4, String.class);
- String type = iom.getArgument(5, String.class);
- return session.getService(ArtifactFactory.class)
- .create(ArtifactFactoryRequest.builder()
- .session(session)
- .groupId(groupId)
- .artifactId(artifactId)
- .version(version)
- .classifier(classifier)
- .extension(extension)
- .type(type)
- .build());
- });
- when(session.createArtifact(any(), any(), any(), any())).thenAnswer(iom -> {
- String groupId = iom.getArgument(0, String.class);
- String artifactId = iom.getArgument(1, String.class);
- String version = iom.getArgument(2, String.class);
- String extension = iom.getArgument(3, String.class);
- return session.getService(ArtifactFactory.class)
- .create(ArtifactFactoryRequest.builder()
- .session(session)
- .groupId(groupId)
- .artifactId(artifactId)
- .version(version)
- .extension(extension)
- .build());
- });
- when(session.createProducedArtifact(any(), any(), any(), any(), any(), any()))
- .thenAnswer(iom -> {
- String groupId = iom.getArgument(0, String.class);
- String artifactId = iom.getArgument(1, String.class);
- String version = iom.getArgument(2, String.class);
- String classifier = iom.getArgument(3, String.class);
- String extension = iom.getArgument(4, String.class);
- String type = iom.getArgument(5, String.class);
- return session.getService(ArtifactFactory.class)
- .createProduced(ArtifactFactoryRequest.builder()
- .session(session)
- .groupId(groupId)
- .artifactId(artifactId)
- .version(version)
- .classifier(classifier)
- .extension(extension)
- .type(type)
- .build());
- });
- when(session.createProducedArtifact(any(), any(), any(), any())).thenAnswer(iom -> {
- String groupId = iom.getArgument(0, String.class);
- String artifactId = iom.getArgument(1, String.class);
- String version = iom.getArgument(2, String.class);
- String extension = iom.getArgument(3, String.class);
- return session.getService(ArtifactFactory.class)
- .createProduced(ArtifactFactoryRequest.builder()
- .session(session)
- .groupId(groupId)
- .artifactId(artifactId)
- .version(version)
- .extension(extension)
- .build());
- });
- when(session.getService(ArtifactFactory.class)).thenReturn(artifactFactory);
-
- //
- // ProjectBuilder
- //
- ProjectBuilder projectBuilder = mock(ProjectBuilder.class);
- when(projectBuilder.build(any(ProjectBuilderRequest.class))).then(iom -> {
- ProjectBuilderRequest request = iom.getArgument(0, ProjectBuilderRequest.class);
- ProjectBuilderResult result = mock(ProjectBuilderResult.class);
- Model model = new MavenStaxReader().read(request.getSource().get().openStream());
- ProjectStub projectStub = new ProjectStub();
- projectStub.setModel(model);
- ProducedArtifactStub artifactStub = new ProducedArtifactStub(
- model.getGroupId(), model.getArtifactId(), "", model.getVersion(), model.getPackaging());
- if (!"pom".equals(model.getPackaging())) {
- projectStub.setMainArtifact(artifactStub);
- }
- when(result.getProject()).thenReturn(Optional.of(projectStub));
- return result;
- });
- when(session.getService(ProjectBuilder.class)).thenReturn(projectBuilder);
-
- //
- // ModelXmlFactory
- //
- when(session.getService(ModelXmlFactory.class)).thenReturn(new DefaultModelXmlFactory());
-
- //
- // Lookup
- //
- when(session.getService(Lookup.class)).thenReturn(LookupStub.EMPTY);
-
- //
- // Other
- //
- Properties sysProps = new Properties();
- Properties usrProps = new Properties();
- doReturn(sysProps).when(session).getSystemProperties();
- doReturn(usrProps).when(session).getUserProperties();
- when(session.getLocalRepository()).thenReturn(localRepository);
- when(session.getData()).thenReturn(new TestSessionData());
- when(session.withLocalRepository(any()))
- .thenAnswer(iom -> getMockSession(iom.getArgument(0, LocalRepository.class)));
-
- return session;
- }
-
- static String getPathForArtifact(Artifact artifact, boolean local) {
- StringBuilder path = new StringBuilder(128);
- path.append(artifact.getGroupId().replace('.', '/')).append('/');
- path.append(artifact.getArtifactId()).append('/');
- path.append(artifact.getVersion()).append('/');
- path.append(artifact.getArtifactId()).append('-');
- path.append(artifact.getVersion());
- if (artifact.getClassifier().length() > 0) {
- path.append('-').append(artifact.getClassifier());
- }
- if (artifact.getExtension().length() > 0) {
- path.append('.').append(artifact.getExtension());
- }
- return path.toString();
- }
-
- static class TestSessionData implements SessionData {
- private final Map<Key<?>, Object> map = new ConcurrentHashMap<>();
-
- @Override
- public <T> void set(Key<T> key, T value) {
- map.put(key, value);
- }
-
- @Override
- public <T> boolean replace(Key<T> key, T oldValue, T newValue) {
- return map.replace(key, oldValue, newValue);
- }
-
- @Override
- @SuppressWarnings("unchecked")
- public <T> T get(Key<T> key) {
- return (T) map.get(key);
- }
-
- @Override
- @SuppressWarnings("unchecked")
- public <T> T computeIfAbsent(Key<T> key, Supplier<T> supplier) {
- return (T) map.computeIfAbsent(key, k -> supplier.get());
- }
- }
-}
diff --git a/maven-plugin-testing-harness/src/main/java/org/apache/maven/api/plugin/testing/stubs/SessionStub.java b/maven-plugin-testing-harness/src/main/java/org/apache/maven/api/plugin/testing/stubs/SessionStub.java
deleted file mode 100644
index 050fcd9..0000000
--- a/maven-plugin-testing-harness/src/main/java/org/apache/maven/api/plugin/testing/stubs/SessionStub.java
+++ /dev/null
@@ -1,458 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.maven.api.plugin.testing.stubs;
-
-import java.nio.file.Path;
-import java.time.Instant;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Optional;
-
-import org.apache.maven.api.Artifact;
-import org.apache.maven.api.ArtifactCoordinates;
-import org.apache.maven.api.Dependency;
-import org.apache.maven.api.DependencyCoordinates;
-import org.apache.maven.api.DependencyScope;
-import org.apache.maven.api.DownloadedArtifact;
-import org.apache.maven.api.Language;
-import org.apache.maven.api.Listener;
-import org.apache.maven.api.LocalRepository;
-import org.apache.maven.api.Node;
-import org.apache.maven.api.Packaging;
-import org.apache.maven.api.PathScope;
-import org.apache.maven.api.PathType;
-import org.apache.maven.api.ProducedArtifact;
-import org.apache.maven.api.Project;
-import org.apache.maven.api.ProjectScope;
-import org.apache.maven.api.RemoteRepository;
-import org.apache.maven.api.Service;
-import org.apache.maven.api.Session;
-import org.apache.maven.api.SessionData;
-import org.apache.maven.api.Type;
-import org.apache.maven.api.Version;
-import org.apache.maven.api.VersionConstraint;
-import org.apache.maven.api.VersionRange;
-import org.apache.maven.api.annotations.Nonnull;
-import org.apache.maven.api.annotations.Nullable;
-import org.apache.maven.api.model.Repository;
-import org.apache.maven.api.settings.Settings;
-import org.apache.maven.api.toolchain.ToolchainModel;
-
-/**
- */
-public class SessionStub implements Session {
-
- private Map<String, String> userProperties;
-
- private Map<String, String> systemProperties;
-
- private final Settings settings;
-
- public SessionStub(Settings settings) {
- this(null, null, settings);
- }
-
- public SessionStub() {
- this(null, null, null);
- }
-
- public SessionStub(Map<String, String> userProperties) {
- this(null, userProperties, null);
- }
-
- public SessionStub(Map<String, String> systemProperties, Map<String, String> userProperties, Settings settings) {
-
- this.settings = settings;
-
- this.systemProperties = new HashMap<>();
- if (systemProperties != null) {
- this.systemProperties.putAll(systemProperties);
- }
- System.getProperties().forEach((k, v) -> this.systemProperties.put(k.toString(), v.toString()));
-
- this.userProperties = new HashMap<>();
- if (userProperties != null) {
- this.userProperties.putAll(userProperties);
- }
- }
-
- @Override
- public Settings getSettings() {
- return settings;
- }
-
- @Override
- public Map<String, String> getSystemProperties() {
- return this.systemProperties;
- }
-
- @Override
- public Map<String, String> getUserProperties() {
- return this.userProperties;
- }
-
- @Nonnull
- @Override
- public Map<String, String> getEffectiveProperties(@Nullable Project project) {
- HashMap<String, String> result = new HashMap<>(getSystemProperties());
- if (project != null) {
- result.putAll(project.getModel().getProperties());
- }
- result.putAll(getUserProperties());
- return result;
- }
-
- @Override
- public LocalRepository getLocalRepository() {
- return null;
- }
-
- @Override
- public Path getTopDirectory() {
- return null;
- }
-
- @Override
- public Path getRootDirectory() {
- return null;
- }
-
- @Override
- public List<RemoteRepository> getRemoteRepositories() {
- return null;
- }
-
- @Override
- public SessionData getData() {
- return null;
- }
-
- @Override
- public Version getMavenVersion() {
- return null;
- }
-
- @Override
- public int getDegreeOfConcurrency() {
- return 0;
- }
-
- @Override
- public Instant getStartTime() {
- return null;
- }
-
- @Override
- public List<Project> getProjects() {
- return null;
- }
-
- @Override
- public Map<String, Object> getPluginContext(Project project) {
- return null;
- }
-
- @Override
- public <T extends Service> T getService(Class<T> clazz) {
- return null;
- }
-
- @Override
- public Session withLocalRepository(LocalRepository localRepository) {
- return null;
- }
-
- @Override
- public Session withRemoteRepositories(List<RemoteRepository> repositories) {
- return null;
- }
-
- @Override
- public void registerListener(Listener listener) {}
-
- @Override
- public void unregisterListener(Listener listener) {}
-
- @Override
- public Collection<Listener> getListeners() {
- return null;
- }
-
- @Override
- public LocalRepository createLocalRepository(Path path) {
- return null;
- }
-
- @Override
- public RemoteRepository createRemoteRepository(String id, String url) {
- return null;
- }
-
- @Override
- public RemoteRepository createRemoteRepository(Repository repository) {
- return null;
- }
-
- @Override
- public Artifact createArtifact(String groupId, String artifactId, String version, String extension) {
- return null;
- }
-
- @Override
- public Artifact createArtifact(
- String groupId, String artifactId, String version, String classifier, String extension, String type) {
- return null;
- }
-
- @Override
- public ProducedArtifact createProducedArtifact(
- String groupId, String artifactId, String version, String extension) {
- return null;
- }
-
- @Override
- public ProducedArtifact createProducedArtifact(
- String groupId, String artifactId, String version, String classifier, String extension, String type) {
- return null;
- }
-
- @Override
- public ArtifactCoordinates createArtifactCoordinates(
- String groupId, String artifactId, String version, String extension) {
- return null;
- }
-
- @Override
- public ArtifactCoordinates createArtifactCoordinates(String coordString) {
- return null;
- }
-
- @Override
- public ArtifactCoordinates createArtifactCoordinates(
- String groupId, String artifactId, String version, String classifier, String extension, String type) {
- return null;
- }
-
- @Override
- public ArtifactCoordinates createArtifactCoordinates(Artifact artifact) {
- return null;
- }
-
- @Override
- public DependencyCoordinates createDependencyCoordinates(ArtifactCoordinates artifactCoordinates) {
- return null;
- }
-
- @Override
- public DependencyCoordinates createDependencyCoordinates(Dependency dependency) {
- return null;
- }
-
- @Override
- public DownloadedArtifact resolveArtifact(Artifact artifact) {
- return null;
- }
-
- @Override
- public DownloadedArtifact resolveArtifact(ArtifactCoordinates coordinate) {
- return null;
- }
-
- @Override
- public DownloadedArtifact resolveArtifact(ArtifactCoordinates coordinates, List<RemoteRepository> repositories) {
- return null;
- }
-
- @Override
- public DownloadedArtifact resolveArtifact(Artifact artifact, List<RemoteRepository> repositories) {
- return null;
- }
-
- @Override
- public Collection<DownloadedArtifact> resolveArtifacts(ArtifactCoordinates... artifactCoordinates) {
- return null;
- }
-
- @Override
- public Collection<DownloadedArtifact> resolveArtifacts(Collection<? extends ArtifactCoordinates> collection) {
- return null;
- }
-
- @Override
- public Collection<DownloadedArtifact> resolveArtifacts(Artifact... artifacts) {
- return null;
- }
-
- @Override
- public Collection<DownloadedArtifact> resolveArtifacts(
- Collection<? extends ArtifactCoordinates> coordinates, List<RemoteRepository> repositories) {
- return null;
- }
-
- @Override
- public List<Node> flattenDependencies(Node node, PathScope scope) {
- return null;
- }
-
- @Override
- public List<Path> resolveDependencies(DependencyCoordinates dependencyCoordinates) {
- return null;
- }
-
- @Override
- public List<Path> resolveDependencies(List<DependencyCoordinates> dependencyCoordinatess) {
- return null;
- }
-
- @Override
- public List<Path> resolveDependencies(Project project, PathScope scope) {
- return null;
- }
-
- @Override
- public Version resolveVersion(ArtifactCoordinates artifact) {
- return null;
- }
-
- @Override
- public List<Version> resolveVersionRange(ArtifactCoordinates artifact) {
- return null;
- }
-
- @Override
- public List<Version> resolveVersionRange(ArtifactCoordinates artifact, List<RemoteRepository> repositories) {
- return null;
- }
-
- @Override
- public void installArtifacts(ProducedArtifact... artifacts) {}
-
- @Override
- public void installArtifacts(Collection<ProducedArtifact> artifacts) {}
-
- @Override
- public void deployArtifact(RemoteRepository repository, ProducedArtifact... artifacts) {}
-
- @Override
- public void setArtifactPath(ProducedArtifact artifact, Path path) {}
-
- @Override
- public Optional<Path> getArtifactPath(Artifact artifact) {
- return Optional.empty();
- }
-
- @Override
- public boolean isVersionSnapshot(String version) {
- return false;
- }
-
- @Override
- public Node collectDependencies(Artifact artifact, PathScope scope) {
- return null;
- }
-
- @Override
- public Node collectDependencies(Project project, PathScope scope) {
- return null;
- }
-
- @Override
- public Node collectDependencies(DependencyCoordinates dependencyCoordinates, PathScope scope) {
- return null;
- }
-
- @Override
- public Path getPathForLocalArtifact(Artifact artifact) {
- return null;
- }
-
- @Override
- public Path getPathForRemoteArtifact(RemoteRepository remote, Artifact artifact) {
- return null;
- }
-
- @Override
- public Version parseVersion(String version) {
- return null;
- }
-
- @Override
- public VersionRange parseVersionRange(String versionRange) {
- return null;
- }
-
- @Override
- public VersionConstraint parseVersionConstraint(String s) {
- return null;
- }
-
- @Override
- public Map<PathType, List<Path>> resolveDependencies(
- DependencyCoordinates dependencyCoordinates, PathScope scope, Collection<PathType> desiredTypes) {
- return Map.of();
- }
-
- @Override
- public Map<PathType, List<Path>> resolveDependencies(
- Project project, PathScope scope, Collection<PathType> desiredTypes) {
- return Map.of();
- }
-
- @Override
- public Type requireType(String id) {
- return null;
- }
-
- @Override
- public Language requireLanguage(String id) {
- return null;
- }
-
- @Override
- public Packaging requirePackaging(String id) {
- return null;
- }
-
- @Override
- public ProjectScope requireProjectScope(String id) {
- return null;
- }
-
- @Override
- public DependencyScope requireDependencyScope(String id) {
- return null;
- }
-
- @Override
- public PathScope requirePathScope(String id) {
- return null;
- }
-
- @Override
- public Optional<Version> resolveHighestVersion(ArtifactCoordinates artifact, List<RemoteRepository> repositories) {
- return Optional.empty();
- }
-
- @Override
- public Collection<ToolchainModel> getToolchains() {
- return List.of();
- }
-}
diff --git a/maven-plugin-testing-harness/src/site/apt/examples/artifact.apt b/maven-plugin-testing-harness/src/site/apt/examples/artifact.apt
deleted file mode 100644
index 8bab33f..0000000
--- a/maven-plugin-testing-harness/src/site/apt/examples/artifact.apt
+++ /dev/null
@@ -1,215 +0,0 @@
- ------
- Testing Project Artifact
- ------
- Vincent Siveton
- ------
- February 2008
- ------
-
-~~ 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.
-
-Testing Project Artifact
-
- <<Note>>: This example improves the {{{../getting-started/index.html}cookbook}} to play with artifact handler.
-
- Sometimes, your Mojo uses project artifact and ArtifactHandler mechanisms. For instance, you could need to
- filter on Java projects, i.e.:
-
-+---+
-public class MyMojo
- extends AbstractMojo
-{
- /**
- * The Maven Project.
- */
- @Component
- protected MavenProject project;
-
- public void execute()
- throws MojoExecutionException
- {
- ...
-
- ArtifactHandler artifactHandler = project.getArtifact().getArtifactHandler();
- if ( "java".equals( artifactHandler.getLanguage() ) )
- {
- ...
- }
-
- ...
- }
-}
-+---+
-
-* Create Stubs
-
-+---+
-public class MyArtifactHandlerStub
- extends DefaultArtifactHandler
-{
- private String language;
-
- public String getLanguage()
- {
- if ( language == null )
- {
- language = "java";
- }
-
- return language;
- }
-
- public void setLanguage( String language )
- {
- this.language = language;
- }
-}
-+---+
-
-+---+
-public class MyArtifactStub
- extends ArtifactStub
-{
- private String groupId;
-
- private String artifactId;
-
- private String version;
-
- private String packaging;
-
- private VersionRange versionRange;
-
- private ArtifactHandler handler;
-
- /**
- * @param groupId
- * @param artifactId
- * @param version
- * @param packaging
- */
- public ProjectInfoPluginArtifactStub( String groupId, String artifactId,
- String version, String packaging )
- {
- this.groupId = groupId;
- this.artifactId = artifactId;
- this.version = version;
- this.packaging = packaging;
- versionRange = VersionRange.createFromVersion( version );
- }
-
- /** {@inheritDoc} */
- public void setGroupId( String groupId )
- {
- this.groupId = groupId;
- }
-
- /** {@inheritDoc} */
- public String getGroupId()
- {
- return groupId;
- }
-
- /** {@inheritDoc} */
- public void setArtifactId( String artifactId )
- {
- this.artifactId = artifactId;
- }
-
- /** {@inheritDoc} */
- public String getArtifactId()
- {
- return artifactId;
- }
-
- /** {@inheritDoc} */
- public void setVersion( String version )
- {
- this.version = version;
- }
-
- /** {@inheritDoc} */
- public String getVersion()
- {
- return version;
- }
-
- /**
- * @param packaging
- */
- public void setPackaging( String packaging )
- {
- this.packaging = packaging;
- }
-
- /**
- * @return the packaging
- */
- public String getPackaging()
- {
- return packaging;
- }
-
- /** {@inheritDoc} */
- public VersionRange getVersionRange()
- {
- return versionRange;
- }
-
- /** {@inheritDoc} */
- public void setVersionRange( VersionRange versionRange )
- {
- this.versionRange = versionRange;
- }
-
- /** {@inheritDoc} */
- public ArtifactHandler getArtifactHandler()
- {
- return handler;
- }
-
- /** {@inheritDoc} */
- public void setArtifactHandler( ArtifactHandler handler )
- {
- this.handler = handler;
- }
-}
-+---+
-
-+---+
-public class MyProjectStub
- extends MavenProjectStub
-{
- /**
- * Default constructor
- */
- public MyProjectStub()
- {
- ...
-
- Artifact artifact = new MyArtifactStub( getGroupId(), getArtifactId(),
- getVersion(), getPackaging() );
- artifact.setArtifactHandler( new MyArtifactHandlerStub() );
- setArtifact( artifact );
-
- ...
- }
-
- ...
-}
-+---+
diff --git a/maven-plugin-testing-harness/src/site/apt/examples/complex-mojo-parameters.apt b/maven-plugin-testing-harness/src/site/apt/examples/complex-mojo-parameters.apt
deleted file mode 100644
index 29b78a9..0000000
--- a/maven-plugin-testing-harness/src/site/apt/examples/complex-mojo-parameters.apt
+++ /dev/null
@@ -1,177 +0,0 @@
- ------
- Testing Complex Mojo Parameters
- ------
- Vincent Siveton
- ------
- February 2008
- ------
-
-~~ 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.
-
-Testing Complex Mojo Parameters
-
- <<Note>>: This example improves the {{{../getting-started/index.html}cookbook}} for testing complex Mojo parameters.
-
- In real plugin development, you will use specific Maven objects like <<<MavenProject>>>, <<<ArtifactRepository>>> or
- <<<MavenSettings>>>. You could use them by defining stubs.
-
- Suppose that you have the following dependencies in the maven-my-plugin pom:
-
-+---+
-<project>
- ...
- <dependencies>
- <dependency>
- <groupId>org.apache.maven</groupId>
- <artifactId>maven-artifact</artifactId>
- <version>2.0.8</version>
- </dependency>
- <dependency>
- <groupId>org.apache.maven</groupId>
- <artifactId>maven-project</artifactId>
- <version>2.0.8</version>
- </dependency>
- ...
- </dependencies>
-</project>
-+---+
-
- You will add the following in the <<<MyMojo>>>:
-
-+---+
-public class MyMojo
- extends AbstractMojo
-{
- /**
- * The Maven Project.
- */
- @Parameter( defaultValue = "${project}", readonly = true )
- protected MavenProject project;
-
- /**
- * Local Repository.
- */
- @Parameter( defaultValue = "${localRepository}", readonly = true, required = true )
- protected ArtifactRepository localRepository;
-
- /**
- * The Maven Settings.
- */
- @Parameter( defaultValue = "${settings}", readonly = true )
- private Settings settings;
-
- ...
-}
-+---+
-
-* Create Stubs
-
- You need to create stub objects to run <<<MyMojoTest#testSomething()>>>. By convention, the package name should
- reflect the stubs, i.e. in our case <<<org.apache.maven.plugin.my.stubs>>>.
-
-+---+
-public class MyProjectStub
- extends MavenProjectStub
-{
- /**
- * Default constructor
- */
- public MyProjectStub()
- {
- MavenXpp3Reader pomReader = new MavenXpp3Reader();
- Model model;
- try
- {
- model = pomReader.read( ReaderFactory.newXmlReader( new File( getBasedir(), "pom.xml" ) ) );
- setModel( model );
- }
- catch ( Exception e )
- {
- throw new RuntimeException( e );
- }
-
- setGroupId( model.getGroupId() );
- setArtifactId( model.getArtifactId() );
- setVersion( model.getVersion() );
- setName( model.getName() );
- setUrl( model.getUrl() );
- setPackaging( model.getPackaging() );
-
- Build build = new Build();
- build.setFinalName( model.getArtifactId() );
- build.setDirectory( getBasedir() + "/target" );
- build.setSourceDirectory( getBasedir() + "/src/main/java" );
- build.setOutputDirectory( getBasedir() + "/target/classes" );
- build.setTestSourceDirectory( getBasedir() + "/src/test/java" );
- build.setTestOutputDirectory( getBasedir() + "/target/test-classes" );
- setBuild( build );
-
- List compileSourceRoots = new ArrayList();
- compileSourceRoots.add( getBasedir() + "/src/main/java" );
- setCompileSourceRoots( compileSourceRoots );
-
- List testCompileSourceRoots = new ArrayList();
- testCompileSourceRoots.add( getBasedir() + "/src/test/java" );
- setTestCompileSourceRoots( testCompileSourceRoots );
- }
-
- /** {@inheritDoc} */
- public File getBasedir()
- {
- return new File( super.getBasedir() + "/src/test/resources/unit/project-to-test/" );
- }
-}
-+---+
-
-+---+
-public class SettingsStub
- extends Settings
-{
- /** {@inheritDoc} */
- public List getProxies()
- {
- return Collections.EMPTY_LIST;
- }
-}
-+---+
-
-* Configure <<<project-to-test>>> pom
-
-+---+
-<project>
- ...
- <build>
- <plugins>
- <plugin>
- <artifactId>maven-my-plugin</artifactId>
- <configuration>
- <!-- Specify where this pom will output files -->
- <outputDirectory>target/test-harness/project-to-test</outputDirectory>
-
- <!-- By default <<<${basedir}/target/local-repo", where basedir refers
- to the basedir of maven-my-plugin. -->
- <localRepository>${localRepository}</localRepository>
- <!-- The defined stubs -->
- <project implementation="org.apache.maven.plugin.my.stubs.MyProjectStub"/>
- <settings implementation="org.apache.maven.plugin.my.stubs.SettingsStub"/>
- </configuration>
- </plugin>
- </plugins>
- </build>
-</project>
-+---+
diff --git a/maven-plugin-testing-harness/src/site/apt/examples/multiproject.apt b/maven-plugin-testing-harness/src/site/apt/examples/multiproject.apt
deleted file mode 100644
index e010348..0000000
--- a/maven-plugin-testing-harness/src/site/apt/examples/multiproject.apt
+++ /dev/null
@@ -1,138 +0,0 @@
- ------
- Testing Multiproject
- ------
- Vincent Siveton
- ------
- February 2008
- ------
-
-~~ 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.
-
-Testing Multiproject
-
- <<Note>>: This example improves the {{{../getting-started/index.html}cookbook}} for multi-project testing.
-
- Your Mojo should have <<<...@aggregator>>> parameter, i.e.:
-
- * with java annotations ({{{/plugin-tools/}maven-plugin-plugin 3.x}}):
-
-+----+
-@Mojo( name = "touch", aggregator = true )
-public class MyMojo
- extends AbstractMojo
-{
- ...
-}
-+----+
-
- * or with javadoc tags:
-
-+----+
-/**
- * @goal touch
- * @aggregator
- */
-public class MyMojo
- extends AbstractMojo
-{
- ...
-}
-+----+
-
- []
-
- To test a Mojo in a multiproject area, you need to define several stubs, i.e. for the main test project and its modules.
-
-* Create Stubs
-
- Stub for the main test project:
-
-+----+
-public class MyProjectStub
- extends MavenProjectStub
-{
- /**
- * Default constructor
- */
- public MyProjectStub()
- {
- ...
-
- setExecutionRoot( true );
- }
-
- /** {@inheritDoc} */
- public MavenProject getExecutionProject()
- {
- return this;
- }
-}
-+----+
-
- Stubs for the subprojects:
-
-+----+
-public class SubProject1Stub
- extends MavenProjectStub
-{
- /**
- * Default constructor
- */
- public SubProject1Stub()
- {
- ...
- }
-}
-+----+
-
-+----+
-public class SubProject2Stub
- extends MavenProjectStub
-{
- /**
- * Default constructor
- */
- public SubProject2Stub()
- {
- ...
- }
-}
-+----+
-
-* Configure <<<project-to-test>>> pom
-
-+----+
-<project>
- ...
- <build>
- <plugins>
- <plugin>
- <artifactId>maven-my-plugin</artifactId>
- <configuration>
- ...
- <project implementation="org.apache.maven.plugin.my.stubs.MyProjectStub"/>
- <reactorProjects>
- <project implementation="org.apache.maven.plugin.my.stubs.SubProject1Stub"/>
- <project implementation="org.apache.maven.plugin.my.stubs.SubProject2Stub"/>
- </reactorProjects>
- </configuration>
- </plugin>
- </plugins>
- </build>
-</project>
-+----+
diff --git a/maven-plugin-testing-harness/src/site/apt/examples/repositories.apt b/maven-plugin-testing-harness/src/site/apt/examples/repositories.apt
deleted file mode 100644
index 6a86ebc..0000000
--- a/maven-plugin-testing-harness/src/site/apt/examples/repositories.apt
+++ /dev/null
@@ -1,133 +0,0 @@
- ------
- Testing Using Repositories
- ------
- Vincent Siveton
- ------
- February 2008
- ------
-
-~~ 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.
-
-Testing Using Repositories
-
- <<Note>>: This example improves the {{{../getting-started/index.html}cookbook}} for testing repositories.
-
- When developing a Maven plugin you often need to play with repositories. Suppose that the MyMojo needs
- to download artifacts into your local repository, i.e.:
-
-+----+
-public class MyMojo
- extends AbstractMojo
-{
- /**
- * Used for resolving artifacts
- */
- @Component
- private ArtifactResolver resolver;
-
- /**
- * Factory for creating artifact objects
- */
- @Component
- private ArtifactFactory factory;
-
- /**
- * Local Repository.
- */
- @Parameter( defaultValue = "${localRepository}", readonly = true, required = true )
- private ArtifactRepository localRepository;
-
- public void execute()
- throws MojoExecutionException
- {
- ...
-
- Artifact artifact = factory.createArtifact( "junit", "junit", "3.8.1", "compile", "jar" );
- try
- {
- resolver.resolve( artifact, project.getRemoteArtifactRepositories(), localRepository );
- }
- catch ( ArtifactResolutionException e )
- {
- throw new MojoExecutionException( "Unable to resolve artifact:" + artifact, e );
- }
- catch ( ArtifactNotFoundException e )
- {
- throw new MojoExecutionException( "Unable to find artifact:" + artifact, e );
- }
-
- ...
- }
-}
-+----+
-
-* Create Stubs
-
- Stub for the test project:
-
-+----+
-public class MyProjectStub
- extends MavenProjectStub
-{
- /**
- * Default constructor
- */
- public MyProjectStub()
- {
- ...
- }
-
- /** {@inheritDoc} */
- public List getRemoteArtifactRepositories()
- {
- ArtifactRepository repository = new DefaultArtifactRepository( "central", "http://repo.maven.apache.org/maven2",
- new DefaultRepositoryLayout() );
-
- return Collections.singletonList( repository );
- }
-}
-+----+
-
-* Configure <<<project-to-test>>> pom
-
-+----+
-<project>
- ...
- <build>
- <plugins>
- <plugin>
- <artifactId>maven-my-plugin</artifactId>
- <configuration>
- <!-- Specify where this pom will output files -->
- <outputDirectory>${basedir}/target/test-harness/project-to-test</outputDirectory>
-
- <!-- By default <<<${basedir}/target/local-repo", where basedir refers
- to the basedir of maven-my-plugin. -->
- <localRepository>${localRepository}</localRepository>
- <!-- The defined stub -->
- <project implementation="org.apache.maven.plugin.my.stubs.MyProjectStub"/>
- </configuration>
- </plugin>
- </plugins>
- </build>
-</project>
-+----+
-
-** Execute test
-
- Calling <<<mvn test>>> will create <<<$\{basedir\}/target/local-repo/junitjunit/3.8.1/junit-3.8.1.jar>>> file.
diff --git a/maven-plugin-testing-harness/src/site/apt/getting-started/index.apt b/maven-plugin-testing-harness/src/site/apt/getting-started/index.apt
deleted file mode 100644
index 749611f..0000000
--- a/maven-plugin-testing-harness/src/site/apt/getting-started/index.apt
+++ /dev/null
@@ -1,249 +0,0 @@
- ------
- How To Use Maven Plugin Testing Harness
- ------
- Vincent Siveton
- ------
- 2008-08-27
- ------
-
-~~ 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.
-
-Cookbook: How To Use Maven Plugin Testing Harness?
-
- This guide is intended as a reference for those developing Maven plugins, with self-contained references and
- solutions for common testing cases.
-
-* Prerequisites
-
- We assume that you have already created a plugin. In this cookbook, we make reference to <<<MyMojo>>> in
- <<<maven-my-plugin>>> which is generated by the Maven Archetype Plugin, i.e.:
-
-+---+
-mvn archetype:create \
- -DgroupId=org.apache.maven.plugin.my \
- -DartifactId=maven-my-plugin \
- -DarchetypeArtifactId=maven-archetype-mojo
-+---+
-
- The generated structure should be:
-
-+---+
-maven-my-plugin
- |- pom.xml
- +- src/
- +- main/
- +- java/
- +- org/
- +- apache/
- +- maven/
- +- plugin/
- +- my/
- |- MyMojo.java
-+---+
-
-* Recipe
-
-** Add <<<maven-plugin-testing-harness>>> dependency
-
- As usual, just add <<<maven-plugin-testing-harness>>> as following in your pom. Be sure to specify <<<test>>> scope.
-
-+---+
-<project>
- ...
- <dependencies>
- <dependency>
- <groupId>org.apache.maven.plugin-testing</groupId>
- <artifactId>maven-plugin-testing-harness</artifactId>
- <scope>test</scope>
- </dependency>
- ...
- </dependencies>
- ...
-</project>
-+---+
-
-** Create a <<<MyMojoTest>>>
-
- Create a <<<MyMojoTest>>> (by convention) class in <<<src/test/java/org/apache/maven/plugin/my>>> directory.
- This class should extend <<<AbstractMojoTestCase>>> from <<<maven-plugin-testing-harness>>>.
-
-+---+
-import org.apache.maven.plugin.testing.AbstractMojoTestCase;
-
-public class MyMojoTest
- extends AbstractMojoTestCase
-{
- /** {@inheritDoc} */
- protected void setUp()
- throws Exception
- {
- // required
- super.setUp();
-
- ...
- }
-
- /** {@inheritDoc} */
- protected void tearDown()
- throws Exception
- {
- // required
- super.tearDown();
-
- ...
- }
-
- /**
- * @throws Exception if any
- */
- public void testSomething()
- throws Exception
- {
- File pom = getTestFile( "src/test/resources/unit/project-to-test/pom.xml" );
- assertNotNull( pom );
- assertTrue( pom.exists() );
-
- MyMojo myMojo = (MyMojo) lookupMojo( "touch", pom );
- assertNotNull( myMojo );
- myMojo.execute();
-
- ...
- }
-}
-+---+
-
- In this case, <<<testSomething()>>> will test <<<MyMojo>>> against a Maven project called <<<project-to-test>>>.
-
- <<Note>>: By convention, projects for unit testing your should be in the test resources directory.
-
- Alternatively to extending <<<AbstractMojoTestCase>>> and when using Junit-4.10 ff., you may use a <<<MojoRule>>>,
- which just embeds an <<<AbstractMojoTestCase>>>.
-
- When you do not need the functionality in every test method, you may use the <<<...@WithoutMojo>>> annotation to
- skip rule executions.
-
-+---+
-
-import org.apache.maven.plugin.testing.MojoRule;
-import org.apache.maven.plugin.testing.WithoutMojo;
-
-import org.junit.Rule;
-import static org.junit.Assert.*;
-import org.junit.Test;
-
-public class MyMojoTest
-{
- @Rule
- public MojoRule rule = new MojoRule()
- {
- @Override
- protected void before() throws Throwable
- {
- }
-
- @Override
- protected void after()
- {
- }
- };
-
- /**
- * @throws Exception if any
- */
- @Test
- public void testSomething()
- throws Exception
- {
- File pom = rule.getTestFile( "src/test/resources/unit/project-to-test/pom.xml" );
- assertNotNull( pom );
- assertTrue( pom.exists() );
-
- MyMojo myMojo = (MyMojo) rule.lookupMojo( "touch", pom );
- assertNotNull( myMojo );
- myMojo.execute();
-
- ...
- }
-
- /** Do not need the MojoRule. */
- @WithoutMojo
- @Test
- public void testSomethingWhichDoesNotNeedTheMojoAndProbablyShouldBeExtractedIntoANewClassOfItsOwn()
- {
- ...
- }
-
-}
-
-
-+---+
-
-** Configuring <<<project-to-test>>> pom
-
- Just create a pom as usual. The names for groupId and artifactId don't really matter since this project will not be deployed.
-
-+---+
-<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>
-
- <groupId>org.apache.maven.plugin.my.unit</groupId>
- <artifactId>project-to-test</artifactId>
- <version>1.0-SNAPSHOT</version>
- <packaging>jar</packaging>
- <name>Test MyMojo</name>
-
- <dependencies>
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <version>3.8.1</version>
- <scope>test</scope>
- </dependency>
- </dependencies>
-
- <build>
- <plugins>
- <plugin>
- <artifactId>maven-my-plugin</artifactId>
- <configuration>
- <!-- Specify the MyMojo parameter -->
- <outputDirectory>target/test-harness/project-to-test</outputDirectory>
- </configuration>
- </plugin>
- </plugins>
- </build>
-</project>
-+---+
-
-** Execute test
-
- As usual, just call:
-
-+---+
-mvn test
-+---+
-
-* Resources
-
- [[1]] {{{http://maven.apache.org/guides/plugin/guide-java-plugin-development.html}Guide to Developing Java Plugins}}
-
- [[2]] {{{http://maven.apache.org/guides/mini/guide-configuring-plugins.html}Guide to Configuring Plugins}}
-
- []
diff --git a/maven-plugin-testing-harness/src/site/apt/index.apt b/maven-plugin-testing-harness/src/site/apt/index.apt
deleted file mode 100644
index bbdca2f..0000000
--- a/maven-plugin-testing-harness/src/site/apt/index.apt
+++ /dev/null
@@ -1,46 +0,0 @@
- ------
- Introduction
- ------
- Vincent Siveton
- ------
- February 2008
- ------
-
-~~ 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.
-
-Maven Plugin Testing Harness
-
- The Maven Plugin Testing Harness provides mechanisms to manage tests on Mojos, i.e. by pre-constructing the
- {{{http://plexus.codehaus.org}Plexus}} components, providing stub objects for Maven functionality such as projects,
- and populating fields from an XML file that resembles the plugin configuration in the POM.
-
- The best way to start is to read the cookbook {{{./getting-started/index.html}How to use Maven Plugin Testing Harness}}.
-
-* Examples
-
- The following examples shows how to use the Testing Harness in more advanced usecases:
-
- * {{{./examples/complex-mojo-parameters.html}Testing Complex Mojo Parameters}}
-
- * {{{./examples/multiproject.html}Testing Multiproject}}
-
- * {{{./examples/repositories.html}Testing Using Repositories}}
-
- * {{{./examples/artifact.html}Testing Project Artifact}}
-
- []
diff --git a/maven-plugin-testing-harness/src/site/fml/faq.fml b/maven-plugin-testing-harness/src/site/fml/faq.fml
deleted file mode 100644
index bcc7712..0000000
--- a/maven-plugin-testing-harness/src/site/fml/faq.fml
+++ /dev/null
@@ -1,72 +0,0 @@
-<?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.
--->
-
-<faqs id="FAQ" title="Frequently Asked Questions">
- <part id="General">
- <faq id="What is a Mojo Testing Harness">
- <question>What is a Mojo Testing Harness?</question>
- <answer>
- <p>
- A unit test attempts to verify a mojo as an isolated unit, by mocking out the rest of the Maven environment.
- A mojo unit test does not attempt to run your plugin in the context of a real Maven build.
- Unit tests are designed to be fast.
- </p>
- <p>
- This testing library is <b>NOT</b> designed for integration or functional testing:
- <a href="/plugins/maven-invoker-plugin/"><code>maven-invoker-plugin</code></a> is the way to go if you need it,
- which gives you a complete Maven environment at the cost of more resources and time consuptions.
- </p>
- </answer>
- </faq>
- <faq id="What kinds of unit tests are supported">
- <question>What kind of unit tests are supported?</question>
- <answer>
- <p>
- <dl>
- <dt>TestCase from JUnit</dt>
- <dd>You could use the <a href="http://junit.org/">JUnit framework</a> to test your plugin in
- the same way you'd write any other JUnit test cases, i.e. by writing a test class which extends
- <i>TestCase</i>.</dd>
- <dt>TestCase from Plexus</dt>
- <dd>Mojos are written to take specific advantage of the <a href="http://plexus.codehaus.org/plexus-containers/">Plexus
- container</a>. If you need Plexus container services, you could write your class which extends <i>PlexusTestCase</i>,
- instead of <i>TestCase</i>.</dd>
- <dt>TestCase from Testing Harness</dt>
- <dd>If you need to inject Maven objects into your mojo, you could use the <i>maven-plugin-testing-harness</i>.
- The <i>maven-plugin-testing-harness</i> is explicitly intended to test the
- <i>org.apache.maven.reporting.AbstractMavenReport#execute()</i> implementation.</dd>
- </dl>
- </p>
- </answer>
- </faq>
- <faq id="Maven 2.x compatibility">
- <question>Is Mojo Testing Harness 2.x compatible with Maven 2.x?</question>
- <answer>
- <p>
- Mojo Testing Harness 2.0+ requires Maven 3.0. This does not necessary mean that your mojos will be
- incompatible with Maven 2.x, it only means that mojo unit tests use Maven 3.x libraries to mock Maven
- environment. Still, if you want to be absolutely sure your mojo is compatible with Maven 2.x, then you probably want
- to use Mojo Testing Harness 1.x.
- </p>
- </answer>
- </faq>
- </part>
-</faqs>
diff --git a/maven-plugin-testing-harness/src/site/site.xml b/maven-plugin-testing-harness/src/site/site.xml
deleted file mode 100644
index 30ffb27..0000000
--- a/maven-plugin-testing-harness/src/site/site.xml
+++ /dev/null
@@ -1,41 +0,0 @@
-<?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/DECORATION/1.8.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/DECORATION/1.8.0 https://maven.apache.org/xsd/decoration-1.8.0.xsd">
-
- <body>
- <menu name="Overview">
- <item name="Introduction" href="index.html"/>
- <item name="Getting Started" href="/getting-started/index.html"/>
- <item name="JavaDocs" href="apidocs/index.html"/>
- <item name="Source Xref" href="xref/index.html"/>
- <item name="FAQ" href="/faq.html"/>
- </menu>
-
- <menu name="Examples">
- <item name="Testing Complex Mojo Parameters" href="/examples/complex-mojo-parameters.html"/>
- <item name="Testing Multiproject" href="/examples/multiproject.html"/>
- <item name="Testing Repositories" href="/examples/repositories.html"/>
- <item name="Testing Project Artifact" href="/examples/artifact.html"/>
- </menu>
- </body>
-</project>
diff --git a/maven-plugin-testing-harness/src/test/java/org/apache/maven/api/di/testing/SimpleDITest.java b/maven-plugin-testing-harness/src/test/java/org/apache/maven/api/di/testing/SimpleDITest.java
deleted file mode 100644
index 49fc6fa..0000000
--- a/maven-plugin-testing-harness/src/test/java/org/apache/maven/api/di/testing/SimpleDITest.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.maven.api.di.testing;
-
-import java.io.File;
-
-import org.apache.maven.api.Session;
-import org.apache.maven.api.di.Inject;
-import org.apache.maven.api.di.Provides;
-import org.apache.maven.api.plugin.testing.stubs.SessionMock;
-import org.junit.jupiter.api.Test;
-
-import static org.apache.maven.api.di.testing.MavenDIExtension.getBasedir;
-import static org.junit.jupiter.api.Assertions.assertNotNull;
-
-@MavenDITest
-public class SimpleDITest {
-
- private static final String LOCAL_REPO = getBasedir() + File.separator + "target" + File.separator + "local-repo";
-
- @Inject
- Session session;
-
- @Test
- void testSession() {
- assertNotNull(session);
- assertNotNull(session.getLocalRepository());
- }
-
- @Provides
- Session createSession() {
- return SessionMock.getMockSession(LOCAL_REPO);
- }
-}
diff --git a/maven-plugin-testing-harness/src/test/java/org/apache/maven/api/plugin/testing/ExpressionEvaluatorTest.java b/maven-plugin-testing-harness/src/test/java/org/apache/maven/api/plugin/testing/ExpressionEvaluatorTest.java
deleted file mode 100644
index 30834c5..0000000
--- a/maven-plugin-testing-harness/src/test/java/org/apache/maven/api/plugin/testing/ExpressionEvaluatorTest.java
+++ /dev/null
@@ -1,139 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.maven.api.plugin.testing;
-
-import java.nio.file.Path;
-import java.nio.file.Paths;
-import java.util.Properties;
-
-import org.apache.maven.api.Project;
-import org.apache.maven.api.Session;
-import org.apache.maven.api.di.Named;
-import org.apache.maven.api.di.Provides;
-import org.apache.maven.api.plugin.MojoException;
-import org.apache.maven.api.plugin.annotations.Mojo;
-import org.apache.maven.api.plugin.testing.stubs.ProjectStub;
-import org.apache.maven.api.plugin.testing.stubs.SessionMock;
-import org.junit.jupiter.api.Test;
-
-import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
-import static org.junit.jupiter.api.Assertions.assertEquals;
-import static org.junit.jupiter.api.Assertions.assertNotNull;
-import static org.mockito.Mockito.doAnswer;
-import static org.mockito.Mockito.doReturn;
-
-/**
- * @author Edwin Punzalan
- */
-@MojoTest
-public class ExpressionEvaluatorTest {
-
- private static final String LOCAL_REPO = "target/local-repo/";
- private static final String GROUP_ID = "test";
- private static final String ARTIFACT_ID = "test-plugin";
- private static final String COORDINATES = GROUP_ID + ":" + ARTIFACT_ID + ":0.0.1-SNAPSHOT:goal";
- private static final String CONFIG = "<project>\n"
- + " <build>\n"
- + " <plugins>\n"
- + " <plugin>\n"
- + " <groupId>" + GROUP_ID + "</groupId>\n"
- + " <artifactId>" + ARTIFACT_ID + "</artifactId>\n"
- + " <configuration>\n"
- + " <basedir>${project.basedir}</basedir>\n"
- + " <workdir>${project.basedir}/workDirectory</workdir>\n"
- + " </configuration>\n"
- + " </plugin>\n"
- + " </plugins>\n"
- + " </build>\n"
- + "</project>\n";
-
- @Test
- @InjectMojo(goal = COORDINATES, pom = CONFIG)
- public void testInjection(ExpressionEvaluatorMojo mojo) {
- assertNotNull(mojo.basedir);
- assertNotNull(mojo.workdir);
- assertDoesNotThrow(mojo::execute);
- }
-
- @Test
- @InjectMojo(goal = COORDINATES, pom = CONFIG)
- @Basedir("${basedir}/target/test-classes")
- @MojoParameter(name = "param", value = "paramValue")
- public void testParam(ExpressionEvaluatorMojo mojo) {
- assertNotNull(mojo.basedir);
- assertNotNull(mojo.workdir);
- assertEquals("paramValue", mojo.param);
- assertDoesNotThrow(mojo::execute);
- }
-
- @Test
- @InjectMojo(goal = COORDINATES, pom = CONFIG)
- @MojoParameter(name = "param", value = "paramValue")
- @MojoParameter(name = "param2", value = "param2Value")
- public void testParams(ExpressionEvaluatorMojo mojo) {
- assertNotNull(mojo.basedir);
- assertNotNull(mojo.workdir);
- assertEquals("paramValue", mojo.param);
- assertEquals("param2Value", mojo.param2);
- assertDoesNotThrow(mojo::execute);
- }
-
- @Mojo(name = "goal")
- @Named("test:test-plugin:0.0.1-SNAPSHOT:goal") // this one is usually generated by maven-plugin-plugin
- public static class ExpressionEvaluatorMojo implements org.apache.maven.api.plugin.Mojo {
- private Path basedir;
-
- private Path workdir;
-
- private String param;
-
- private String param2;
-
- /** {@inheritDoc} */
- @Override
- public void execute() throws MojoException {
- if (basedir == null) {
- throw new MojoException("basedir was not injected.");
- }
-
- if (workdir == null) {
- throw new MojoException("workdir was not injected.");
- } else if (!workdir.startsWith(basedir)) {
- throw new MojoException("workdir does not start with basedir.");
- }
- }
- }
-
- @Provides
- @SuppressWarnings("unused")
- Session session() {
- Session session = SessionMock.getMockSession(LOCAL_REPO);
- doReturn(new Properties()).when(session).getSystemProperties();
- doReturn(new Properties()).when(session).getUserProperties();
- doAnswer(iom -> Paths.get(MojoExtension.getBasedir())).when(session).getRootDirectory();
- return session;
- }
-
- @Provides
- Project project() {
- ProjectStub project = new ProjectStub();
- project.setBasedir(Paths.get(MojoExtension.getBasedir()));
- return project;
- }
-}
diff --git a/maven-plugin-testing-harness/src/test/resources/META-INF/maven/org.apache.maven.api.di.Inject b/maven-plugin-testing-harness/src/test/resources/META-INF/maven/org.apache.maven.api.di.Inject
deleted file mode 100644
index 2a771d7..0000000
--- a/maven-plugin-testing-harness/src/test/resources/META-INF/maven/org.apache.maven.api.di.Inject
+++ /dev/null
@@ -1,19 +0,0 @@
-#
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied. See the License for the
-# specific language governing permissions and limitations
-# under the License.
-#
-org.apache.maven.api.plugin.testing.ExpressionEvaluatorTest$ExpressionEvaluatorMojo
\ No newline at end of file
diff --git a/maven-plugin-testing-harness/src/test/resources/META-INF/maven/plugin.xml b/maven-plugin-testing-harness/src/test/resources/META-INF/maven/plugin.xml
deleted file mode 100644
index 6657446..0000000
--- a/maven-plugin-testing-harness/src/test/resources/META-INF/maven/plugin.xml
+++ /dev/null
@@ -1,95 +0,0 @@
-<?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.
--->
-
-<plugin xmlns="http://maven.apache.org/PLUGIN/2.0.0" >
- <name>test-plugin</name>
- <description></description>
- <groupId>test</groupId>
- <artifactId>test-plugin</artifactId>
- <version>0.0.1-SNAPSHOT</version>
- <goalPrefix>test</goalPrefix>
- <isolatedRealm>false</isolatedRealm>
- <inheritedByDefault>true</inheritedByDefault>
- <mojos>
- <mojo>
- <goal>goal</goal>
- <projectRequired>true</projectRequired>
- <aggregator>false</aggregator>
- <onlineRequired>false</onlineRequired>
- <inheritedByDefault>true</inheritedByDefault>
- <implementation>org.apache.maven.plugin.testing.ParametersMojo</implementation>
- <language>java</language>
- <parameters>
- <parameter>
- <name>basedir</name>
- <type>java.nio.file.Path</type>
- </parameter>
- <parameter>
- <name>workdir</name>
- <type>java.nio.file.Path</type>
- </parameter>
- <parameter>
- <name>param</name>
- <type>java.lang.String</type>
- </parameter>
- <parameter>
- <name>param2</name>
- <type>java.lang.String</type>
- </parameter>
- <!--
- <parameter>
- <name>plain</name>
- <type>java.lang.String</type>
- <required>false</required>
- <editable>true</editable>
- <description></description>
- </parameter>
- <parameter>
- <name>withDefault</name>
- <type>java.lang.String</type>
- <required>false</required>
- <editable>true</editable>
- <description></description>
- <defaultValue>default</defaultValue>
- </parameter>
- <parameter>
- <name>withProperty</name>
- <type>java.lang.String</type>
- <required>false</required>
- <editable>true</editable>
- <description></description>
- <expression>${property}</expression>
- </parameter>
- <parameter>
- <name>withPropertyAndDefault</name>
- <type>java.lang.String</type>
- <required>false</required>
- <editable>true</editable>
- <description></description>
- <defaultValue>default</defaultValue>
- <expression>${property}</expression>
- </parameter>
- -->
- </parameters>
- </mojo>
- </mojos>
-</plugin>
\ No newline at end of file
diff --git a/pom.xml b/pom.xml
deleted file mode 100644
index 02ca468..0000000
--- a/pom.xml
+++ /dev/null
@@ -1,76 +0,0 @@
-<?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-parent</artifactId>
- <version>45</version>
- <relativePath />
- </parent>
-
- <groupId>org.apache.maven.plugin-testing</groupId>
- <artifactId>maven-plugin-testing</artifactId>
- <version>4.0.0-beta-5-SNAPSHOT</version>
- <packaging>pom</packaging>
-
- <name>Maven Plugin Testing</name>
- <description>The Maven Plugin Testing contains the necessary modules to be able to test Maven Plugins.</description>
- <url>https://maven.apache.org/plugin-testing/</url>
- <inceptionYear>2008</inceptionYear>
-
- <!-- this project used to be a multimodule project. For easy of history comparison structure is kept -->
- <modules>
- <module>maven-plugin-testing-harness</module>
- </modules>
-
- <scm>
- <connection>scm:git:https://gitbox.apache.org/repos/asf/maven-plugin-testing.git</connection>
- <developerConnection>scm:git:https://gitbox.apache.org/repos/asf/maven-plugin-testing.git</developerConnection>
- <tag>master</tag>
- <url>https://github.com/apache/maven-plugin-testing/tree/${project.scm.tag}</url>
- </scm>
- <issueManagement>
- <system>GitHub</system>
- <url>https://github.com/apache/maven-plugin-testing/issues</url>
- </issueManagement>
- <ciManagement>
- <system>Jenkins</system>
- <url>https://ci-maven.apache.org/job/Maven/job/maven-box/job/maven-plugin-testing/</url>
- </ciManagement>
- <distributionManagement>
- <site>
- <id>apache.website</id>
- <url>scm:svn:https://svn.apache.org/repos/asf/maven/website/components/${maven.site.path}</url>
- </site>
- </distributionManagement>
-
- <properties>
- <surefire.version>3.5.1</surefire.version>
- <mavenVersion>4.0.0-rc-3</mavenVersion>
- <maven.site.path>plugin-testing-archives/LATEST</maven.site.path>
- <javaVersion>17</javaVersion>
- <project.build.outputTimestamp>2025-03-26T09:53:34Z</project.build.outputTimestamp>
- <version.maven-site-plugin>4.0.0-M16</version.maven-site-plugin>
- <version.maven-fluido-skin>2.0.0-M10</version.maven-fluido-skin>
- </properties>
-
-</project>
diff --git a/src/site/apt/index.apt b/src/site/apt/index.apt
deleted file mode 100644
index 7075194..0000000
--- a/src/site/apt/index.apt
+++ /dev/null
@@ -1,40 +0,0 @@
- ------
- Introduction
- ------
- Vincent Siveton
- ------
- 2008-07-15
- ------
-
-~~ 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.
-
-~~ NOTE: For help with the syntax of this file, see:
-~~ http://maven.apache.org/doxia/references/apt-format.html
-
-Maven Plugin Testing
-
- The Maven Plugin Testing Modules contains the necessary tools to be able to test Maven Plugins.
-
-* Matrix Comparison
-
-*-----------------------------------------------------------------------------+---------------------------------------------------------+
-|| <<Testing Module for Maven Plugins>> || <<Overview>>
-*-----------------------------------------------------------------------------+---------------------------------------------------------+
-| {{{./maven-plugin-testing-harness/index.html}maven-plugin-testing-harness}} | Framework to test Maven Plugins with Maven Mock projects.
-*-----------------------------------------------------------------------------+---------------------------------------------------------+
-
diff --git a/src/site/resources/download.cgi b/src/site/resources/download.cgi
deleted file mode 100644
index 1b178d2..0000000
--- a/src/site/resources/download.cgi
+++ /dev/null
@@ -1,22 +0,0 @@
-#!/bin/sh
-#
-# 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.
-#
-# Just call the standard mirrors.cgi script. It will use download.html
-# as the input template.
-exec /www/www.apache.org/dyn/mirrors/mirrors.cgi $*
\ No newline at end of file
diff --git a/src/site/site.xml b/src/site/site.xml
deleted file mode 100644
index 4c9563d..0000000
--- a/src/site/site.xml
+++ /dev/null
@@ -1,35 +0,0 @@
-<?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/DECORATION/1.8.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/DECORATION/1.8.0 https://maven.apache.org/xsd/decoration-1.8.0.xsd">
- <body>
-
- <menu name="Overview">
- <item name="Introduction" href="index.html"/>
- <!-- According to http://jira.codehaus.org/browse/MNGSITE-152 -->
- <item name="License" href="https://www.apache.org/licenses/"/>
- <item name="Download" href="download.html"/>
- </menu>
-
- <menu ref="modules" />
- </body>
-</project>
diff --git a/src/site/xdoc/download.xml.vm b/src/site/xdoc/download.xml.vm
deleted file mode 100644
index 413f12a..0000000
--- a/src/site/xdoc/download.xml.vm
+++ /dev/null
@@ -1,75 +0,0 @@
-<?xml version="1.0"?>
-
-<!--
-Licensed to the Apache Software Foundation (ASF) under one
-or more contributor license agreements. See the NOTICE file
-distributed with this work for additional information
-regarding copyright ownership. The ASF licenses this file
-to you under the Apache License, Version 2.0 (the
-"License"); you may not use this file except in compliance
-with the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing,
-software distributed under the License is distributed on an
-"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-KIND, either express or implied. See the License for the
-specific language governing permissions and limitations
-under the License.
--->
-
-<document>
- <properties>
- <title>Download ${project.name} Source</title>
- </properties>
-
- <body>
- <section name="Download ${project.name} ${project.version} Source">
-
- <p><strong>${project.name} ${project.version}</strong> is distributed in source format.</p>
-
- <p>Use a source archive if you intend to build <strong>${project.name}</strong> yourself.</p>
-
- <p>Otherwise, simply use the ready-made binary artifacts from <strong>central repository</strong>.</p>
-
- <p><strong>${project.name}</strong> is distributed under the <a href="https://www.apache.org/licenses/">Apache License, version 2.0</a>.</p>
-
- <subsection name="Files">
-
- <p>This is the current stable version of <strong>${project.name}</strong>.</p>
-
- <table>
- <thead>
- <tr>
- <th></th>
- <th>Link</th>
- <th>Checksum</th>
- <th>Signature</th>
- </tr>
- </thead>
- <tbody>
- <tr>
- <td>${project.name} ${project.version} (Source zip)</td>
- <td><a href="https://dlcdn.apache.org/maven/plugin-testing/${project.artifactId}-${project.version}-source-release.zip">${project.artifactId}-${project.version}-source-release.zip</a></td>
- <td><a href="https://downloads.apache.org/maven/plugin-testing/${project.artifactId}-${project.version}-source-release.zip.sha512">${project.artifactId}-${project.version}-source-release.zip.sha512</a></td>
- <td><a href="https://downloads.apache.org/maven/plugin-testing/${project.artifactId}-${project.version}-source-release.zip.asc">${project.artifactId}-${project.version}-source-release.zip.asc</a></td>
- </tr>
- </tbody>
- </table>
-
- <p>It is essential that you <a href="https://www.apache.org/info/verification.html">verify the integrity</a> of the downloaded file
- using the checksum (.sha512 file)
- or using the signature (.asc file) against the public <a href="https://downloads.apache.org/maven/KEYS">KEYS</a> used by the Apache Maven developers.
- </p>
-
- </subsection>
-
- <subsection name="Previous Versions">
- <p>It is strongly recommended to use the latest release version of <strong>${project.name}</strong> to take advantage of the newest features and bug fixes.</p>
- <p>Older non-recommended releases can be found on our <a href="https://archive.apache.org/dist/maven/plugin-testing/">archive site</a>.</p>
- </subsection>
- </section>
- </body>
-</document>
-