Return-Path: Delivered-To: apmail-geronimo-scm-archive@www.apache.org Received: (qmail 58628 invoked from network); 3 Jan 2007 15:57:48 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 3 Jan 2007 15:57:48 -0000 Received: (qmail 6677 invoked by uid 500); 3 Jan 2007 15:57:54 -0000 Delivered-To: apmail-geronimo-scm-archive@geronimo.apache.org Received: (qmail 6631 invoked by uid 500); 3 Jan 2007 15:57:54 -0000 Mailing-List: contact scm-help@geronimo.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: List-Post: Reply-To: dev@geronimo.apache.org List-Id: Delivered-To: mailing list scm@geronimo.apache.org Received: (qmail 6618 invoked by uid 99); 3 Jan 2007 15:57:54 -0000 Received: from herse.apache.org (HELO herse.apache.org) (140.211.11.133) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 03 Jan 2007 07:57:54 -0800 X-ASF-Spam-Status: No, hits=-9.4 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Received: from [140.211.11.3] (HELO eris.apache.org) (140.211.11.3) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 03 Jan 2007 07:57:46 -0800 Received: by eris.apache.org (Postfix, from userid 65534) id 064371A981A; Wed, 3 Jan 2007 07:56:50 -0800 (PST) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit 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 -0000 To: scm@geronimo.apache.org From: sppatel@apache.org X-Mailer: svnmailer-1.1.0 Message-Id: <20070103155650.064371A981A@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org 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 @@ qualifier manifestbundles install + validatemanifest