geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sppa...@apache.org
Subject svn commit: r492190 - 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 Wed, 03 Jan 2007 15:56:49 GMT
Author: sppatel
Date: Wed Jan  3 07:56:49 2007
New Revision: 492190

URL: http://svn.apache.org/viewvc?view=rev&rev=492190
Log:
add mojo to validate bundle manifest entries

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

Added: 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=auto&rev=492190
==============================================================================
--- geronimo/devtools/eclipse-plugin/branches/1.2.1/maven-plugins/maven-geronimodevtools-plugin/src/main/java/org/apache/geronimo/eclipse/devtools/BundleManifestMojo.java
(added)
+++ geronimo/devtools/eclipse-plugin/branches/1.2.1/maven-plugins/maven-geronimodevtools-plugin/src/main/java/org/apache/geronimo/eclipse/devtools/BundleManifestMojo.java
Wed Jan  3 07:56:49 2007
@@ -0,0 +1,93 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.
+ */
+package org.apache.geronimo.eclipse.devtools;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.util.jar.Attributes;
+import java.util.jar.Manifest;
+
+import org.apache.maven.plugin.AbstractMojo;
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugin.MojoFailureException;
+import org.apache.maven.project.MavenProject;
+import org.osgi.framework.Constants;
+
+/**
+ *@goal validatemanifest
+ */
+public class BundleManifestMojo extends AbstractMojo {
+
+	/**
+	 * @parameter expression="${project}"
+	 * @required
+	 */
+	private MavenProject project;
+
+	/**
+	 * @parameter expression="${project.basedir}/META-INF/MANIFEST.MF"
+	 * @required
+	 */
+	private File manifestFile;
+	
+	/**
+	 * @parameter
+	 */
+	private File classpathEntriesDir;
+	
+	/**
+	 * @parameter
+	 */
+	private boolean includeRootClasspathEntry = false;
+	
+	private Attributes attributes = null;
+
+	/* (non-Javadoc)
+	 * @see org.apache.maven.plugin.Mojo#execute()
+	 */
+	public void execute() throws MojoExecutionException, MojoFailureException {
+		try {
+			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) {
+						
+					}
+				}
+			}
+			
+		} catch (Exception e) {
+			throw new MojoExecutionException(e.getMessage(), e);
+		}
+	}
+	
+	private void validate(String attribute, String correctValue) throws MojoFailureException
{
+		String currentValue = attributes.getValue(attribute);
+		if(!correctValue.trim().equals(currentValue)) {
+			throw new MojoFailureException("Attribute value for " + attribute + " in bundle manifest
is incorrect. [Found: " + currentValue + "] [Expected: " + correctValue + "]");
+		}
+	}
+
+}

Propchange: geronimo/devtools/eclipse-plugin/branches/1.2.1/maven-plugins/maven-geronimodevtools-plugin/src/main/java/org/apache/geronimo/eclipse/devtools/BundleManifestMojo.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/devtools/eclipse-plugin/branches/1.2.1/maven-plugins/maven-geronimodevtools-plugin/src/main/java/org/apache/geronimo/eclipse/devtools/BundleManifestMojo.java
------------------------------------------------------------------------------
    svn:keywords = Date Rev

Propchange: geronimo/devtools/eclipse-plugin/branches/1.2.1/maven-plugins/maven-geronimodevtools-plugin/src/main/java/org/apache/geronimo/eclipse/devtools/BundleManifestMojo.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

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=492190&r1=492189&r2=492190
==============================================================================
--- geronimo/devtools/eclipse-plugin/branches/1.2.1/plugins/pom.xml (original)
+++ geronimo/devtools/eclipse-plugin/branches/1.2.1/plugins/pom.xml Wed Jan  3 07:56:49 2007
@@ -62,6 +62,7 @@
                                 <goal>qualifier</goal>
                                 <goal>manifestbundles</goal>
                                 <goal>install</goal>
+                                <goal>validatemanifest</goal>
                             </goals>
                         </execution>
                     </executions>



Mime
View raw message