Skip to content

Commit da642e9

Browse files
[MNG-8005] test for ide WorkspaceReader (apache#332)
Adds an IT that verifies that "ide" WorkspaceReader is used by Maven. Relates to fix apache/maven@3f47580
1 parent 9bd5a81 commit da642e9

File tree

8 files changed

+264
-0
lines changed

8 files changed

+264
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
package org.apache.maven.it;
20+
21+
import java.io.File;
22+
23+
import org.apache.maven.shared.verifier.Verifier;
24+
import org.apache.maven.shared.verifier.util.ResourceExtractor;
25+
import org.junit.jupiter.api.Test;
26+
27+
public class MavenITmng8005IdeWorkspaceReaderUsedTest extends AbstractMavenIntegrationTestCase {
28+
public MavenITmng8005IdeWorkspaceReaderUsedTest() {
29+
super("(3.5.0,)");
30+
}
31+
32+
@Test
33+
public void testWithIdeWorkspaceReaderUsed() throws Exception {
34+
File testDir = ResourceExtractor.simpleExtractResources(getClass(), "/mng-8005");
35+
36+
Verifier verifier = newVerifier(new File(testDir, "extension").getAbsolutePath());
37+
verifier.addCliArgument("install");
38+
verifier.execute();
39+
verifier.verifyErrorFreeLog();
40+
41+
verifier = newVerifier(testDir.getAbsolutePath());
42+
43+
verifier.addCliArgument("process-resources");
44+
verifier.execute();
45+
46+
verifier.verifyTextInLog("[INFO] findArtifact(org.apache.maven.plugins:maven-resources-plugin:pom:");
47+
}
48+
}

core-it-suite/src/test/java/org/apache/maven/it/TestSuiteOrdering.java

+1
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@ public TestSuiteOrdering() {
120120
* the tests are to finishing. Newer tests are also more likely to fail, so this is
121121
* a fail fast technique as well.
122122
*/
123+
suite.addTestSuite(MavenITmng8005IdeWorkspaceReaderUsedTest.class);
123124
suite.addTestSuite(MavenITmng7967ArtifactHandlerLanguageTest.class);
124125
suite.addTestSuite(MavenITmng7965PomDuplicateTagsTest.class);
125126
suite.addTestSuite(MavenITmng7939PluginsValidationExcludesTest.class);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
3+
<!--
4+
Licensed to the Apache Software Foundation (ASF) under one
5+
or more contributor license agreements. See the NOTICE file
6+
distributed with this work for additional information
7+
regarding copyright ownership. The ASF licenses this file
8+
to you under the Apache License, Version 2.0 (the
9+
"License"); you may not use this file except in compliance
10+
with the License. You may obtain a copy of the License at
11+
12+
http://www.apache.org/licenses/LICENSE-2.0
13+
14+
Unless required by applicable law or agreed to in writing,
15+
software distributed under the License is distributed on an
16+
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17+
KIND, either express or implied. See the License for the
18+
specific language governing permissions and limitations
19+
under the License.
20+
-->
21+
22+
<extensions>
23+
<extension>
24+
<groupId>org.apache.maven.its.8005</groupId>
25+
<artifactId>ide-workspace-reader</artifactId>
26+
<version>0.1</version>
27+
</extension>
28+
</extensions>

core-it-suite/src/test/resources/mng-8005/extension/.mvn/.gitkeep

Whitespace-only changes.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
Licensed to the Apache Software Foundation (ASF) under one
4+
or more contributor license agreements. See the NOTICE file
5+
distributed with this work for additional information
6+
regarding copyright ownership. The ASF licenses this file
7+
to you under the Apache License, Version 2.0 (the
8+
"License"); you may not use this file except in compliance
9+
with the License. You may obtain a copy of the License at
10+
11+
http://www.apache.org/licenses/LICENSE-2.0
12+
13+
Unless required by applicable law or agreed to in writing,
14+
software distributed under the License is distributed on an
15+
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16+
KIND, either express or implied. See the License for the
17+
specific language governing permissions and limitations
18+
under the License.
19+
-->
20+
<project>
21+
<modelVersion>4.0.0</modelVersion>
22+
23+
<groupId>org.apache.maven.its.8005</groupId>
24+
<artifactId>ide-workspace-reader</artifactId>
25+
<version>0.1</version>
26+
<packaging>jar</packaging>
27+
28+
<name>Maven Integration Test :: ide-workspace-reader</name>
29+
<description>Ide Workspace Reader</description>
30+
31+
<!--
32+
mvn clean deploy -DaltDeploymentRepository=default::default::file://
33+
-->
34+
35+
<dependencies>
36+
<dependency>
37+
<groupId>org.apache.maven</groupId>
38+
<artifactId>maven-core</artifactId>
39+
<version>3.8.6</version>
40+
<scope>provided</scope>
41+
</dependency>
42+
43+
<dependency>
44+
<groupId>javax.inject</groupId>
45+
<artifactId>javax.inject</artifactId>
46+
<version>1</version>
47+
<scope>provided</scope>
48+
</dependency>
49+
</dependencies>
50+
51+
<build>
52+
<plugins>
53+
<plugin>
54+
<groupId>org.eclipse.sisu</groupId>
55+
<artifactId>sisu-maven-plugin</artifactId>
56+
<version>0.3.5</version>
57+
<executions>
58+
<execution>
59+
<id>generate-index</id>
60+
<goals>
61+
<goal>main-index</goal>
62+
</goals>
63+
</execution>
64+
</executions>
65+
</plugin>
66+
</plugins>
67+
</build>
68+
</project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
package org.apache.maven.its.extensions;
20+
21+
import javax.inject.Named;
22+
import javax.inject.Singleton;
23+
24+
import java.io.File;
25+
import java.util.Collections;
26+
import java.util.List;
27+
28+
import org.eclipse.aether.artifact.Artifact;
29+
import org.eclipse.aether.repository.WorkspaceReader;
30+
import org.eclipse.aether.repository.WorkspaceRepository;
31+
import org.slf4j.Logger;
32+
import org.slf4j.LoggerFactory;
33+
34+
@Named("ide")
35+
@Singleton
36+
public class IdeWorkspaceReader implements WorkspaceReader {
37+
38+
private static final Logger log = LoggerFactory.getLogger(IdeWorkspaceReader.class);
39+
40+
private final WorkspaceRepository repository = new WorkspaceRepository();
41+
42+
public IdeWorkspaceReader() {
43+
log.info("created");
44+
}
45+
46+
@Override
47+
public WorkspaceRepository getRepository() {
48+
return repository;
49+
}
50+
51+
@Override
52+
public File findArtifact(Artifact artifact) {
53+
log.info("findArtifact({})", artifact);
54+
return null;
55+
}
56+
57+
@Override
58+
public List<String> findVersions(Artifact artifact) {
59+
log.info("findVersions({})", artifact);
60+
return Collections.emptyList();
61+
}
62+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
3+
<!--
4+
Licensed to the Apache Software Foundation (ASF) under one
5+
or more contributor license agreements. See the NOTICE file
6+
distributed with this work for additional information
7+
regarding copyright ownership. The ASF licenses this file
8+
to you under the Apache License, Version 2.0 (the
9+
"License"); you may not use this file except in compliance
10+
with the License. You may obtain a copy of the License at
11+
12+
http://www.apache.org/licenses/LICENSE-2.0
13+
14+
Unless required by applicable law or agreed to in writing,
15+
software distributed under the License is distributed on an
16+
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17+
KIND, either express or implied. See the License for the
18+
specific language governing permissions and limitations
19+
under the License.
20+
-->
21+
22+
<extension>
23+
<exportedPackages>
24+
<exportedPackage>org.apache.maven.its.extensions</exportedPackage>
25+
</exportedPackages>
26+
</extension>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
Licensed to the Apache Software Foundation (ASF) under one
4+
or more contributor license agreements. See the NOTICE file
5+
distributed with this work for additional information
6+
regarding copyright ownership. The ASF licenses this file
7+
to you under the Apache License, Version 2.0 (the
8+
"License"); you may not use this file except in compliance
9+
with the License. You may obtain a copy of the License at
10+
11+
http://www.apache.org/licenses/LICENSE-2.0
12+
13+
Unless required by applicable law or agreed to in writing,
14+
software distributed under the License is distributed on an
15+
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16+
KIND, either express or implied. See the License for the
17+
specific language governing permissions and limitations
18+
under the License.
19+
-->
20+
<project>
21+
<modelVersion>4.0.0</modelVersion>
22+
23+
<groupId>org.apache.maven.its.8005</groupId>
24+
<artifactId>test</artifactId>
25+
<version>0.1</version>
26+
<packaging>jar</packaging>
27+
28+
<name>Maven Integration Test :: mng-8005</name>
29+
<description>Verify that Maven uses the ide workspace reader.</description>
30+
31+
</project>

0 commit comments

Comments
 (0)