cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From giac...@apache.org
Subject svn commit: r370628 - in /cocoon/trunk/cocoon-plugins/cocoon-deployer-plugin/src/main/java/org/apache/cocoon/maven/deployer: MavenLoggingWrapper.java SimpleDeployMojo.java SingleBlockDeployMojo.java
Date Thu, 19 Jan 2006 20:44:52 GMT
Author: giacomo
Date: Thu Jan 19 12:44:48 2006
New Revision: 370628

URL: http://svn.apache.org/viewcvs?rev=370628&view=rev
Log:
merged Reinhard's and mine's work 

Added:
    cocoon/trunk/cocoon-plugins/cocoon-deployer-plugin/src/main/java/org/apache/cocoon/maven/deployer/MavenLoggingWrapper.java
    cocoon/trunk/cocoon-plugins/cocoon-deployer-plugin/src/main/java/org/apache/cocoon/maven/deployer/SimpleDeployMojo.java
    cocoon/trunk/cocoon-plugins/cocoon-deployer-plugin/src/main/java/org/apache/cocoon/maven/deployer/SingleBlockDeployMojo.java

Added: cocoon/trunk/cocoon-plugins/cocoon-deployer-plugin/src/main/java/org/apache/cocoon/maven/deployer/MavenLoggingWrapper.java
URL: http://svn.apache.org/viewcvs/cocoon/trunk/cocoon-plugins/cocoon-deployer-plugin/src/main/java/org/apache/cocoon/maven/deployer/MavenLoggingWrapper.java?rev=370628&view=auto
==============================================================================
--- cocoon/trunk/cocoon-plugins/cocoon-deployer-plugin/src/main/java/org/apache/cocoon/maven/deployer/MavenLoggingWrapper.java
(added)
+++ cocoon/trunk/cocoon-plugins/cocoon-deployer-plugin/src/main/java/org/apache/cocoon/maven/deployer/MavenLoggingWrapper.java
Thu Jan 19 12:44:48 2006
@@ -0,0 +1,30 @@
+package org.apache.cocoon.maven.deployer;
+
+import org.apache.cocoon.deployer.logger.Logger;
+import org.apache.maven.plugin.logging.Log;
+
+/**
+ * This logger can be used within the cocoon-deployer library to send all 
+ * logging messages of the library to the Maven logger.
+ */
+public class MavenLoggingWrapper implements Logger {
+	
+	private Log logger;
+
+	public MavenLoggingWrapper(Log logger) {
+		this.logger = logger;
+	}
+
+	public void verbose(String msg) {
+		this.logger.debug(msg);		
+	}
+
+	public void info(String msg) {
+		this.logger.info(msg);
+	}
+
+	public void error(String msg) {
+		this.logger.error(msg);
+	}
+
+}

Added: cocoon/trunk/cocoon-plugins/cocoon-deployer-plugin/src/main/java/org/apache/cocoon/maven/deployer/SimpleDeployMojo.java
URL: http://svn.apache.org/viewcvs/cocoon/trunk/cocoon-plugins/cocoon-deployer-plugin/src/main/java/org/apache/cocoon/maven/deployer/SimpleDeployMojo.java?rev=370628&view=auto
==============================================================================
--- cocoon/trunk/cocoon-plugins/cocoon-deployer-plugin/src/main/java/org/apache/cocoon/maven/deployer/SimpleDeployMojo.java
(added)
+++ cocoon/trunk/cocoon-plugins/cocoon-deployer-plugin/src/main/java/org/apache/cocoon/maven/deployer/SimpleDeployMojo.java
Thu Jan 19 12:44:48 2006
@@ -0,0 +1,122 @@
+/*
+ * Copyright 2002-2005 The Apache Software Foundation
+ * Licensed  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.cocoon.maven.deployer;
+
+import org.apache.cocoon.deployer.ArtifactProvider;
+import org.apache.cocoon.deployer.BlockDeployer;
+import org.apache.cocoon.deployer.generated.deploy.x10.Deploy;
+import org.apache.cocoon.deployer.resolver.NullVariableResolver;
+
+import org.apache.maven.artifact.factory.ArtifactFactory;
+import org.apache.maven.artifact.repository.ArtifactRepository;
+import org.apache.maven.artifact.resolver.ArtifactResolver;
+
+import org.apache.maven.plugin.AbstractMojo;
+import org.apache.maven.plugin.MojoExecutionException;
+
+import org.apache.maven.project.artifact.MavenMetadataSource;
+
+import java.io.FileReader;
+import java.util.List;
+
+
+/**
+ * DOCUMENT ME!
+ *
+ * @goal simple-deploy
+ * @phase package
+ * @requiresProject false
+ */
+public class SimpleDeployMojo
+    extends AbstractMojo {
+    //~ Instance fields ---------------------------------------------------------------------------------
+
+    /**
+     * Artifact factory, needed to download source jars for inclusion in classpath.
+     *
+     * @component role="org.apache.maven.artifact.factory.ArtifactFactory"
+     * @required
+     * @readonly
+     */
+    private ArtifactFactory artifactFactory;
+
+    /**
+     * Local maven repository.
+     *
+     * @required
+     * @readonly
+     */
+    private ArtifactRepository localRepository;
+
+    /**
+     * Artifact resolver, needed to download source jars for inclusion in classpath.
+     *
+     * @component role="org.apache.maven.artifact.resolver.ArtifactResolver"
+     * @required
+     * @readonly
+     */
+    private ArtifactResolver artifactResolver;
+
+    /**
+     * Remote repositories which will be searched for blocks.
+     *
+     * @required
+     * @readonly
+     */
+    private List remoteArtifactRepositories;
+
+    /**
+     * Artifact resolver, needed to download source jars for inclusion in classpath.
+     *
+     * @component role="org.apache.maven.artifact.metadata.ArtifactMetadataSource"
+     * @required
+     * @readonly
+     */
+    private MavenMetadataSource metadataSource;
+
+    /**
+     * The source directory containing .xsd files
+     */
+    private String deployDescriptor;
+
+    //~ Methods -----------------------------------------------------------------------------------------
+
+    /**
+     * DOCUMENT ME!
+     *
+     * @throws MojoExecutionException DOCUMENT ME!
+     */
+    public void execute()
+        throws MojoExecutionException {
+        getLog().info("Cocoon simple block deployer");
+
+        final ArtifactProvider artifactProvider =
+            new MavenArtifactProvider(this.artifactResolver, this.artifactFactory, this.localRepository,
+                                      this.remoteArtifactRepositories, this.metadataSource,
getLog());
+        final BlockDeployer blockDeployer =
+            new BlockDeployer(artifactProvider, new NullVariableResolver(),
+                              new MavenLoggingWrapper(getLog()));
+
+        try {
+            // This Deployment descriptor should probably be created programmatically
+            final Deploy deploy = (Deploy)Deploy.unmarshal(new FileReader(deployDescriptor));
+            blockDeployer.deploy(deploy);
+        } catch(final Exception e) {
+            throw new MojoExecutionException(e.getMessage(), e);
+        }
+    }
+}

Added: cocoon/trunk/cocoon-plugins/cocoon-deployer-plugin/src/main/java/org/apache/cocoon/maven/deployer/SingleBlockDeployMojo.java
URL: http://svn.apache.org/viewcvs/cocoon/trunk/cocoon-plugins/cocoon-deployer-plugin/src/main/java/org/apache/cocoon/maven/deployer/SingleBlockDeployMojo.java?rev=370628&view=auto
==============================================================================
--- cocoon/trunk/cocoon-plugins/cocoon-deployer-plugin/src/main/java/org/apache/cocoon/maven/deployer/SingleBlockDeployMojo.java
(added)
+++ cocoon/trunk/cocoon-plugins/cocoon-deployer-plugin/src/main/java/org/apache/cocoon/maven/deployer/SingleBlockDeployMojo.java
Thu Jan 19 12:44:48 2006
@@ -0,0 +1,129 @@
+/*
+ * Copyright 2002-2005 The Apache Software Foundation
+ * Licensed  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.cocoon.maven.deployer;
+
+import org.apache.cocoon.deployer.BlockDeployer;
+import org.apache.cocoon.deployer.generated.deploy.x10.Block;
+import org.apache.cocoon.deployer.generated.deploy.x10.Cocoon;
+import org.apache.cocoon.deployer.generated.deploy.x10.Deploy;
+import org.apache.cocoon.deployer.generated.deploy.x10.Mount;
+import org.apache.cocoon.deployer.resolver.NullVariableResolver;
+
+import org.apache.maven.artifact.factory.ArtifactFactory;
+import org.apache.maven.artifact.repository.ArtifactRepository;
+import org.apache.maven.artifact.resolver.ArtifactResolver;
+
+import org.apache.maven.plugin.AbstractMojo;
+import org.apache.maven.plugin.MojoExecutionException;
+
+import org.apache.maven.project.artifact.MavenMetadataSource;
+
+import java.util.List;
+
+
+/**
+ * DOCUMENT ME!
+ *
+ * @goal test-deploy
+ * @phase package
+ * @requiresProject true
+ */
+public class SingleBlockDeployMojo
+    extends AbstractMojo {
+    //~ Instance fields ---------------------------------------------------------------------------------
+
+    /**
+     * Artifact factory, needed to download source jars for inclusion in classpath.
+     *
+     * @component role="org.apache.maven.artifact.factory.ArtifactFactory"
+     * @required
+     * @readonly
+     */
+    private ArtifactFactory artifactFactory;
+
+    /**
+     * Local maven repository.
+     *
+     * @required
+     * @readonly
+     */
+    private ArtifactRepository localRepository;
+
+    /**
+     * Artifact resolver, needed to download source jars for inclusion in classpath.
+     *
+     * @component role="org.apache.maven.artifact.resolver.ArtifactResolver"
+     * @required
+     * @readonly
+     */
+    private ArtifactResolver artifactResolver;
+
+    /**
+     * Remote repositories which will be searched for blocks.
+     *
+     * @required
+     * @readonly
+     */
+    private List remoteArtifactRepositories;
+
+    /**
+     * Artifact resolver, needed to download source jars for inclusion in classpath.
+     *
+     * @component role="org.apache.maven.artifact.metadata.ArtifactMetadataSource"
+     * @required
+     * @readonly
+     */
+    private MavenMetadataSource metadataSource;
+
+    //~ Methods -----------------------------------------------------------------------------------------
+
+    /**
+     * DOCUMENT ME!
+     *
+     * @throws MojoExecutionException DOCUMENT ME!
+     */
+    public void execute()
+        throws MojoExecutionException {
+        getLog().info("Start deployment of ...");
+
+        Cocoon cocoon = new Cocoon();
+        cocoon.setExclusive(true);
+        cocoon.setUrl("target/webapp/xyz");
+        cocoon.setVersion("2.2");
+
+        Block block = new Block();
+        block.setAutoWire(true);
+        block.setLocation("blah");
+
+        Mount mount = new Mount();
+        mount.setPath("xyz");
+        block.setMount(mount);
+        block.setUrn("blah");
+
+        Deploy deploy = new Deploy();
+        deploy.setCocoon(cocoon);
+        deploy.addBlock(block);
+
+        BlockDeployer blockDeployer =
+            new BlockDeployer(new MavenArtifactProvider(this.artifactResolver, this.artifactFactory,
+                                                        this.localRepository,
+                                                        this.remoteArtifactRepositories,
+                                                        this.metadataSource, this.getLog()),
+                              new NullVariableResolver(), new MavenLoggingWrapper(this.getLog()));
+        blockDeployer.deploy(deploy);
+    }
+}



Mime
View raw message