You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@maven.apache.org by br...@apache.org on 2005/09/12 07:32:26 UTC

svn commit: r280260 - in /maven/components/trunk/maven-plugins/maven-eclipse-plugin/src/main/java/org/apache/maven/plugin/eclipse: AddMavenRepoMojo.java EclipseCleanMojo.java

Author: brett
Date: Sun Sep 11 22:32:22 2005
New Revision: 280260

URL: http://svn.apache.org/viewcvs?rev=280260&view=rev
Log:
PR: MNG-824
Submitted by: Edwin Punzalan
Reviewed by:  Brett Porter
add goals that are in the m1 version

Added:
    maven/components/trunk/maven-plugins/maven-eclipse-plugin/src/main/java/org/apache/maven/plugin/eclipse/AddMavenRepoMojo.java   (with props)
    maven/components/trunk/maven-plugins/maven-eclipse-plugin/src/main/java/org/apache/maven/plugin/eclipse/EclipseCleanMojo.java   (with props)

Added: maven/components/trunk/maven-plugins/maven-eclipse-plugin/src/main/java/org/apache/maven/plugin/eclipse/AddMavenRepoMojo.java
URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-plugins/maven-eclipse-plugin/src/main/java/org/apache/maven/plugin/eclipse/AddMavenRepoMojo.java?rev=280260&view=auto
==============================================================================
--- maven/components/trunk/maven-plugins/maven-eclipse-plugin/src/main/java/org/apache/maven/plugin/eclipse/AddMavenRepoMojo.java (added)
+++ maven/components/trunk/maven-plugins/maven-eclipse-plugin/src/main/java/org/apache/maven/plugin/eclipse/AddMavenRepoMojo.java Sun Sep 11 22:32:22 2005
@@ -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() );
+        }
+    }
+}

Propchange: maven/components/trunk/maven-plugins/maven-eclipse-plugin/src/main/java/org/apache/maven/plugin/eclipse/AddMavenRepoMojo.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/components/trunk/maven-plugins/maven-eclipse-plugin/src/main/java/org/apache/maven/plugin/eclipse/AddMavenRepoMojo.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Added: maven/components/trunk/maven-plugins/maven-eclipse-plugin/src/main/java/org/apache/maven/plugin/eclipse/EclipseCleanMojo.java
URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-plugins/maven-eclipse-plugin/src/main/java/org/apache/maven/plugin/eclipse/EclipseCleanMojo.java?rev=280260&view=auto
==============================================================================
--- maven/components/trunk/maven-plugins/maven-eclipse-plugin/src/main/java/org/apache/maven/plugin/eclipse/EclipseCleanMojo.java (added)
+++ maven/components/trunk/maven-plugins/maven-eclipse-plugin/src/main/java/org/apache/maven/plugin/eclipse/EclipseCleanMojo.java Sun Sep 11 22:32:22 2005
@@ -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." );
+    }
+}

Propchange: maven/components/trunk/maven-plugins/maven-eclipse-plugin/src/main/java/org/apache/maven/plugin/eclipse/EclipseCleanMojo.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/components/trunk/maven-plugins/maven-eclipse-plugin/src/main/java/org/apache/maven/plugin/eclipse/EclipseCleanMojo.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
For additional commands, e-mail: dev-help@maven.apache.org