diff --git a/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng8005IdeWorkspaceReaderUsedTest.java b/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng8005IdeWorkspaceReaderUsedTest.java new file mode 100644 index 000000000..8394636c8 --- /dev/null +++ b/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng8005IdeWorkspaceReaderUsedTest.java @@ -0,0 +1,48 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.maven.it; + +import java.io.File; + +import org.apache.maven.shared.verifier.Verifier; +import org.apache.maven.shared.verifier.util.ResourceExtractor; +import org.junit.jupiter.api.Test; + +public class MavenITmng8005IdeWorkspaceReaderUsedTest extends AbstractMavenIntegrationTestCase { + public MavenITmng8005IdeWorkspaceReaderUsedTest() { + super("(3.5.0,)"); + } + + @Test + public void testWithIdeWorkspaceReaderUsed() throws Exception { + File testDir = ResourceExtractor.simpleExtractResources(getClass(), "/mng-8005"); + + Verifier verifier = newVerifier(new File(testDir, "extension").getAbsolutePath()); + verifier.addCliArgument("install"); + verifier.execute(); + verifier.verifyErrorFreeLog(); + + verifier = newVerifier(testDir.getAbsolutePath()); + + verifier.addCliArgument("process-resources"); + verifier.execute(); + + verifier.verifyTextInLog("[INFO] findArtifact(org.apache.maven.plugins:maven-resources-plugin:pom:"); + } +} diff --git a/core-it-suite/src/test/java/org/apache/maven/it/TestSuiteOrdering.java b/core-it-suite/src/test/java/org/apache/maven/it/TestSuiteOrdering.java index 39faaec32..27fe7d9d0 100644 --- a/core-it-suite/src/test/java/org/apache/maven/it/TestSuiteOrdering.java +++ b/core-it-suite/src/test/java/org/apache/maven/it/TestSuiteOrdering.java @@ -120,6 +120,7 @@ public TestSuiteOrdering() { * the tests are to finishing. Newer tests are also more likely to fail, so this is * a fail fast technique as well. */ + suite.addTestSuite(MavenITmng8005IdeWorkspaceReaderUsedTest.class); suite.addTestSuite(MavenITmng7967ArtifactHandlerLanguageTest.class); suite.addTestSuite(MavenITmng7965PomDuplicateTagsTest.class); suite.addTestSuite(MavenITmng7939PluginsValidationExcludesTest.class); diff --git a/core-it-suite/src/test/resources/mng-8005/.mvn/extensions.xml b/core-it-suite/src/test/resources/mng-8005/.mvn/extensions.xml new file mode 100644 index 000000000..b2c1c4896 --- /dev/null +++ b/core-it-suite/src/test/resources/mng-8005/.mvn/extensions.xml @@ -0,0 +1,28 @@ + + + + + + + org.apache.maven.its.8005 + ide-workspace-reader + 0.1 + + diff --git a/core-it-suite/src/test/resources/mng-8005/extension/.mvn/.gitkeep b/core-it-suite/src/test/resources/mng-8005/extension/.mvn/.gitkeep new file mode 100644 index 000000000..e69de29bb diff --git a/core-it-suite/src/test/resources/mng-8005/extension/pom.xml b/core-it-suite/src/test/resources/mng-8005/extension/pom.xml new file mode 100644 index 000000000..7b29c040a --- /dev/null +++ b/core-it-suite/src/test/resources/mng-8005/extension/pom.xml @@ -0,0 +1,68 @@ + + + + 4.0.0 + + org.apache.maven.its.8005 + ide-workspace-reader + 0.1 + jar + + Maven Integration Test :: ide-workspace-reader + Ide Workspace Reader + + + + + + org.apache.maven + maven-core + 3.8.6 + provided + + + + javax.inject + javax.inject + 1 + provided + + + + + + + org.eclipse.sisu + sisu-maven-plugin + 0.3.5 + + + generate-index + + main-index + + + + + + + diff --git a/core-it-suite/src/test/resources/mng-8005/extension/src/main/java/org/apache/maven/its/extensions/IdeWorkspaceReader.java b/core-it-suite/src/test/resources/mng-8005/extension/src/main/java/org/apache/maven/its/extensions/IdeWorkspaceReader.java new file mode 100644 index 000000000..5b794f35d --- /dev/null +++ b/core-it-suite/src/test/resources/mng-8005/extension/src/main/java/org/apache/maven/its/extensions/IdeWorkspaceReader.java @@ -0,0 +1,62 @@ +/* + * 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.its.extensions; + +import javax.inject.Named; +import javax.inject.Singleton; + +import java.io.File; +import java.util.Collections; +import java.util.List; + +import org.eclipse.aether.artifact.Artifact; +import org.eclipse.aether.repository.WorkspaceReader; +import org.eclipse.aether.repository.WorkspaceRepository; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +@Named("ide") +@Singleton +public class IdeWorkspaceReader implements WorkspaceReader { + + private static final Logger log = LoggerFactory.getLogger(IdeWorkspaceReader.class); + + private final WorkspaceRepository repository = new WorkspaceRepository(); + + public IdeWorkspaceReader() { + log.info("created"); + } + + @Override + public WorkspaceRepository getRepository() { + return repository; + } + + @Override + public File findArtifact(Artifact artifact) { + log.info("findArtifact({})", artifact); + return null; + } + + @Override + public List findVersions(Artifact artifact) { + log.info("findVersions({})", artifact); + return Collections.emptyList(); + } +} diff --git a/core-it-suite/src/test/resources/mng-8005/extension/src/main/resources/META-INF/maven/extension.xml b/core-it-suite/src/test/resources/mng-8005/extension/src/main/resources/META-INF/maven/extension.xml new file mode 100644 index 000000000..dc3b4f545 --- /dev/null +++ b/core-it-suite/src/test/resources/mng-8005/extension/src/main/resources/META-INF/maven/extension.xml @@ -0,0 +1,26 @@ + + + + + + + org.apache.maven.its.extensions + + \ No newline at end of file diff --git a/core-it-suite/src/test/resources/mng-8005/pom.xml b/core-it-suite/src/test/resources/mng-8005/pom.xml new file mode 100644 index 000000000..90f9325b5 --- /dev/null +++ b/core-it-suite/src/test/resources/mng-8005/pom.xml @@ -0,0 +1,31 @@ + + + + 4.0.0 + + org.apache.maven.its.8005 + test + 0.1 + jar + + Maven Integration Test :: mng-8005 + Verify that Maven uses the ide workspace reader. + +