mirror of https://github.com/apache/maven.git
PR: MNG-824
Submitted by: Edwin Punzalan Reviewed by: Brett Porter add goals that are in the m1 version git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@280260 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
fe3df1bd1d
commit
6b229cd09a
|
@ -0,0 +1,78 @@
|
|||
package org.apache.maven.plugin.eclipse;
|
||||
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
import org.apache.maven.artifact.repository.ArtifactRepository;
|
||||
import org.apache.maven.plugin.AbstractMojo;
|
||||
import org.apache.maven.plugin.MojoExecutionException;
|
||||
|
||||
/**
|
||||
* A Maven2 plugin to ensure that the classpath variable MAVEN_REPO exists in the Eclipse environment.
|
||||
*
|
||||
* @goal add-maven-repo
|
||||
*/
|
||||
public class AddMavenRepoMojo extends AbstractMojo
|
||||
{
|
||||
/**
|
||||
* Location of the <code>Eclipse</code> workspace that holds your configuration and source.
|
||||
*
|
||||
* On Windows, this will be the <code>workspace</code> directory under your eclipse
|
||||
* installation. For example, if you installed eclipse into <code>c:\eclipse</code>, the
|
||||
* workspace is <code>c:\eclipse\workspace</code>.
|
||||
*
|
||||
* @parameter
|
||||
* @required
|
||||
*/
|
||||
private String workspace;
|
||||
|
||||
/**
|
||||
* @parameter expression="${localRepository}"
|
||||
* @required
|
||||
* @readonly
|
||||
*/
|
||||
private ArtifactRepository localRepository;
|
||||
|
||||
public void execute() throws MojoExecutionException
|
||||
{
|
||||
workspace += "X";
|
||||
|
||||
File workDir = new File( workspace, ".metadata/.plugins/org.eclipse.core.runtime/.settings" );
|
||||
|
||||
workDir.mkdirs();
|
||||
|
||||
File f = new File( workDir.getAbsolutePath(), "org.eclipse.jdt.core.prefs" );
|
||||
|
||||
try
|
||||
{
|
||||
FileWriter fWriter = new FileWriter( f );
|
||||
|
||||
fWriter.write( "\norg.eclipse.jdt.core.classpathVariable.MAVEN_REPO=" + localRepository.getBasedir() );
|
||||
|
||||
fWriter.flush();
|
||||
|
||||
fWriter.close();
|
||||
}
|
||||
catch( IOException ioe )
|
||||
{
|
||||
throw new MojoExecutionException( "Unable to write to file: " + f.getAbsolutePath() );
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,65 @@
|
|||
package org.apache.maven.plugin.eclipse;
|
||||
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
|
||||
import java.io.File;
|
||||
import org.apache.maven.plugin.AbstractMojo;
|
||||
import org.apache.maven.plugin.MojoExecutionException;
|
||||
|
||||
|
||||
/**
|
||||
* A Maven2 plugin to delete the .project and .classpath files needed for Eclipse
|
||||
*
|
||||
* @goal clean
|
||||
*/
|
||||
public class EclipseCleanMojo extends AbstractMojo
|
||||
{
|
||||
/**
|
||||
* @parameter expression="${project.basedir}"
|
||||
*/
|
||||
private String basedir;
|
||||
|
||||
public void execute() throws MojoExecutionException
|
||||
{
|
||||
File f = new File( basedir, ".project" );
|
||||
|
||||
getLog().info( "Deleting project file..." );
|
||||
if ( f.exists() )
|
||||
{
|
||||
if ( !f.delete() )
|
||||
{
|
||||
throw new MojoExecutionException( "Failed to delete project file: " + f.getAbsolutePath() );
|
||||
}
|
||||
}
|
||||
else
|
||||
getLog().info( "No .project file found." );
|
||||
|
||||
f = new File( basedir, ".classpath" );
|
||||
|
||||
getLog().info( "Deleting classpath file..." );
|
||||
if ( f.exists() )
|
||||
{
|
||||
if ( !f.delete() )
|
||||
{
|
||||
throw new MojoExecutionException( "Failed to delete classpath file: " + f.getAbsolutePath() );
|
||||
}
|
||||
}
|
||||
else
|
||||
getLog().info( "No .classpath file found." );
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue