Skip to content

Commit

Permalink
[MNG-8005] test for ide WorkspaceReader (apache#332)
Browse files Browse the repository at this point in the history
Adds an IT that verifies that "ide" WorkspaceReader is used by Maven.
Relates to fix apache/maven@3f47580
  • Loading branch information
jonasrutishauser authored Jan 18, 2024
1 parent 9bd5a81 commit da642e9
Show file tree
Hide file tree
Showing 8 changed files with 264 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -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:");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
28 changes: 28 additions & 0 deletions core-it-suite/src/test/resources/mng-8005/.mvn/extensions.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?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.
-->

<extensions>
<extension>
<groupId>org.apache.maven.its.8005</groupId>
<artifactId>ide-workspace-reader</artifactId>
<version>0.1</version>
</extension>
</extensions>
Empty file.
68 changes: 68 additions & 0 deletions core-it-suite/src/test/resources/mng-8005/extension/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
<?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>
<modelVersion>4.0.0</modelVersion>

<groupId>org.apache.maven.its.8005</groupId>
<artifactId>ide-workspace-reader</artifactId>
<version>0.1</version>
<packaging>jar</packaging>

<name>Maven Integration Test :: ide-workspace-reader</name>
<description>Ide Workspace Reader</description>

<!--
mvn clean deploy -DaltDeploymentRepository=default::default::file://
-->

<dependencies>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-core</artifactId>
<version>3.8.6</version>
<scope>provided</scope>
</dependency>

<dependency>
<groupId>javax.inject</groupId>
<artifactId>javax.inject</artifactId>
<version>1</version>
<scope>provided</scope>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.eclipse.sisu</groupId>
<artifactId>sisu-maven-plugin</artifactId>
<version>0.3.5</version>
<executions>
<execution>
<id>generate-index</id>
<goals>
<goal>main-index</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
Original file line number Diff line number Diff line change
@@ -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<String> findVersions(Artifact artifact) {
log.info("findVersions({})", artifact);
return Collections.emptyList();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?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.
-->

<extension>
<exportedPackages>
<exportedPackage>org.apache.maven.its.extensions</exportedPackage>
</exportedPackages>
</extension>
31 changes: 31 additions & 0 deletions core-it-suite/src/test/resources/mng-8005/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?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>
<modelVersion>4.0.0</modelVersion>

<groupId>org.apache.maven.its.8005</groupId>
<artifactId>test</artifactId>
<version>0.1</version>
<packaging>jar</packaging>

<name>Maven Integration Test :: mng-8005</name>
<description>Verify that Maven uses the ide workspace reader.</description>

</project>

0 comments on commit da642e9

Please sign in to comment.