geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sppa...@apache.org
Subject svn commit: r492650 - in /geronimo/devtools/eclipse-plugin/branches/1.2.1: maven-plugins/maven-geronimodevtools-plugin/src/main/java/org/apache/geronimo/eclipse/devtools/BundleManifestMojo.java plugins/pom.xml
Date Thu, 04 Jan 2007 17:44:54 GMT
Author: sppatel
Date: Thu Jan  4 09:44:53 2007
New Revision: 492650

URL: http://svn.apache.org/viewvc?view=rev&rev=492650
Log:
validate manifest's bundleclasspath after required libs are copied into bundle

Modified:
    geronimo/devtools/eclipse-plugin/branches/1.2.1/maven-plugins/maven-geronimodevtools-plugin/src/main/java/org/apache/geronimo/eclipse/devtools/BundleManifestMojo.java
    geronimo/devtools/eclipse-plugin/branches/1.2.1/plugins/pom.xml

Modified: geronimo/devtools/eclipse-plugin/branches/1.2.1/maven-plugins/maven-geronimodevtools-plugin/src/main/java/org/apache/geronimo/eclipse/devtools/BundleManifestMojo.java
URL: http://svn.apache.org/viewvc/geronimo/devtools/eclipse-plugin/branches/1.2.1/maven-plugins/maven-geronimodevtools-plugin/src/main/java/org/apache/geronimo/eclipse/devtools/BundleManifestMojo.java?view=diff&rev=492650&r1=492649&r2=492650
==============================================================================
--- geronimo/devtools/eclipse-plugin/branches/1.2.1/maven-plugins/maven-geronimodevtools-plugin/src/main/java/org/apache/geronimo/eclipse/devtools/BundleManifestMojo.java
(original)
+++ geronimo/devtools/eclipse-plugin/branches/1.2.1/maven-plugins/maven-geronimodevtools-plugin/src/main/java/org/apache/geronimo/eclipse/devtools/BundleManifestMojo.java
Thu Jan  4 09:44:53 2007
@@ -18,6 +18,9 @@
 
 import java.io.File;
 import java.io.FileInputStream;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.StringTokenizer;
 import java.util.jar.Attributes;
 import java.util.jar.Manifest;
 
@@ -28,7 +31,7 @@
 import org.osgi.framework.Constants;
 
 /**
- *@goal validatemanifest
+ * @goal validatemanifest
  */
 public class BundleManifestMojo extends AbstractMojo {
 
@@ -43,20 +46,17 @@
 	 * @required
 	 */
 	private File manifestFile;
-	
-	/**
-	 * @parameter
-	 */
-	private File classpathEntriesDir;
-	
+
 	/**
 	 * @parameter
 	 */
-	private boolean includeRootClasspathEntry = false;
-	
+	private String classpathEntriesDir;
+
 	private Attributes attributes = null;
 
-	/* (non-Javadoc)
+	/*
+	 * (non-Javadoc)
+	 * 
 	 * @see org.apache.maven.plugin.Mojo#execute()
 	 */
 	public void execute() throws MojoExecutionException, MojoFailureException {
@@ -64,29 +64,43 @@
 			FileInputStream fis = new FileInputStream(manifestFile);
 			Manifest manifest = new Manifest(fis);
 			attributes = manifest.getMainAttributes();
-			
 			validate(Constants.BUNDLE_SYMBOLICNAME, project.getName() + ";singleton:=true");
-			//validate(Constants.BUNDLE_NAME, project.getName());
 			validate(Constants.BUNDLE_VERSION, project.getVersion());
-			
-			if(classpathEntriesDir != null && classpathEntriesDir.exists()) {
-				File entries[] = classpathEntriesDir.listFiles();
-				if(entries.length > 0) {
-					if(includeRootClasspathEntry) {
-						
-					}
-				}
-			}
-			
+			validateBundleClasspath();
 		} catch (Exception e) {
 			throw new MojoExecutionException(e.getMessage(), e);
 		}
 	}
-	
+
+	private void validateBundleClasspath() throws MojoFailureException {
+		if (classpathEntriesDir == null)
+			return;
+		File libs[] = new File(project.getBasedir(), classpathEntriesDir).listFiles();
+		if (libs == null)
+			return;
+		String classpath = attributes.getValue(Constants.BUNDLE_CLASSPATH);
+		StringTokenizer tokenizer = new StringTokenizer(classpath, ",");
+		List cpEntries = new ArrayList();
+		while (tokenizer.hasMoreTokens()) {
+			cpEntries.add(tokenizer.nextToken());
+		}
+		List missingEntries = new ArrayList();
+		for (int i = 0; i < libs.length; i++) {
+			File lib = libs[i];
+			String expectedEntry = classpathEntriesDir + "/" + lib.getName();
+			if (!cpEntries.contains(expectedEntry)) {
+				missingEntries.add(expectedEntry);
+			}
+		}
+		if (!missingEntries.isEmpty()) {
+			throw new MojoFailureException("Manifest Bundle-Classpath is missing the following entries:
" + missingEntries.toString());
+		}
+	}
+
 	private void validate(String attribute, String correctValue) throws MojoFailureException
{
 		String currentValue = attributes.getValue(attribute).replaceAll(" ", "");
 		correctValue = correctValue.replaceAll(" ", "");
-		if(!correctValue.equals(currentValue)) {
+		if (!correctValue.equals(currentValue)) {
 			throw new MojoFailureException("Attribute value for " + attribute + " in bundle manifest
is incorrect. [Found: " + currentValue + "] [Expected: " + correctValue + "]");
 		}
 	}

Modified: geronimo/devtools/eclipse-plugin/branches/1.2.1/plugins/pom.xml
URL: http://svn.apache.org/viewvc/geronimo/devtools/eclipse-plugin/branches/1.2.1/plugins/pom.xml?view=diff&rev=492650&r1=492649&r2=492650
==============================================================================
--- geronimo/devtools/eclipse-plugin/branches/1.2.1/plugins/pom.xml (original)
+++ geronimo/devtools/eclipse-plugin/branches/1.2.1/plugins/pom.xml Thu Jan  4 09:44:53 2007
@@ -56,7 +56,7 @@
                     <artifactId>maven-geronimodevtools-plugin</artifactId>
                     <executions>
                         <execution>
-                            <id>install-dependencies</id>
+                            <id>initialize</id>
                             <phase>validate</phase>
                             <goals>
                                 <goal>qualifier</goal>
@@ -65,6 +65,16 @@
                                 <goal>validatemanifest</goal>
                             </goals>
                         </execution>
+                        <execution>
+                            <id>validate-bundle-classpath</id>
+                            <phase>process-resources</phase>
+                            <goals>
+                                <goal>validatemanifest</goal>
+                            </goals>
+                            <configuration>
+                                <classpathEntriesDir>lib</classpathEntriesDir>
+                            </configuration>
+                        </execution>
                     </executions>
                 </plugin>
                 <plugin>
@@ -125,5 +135,6 @@
         <module>org.apache.geronimo.runtime.common</module>
         <module>org.apache.geronimo.runtime.v1</module>
         <module>org.apache.geronimo.runtime.v11</module>
+        <!--<module>org.apache.geronimo.runtime.v12</module>-->
     </modules>
 </project>



Mime
View raw message