<project>\r
<modelVersion>4.0.0</modelVersion>\r
- <groupId>org.argeo.slc.maven</groupId>\r
+ <parent>\r
+ <groupId>org.argeo.slc.maven</groupId>\r
+ <artifactId>slc-maven</artifactId>\r
+ <version>0.1.1</version>\r
+ <relativePath>..</relativePath>\r
+ </parent>\r
<artifactId>maven-argeo-osgi-plugin</artifactId>\r
- <version>0.1.3</version>\r
+ <version>0.1.4</version>\r
<packaging>maven-plugin</packaging>\r
<name>Argeo OSGi Plugin</name>\r
\r
<plugins>\r
<plugin>\r
<artifactId>maven-compiler-plugin</artifactId>\r
- <configuration>\r
- <source>1.4</source>\r
- <target>1.4</target>\r
- </configuration>\r
</plugin>\r
<plugin>\r
<artifactId>maven-plugin-plugin</artifactId>\r
<dependencies>\r
<dependency>\r
<groupId>org.apache.maven</groupId>\r
- <artifactId>maven-plugin-api</artifactId>\r
- <version>2.0</version>\r
+ <artifactId>maven-project</artifactId>\r
</dependency>\r
<dependency>\r
<groupId>org.apache.maven</groupId>\r
- <artifactId>maven-script-ant</artifactId>\r
- <version>2.0.9</version>\r
+ <artifactId>maven-plugin-api</artifactId>\r
+ </dependency>\r
+ <dependency>\r
+ <groupId>org.codehaus.plexus</groupId>\r
+ <artifactId>plexus-archiver</artifactId>\r
</dependency>\r
<dependency>\r
<groupId>org.apache.maven</groupId>\r
- <artifactId>maven-project</artifactId>\r
- <version>2.0.7</version>\r
+ <artifactId>maven-script-ant</artifactId>\r
</dependency>\r
<dependency>\r
<groupId>ant-contrib</groupId>\r
<artifactId>ant-contrib</artifactId>\r
- <version>1.0b3</version>\r
- <exclusions>\r
- <exclusion>\r
- <groupId>ant</groupId>\r
- <artifactId>ant</artifactId>\r
- </exclusion>\r
- </exclusions>\r
</dependency>\r
</dependencies>\r
- <distributionManagement>\r
- <repository>\r
- <uniqueVersion>false</uniqueVersion>\r
- <id>argeo-restricted</id>\r
- <name>Argeo FOSS Repository</name>\r
- <url>file:///var/argeo/maven2/argeo\r
- </url>\r
- </repository>\r
- <snapshotRepository>\r
- <uniqueVersion>true</uniqueVersion>\r
- <id>argeo-snapshots-restricted</id>\r
- <name>Argeo FOSS Snapshots Repository</name>\r
- <url>file:///var/argeo/maven2/argeo-snapshots\r
- </url>\r
- </snapshotRepository>\r
- </distributionManagement>\r
</project>
--- /dev/null
+package org.argeo.slc.maven.plugins.osgi;
+
+import java.io.File;
+import java.io.FileFilter;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.jar.Manifest;
+
+import org.apache.maven.artifact.Artifact;
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.project.MavenProject;
+
+/**
+ * @author mbaudier
+ *
+ */
+public abstract class AbstractBundlesPackagerMojo extends AbstractOsgiMojo {
+
+ /**
+ * The maven project.
+ *
+ * @parameter expression="${project}"
+ * @required
+ * @readonly
+ */
+ protected MavenProject project;
+
+ /**
+ * Directory of the simple bundles
+ *
+ * @parameter expression="${bundlesDirectory}" default-value="."
+ * @required
+ */
+ private File bundlesDirectory;
+
+ /**
+ * Directory containing the packaged bundles.
+ *
+ * @parameter expression="${packagedBundlesDir}"
+ * default-value="${project.build.directory}/argeo-osgi"
+ * @required
+ */
+ protected File packagedBundlesDir;
+
+ /**
+ * Artifact id for the dependency pom
+ *
+ * @parameter expression="${bundlesPomArtifactId}" default-value="bundles"
+ * @required
+ */
+ protected String bundlesPomArtifactId;
+
+ protected List analyze() throws MojoExecutionException {
+ List list = new ArrayList();
+
+ File[] bundleDirs = bundlesDirectory.listFiles(new FileFilter() {
+ public boolean accept(File file) {
+ if (!file.isDirectory())
+ return false;
+
+ return manifestFileFromDir(file).exists();
+ }
+ });
+ for (int i = 0; i < bundleDirs.length; i++) {
+ File dir = bundleDirs[i];
+ File manifestFile = manifestFileFromDir(dir);
+ String artifactId = dir.getName();
+ File destFile = new File(packagedBundlesDir.getPath()
+ + File.separator + artifactId + ".jar");
+ try {
+ Manifest manifest = readManifest(manifestFile);
+ // Symbolic name
+ String symbolicNameMf = manifest.getMainAttributes().getValue(
+ "Bundle-SymbolicName");
+ if (!artifactId.equals(symbolicNameMf))
+ getLog().warn(
+ "Symbolic name " + symbolicNameMf
+ + " does not match with directory name "
+ + artifactId);
+
+ // Version
+ String versionMf = manifest.getMainAttributes().getValue(
+ "Bundle-Version");
+ int qIndex = versionMf.lastIndexOf(".qualifier");
+ String versionMfMain;
+ if (qIndex >= 0)
+ versionMfMain = versionMf.substring(0, qIndex);
+ else
+ versionMfMain = versionMf;
+
+ int sIndex = project.getVersion().lastIndexOf("-SNAPSHOT");
+ String versionMain;
+ boolean isSnapshot = false;
+ if (sIndex >= 0) {// SNAPSHOT
+ versionMain = project.getVersion().substring(0, sIndex);
+ isSnapshot = true;
+ } else {
+ versionMain = project.getVersion();
+ }
+
+ if (!versionMain.equals(versionMfMain))
+ getLog()
+ .warn(
+ "Main manifest version "
+ + versionMfMain
+ + " of bundle "
+ + artifactId
+ + " do not match with main project version "
+ + versionMain);
+
+ String newVersionMf;
+ String newVersionArt;
+ if (isSnapshot) {
+ newVersionMf = versionMfMain + ".SNAPSHOT";
+ newVersionArt = versionMfMain + "-SNAPSHOT";
+ } else {
+ newVersionMf = versionMfMain;
+ newVersionArt = versionMfMain;
+ }
+
+ manifest.getMainAttributes().putValue("Bundle-Version",
+ newVersionMf);
+ Artifact artifact = artifactFactory.createBuildArtifact(project
+ .getGroupId(), artifactId, newVersionArt, "jar");
+ BundlePackage bundlePackage = new BundlePackage(artifact, dir,
+ manifest, destFile);
+ list.add(bundlePackage);
+ } catch (Exception e) {
+ throw new MojoExecutionException("Could not analyze " + dir, e);
+ }
+ }
+ return list;
+ }
+
+ protected File manifestFileFromDir(File dir) {
+ return new File(dir + File.separator + "META-INF" + File.separator
+ + "MANIFEST.MF");
+ }
+
+ protected File bundlesPomFile() {
+ return new File(packagedBundlesDir + File.separator + "bundles.pom");
+ }
+
+ protected Artifact bundlesPomArtifact() {
+ return artifactFactory.createBuildArtifact(project.getGroupId(),
+ bundlesPomArtifactId, project.getVersion(), "pom");
+ }
+
+ protected static class BundlePackage {
+ private final Artifact artifact;
+ private final File bundleDir;
+ private final Manifest manifest;
+ private final File packageFile;
+
+ public BundlePackage(Artifact artifact, File bundleDir,
+ Manifest manifest, File packageFile) {
+ super();
+ this.artifact = artifact;
+ this.bundleDir = bundleDir;
+ this.manifest = manifest;
+ this.packageFile = packageFile;
+ }
+
+ public Artifact getArtifact() {
+ return artifact;
+ }
+
+ public File getPackageFile() {
+ return packageFile;
+ }
+
+ public File getBundleDir() {
+ return bundleDir;
+ }
+
+ public Manifest getManifest() {
+ return manifest;
+ }
+ }
+
+ protected Manifest readManifest(File file) throws IOException {
+ Manifest manifest = new Manifest();
+ FileInputStream in = new FileInputStream(file);
+ manifest.read(in);
+ in.close();
+ return manifest;
+ }
+}
--- /dev/null
+package org.argeo.slc.maven.plugins.osgi;
+
+import java.io.File;
+
+import org.apache.maven.artifact.repository.ArtifactRepository;
+import org.apache.maven.plugin.AbstractMojo;
+
+/**
+ * Factorize common configuration
+ */
+public abstract class AbstractOsgiMojo extends AbstractMojo {
+ /**
+ * List of Remote Repositories used by the resolver
+ *
+ * @parameter expression="${project.remoteArtifactRepositories}"
+ * @readonly
+ * @required
+ */
+ protected java.util.List remoteRepos;
+ /**
+ * Location of the local repository.
+ *
+ * @parameter expression="${localRepository}"
+ * @readonly
+ * @required
+ */
+ protected ArtifactRepository local;
+
+ /**
+ * @parameter
+ * expression="${project.distributionManagementArtifactRepository}"
+ */
+ protected ArtifactRepository deploymentRepository;
+
+ /**
+ * The directory for the pom
+ *
+ * @parameter expression="${basedir}"
+ * @required
+ */
+ protected File baseDir;
+
+ /**
+ * Directory containing the build files.
+ *
+ * @parameter expression="${project.build.directory}"
+ */
+ protected File buildDirectory;
+
+ /** @component */
+ protected org.apache.maven.artifact.factory.ArtifactFactory artifactFactory;
+
+}
--- /dev/null
+package org.argeo.slc.maven.plugins.osgi;
+
+import java.io.File;
+import java.util.List;
+
+import org.apache.maven.artifact.deployer.ArtifactDeployer;
+import org.apache.maven.artifact.deployer.ArtifactDeploymentException;
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugin.MojoFailureException;
+
+/**
+ * @goal deploy-bundles
+ * @phase deploy
+ * @author mbaudier
+ *
+ */
+public class DeployBundlesMojo extends AbstractBundlesPackagerMojo {
+ /** @component */
+ private ArtifactDeployer deployer;
+
+ public void execute() throws MojoExecutionException, MojoFailureException {
+ List bundlePackages = analyze();
+ for (int i = 0; i < bundlePackages.size(); i++) {
+ AbstractBundlesPackagerMojo.BundlePackage bundlePackage = (BundlePackage) bundlePackages
+ .get(i);
+ try {
+ deployer.deploy(bundlePackage.getPackageFile(), bundlePackage
+ .getArtifact(), deploymentRepository, local);
+ } catch (ArtifactDeploymentException e) {
+ throw new MojoExecutionException("Could not deploy bundle "
+ + bundlePackage.getBundleDir(), e);
+ }
+ }
+
+ // bundles POM
+ try {
+ deployer.deploy(bundlesPomFile(), bundlesPomArtifact(),
+ deploymentRepository, local);
+ deployer.deploy(new File(baseDir.getPath() + File.separator
+ + "pom.xml"), project.getArtifact(), deploymentRepository,
+ local);
+ } catch (ArtifactDeploymentException e) {
+ throw new MojoExecutionException("Could not deploy bundles POM", e);
+ }
+
+ }
+}
--- /dev/null
+package org.argeo.slc.maven.plugins.osgi;
+
+import java.io.File;
+import java.util.List;
+
+import org.apache.maven.artifact.installer.ArtifactInstallationException;
+import org.apache.maven.artifact.installer.ArtifactInstaller;
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugin.MojoFailureException;
+
+/**
+ * @goal install-bundles
+ * @phase install
+ * @author mbaudier
+ *
+ */
+public class InstallBundlesMojo extends AbstractBundlesPackagerMojo {
+ /** @component */
+ private ArtifactInstaller installer;
+
+ public void execute() throws MojoExecutionException, MojoFailureException {
+ List bundlePackages = analyze();
+ for (int i = 0; i < bundlePackages.size(); i++) {
+ AbstractBundlesPackagerMojo.BundlePackage bundlePackage = (BundlePackage) bundlePackages
+ .get(i);
+ try {
+ installer.install(bundlePackage.getPackageFile(), bundlePackage
+ .getArtifact(), local);
+ } catch (ArtifactInstallationException e) {
+ throw new MojoExecutionException("Could not install bundle "
+ + bundlePackage.getBundleDir(), e);
+ }
+ }
+
+ // Bundles pom
+ try {
+ installer.install(bundlesPomFile(), bundlesPomArtifact(), local);
+ installer.install(new File(baseDir.getPath() + File.separator
+ + "pom.xml"), project.getArtifact(), local);
+ } catch (ArtifactInstallationException e) {
+ throw new MojoExecutionException("Could not install bundles POM", e);
+ }
+
+ }
+}
--- /dev/null
+package org.argeo.slc.maven.plugins.osgi;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.util.Iterator;
+import java.util.List;
+import java.util.jar.Attributes;
+
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugin.MojoFailureException;
+import org.codehaus.plexus.archiver.jar.JarArchiver;
+import org.codehaus.plexus.archiver.util.DefaultFileSet;
+
+/**
+ * @goal package-bundles
+ * @phase package
+ * @author mbaudier
+ *
+ */
+public class PackageBundlesMojo extends AbstractBundlesPackagerMojo {
+
+ public void execute() throws MojoExecutionException, MojoFailureException {
+ StringBuffer bundlesPom = new StringBuffer();
+ // not using append() systematically for the sake of clarity
+ bundlesPom.append("<project>\n");
+ bundlesPom.append("\t<modelVersion>4.0.0</modelVersion>\n");
+ bundlesPom.append("\t<parent>\n");
+ bundlesPom.append("\t\t<groupId>"
+ + project.getParentArtifact().getGroupId() + "</groupId>\n");
+ bundlesPom.append("\t\t<artifactId>"
+ + project.getParentArtifact().getArtifactId()
+ + "</artifactId>\n");
+ bundlesPom.append("\t\t<version>"
+ + project.getParentArtifact().getVersion() + "</version>\n");
+ bundlesPom.append("\t</parent>\n");
+ bundlesPom
+ .append("\t<groupId>" + project.getGroupId() + "</groupId>\n");
+ bundlesPom.append("\t<artifactId>" + bundlesPomArtifactId
+ + "</artifactId>\n");
+ bundlesPom.append("\t<packaging>pom</packaging>\n");
+ bundlesPom.append("\t<dependencies>\n");
+
+ List bundlePackages = analyze();
+
+ for (int i = 0; i < bundlePackages.size(); i++) {
+ AbstractBundlesPackagerMojo.BundlePackage bundlePackage = (BundlePackage) bundlePackages
+ .get(i);
+
+ File manifestFile = new File(bundlePackage.getPackageFile()
+ .getPath()
+ + ".MF");
+
+ // Package as jar
+ JarArchiver jarArchiver = new JarArchiver();
+ jarArchiver.setDestFile(bundlePackage.getPackageFile());
+ DefaultFileSet fileSet = new DefaultFileSet();
+ fileSet.setDirectory(bundlePackage.getBundleDir());
+ String[] includes = { "**/*" };
+ String[] excludes = { "**/.svn", "**/.svn/**" };
+ fileSet.setIncludes(includes);
+ fileSet.setExcludes(excludes);
+ try {
+ jarArchiver.addFileSet(fileSet);
+
+ // Write manifest
+ FileOutputStream out = new FileOutputStream(manifestFile);
+ bundlePackage.getManifest().getMainAttributes().put(
+ Attributes.Name.MANIFEST_VERSION, "1.0");
+
+ System.out.println("# BUNDLE "
+ + bundlePackage.getArtifact().getArtifactId());
+ Attributes mainAttrs = bundlePackage.getManifest()
+ .getMainAttributes();
+ for (Iterator it = mainAttrs.keySet().iterator(); it.hasNext();) {
+ Object key = it.next();
+ Object value = mainAttrs.get(key);
+ System.out.println(key + ": " + value);
+ }
+
+ bundlePackage.getManifest().write(out);
+ out.close();
+ jarArchiver.setManifest(manifestFile);
+
+ jarArchiver.createArchive();
+ } catch (Exception e) {
+ throw new MojoExecutionException("Could not package bundle "
+ + bundlePackage.getBundleDir(), e);
+ }
+
+ // update dependencies POM
+ bundlesPom.append("\t\t<dependency>\n");
+ bundlesPom
+ .append("\t\t\t<groupId>"
+ + bundlePackage.getArtifact().getGroupId()
+ + "</groupId>\n");
+ bundlesPom.append("\t\t\t<artifactId>"
+ + bundlePackage.getArtifact().getArtifactId()
+ + "</artifactId>\n");
+ bundlesPom
+ .append("\t\t\t<version>"
+ + bundlePackage.getArtifact().getVersion()
+ + "</version>\n");
+ bundlesPom.append("\t\t</dependency>\n");
+
+ }
+
+ bundlesPom.append("\t</dependencies>\n");
+ bundlesPom.append("</project>\n");
+
+ try {
+ FileWriter writer = new FileWriter(bundlesPomFile());
+ writer.write(bundlesPom.toString());
+ writer.close();
+ } catch (IOException e) {
+ throw new MojoExecutionException("Could not write dependency pom",
+ e);
+ }
+ }
+
+}
--- /dev/null
+<component-set>
+ <components>
+ <component>
+ <role>org.apache.maven.lifecycle.mapping.LifecycleMapping
+ </role>
+ <role-hint>bundles</role-hint>
+ <implementation>
+ org.apache.maven.lifecycle.mapping.DefaultLifecycleMapping
+ </implementation>
+ <configuration>
+ <phases>
+ <package>
+ org.argeo.slc.maven:maven-argeo-osgi-plugin:package-bundles
+ </package>
+ <install>
+ org.argeo.slc.maven:maven-argeo-osgi-plugin:install-bundles
+ </install>
+ <deploy>
+ org.argeo.slc.maven:maven-argeo-osgi-plugin:deploy-bundles
+ </deploy>
+ </phases>
+ </configuration>
+ </component>
+ </components>
+</component-set>
<pluginMetadata>
<mojos>
<mojo>
- <goal>simple-bundles</goal>
- <call>simple-bundles</call>
+ <goal>simple-bundles-old</goal>
+ <call>simple-bundles-old</call>
<description>
Process a simple bundle (no Java)
</description>
-<project>\r
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"\r
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">\r
<modelVersion>4.0.0</modelVersion>\r
- <groupId>org.argeo.slc.maven</groupId>\r
- <artifactId>maven-argeo-qooxdoo-plugin\r
- </artifactId>\r
- <version>0.8.1.3</version>\r
+ <parent>\r
+ <groupId>org.argeo.slc.maven</groupId>\r
+ <artifactId>slc-maven</artifactId>\r
+ <version>0.1.1</version>\r
+ <relativePath>..</relativePath>\r
+ </parent>\r
+ <artifactId>maven-argeo-qooxdoo-plugin</artifactId>\r
+ <version>0.8.1.4</version>\r
<packaging>maven-plugin</packaging>\r
<name>Argeo Qooxdoo Plugin</name>\r
\r
</plugins>\r
</build>\r
<dependencies>\r
+ <dependency>\r
+ <groupId>org.argeo.slc.maven</groupId>\r
+ <artifactId>org.argeo.slc.maven.plugin</artifactId>\r
+ </dependency>\r
<dependency>\r
<groupId>org.apache.maven</groupId>\r
<artifactId>maven-plugin-api</artifactId>\r
- <version>2.0</version>\r
</dependency>\r
<dependency>\r
<groupId>org.apache.maven</groupId>\r
<artifactId>maven-project</artifactId>\r
- <version>2.0.7</version>\r
</dependency>\r
<dependency>\r
<groupId>org.codehaus.plexus</groupId>\r
<artifactId>plexus-archiver</artifactId>\r
- <version>1.0-alpha-9</version>\r
- <exclusions>\r
- <exclusion>\r
- <groupId>org.codehaus.plexus</groupId>\r
- <artifactId>plexus-container-default\r
- </artifactId>\r
- </exclusion>\r
- <exclusion>\r
- <groupId>org.codehaus.plexus</groupId>\r
- <artifactId>plexus-component-api</artifactId>\r
- </exclusion>\r
- </exclusions>\r
</dependency>\r
</dependencies>\r
- <distributionManagement>\r
- <repository>\r
- <uniqueVersion>false</uniqueVersion>\r
- <id>argeo-restricted</id>\r
- <name>Argeo FOSS Repository</name>\r
- <url>file:///var/argeo/maven2/argeo\r
- </url>\r
- </repository>\r
- <snapshotRepository>\r
- <uniqueVersion>true</uniqueVersion>\r
- <id>argeo-snapshots-restricted</id>\r
- <name>Argeo FOSS Snapshots Repository</name>\r
- <url>file:///var/argeo/maven2/argeo-snapshots\r
- </url>\r
- </snapshotRepository>\r
- </distributionManagement>\r
</project>
--- /dev/null
+package org.argeo.slc.maven.plugins.qooxdoo;
+
+import java.io.File;
+
+import org.apache.maven.artifact.repository.ArtifactRepository;
+import org.apache.maven.plugin.AbstractMojo;
+import org.argeo.slc.maven.plugin.MavenDependencyManager;
+
+/**
+ * Factorize common configuration
+ */
+public abstract class AbstractQooxdooMojo extends AbstractMojo {
+ /**
+ * List of Remote Repositories used by the resolver
+ *
+ * @parameter expression="${project.remoteArtifactRepositories}"
+ * @readonly
+ * @required
+ */
+ protected java.util.List<ArtifactRepository> remoteRepos;
+ /**
+ * Location of the local repository.
+ *
+ * @parameter expression="${localRepository}"
+ * @readonly
+ * @required
+ */
+ protected org.apache.maven.artifact.repository.ArtifactRepository local;
+
+ /**
+ * The directory for the pom
+ *
+ * @parameter expression="${basedir}"
+ * @required
+ */
+ protected File baseDir;
+
+ /**
+ * Dependency manager
+ *
+ * @component
+ */
+ protected MavenDependencyManager depManager;
+
+ /**
+ * Source base where Qooxdoo SDK will be unpacked
+ *
+ * @parameter expression="${srcBase}" default-value="src"
+ * @required
+ */
+ protected File srcBase;
+
+ /**
+ * Qooxdoo cache location
+ *
+ * @parameter expression="${cache}" default-value="cache"
+ * @required
+ */
+ protected File cache;
+
+ /**
+ * Name of the SDK directory (the base dire in the unpacked distribution)
+ *
+ * @parameter expression="${sdkDirName}" default-value="qooxdoo-sdk"
+ * @required
+ */
+ protected String sdkDirName;
+
+ /**
+ * SDK maven groupId
+ *
+ * @parameter expression="${sdkGroupId}" default-value="org.argeo.dep.dist"
+ * @required
+ */
+ protected String sdkGroupId;
+
+ /**
+ * SDK maven artifactId
+ *
+ * @parameter expression="${sdkArtifactId}" default-value="qooxdoo-sdk"
+ * @required
+ */
+ protected String sdkArtifactId;
+
+ /**
+ * SDK maven classifier
+ *
+ * @parameter expression="${sdkClassifier}" default-value="dist"
+ * @required
+ */
+ protected String sdkClassifier;
+
+ /**
+ * SDK maven version
+ *
+ * @parameter expression="${sdkVersion}" default-value="0.8.1.argeo.1"
+ * @required
+ */
+ protected String sdkVersion;
+
+ /**
+ * SDK maven type
+ *
+ * @parameter expression="${sdkType}" default-value="zip"
+ * @required
+ */
+ protected String sdkType;
+
+ protected File getSdkDir() {
+ return new File(srcBase.getPath() + File.separator + sdkDirName);
+ }
+}
package org.argeo.slc.maven.plugins.qooxdoo;
-import java.io.File;
-
import org.apache.maven.artifact.Artifact;
-import org.apache.maven.artifact.resolver.ArtifactNotFoundException;
-import org.apache.maven.artifact.resolver.ArtifactResolutionException;
-import org.apache.maven.artifact.versioning.InvalidVersionSpecificationException;
-import org.apache.maven.artifact.versioning.VersionRange;
-import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;
-import org.codehaus.plexus.archiver.ArchiverException;
-import org.codehaus.plexus.archiver.UnArchiver;
-import org.codehaus.plexus.archiver.manager.ArchiverManager;
-import org.codehaus.plexus.archiver.manager.NoSuchArchiverException;
/**
* Prepares Qooxdoo environment
*
* @goal env
*/
-public class EnvironmentMojo extends AbstractMojo {
- /**
- * Used to look up Artifacts in the remote repository.
- *
- * @parameter expression=
- * "${component.org.apache.maven.artifact.factory.ArtifactFactory}"
- * @required
- * @readonly
- */
- protected org.apache.maven.artifact.factory.ArtifactFactory factory;
-
- /**
- * Used to look up Artifacts in the remote repository.
- *
- * @parameter expression=
- * "${component.org.apache.maven.artifact.resolver.ArtifactResolver}"
- * @required
- * @readonly
- */
- protected org.apache.maven.artifact.resolver.ArtifactResolver resolver;
-
- /**
- * Location of the local repository.
- *
- * @parameter expression="${localRepository}"
- * @readonly
- * @required
- */
- protected org.apache.maven.artifact.repository.ArtifactRepository local;
-
- /**
- * List of Remote Repositories used by the resolver
- *
- * @parameter expression="${project.remoteArtifactRepositories}"
- * @readonly
- * @required
- */
- protected java.util.List remoteRepos;
- /**
- * To look up Archiver/UnArchiver implementations
- *
- * @parameter expression=
- * "${component.org.codehaus.plexus.archiver.manager.ArchiverManager}"
- * @required
- * @readonly
- */
- protected ArchiverManager archiverManager;
-
- /**
- * Source base where Qooxdoo SDK will be unpacked
- *
- * @parameter expression="${srcBase}" default-value="src"
- * @required
- */
- private File srcBase;
-
- private String qxSdkDirName = "qooxdoo-sdk";
-
- private String qxSdkGroupId = "org.argeo.dep.dist";
- private String qxSdkArtifactId = "qooxdoo-sdk";
- private String qxSdkClassifier = "dist";
- private String qxSdkVersion = "0.8.1.argeo.1";
- private String qxSdkType = "zip";
+public class EnvironmentMojo extends AbstractQooxdooMojo {
public void execute() throws MojoExecutionException, MojoFailureException {
- Artifact qxSdkArtifact = getQxSdkArtifact();
- File qxSdkDir = new File(srcBase.getPath() + File.separator
- + qxSdkDirName);
- if (!qxSdkDir.exists())
- unpackArtifact(qxSdkArtifact, srcBase);
+ Artifact qxSdkArtifact = depManager.getResolvedArtifact(remoteRepos,
+ local, sdkGroupId, sdkArtifactId, sdkVersion, sdkType,
+ sdkClassifier, Artifact.SCOPE_COMPILE);
+ if (!getSdkDir().exists())
+ depManager.unpackArtifact(qxSdkArtifact, srcBase);
else
- getLog()
- .warn("Qooxdoo SDK already unpacked, skipping unpacking...");
+ getLog().warn("Qooxdoo SDK already unpacked, skip unpacking...");
getLog().info("Qooxdoo environment prepared");
}
-
- protected Artifact getQxSdkArtifact() throws MojoExecutionException {
- VersionRange vr;
- try {
- vr = VersionRange.createFromVersionSpec(qxSdkVersion);
- } catch (InvalidVersionSpecificationException e1) {
- e1.printStackTrace();
- vr = VersionRange.createFromVersion(qxSdkVersion);
- }
-
- Artifact qxSdkArtifact = factory.createDependencyArtifact(qxSdkGroupId,
- qxSdkArtifactId, vr, qxSdkType, qxSdkClassifier,
- Artifact.SCOPE_COMPILE);
- try {
- resolver.resolve(qxSdkArtifact, remoteRepos, local);
- } catch (ArtifactResolutionException e) {
- throw new MojoExecutionException("Unable to resolve artifact.", e);
- } catch (ArtifactNotFoundException e) {
- throw new MojoExecutionException("Unable to find artifact.", e);
- }
-
- return qxSdkArtifact;
- }
-
- protected void unpackArtifact(Artifact artifact, File location)
- throws MojoExecutionException {
- File file = artifact.getFile();
- try {
- UnArchiver unArchiver;
- unArchiver = archiverManager.getUnArchiver(file);
- unArchiver.setSourceFile(file);
- unArchiver.setDestDirectory(location);
- unArchiver.extract();
- } catch (NoSuchArchiverException e) {
- throw new MojoExecutionException("Unknown archiver type", e);
- } catch (ArchiverException e) {
- e.printStackTrace();
- throw new MojoExecutionException("Error unpacking file: " + file
- + " to: " + location + "\r\n" + e.toString(), e);
- }
- }
}
import java.io.File;
-import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;
import org.apache.maven.plugin.logging.Log;
*
* @goal generate
*/
-public class GenerateMojo extends AbstractMojo {
+public class GenerateMojo extends AbstractQooxdooMojo {
/**
* The Qooxdoo build target.
*
* @required
*/
private String job;
-
- /**
- * Location of the qooxdoo sdk.
- *
- * @parameter expression="${qooxdooSdk}" default-value="src/qooxdoo-sdk"
- */
- private String qooxdooSdk;
-
- /**
- * The build directory.
- *
- * @parameter expression="${project.build.directory}"
- * @required
- */
- private File buildDirectory;
-
- /**
- * The directory for the pom
- *
- * @parameter expression="${basedir}"
- * @required
- */
- private File baseDir;
public void execute() throws MojoExecutionException, MojoFailureException {
try {
- File generateScript = new File(baseDir.getPath() + File.separator
- + qooxdooSdk + File.separator + "tool" + File.separator
+ File generateScript = new File(srcBase+ File.separator
+ + sdkDirName + File.separator + "tool" + File.separator
+ "bin", "generator.py");
getLog().info("Running Qooxdoo job: " + job + " ...");
--- /dev/null
+package org.argeo.slc.maven.plugins.qooxdoo;
+
+import java.io.File;
+import java.io.IOException;
+
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugin.MojoFailureException;
+import org.codehaus.plexus.util.FileUtils;
+
+/**
+ * Reset Qooxdoo context: removes SDK, clean cache, etc.
+ *
+ * @goal reset
+ */
+public class ResetMojo extends AbstractQooxdooMojo {
+ public void execute() throws MojoExecutionException, MojoFailureException {
+ if (getSdkDir().exists()) {
+ delete(getSdkDir());
+ }
+
+ if (cache.exists()) {
+ delete(cache);
+ }
+
+ }
+
+ protected void delete(File dir) throws MojoExecutionException {
+ try {
+ FileUtils.deleteDirectory(dir);
+ getLog().info("Deleted directory " + dir);
+ } catch (IOException e) {
+ throw new MojoExecutionException("Cannot delete " + dir, e);
+ }
+ }
+}
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" output="target/classes" path="src/main/java"/>
+ <classpathentry kind="src" path="src/main/resources"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
+ <classpathentry kind="con" path="org.maven.ide.eclipse.MAVEN2_CLASSPATH_CONTAINER"/>
+ <classpathentry kind="output" path="target/classes"/>
+</classpath>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.argeo.slc.maven.plugin</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.maven.ide.eclipse.maven2Builder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.maven.ide.eclipse.maven2Nature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
--- /dev/null
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"\r
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">\r
+ <modelVersion>4.0.0</modelVersion>\r
+ <parent>\r
+ <groupId>org.argeo.slc.maven</groupId>\r
+ <artifactId>slc-maven</artifactId>\r
+ <version>0.1.1</version>\r
+ <relativePath>..</relativePath>\r
+ </parent>\r
+ <artifactId>org.argeo.slc.maven.plugin</artifactId>\r
+ <packaging>jar</packaging>\r
+ <name>Argeo Maven Plugin Development Support</name>\r
+\r
+ <build>\r
+ <plugins>\r
+ <plugin>\r
+ <artifactId>maven-compiler-plugin</artifactId>\r
+ </plugin>\r
+ </plugins>\r
+ </build>\r
+ <dependencies>\r
+ <dependency>\r
+ <groupId>org.apache.maven</groupId>\r
+ <artifactId>maven-plugin-api</artifactId>\r
+ </dependency>\r
+ <dependency>\r
+ <groupId>org.apache.maven</groupId>\r
+ <artifactId>maven-project</artifactId>\r
+ </dependency>\r
+ <dependency>\r
+ <groupId>org.codehaus.plexus</groupId>\r
+ <artifactId>plexus-archiver</artifactId>\r
+ </dependency>\r
+ </dependencies>\r
+</project>
--- /dev/null
+package org.argeo.slc.maven.plugin;
+
+import java.io.File;
+import java.util.List;
+
+import org.apache.maven.artifact.Artifact;
+import org.apache.maven.artifact.repository.ArtifactRepository;
+import org.apache.maven.artifact.resolver.ArtifactNotFoundException;
+import org.apache.maven.artifact.resolver.ArtifactResolutionException;
+import org.apache.maven.artifact.versioning.InvalidVersionSpecificationException;
+import org.apache.maven.artifact.versioning.VersionRange;
+import org.apache.maven.plugin.MojoExecutionException;
+import org.codehaus.plexus.archiver.ArchiverException;
+import org.codehaus.plexus.archiver.UnArchiver;
+import org.codehaus.plexus.archiver.manager.ArchiverManager;
+import org.codehaus.plexus.archiver.manager.NoSuchArchiverException;
+
+/**
+ * Abstract Maven plugin for interacting with dependencies
+ */
+public class DefaultMavenDependencyManager implements MavenDependencyManager {
+ /**
+ * Used to look up Artifacts in the remote repository.
+ *
+ * @parameter expression=
+ * "${component.org.apache.maven.artifact.factory.ArtifactFactory}"
+ * @required
+ * @readonly
+ */
+ protected org.apache.maven.artifact.factory.ArtifactFactory factory;
+
+ /**
+ * Used to look up Artifacts in the remote repository.
+ *
+ * @parameter expression=
+ * "${component.org.apache.maven.artifact.resolver.ArtifactResolver}"
+ * @required
+ * @readonly
+ */
+ protected org.apache.maven.artifact.resolver.ArtifactResolver resolver;
+
+ /**
+ * To look up Archiver/UnArchiver implementations
+ *
+ * @parameter expression=
+ * "${component.org.codehaus.plexus.archiver.manager.ArchiverManager}"
+ * @required
+ * @readonly
+ */
+ protected ArchiverManager archiverManager;
+
+ public DefaultMavenDependencyManager() {
+ }
+
+ public Artifact getResolvedArtifact(List remoteRepos,
+ ArtifactRepository local, String groupId, String artifactId,
+ String version, String type, String classifier, String scope)
+ throws MojoExecutionException {
+ VersionRange vr;
+ try {
+ vr = VersionRange.createFromVersionSpec(version);
+ } catch (InvalidVersionSpecificationException e1) {
+ e1.printStackTrace();
+ vr = VersionRange.createFromVersion(version);
+ }
+
+ Artifact qxSdkArtifact = factory.createDependencyArtifact(groupId,
+ artifactId, vr, type, classifier, scope);
+ try {
+ resolver.resolve(qxSdkArtifact, remoteRepos, local);
+ } catch (ArtifactResolutionException e) {
+ throw new MojoExecutionException("Unable to resolve artifact.", e);
+ } catch (ArtifactNotFoundException e) {
+ throw new MojoExecutionException("Unable to find artifact.", e);
+ }
+
+ return qxSdkArtifact;
+ }
+
+ public void unpackArtifact(Artifact artifact, File location)
+ throws MojoExecutionException {
+ File file = artifact.getFile();
+ try {
+ UnArchiver unArchiver;
+ unArchiver = archiverManager.getUnArchiver(file);
+ unArchiver.setSourceFile(file);
+ unArchiver.setDestDirectory(location);
+ unArchiver.extract();
+ } catch (NoSuchArchiverException e) {
+ throw new MojoExecutionException("Unknown archiver type", e);
+ } catch (ArchiverException e) {
+ e.printStackTrace();
+ throw new MojoExecutionException("Error unpacking file: " + file
+ + " to: " + location + "\r\n" + e.toString(), e);
+ }
+ }
+}
--- /dev/null
+package org.argeo.slc.maven.plugin;
+
+import java.io.File;
+import java.util.List;
+
+import org.apache.maven.artifact.Artifact;
+import org.apache.maven.artifact.repository.ArtifactRepository;
+import org.apache.maven.plugin.MojoExecutionException;
+
+public interface MavenDependencyManager {
+ String ROLE = MavenDependencyManager.class.getName();
+
+ public Artifact getResolvedArtifact(List remoteRepos,
+ ArtifactRepository local, String groupId, String artifactId,
+ String version, String type, String classifier, String scope)
+ throws MojoExecutionException;
+
+ public void unpackArtifact(Artifact artifact, File location)
+ throws MojoExecutionException;
+
+}
--- /dev/null
+<component-set>
+ <components>
+ <component>
+ <role>org.argeo.slc.maven.plugin.MavenDependencyManager
+ </role>
+ <implementation>
+ org.argeo.slc.maven.plugin.DefaultMavenDependencyManager
+ </implementation>
+ <requirements>
+ <requirement>
+ <role>org.apache.maven.artifact.factory.ArtifactFactory
+ </role>
+ <field-name>factory</field-name>
+ </requirement>
+ <requirement>
+ <role>org.apache.maven.artifact.resolver.ArtifactResolver
+ </role>
+ <field-name>resolver</field-name>
+ </requirement>
+ <requirement>
+ <role>org.codehaus.plexus.archiver.manager.ArchiverManager
+ </role>
+ <field-name>archiverManager</field-name>
+ </requirement>
+ </requirements>
+ <configuration />
+ </component>
+ </components>
+</component-set>