This project has retired. For details please refer to its Attic page.
GenerateVelocityMojo xref
View Javadoc

1   /*
2    * $Id: GenerateVelocityMojo.java 1643653 2014-12-07 06:47:59Z nlebas $
3    *
4    * Licensed to the Apache Software Foundation (ASF) under one
5    * or more contributor license agreements.  See the NOTICE file
6    * distributed with this work for additional information
7    * regarding copyright ownership.  The ASF licenses this file
8    * to you under the Apache License, Version 2.0 (the
9    * "License"); you may not use this file except in compliance
10   * with the License.  You may obtain a copy of the License at
11   *
12   * http://www.apache.org/licenses/LICENSE-2.0
13   *
14   * Unless required by applicable law or agreed to in writing,
15   * software distributed under the License is distributed on an
16   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17   * KIND, either express or implied.  See the License for the
18   * specific language governing permissions and limitations
19   * under the License.
20   */
21  package org.apache.tiles.autotag.plugin;
22  
23  /*
24   * Copyright 2001-2005 The Apache Software Foundation.
25   *
26   * Licensed under the Apache License, Version 2.0 (the "License");
27   * you may not use this file except in compliance with the License.
28   * You may obtain a copy of the License at
29   *
30   *      http://www.apache.org/licenses/LICENSE-2.0
31   *
32   * Unless required by applicable law or agreed to in writing, software
33   * distributed under the License is distributed on an "AS IS" BASIS,
34   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
35   * See the License for the specific language governing permissions and
36   * limitations under the License.
37   */
38  
39  import java.util.Map;
40  
41  import org.apache.maven.plugins.annotations.LifecyclePhase;
42  import org.apache.maven.plugins.annotations.Mojo;
43  import org.apache.maven.plugins.annotations.Parameter;
44  import org.apache.maven.plugins.annotations.ResolutionScope;
45  import org.apache.tiles.autotag.generate.TemplateGeneratorBuilder;
46  import org.apache.tiles.autotag.generate.TemplateGeneratorFactory;
47  import org.apache.tiles.autotag.velocity.VelocityTemplateGeneratorFactory;
48  import org.apache.velocity.app.VelocityEngine;
49  
50  
51  /**
52   * Generates Velocity code.
53   */
54  @Mojo(
55  	name = "generate-velocity",
56  	defaultPhase = LifecyclePhase.GENERATE_SOURCES,
57  	requiresDependencyResolution = ResolutionScope.COMPILE)
58  public class GenerateVelocityMojo extends AbstractGenerateMojo {
59  
60      /**
61       * Name of the Runtime.
62       */
63  	@Parameter(defaultValue = "org.apache.tiles.autotag.velocity.runtime.Runtime", required = true)
64      String velocityRuntime;
65  
66      /** {@inheritDoc} */
67      @Override
68      protected Map<String, String> getParameters() {
69          return null;
70      }
71  
72      /** {@inheritDoc} */
73      @Override
74      protected String getRuntimeClass() {
75          return velocityRuntime;
76      }
77  
78      @Override
79      protected TemplateGeneratorFactory createTemplateGeneratorFactory(
80              VelocityEngine velocityEngine) {
81          return new VelocityTemplateGeneratorFactory(classesOutputLocator,
82                  resourcesOutputLocator, velocityEngine,
83                  TemplateGeneratorBuilder.createNewInstance());
84      }
85  }