[MNG-6389] Move the toolchains model to a separate artifactId

Closes #586
This commit is contained in:
Giovanni van der Schelde 2021-09-29 13:44:08 +02:00 committed by Maarten Mulders
parent 8852b87412
commit ffc2b99e3e
29 changed files with 183 additions and 26 deletions

View File

@ -128,6 +128,16 @@ under the License.
<artifactId>maven-settings-builder</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-toolchain-model</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-toolchain-builder</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-slf4j-wrapper</artifactId>

View File

@ -52,6 +52,14 @@ under the License.
<groupId>org.apache.maven</groupId>
<artifactId>maven-builder-support</artifactId>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-toolchain-model</artifactId>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-toolchain-builder</artifactId>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-repository-metadata</artifactId>
@ -212,12 +220,12 @@ under the License.
<artifactId>modello-maven-plugin</artifactId>
<configuration>
<version>1.1.0</version>
<models>
<model>src/main/mdo/toolchains.mdo</model>
</models>
<!-- This is a required attribute and is intentionally left empty -->
<models></models>
</configuration>
<executions>
<execution>
<!-- This step is required to generate xdoc, and does not generate java code -->
<id>modello-site-doc</id>
<phase>pre-site</phase>
<goals>

View File

@ -25,13 +25,11 @@
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import java.io.InputStream;
import java.util.Collections;
import org.apache.maven.toolchain.java.DefaultJavaToolChain;
import org.apache.maven.toolchain.model.PersistedToolchains;
import org.apache.maven.toolchain.model.ToolchainModel;
import org.apache.maven.toolchain.model.io.xpp3.MavenToolchainsXpp3Reader;
import org.codehaus.plexus.util.xml.Xpp3Dom;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.mockito.MockitoAnnotations;
@ -41,8 +39,6 @@ public class DefaultToolchainTest
{
private final Logger logger = mock( Logger.class );
private MavenToolchainsXpp3Reader reader = new MavenToolchainsXpp3Reader();
@BeforeEach
public void setUp()
throws Exception
@ -129,21 +125,33 @@ public void testNonMatchingRequirementProperty()
@Test
public void testEquals()
throws Exception
{
try ( InputStream jdksIS = ToolchainModel.class.getResourceAsStream( "toolchains-jdks.xml" );
InputStream jdksExtraIS = ToolchainModel.class.getResourceAsStream( "toolchains-jdks-extra.xml" ) )
{
PersistedToolchains jdks = reader.read( jdksIS );
PersistedToolchains jdksExtra = reader.read( jdksExtraIS );
ToolchainModel tm1 = new ToolchainModel();
tm1.setType( "jdk" );
tm1.addProvide( "version", "1.5" );
tm1.addProvide( "vendor", "sun" );
Xpp3Dom configuration1 = new Xpp3Dom("configuration");
Xpp3Dom jdkHome1 = new Xpp3Dom( "jdkHome" );
jdkHome1.setValue("${env.JAVA_HOME}");
configuration1.addChild( jdkHome1 );
tm1.setConfiguration( configuration1 );
DefaultToolchain tc1 = new DefaultJavaToolChain( jdks.getToolchains().get( 0 ), null );
DefaultToolchain tc2 = new DefaultJavaToolChain( jdksExtra.getToolchains().get( 0 ), null );
ToolchainModel tm2 = new ToolchainModel();
tm1.setType( "jdk" );
tm1.addProvide( "version", "1.4" );
tm1.addProvide( "vendor", "sun" );
Xpp3Dom configuration2 = new Xpp3Dom("configuration");
Xpp3Dom jdkHome2 = new Xpp3Dom( "jdkHome" );
jdkHome2.setValue("${env.JAVA_HOME}");
configuration2.addChild( jdkHome2 );
tm2.setConfiguration( configuration2 );
assertEquals( tc1, tc1 );
assertNotEquals( tc1, tc2 );
assertNotEquals( tc2, tc1 );
assertEquals( tc2, tc2 );
}
DefaultToolchain tc1 = new DefaultJavaToolChain( tm1, null );
DefaultToolchain tc2 = new DefaultJavaToolChain( tm2, null );
assertEquals( tc1, tc1 );
assertNotEquals( tc1, tc2 );
assertNotEquals( tc2, tc1 );
assertEquals( tc2, tc2 );
}
}

View File

@ -0,0 +1,70 @@
<?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">
<parent>
<artifactId>maven</artifactId>
<groupId>org.apache.maven</groupId>
<version>4.0.0-alpha-1-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>maven-toolchain-builder</artifactId>
<name>Maven Toolchain Builder</name>
<description>The effective toolchain builder.</description>
<dependencies>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-toolchain-model</artifactId>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-builder-support</artifactId>
</dependency>
<dependency>
<groupId>javax.inject</groupId>
<artifactId>javax.inject</artifactId>
</dependency>
<dependency>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-interpolation</artifactId>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.eclipse.sisu</groupId>
<artifactId>sisu-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>

View File

@ -27,8 +27,8 @@
import org.apache.maven.toolchain.model.ToolchainModel;
import org.codehaus.plexus.interpolation.os.OperatingSystemUtils;
import org.codehaus.plexus.util.xml.Xpp3Dom;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.mockito.ArgumentMatchers;
import org.mockito.InjectMocks;
import org.mockito.MockitoAnnotations;

View File

@ -19,15 +19,15 @@
* under the License.
*/
import static org.junit.jupiter.api.Assertions.assertEquals;
import java.util.Collections;
import org.apache.maven.building.Problem;
import org.apache.maven.building.ProblemCollector;
import org.apache.maven.building.ProblemCollectorFactory;
import org.junit.jupiter.api.Test;
import java.util.Collections;
import static org.junit.jupiter.api.Assertions.assertEquals;
public class ToolchainsBuildingExceptionTest
{
private static final String LS = System.lineSeparator();

View File

@ -0,0 +1,59 @@
<?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">
<parent>
<artifactId>maven</artifactId>
<groupId>org.apache.maven</groupId>
<version>4.0.0-alpha-1-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>maven-toolchain-model</artifactId>
<name>Maven Toolchain Model</name>
<description>Maven Toolchain model.</description>
<dependencies>
<dependency>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-utils</artifactId>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.modello</groupId>
<artifactId>modello-maven-plugin</artifactId>
<configuration>
<version>1.1.0</version>
<models>
<model>src/main/mdo/toolchains.mdo</model>
</models>
</configuration>
</plugin>
</plugins>
</build>
</project>

View File

@ -98,6 +98,8 @@ under the License.
<module>apache-maven</module> <!-- rename to apache-maven/maven.pom after RAT-268 -->
<module>maven-wrapper</module>
<module>apache-maven/maven-wrapper.pom</module>
<module>maven-toolchain-model</module>
<module>maven-toolchain-builder</module>
</modules>
<scm>

Binary file not shown.