labs-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From simo...@apache.org
Subject svn commit: r718606 - in /labs/magma/trunk/maven-magma-plugin: ./ src/main/java/org/apache/magma/tools/maven/
Date Tue, 18 Nov 2008 14:24:26 GMT
Author: simoneg
Date: Tue Nov 18 06:24:25 2008
New Revision: 718606

URL: http://svn.apache.org/viewvc?rev=718606&view=rev
Log:
Support for magma.locals and other minor fixes

Modified:
    labs/magma/trunk/maven-magma-plugin/pom.xml
    labs/magma/trunk/maven-magma-plugin/src/main/java/org/apache/magma/tools/maven/JettyWeavingURLClassLoader.java
    labs/magma/trunk/maven-magma-plugin/src/main/java/org/apache/magma/tools/maven/MagmaJettyRun.java
    labs/magma/trunk/maven-magma-plugin/src/main/java/org/apache/magma/tools/maven/MagmaTestMojo.java

Modified: labs/magma/trunk/maven-magma-plugin/pom.xml
URL: http://svn.apache.org/viewvc/labs/magma/trunk/maven-magma-plugin/pom.xml?rev=718606&r1=718605&r2=718606&view=diff
==============================================================================
--- labs/magma/trunk/maven-magma-plugin/pom.xml (original)
+++ labs/magma/trunk/maven-magma-plugin/pom.xml Tue Nov 18 06:24:25 2008
@@ -23,7 +23,7 @@
 	<groupId>org.apache.magma.tools</groupId>
 	<artifactId>maven-magma-plugin</artifactId>
 	<name>Magma Extension Mojo</name>
-	<version>0.0.2-r2</version>
+	<version>0.0.2-r6</version>
 	<description>
 		Extends the AspectJ compiler plugin, surefire test plugin and
 		jetty plugin to better suite magma components.

Modified: labs/magma/trunk/maven-magma-plugin/src/main/java/org/apache/magma/tools/maven/JettyWeavingURLClassLoader.java
URL: http://svn.apache.org/viewvc/labs/magma/trunk/maven-magma-plugin/src/main/java/org/apache/magma/tools/maven/JettyWeavingURLClassLoader.java?rev=718606&r1=718605&r2=718606&view=diff
==============================================================================
--- labs/magma/trunk/maven-magma-plugin/src/main/java/org/apache/magma/tools/maven/JettyWeavingURLClassLoader.java
(original)
+++ labs/magma/trunk/maven-magma-plugin/src/main/java/org/apache/magma/tools/maven/JettyWeavingURLClassLoader.java
Tue Nov 18 06:24:25 2008
@@ -27,6 +27,7 @@
 import java.security.AccessController;
 import java.security.CodeSource;
 import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.Enumeration;
 import java.util.HashMap;
 import java.util.List;
@@ -76,6 +77,9 @@
 			}
 		}
 		this.context = context;
+		System.out.println("LTW setup");
+		System.out.println("All classses : " + Arrays.toString(classURLs));
+		System.out.println("Aspects : " + Arrays.toString(aspectURLs));
 	}
 	
 	private static String getAspectPath () {

Modified: labs/magma/trunk/maven-magma-plugin/src/main/java/org/apache/magma/tools/maven/MagmaJettyRun.java
URL: http://svn.apache.org/viewvc/labs/magma/trunk/maven-magma-plugin/src/main/java/org/apache/magma/tools/maven/MagmaJettyRun.java?rev=718606&r1=718605&r2=718606&view=diff
==============================================================================
--- labs/magma/trunk/maven-magma-plugin/src/main/java/org/apache/magma/tools/maven/MagmaJettyRun.java
(original)
+++ labs/magma/trunk/maven-magma-plugin/src/main/java/org/apache/magma/tools/maven/MagmaJettyRun.java
Tue Nov 18 06:24:25 2008
@@ -16,13 +16,17 @@
  */
 package org.apache.magma.tools.maven;
 
+import java.io.BufferedReader;
 import java.io.File;
+import java.io.FileReader;
 import java.io.IOException;
 import java.net.URL;
 import java.util.ArrayList;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Set;
+import java.util.zip.ZipEntry;
+import java.util.zip.ZipFile;
 
 import org.apache.maven.artifact.Artifact;
 import org.apache.maven.plugin.AbstractMojo;
@@ -142,7 +146,7 @@
         */
 		webapp.addServlet("org.apache.magma.website.Dispatch", "/*");
         
-        // Setup the classloader
+        // Setup the classloader		
         List urls = new ArrayList();
 		try {
 			List resources = project.getResources();
@@ -151,6 +155,35 @@
 				urls.add(new File(res.getDirectory()).toURI().toURL());
 			}
 			urls.add(this.classesDirectory.toURI().toURL());
+
+			// Check for a local paths file			
+			File locpaths = new File(project.getBasedir(), "magma.locals");
+			if (locpaths.exists()) {
+				FileReader fr = new FileReader(locpaths);
+				BufferedReader br = new BufferedReader(fr);
+				String line = null;
+				while ((line = br.readLine()) != null) {
+					File lpf = null;
+					if (line.startsWith(File.separator)) {
+						lpf = new File(line);
+					} else {
+						lpf = new File(project.getBasedir(), line);
+					}
+					if (lpf.exists() && lpf.isDirectory()) {
+						File pom = new File(lpf, "pom.xml");
+						if (pom.exists()) {
+							lpf = new File(lpf, "src/main/resources/");
+						}
+						if (lpf.exists()) {
+							urls.add(lpf.toURI().toURL());
+						} else {
+							getLog().warn("Cannot add to classpath " + lpf.getAbsolutePath() + " : it points to
a maven project without main resources");							
+						}
+					} else {
+						getLog().warn("Cannot add to classpath " + lpf.getAbsolutePath() + " : it is non existing
or not a directory");
+					}
+				}
+			}
 			
 			Set artifacts = project.getArtifacts();
 			for (Iterator iterator = artifacts.iterator(); iterator.hasNext();) {
@@ -162,7 +195,21 @@
 		}
 		
 		URL[] urlarray = (URL[]) urls.toArray(new URL[urls.size()]);
-        JettyWeavingURLClassLoader cl = new JettyWeavingURLClassLoader(urlarray, urlarray,
Thread.currentThread().getContextClassLoader(), webapp);
+		List<URL> aspects = new ArrayList<URL>();
+		for (URL url : urlarray) {
+			try {
+				File f = new File(url.toURI());
+				if (f.isDirectory()) {
+					aspects.add(url);
+				} else {
+					ZipFile zf = new ZipFile(f);
+					ZipEntry entry = zf.getEntry("META-INF/aop-ajc.xml");
+					if (entry != null) aspects.add(url);
+				}
+			} catch (Exception e) {
+			}
+		}
+        JettyWeavingURLClassLoader cl = new JettyWeavingURLClassLoader(urlarray, aspects.toArray(new
URL[] {}), Thread.currentThread().getContextClassLoader(), webapp);
         webapp.setClassLoader(cl);
 
 

Modified: labs/magma/trunk/maven-magma-plugin/src/main/java/org/apache/magma/tools/maven/MagmaTestMojo.java
URL: http://svn.apache.org/viewvc/labs/magma/trunk/maven-magma-plugin/src/main/java/org/apache/magma/tools/maven/MagmaTestMojo.java?rev=718606&r1=718605&r2=718606&view=diff
==============================================================================
--- labs/magma/trunk/maven-magma-plugin/src/main/java/org/apache/magma/tools/maven/MagmaTestMojo.java
(original)
+++ labs/magma/trunk/maven-magma-plugin/src/main/java/org/apache/magma/tools/maven/MagmaTestMojo.java
Tue Nov 18 06:24:25 2008
@@ -853,7 +853,7 @@
             String key = ArtifactUtils.versionlessKey( "org.apache.openjpa", "openjpa");
             Artifact art = (Artifact) projectArtifactMap.get(key);
             if (art != null) {
-                art = artifactFactory.createPluginArtifact("org.apache.magma.tools", "maven-magma-plugin",
VersionRange.createFromVersion("0.0.2-r2"));            	
+                art = artifactFactory.createPluginArtifact("org.apache.magma.tools", "maven-magma-plugin",
VersionRange.createFromVersion("0.0.2-r6"));            	
                 try {
 					artifactResolver.resolve(art, Collections.EMPTY_LIST, localRepository);
 				} catch (ArtifactResolutionException e) {



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@labs.apache.org
For additional commands, e-mail: commits-help@labs.apache.org


Mime
View raw message