You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by lu...@apache.org on 2008/04/09 02:42:40 UTC
svn commit: r646155 - in
/myfaces/myfaces-build-tools/branches/builder_plugin:
myfaces-builder-plugin/src/main/java/org/apache/myfaces/buildtools/maven2/plugin/builder/MakeTagsMojo.java
test/api/pom.xml
Author: lu4242
Date: Tue Apr 8 17:42:39 2008
New Revision: 646155
URL: http://svn.apache.org/viewvc?rev=646155&view=rev
Log:
added replacePackagePrefixFrom and replacePackagePrefixFrom properties to manage the use case for tomahawk
Modified:
myfaces/myfaces-build-tools/branches/builder_plugin/myfaces-builder-plugin/src/main/java/org/apache/myfaces/buildtools/maven2/plugin/builder/MakeTagsMojo.java
myfaces/myfaces-build-tools/branches/builder_plugin/test/api/pom.xml
Modified: myfaces/myfaces-build-tools/branches/builder_plugin/myfaces-builder-plugin/src/main/java/org/apache/myfaces/buildtools/maven2/plugin/builder/MakeTagsMojo.java
URL: http://svn.apache.org/viewvc/myfaces/myfaces-build-tools/branches/builder_plugin/myfaces-builder-plugin/src/main/java/org/apache/myfaces/buildtools/maven2/plugin/builder/MakeTagsMojo.java?rev=646155&r1=646154&r2=646155&view=diff
==============================================================================
--- myfaces/myfaces-build-tools/branches/builder_plugin/myfaces-builder-plugin/src/main/java/org/apache/myfaces/buildtools/maven2/plugin/builder/MakeTagsMojo.java (original)
+++ myfaces/myfaces-build-tools/branches/builder_plugin/myfaces-builder-plugin/src/main/java/org/apache/myfaces/buildtools/maven2/plugin/builder/MakeTagsMojo.java Tue Apr 8 17:42:39 2008
@@ -102,16 +102,33 @@
private File generatedSourceDirectory;
/**
+ * Only generate tag classes that contains that package prefix
+ *
* @parameter
* @required
*/
private String packageContains;
/**
+ * Only generate tag classes that its component starts with this type prefix
+ *
* @parameter
- * @required
*/
private String typePrefix;
+
+ /**
+ * Replace the package prefix
+ *
+ * @parameter
+ */
+ private String replacePackagePrefixFrom;
+
+ /**
+ * Replace the package prefix
+ *
+ * @parameter
+ */
+ private String replacePackagePrefixTo;
/**
* @parameter
@@ -150,6 +167,7 @@
Model model = IOUtils.loadModel(new File(buildDirectory,
metadataFile));
List models = IOUtils.getModelsFromArtifacts(project);
+ resolveReplacePackage(model);
new Flattener(model).flatten();
generateComponents(model);
}
@@ -163,6 +181,30 @@
}
}
+ private void resolveReplacePackage(Model model)
+ {
+ if (replacePackagePrefixFrom == null ||
+ replacePackagePrefixTo == null)
+ return;
+
+ List components = model.getComponents();
+ for (Iterator i = components.iterator(); i.hasNext();)
+ {
+ ComponentMeta comp = (ComponentMeta) i.next();
+
+ if (comp.getTagClass() == null)
+ {
+ break;
+ }
+ if (comp.getTagClass().startsWith(replacePackagePrefixFrom))
+ {
+ comp.setTagClass(StringUtils.replaceOnce(
+ comp.getTagClass(), replacePackagePrefixFrom, replacePackagePrefixTo));
+ log.info("Tag class changed to:"+comp.getTagClass());
+ }
+ }
+ }
+
private VelocityEngine initVelocity() throws MojoExecutionException
{
@@ -225,7 +267,7 @@
File f = new File(mainSourceDirectory, StringUtils.replace(
component.getTagClass(), ".", "/")+".java");
- if (!f.exists() && modelIds.contains(component.getModelId()))
+ if (!f.exists() && canGenerateComponentTag(component))
{
log.info("Generating tag class:"+component.getTagClass());
_generateComponent(velocityEngine, component,baseContext);
@@ -234,6 +276,59 @@
}
//throw new MojoExecutionException("stopping..");
}
+
+ public boolean canGenerateComponentTag(ComponentMeta component)
+ {
+ if ( modelIds.contains(component.getModelId())
+ && includePackageTag(component)
+ && includeType(component))
+ {
+ return true;
+ }
+ else
+ {
+ return false;
+ }
+ }
+
+ public boolean includePackageTag(ComponentMeta component)
+ {
+ if (packageContains != null)
+ {
+ if (component.getTagPackage().startsWith(packageContains))
+ {
+ return true;
+ }
+ else
+ {
+ return false;
+ }
+ }
+ else
+ {
+ return true;
+ }
+ }
+
+ public boolean includeType(ComponentMeta component)
+ {
+ if (typePrefix != null)
+ {
+ if (component.getType().startsWith(typePrefix))
+ {
+ return true;
+ }
+ else
+ {
+ return false;
+ }
+ }
+ else
+ {
+ return true;
+ }
+ }
+
/**
* Generates a parsed component.
Modified: myfaces/myfaces-build-tools/branches/builder_plugin/test/api/pom.xml
URL: http://svn.apache.org/viewvc/myfaces/myfaces-build-tools/branches/builder_plugin/test/api/pom.xml?rev=646155&r1=646154&r2=646155&view=diff
==============================================================================
--- myfaces/myfaces-build-tools/branches/builder_plugin/test/api/pom.xml (original)
+++ myfaces/myfaces-build-tools/branches/builder_plugin/test/api/pom.xml Tue Apr 8 17:42:39 2008
@@ -25,8 +25,8 @@
<artifactId>myfaces-builder-plugin</artifactId>
<version>1.0.0-SNAPSHOT</version>
<configuration>
- <packageContains>org.apache</packageContains>
- <typePrefix>org.apache</typePrefix>
+ <packageContains>javax.faces</packageContains>
+ <typePrefix>javax.faces</typePrefix>
</configuration>
<executions>
<execution>
@@ -37,6 +37,10 @@
<execution>
<id>maketags</id>
<configuration>
+ <packageContains>org.apache</packageContains>
+ <typePrefix>javax.faces</typePrefix>
+ <replacePackagePrefixFrom>javax.faces.component.html</replacePackagePrefixFrom>
+ <replacePackagePrefixTo>org.apache.myfaces.shared_tomahawk.taglib</replacePackagePrefixTo>
<modelIds>
<modelId>myfaces-builder-plugin-test-api</modelId>
</modelIds>