mirror of https://github.com/apache/maven.git
Initial revision
git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@163098 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
9cc7a9e92b
commit
2e5828037e
|
@ -0,0 +1,14 @@
|
|||
Maven 1.x Integration
|
||||
|
||||
This component will internally spawn a complete Maven 1.x instance
|
||||
that will run a project from within m2, using a specified version of
|
||||
Maven 1.x.
|
||||
|
||||
This will allow a mix of m2 and m1 projects in a single organization
|
||||
with only one installation, aiding the transition.
|
||||
|
||||
Work in progress, Brett Porter, 18/8/04
|
||||
|
||||
|
||||
Currently it does require an m1 installation to obtain the plugins installed. It could potentially use
|
||||
the plugin descriptor file for this.
|
|
@ -0,0 +1,25 @@
|
|||
<?xml version="1.0" encoding="ISO-8859-1"?>
|
||||
|
||||
<project>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>maven</groupId>
|
||||
<artifactId>maven-component</artifactId>
|
||||
<version>2.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
<groupId>maven</groupId>
|
||||
<artifactId>maven-1.x-integration</artifactId>
|
||||
<name>Maven 1.x Compatibility</name>
|
||||
<version>2.0-SNAPSHOT</version>
|
||||
<inceptionYear>2004</inceptionYear>
|
||||
<package>org.apache.maven.legacy</package>
|
||||
|
||||
<!-- TODO: is there a way around this using classworlds? -->
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>forehead</groupId>
|
||||
<artifactId>forehead</artifactId>
|
||||
<version>1.0-beta-5</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
|
@ -0,0 +1,117 @@
|
|||
package org.apache.maven.legacy;
|
||||
|
||||
/*
|
||||
* Copyright 2001-2004 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.
|
||||
*/
|
||||
|
||||
import com.werken.forehead.Forehead;
|
||||
import com.werken.forehead.ForeheadClassLoader;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.util.Arrays;
|
||||
import java.util.Date;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import java.lang.reflect.*;
|
||||
import java.net.*;
|
||||
|
||||
import org.codehaus.plexus.logging.AbstractLogEnabled;
|
||||
|
||||
/**
|
||||
* @author <a href="mailto:brett@apache.org">Brett Porter</a>
|
||||
* @version $Id$
|
||||
*/
|
||||
public class DefaultMaven1xIntegration
|
||||
extends AbstractLogEnabled
|
||||
implements Maven1xIntegration
|
||||
{
|
||||
private String mavenHome;
|
||||
private String mavenHomeLocal;
|
||||
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// Execution
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
// TODO: may want an executionresponse returned? If so, that may need to be part of another component
|
||||
public void execute( File project, List goals )
|
||||
{
|
||||
// TODO: need real integration
|
||||
try
|
||||
{
|
||||
ClassLoader oldClassLoader = Thread.currentThread().getContextClassLoader();
|
||||
URL foreheadUrl = new File( mavenHome, "lib/forehead-1.0-beta-5.jar" ).toURL();
|
||||
File foreheadConf = new File( mavenHome, "bin/forehead.conf" );
|
||||
ClassLoader cl = URLClassLoader.newInstance( new URL[] { foreheadUrl } );
|
||||
Class c = Class.forName( "com.werken.forehead.Forehead", true, cl );
|
||||
Method m = c.getMethod( "getInstance", new Class[] {} );
|
||||
Object forehead = m.invoke( null, new Object[] {} );
|
||||
System.setProperty( "maven.home", mavenHome );
|
||||
System.setProperty( "tools.jar", "file:" + System.getProperty( "java.home" ) + "/lib/tools.jar" );
|
||||
m = c.getMethod( "config", new Class[] { java.io.InputStream.class } );
|
||||
m.invoke( forehead, new Object[] { new FileInputStream( foreheadConf ) } );
|
||||
|
||||
System.setProperty( "user.dir", project.getParentFile().getAbsolutePath() );
|
||||
/*m = c.getMethod( "getClassLoader", new Class[] { String.class } );
|
||||
cl = ( ClassLoader ) m.invoke( forehead, new Object[] { "root.maven" } );
|
||||
Thread.currentThread().setContextClassLoader( cl );
|
||||
c = Class.forName( "org.apache.maven.cli.App", true, cl );
|
||||
Object app = c.newInstance();
|
||||
m = c.getMethod( "initialize", new Class[] { String[].class } );
|
||||
m.invoke( app, new Object[] { (String[]) goals.toArray( new String[0] ) } );
|
||||
Object session = c.getDeclaredField( "mavenSession" ).get( app );
|
||||
m = session.getClass().getMethod( "initialize", new Class[0] );
|
||||
m.invoke( session, new Object[0] );
|
||||
m = session.getClass().getMethod( "getRootProject", new Class[0] );
|
||||
Object p = m.invoke( session, new Object[0] );
|
||||
m = session.getClass().getMethod( "attainGoals", new Class[] { p.getClass(), List.class } );
|
||||
m.invoke( session, new Object[] { p, goals } ); */
|
||||
|
||||
// TODO: this currently system.exit's
|
||||
m = c.getMethod( "run", new Class[] { String[].class } );
|
||||
m.invoke( forehead, new Object[] { (String[]) goals.toArray( new String[0] ) } );
|
||||
Thread.currentThread().setContextClassLoader( oldClassLoader );
|
||||
}
|
||||
catch ( Exception e )
|
||||
{
|
||||
// TODO: handle this
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public void setMavenHome( String mavenHome )
|
||||
{
|
||||
this.mavenHome = mavenHome;
|
||||
}
|
||||
|
||||
public String getMavenHome()
|
||||
{
|
||||
return mavenHome;
|
||||
}
|
||||
|
||||
public void setMavenHomeLocal( String mavenHomeLocal )
|
||||
{
|
||||
this.mavenHomeLocal = mavenHomeLocal;
|
||||
}
|
||||
|
||||
public String getMavenHomeLocal()
|
||||
{
|
||||
return mavenHomeLocal;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,54 @@
|
|||
package org.apache.maven.legacy;
|
||||
|
||||
/*
|
||||
* Copyright 2001-2004 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.
|
||||
*/
|
||||
|
||||
import java.io.File;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author <a href="mailto:brett@apache.org">Brett Porter</a>
|
||||
* @version $Id$
|
||||
*/
|
||||
public interface Maven1xIntegration
|
||||
{
|
||||
static String ROLE = Maven1xIntegration.class.getName();
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// Execution
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
void execute( File project, List goals );
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// Reactor execution
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
// TODO: perhaps?
|
||||
// ExecutionResponse executeReactor( String goal, String includes, String excludes );
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// Maven home
|
||||
// ----------------------------------------------------------------------
|
||||
void setMavenHome( String mavenHome );
|
||||
|
||||
String getMavenHome();
|
||||
|
||||
void setMavenHomeLocal( String mavenHomeLocal );
|
||||
|
||||
String getMavenHomeLocal();
|
||||
}
|
||||
|
|
@ -0,0 +1,16 @@
|
|||
<component-set>
|
||||
<components>
|
||||
|
||||
<!--
|
||||
|
|
||||
| Maven 1.x Integration Interface
|
||||
|
|
||||
-->
|
||||
<component>
|
||||
<role>org.apache.maven.legacy.Maven1xIntegration</role>
|
||||
<implementation>org.apache.maven.legacy.DefaultMaven1xIntegration</implementation>
|
||||
</component>
|
||||
|
||||
</components>
|
||||
</component-set>
|
||||
|
Loading…
Reference in New Issue