You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tiles.apache.org by ap...@apache.org on 2010/03/21 21:00:31 UTC
svn commit: r925878 - in
/tiles/sandbox/trunk/tiles-autotag/maven-autotag-plugin: pom.xml
src/main/java/org/apache/tiles/autotag/plugin/GenerateVelocityMojo.java
Author: apetrelli
Date: Sun Mar 21 20:00:31 2010
New Revision: 925878
URL: http://svn.apache.org/viewvc?rev=925878&view=rev
Log:
TILESSB-25
Created Velocity mojo.
Added:
tiles/sandbox/trunk/tiles-autotag/maven-autotag-plugin/src/main/java/org/apache/tiles/autotag/plugin/GenerateVelocityMojo.java (with props)
Modified:
tiles/sandbox/trunk/tiles-autotag/maven-autotag-plugin/pom.xml
Modified: tiles/sandbox/trunk/tiles-autotag/maven-autotag-plugin/pom.xml
URL: http://svn.apache.org/viewvc/tiles/sandbox/trunk/tiles-autotag/maven-autotag-plugin/pom.xml?rev=925878&r1=925877&r2=925878&view=diff
==============================================================================
--- tiles/sandbox/trunk/tiles-autotag/maven-autotag-plugin/pom.xml (original)
+++ tiles/sandbox/trunk/tiles-autotag/maven-autotag-plugin/pom.xml Sun Mar 21 20:00:31 2010
@@ -54,5 +54,10 @@
<artifactId>tiles-autotag-freemarker</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
+ <dependency>
+ <groupId>org.apache.tiles</groupId>
+ <artifactId>tiles-autotag-velocity</artifactId>
+ <version>1.0-SNAPSHOT</version>
+ </dependency>
</dependencies>
</project>
Added: tiles/sandbox/trunk/tiles-autotag/maven-autotag-plugin/src/main/java/org/apache/tiles/autotag/plugin/GenerateVelocityMojo.java
URL: http://svn.apache.org/viewvc/tiles/sandbox/trunk/tiles-autotag/maven-autotag-plugin/src/main/java/org/apache/tiles/autotag/plugin/GenerateVelocityMojo.java?rev=925878&view=auto
==============================================================================
--- tiles/sandbox/trunk/tiles-autotag/maven-autotag-plugin/src/main/java/org/apache/tiles/autotag/plugin/GenerateVelocityMojo.java (added)
+++ tiles/sandbox/trunk/tiles-autotag/maven-autotag-plugin/src/main/java/org/apache/tiles/autotag/plugin/GenerateVelocityMojo.java Sun Mar 21 20:00:31 2010
@@ -0,0 +1,80 @@
+package org.apache.tiles.autotag.plugin;
+
+/*
+ * Copyright 2001-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.
+ */
+
+import java.io.File;
+
+import org.apache.maven.model.Resource;
+import org.apache.maven.project.MavenProject;
+import org.apache.tiles.autotag.generate.BasicTemplateGenerator;
+import org.apache.tiles.autotag.model.TemplateSuite;
+import org.apache.tiles.autotag.velocity.VelocityDirectiveGenerator;
+import org.apache.tiles.autotag.velocity.VelocityPropertiesGenerator;
+
+
+/**
+ * Generates Velocity code.
+ *
+ * @goal generate-velocity
+ *
+ * @phase generate-sources
+ * @requiresDependencyResolution compile
+ */
+public class GenerateVelocityMojo extends AbstractGenerateMojo {
+
+ /**
+ * Location of the file.
+ *
+ * @parameter expression="${project.build.directory}/autotag-velocity-classes"
+ * @required
+ */
+ private File classesOutputDirectory;
+
+ /**
+ * Location of the file.
+ *
+ * @parameter expression="${project.build.directory}/autotag-velocity-resources"
+ * @required
+ */
+ private File resourcesOutputDirectory;
+
+ /**
+ * Name of the package.
+ * @parameter expression="sample"
+ * @required
+ */
+ private String packageName;
+
+ /**
+ * @parameter expression="${project}"
+ * @required
+ * @readonly
+ */
+ private MavenProject project;
+
+ protected void generate(TemplateSuite suite) {
+ BasicTemplateGenerator generator = new BasicTemplateGenerator();
+ generator.addTemplateSuiteGenerator(resourcesOutputDirectory, new VelocityPropertiesGenerator());
+ generator.addTemplateClassGenerator(classesOutputDirectory, new VelocityDirectiveGenerator());
+ generator.generate(packageName, suite);
+
+ Resource resource = new Resource();
+ resource.setDirectory(resourcesOutputDirectory.getAbsolutePath());
+ project.addResource(resource);
+ project.addCompileSourceRoot(classesOutputDirectory.getAbsolutePath());
+ }
+}
Propchange: tiles/sandbox/trunk/tiles-autotag/maven-autotag-plugin/src/main/java/org/apache/tiles/autotag/plugin/GenerateVelocityMojo.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: tiles/sandbox/trunk/tiles-autotag/maven-autotag-plugin/src/main/java/org/apache/tiles/autotag/plugin/GenerateVelocityMojo.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL