diff --git a/maven-embedder-it/pom.xml b/maven-embedder-it/pom.xml new file mode 100644 index 0000000000..f8cc9d1c5f --- /dev/null +++ b/maven-embedder-it/pom.xml @@ -0,0 +1,20 @@ + + + maven + org.apache.maven + 2.0-beta-2-SNAPSHOT + + 4.0.0 + org.apache.maven + maven-embedder-it + Maven Embedder Integration Tests + 2.0-beta-2-SNAPSHOT + + + org.apache.maven + maven-embedder + 2.0-beta-2-SNAPSHOT + dep + + + diff --git a/maven-embedder-it/src/main/java/org/apache/maven/embedder/it/MockPlugin.java b/maven-embedder-it/src/main/java/org/apache/maven/embedder/it/MockPlugin.java new file mode 100644 index 0000000000..034005b2ac --- /dev/null +++ b/maven-embedder-it/src/main/java/org/apache/maven/embedder/it/MockPlugin.java @@ -0,0 +1,49 @@ +package org.apache.maven.embedder.it; + +import org.apache.maven.embedder.MavenEmbedder; +import org.apache.maven.model.Model; + +import java.io.File;/* + * Copyright 2001-2005 The Apache Software Foundation. + * + * Licensed 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. + */ + +/** + * A mock tool plugin that uses the Maven Embedder API + * + * @author Jason van Zyl + * @version $Id:$ + */ +public class MockPlugin +{ + private MavenEmbedder maven; + + public MockPlugin() + throws Exception + { + ClassLoader classLoader = Thread.currentThread().getContextClassLoader(); + + maven = new MavenEmbedder(); + + maven.setClassLoader( classLoader ); + + maven.start(); + } + + public Model readModel( File model ) + throws Exception + { + return maven.readModel( model ); + } +} diff --git a/maven-embedder-it/src/test/java/org/apache/maven/embedder/it/MockPluginTest.java b/maven-embedder-it/src/test/java/org/apache/maven/embedder/it/MockPluginTest.java new file mode 100644 index 0000000000..13846ab7c3 --- /dev/null +++ b/maven-embedder-it/src/test/java/org/apache/maven/embedder/it/MockPluginTest.java @@ -0,0 +1,40 @@ +package org.apache.maven.embedder.it; + +import junit.framework.TestCase; +import org.apache.maven.model.Model; + +import java.io.File;/* + * Copyright 2001-2005 The Apache Software Foundation. + * + * Licensed 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. + */ + +/** + * @author Jason van Zyl + * @version $Id:$ + */ +public class MockPluginTest + extends TestCase +{ + public void testMockPlugin() + throws Exception + { + MockPlugin plugin = new MockPlugin(); + + String basedir = System.getProperty( "basedir" ); + + Model model = plugin.readModel( new File( basedir, "pom.xml" ) ); + + assertEquals( "org.apache.maven", model.getGroupId() ); + } +}