myfaces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bom...@apache.org
Subject svn commit: r1517146 - in /myfaces/tobago/trunk: tobago-theme/ tobago-theme/tobago-theme-scarborough/ tobago-theme/tobago-theme-standard/ tobago-tool/tobago-theme-plugin/ tobago-tool/tobago-theme-plugin/src/main/java/org/apache/myfaces/tobago/maven/plu...
Date Sat, 24 Aug 2013 15:21:09 GMT
Author: bommel
Date: Sat Aug 24 15:21:09 2013
New Revision: 1517146

URL: http://svn.apache.org/r1517146
Log:
(TOBAGO-1302)
Add support for a theme resources index file per theme

Added:
    myfaces/tobago/trunk/tobago-tool/tobago-theme-plugin/src/main/java/org/apache/myfaces/tobago/maven/plugin/IndexThemeMojo.java
  (with props)
Modified:
    myfaces/tobago/trunk/tobago-theme/pom.xml
    myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/pom.xml
    myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/pom.xml
    myfaces/tobago/trunk/tobago-tool/tobago-theme-plugin/pom.xml
    myfaces/tobago/trunk/tobago-tool/tobago-theme-plugin/src/main/java/org/apache/myfaces/tobago/maven/plugin/AbstractThemeMojo.java

Modified: myfaces/tobago/trunk/tobago-theme/pom.xml
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-theme/pom.xml?rev=1517146&r1=1517145&r2=1517146&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-theme/pom.xml (original)
+++ myfaces/tobago/trunk/tobago-theme/pom.xml Sat Aug 24 15:21:09 2013
@@ -28,7 +28,17 @@
 
   <build>
     <plugins>
-
+      <plugin>
+        <groupId>org.apache.myfaces.tobago</groupId>
+        <artifactId>tobago-theme-plugin</artifactId>
+        <executions>
+          <execution>
+            <goals>
+              <goal>index</goal>
+            </goals>
+          </execution>
+        </executions>
+      </plugin>
     </plugins>
   </build>
 

Modified: myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/pom.xml
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/pom.xml?rev=1517146&r1=1517145&r2=1517146&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/pom.xml (original)
+++ myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/pom.xml Sat Aug 24 15:21:09
2013
@@ -51,7 +51,7 @@
             <phase>compile</phase>
             <configuration>
               <target>
-                <concat destfile="${project.build.directory}/javascript-min/scarborough/script/tobago.min.js">
+                <concat destfile="${project.build.directory}/javascript-min/scarborough/script/tobago.min.js"
force="no">
                   <filelist dir="${basedir}/src/main/resources/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/script"
files="tobago.js" />
                 </concat>
                 <replaceregexp match="^.*//.*@DEV_ONLY.*$" replace="" byline="true">

Modified: myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/pom.xml
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/pom.xml?rev=1517146&r1=1517145&r2=1517146&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/pom.xml (original)
+++ myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/pom.xml Sat Aug 24 15:21:09 2013
@@ -59,10 +59,10 @@
             <phase>compile</phase>
             <configuration>
               <target>
-                <concat destfile="${project.build.directory}/javascript-min/standard/script/tobago.min.js">
+                <concat destfile="${project.build.directory}/javascript-min/standard/script/tobago.min.js"
force="no">
                   <filelist dir="${basedir}/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script"
files="tobago.js,tobago-calendar.js,tobago-converter.js,tobago-in.js,tobago-menu.js,tobago-overlay.js,tobago-popup.js,tobago-sheet.js,tobago-suggest.js,tobago-tree.js,tobago-utils.js"
/>
                 </concat>
-                <concat destfile="${project.build.directory}/javascript-min/msie_6_0/script/tobago.min.js">
+                <concat destfile="${project.build.directory}/javascript-min/msie_6_0/script/tobago.min.js"
force="no">
                   <filelist dir="${basedir}/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/msie_6_0/script"
files="tobago.js" />
                 </concat>
                 <replaceregexp match="^.*//.*@DEV_ONLY.*$" replace="" byline="true">

Modified: myfaces/tobago/trunk/tobago-tool/tobago-theme-plugin/pom.xml
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-tool/tobago-theme-plugin/pom.xml?rev=1517146&r1=1517145&r2=1517146&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-tool/tobago-theme-plugin/pom.xml (original)
+++ myfaces/tobago/trunk/tobago-tool/tobago-theme-plugin/pom.xml Sat Aug 24 15:21:09 2013
@@ -36,12 +36,17 @@
     <dependency>
       <groupId>org.apache.maven</groupId>
       <artifactId>maven-plugin-api</artifactId>
-      <version>2.2.1</version>
+      <version>${mavenVersion}</version>
     </dependency>
     <dependency>
       <groupId>org.apache.maven</groupId>
       <artifactId>maven-project</artifactId>
-      <version>2.2.1</version>
+      <version>${mavenVersion}</version>
+    </dependency>
+    <dependency>
+    <groupId>org.apache.maven</groupId>
+      <artifactId>maven-model</artifactId>
+      <version>${mavenVersion}</version>
     </dependency>
     <dependency>
       <groupId>org.apache.maven</groupId>
@@ -51,12 +56,17 @@
     <dependency>
       <groupId>org.codehaus.plexus</groupId>
       <artifactId>plexus-utils</artifactId>
-      <version>2.0.5</version>
+      <version>2.0.6</version>
     </dependency>
     <dependency>
       <groupId>org.apache.maven</groupId>
       <artifactId>maven-artifact</artifactId>
-      <version>2.2.1</version>
+      <version>${mavenVersion}</version>
+    </dependency>
+    <dependency>
+      <groupId>org.codehaus.plexus</groupId>
+      <artifactId>plexus-compiler-api</artifactId>
+      <version>1.5.3</version>
     </dependency>
   </dependencies>
   <build>
@@ -78,4 +88,7 @@
       </plugins>
     </pluginManagement>
   </build>
+  <properties>
+     <mavenVersion>2.2.1</mavenVersion>
+  </properties>
 </project>

Modified: myfaces/tobago/trunk/tobago-tool/tobago-theme-plugin/src/main/java/org/apache/myfaces/tobago/maven/plugin/AbstractThemeMojo.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-tool/tobago-theme-plugin/src/main/java/org/apache/myfaces/tobago/maven/plugin/AbstractThemeMojo.java?rev=1517146&r1=1517145&r2=1517146&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-tool/tobago-theme-plugin/src/main/java/org/apache/myfaces/tobago/maven/plugin/AbstractThemeMojo.java
(original)
+++ myfaces/tobago/trunk/tobago-tool/tobago-theme-plugin/src/main/java/org/apache/myfaces/tobago/maven/plugin/AbstractThemeMojo.java
Sat Aug 24 15:21:09 2013
@@ -35,6 +35,10 @@ public abstract class AbstractThemeMojo 
    */
   private MavenProject project;
 
+  private String[] includes = new String[]{"**"};
+  private String[] excludes = new String[]{"META-INF/**/*",
+      "**/*.properties", "**/*.xml", "**/*.class"};
+
   public MavenProject getProject() {
     return project;
   }
@@ -42,10 +46,19 @@ public abstract class AbstractThemeMojo 
   protected String[] getThemeFiles(File sourceDir) {
     DirectoryScanner scanner = new DirectoryScanner();
     scanner.setBasedir(sourceDir);
-    scanner.setIncludes(new String[]{"**"});
-    scanner.setExcludes(new String [] {"META-INF/**/*",
-        "**/*.properties", "**/*.xml", "**/*.class"});
+    scanner.setIncludes(includes);
+    scanner.setExcludes(excludes);
     scanner.scan();
     return scanner.getIncludedFiles();
   }
+
+  public String[] getIncludes() {
+    return includes;
+  }
+
+  public String[] getExcludes() {
+    return excludes;
+  }
+
+
 }

Added: myfaces/tobago/trunk/tobago-tool/tobago-theme-plugin/src/main/java/org/apache/myfaces/tobago/maven/plugin/IndexThemeMojo.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-tool/tobago-theme-plugin/src/main/java/org/apache/myfaces/tobago/maven/plugin/IndexThemeMojo.java?rev=1517146&view=auto
==============================================================================
--- myfaces/tobago/trunk/tobago-tool/tobago-theme-plugin/src/main/java/org/apache/myfaces/tobago/maven/plugin/IndexThemeMojo.java
(added)
+++ myfaces/tobago/trunk/tobago-tool/tobago-theme-plugin/src/main/java/org/apache/myfaces/tobago/maven/plugin/IndexThemeMojo.java
Sat Aug 24 15:21:09 2013
@@ -0,0 +1,123 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.myfaces.tobago.maven.plugin;
+
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugin.MojoFailureException;
+import org.codehaus.plexus.util.DirectoryScanner;
+import org.codehaus.plexus.util.FileUtils;
+import org.codehaus.plexus.util.IOUtil;
+
+import java.io.BufferedWriter;
+import java.io.File;
+import java.io.IOException;
+import java.io.StringWriter;
+
+/**
+ * @goal index
+ * @phase prepare-package
+ */
+public class IndexThemeMojo extends AbstractThemeMojo {
+
+  /**
+   * Directory containing the resource files that should be listed into the tobago-resources.properties.
+   *
+   * @parameter default-value="${project.build.outputDirectory}"
+   * @required
+   */
+  private File outputDirectory;
+
+  /**
+   * @parameter default-value="${project.build.outputDirectory}/META-INF/tobago-resources.properties"
+   * @required
+   */
+  private File tobagoResourcesFile;
+
+  public void execute() throws MojoExecutionException, MojoFailureException {
+    if ("pom".equalsIgnoreCase(getProject().getPackaging())) {
+      getLog().info("Not creating tobago-resources.properties as the project is a pom package");
+      return;
+    }
+    if (getLog().isDebugEnabled()) {
+      getLog().debug("Scanning resource: " + outputDirectory.getName());
+    }
+
+    if (!outputDirectory.isAbsolute()) {
+      outputDirectory = new File(getProject().getBasedir(), outputDirectory.getPath());
+    }
+    StaleCheckDirectoryScanner scanner = new StaleCheckDirectoryScanner(tobagoResourcesFile.lastModified());
+    scanner.setBasedir(outputDirectory);
+    scanner.setIncludes(getIncludes());
+    scanner.setExcludes(getExcludes());
+    scanner.scan();
+
+    String[] fileNames = scanner.getIncludedFiles();
+    if (fileNames != null && fileNames.length == 0) {
+      getLog().info("Skipping create resource file " + tobagoResourcesFile.getName() + ".
No resources found");
+      return;
+    }
+
+    if (scanner.isUp2date) {
+    //tobagoResourcesFile.lastModified() == 0L || scanner.maxLastModified > tobagoResourcesFile.lastModified())
{
+      File metaInf = tobagoResourcesFile.getParentFile();
+      if (!metaInf.exists()) {
+        if (!metaInf.mkdirs()) {
+          getLog().error("Error creating directory " + metaInf.getName());
+        }
+      }
+      BufferedWriter bufferedWriter = null;
+      try {
+        StringWriter stringWriter = new StringWriter();
+        bufferedWriter = new BufferedWriter(stringWriter);
+        for (String file : scanner.getIncludedFiles()) {
+          bufferedWriter.append(file);
+          bufferedWriter.newLine();
+        }
+        bufferedWriter.flush();
+        // TODO encoding
+        FileUtils.fileWrite(tobagoResourcesFile, stringWriter.toString());
+      } catch (IOException e) {
+        getLog().error("Error creating resource file " + tobagoResourcesFile.getName(), e);
+      } finally {
+        IOUtil.close(bufferedWriter);
+      }
+    } else {
+      getLog().info("Skipping create resource file " + tobagoResourcesFile.getName());
+    }
+  }
+
+  private static class StaleCheckDirectoryScanner extends DirectoryScanner {
+    private long lastModified;
+    private boolean isUp2date = true;
+
+    private StaleCheckDirectoryScanner(long lastModified) {
+      this.lastModified = lastModified;
+    }
+
+    @Override
+    protected boolean isSelected(String name, File file) {
+      long lastModified = file.lastModified();
+      if (lastModified > this.lastModified) {
+        isUp2date = false;
+      }
+      return super.isSelected(name, file);
+    }
+  }
+}

Propchange: myfaces/tobago/trunk/tobago-tool/tobago-theme-plugin/src/main/java/org/apache/myfaces/tobago/maven/plugin/IndexThemeMojo.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: myfaces/tobago/trunk/tobago-tool/tobago-theme-plugin/src/main/java/org/apache/myfaces/tobago/maven/plugin/IndexThemeMojo.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL



Mime
View raw message