sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject svn commit: r1519676 - in /sis/branches/JDK7: ./ core/sis-build-helper/ core/sis-build-helper/src/main/java/org/apache/sis/util/resources/ core/sis-build-helper/src/main/resources/META-INF/ ide-project/NetBeans/
Date Tue, 03 Sep 2013 13:34:59 GMT
Author: desruisseaux
Date: Tue Sep  3 13:34:58 2013
New Revision: 1519676

URL: http://svn.apache.org/r1519676
Log:
Merge from the trunk.

Added:
    sis/branches/JDK7/core/sis-build-helper/src/main/resources/META-INF/
      - copied from r1519674, sis/trunk/core/sis-build-helper/src/main/resources/META-INF/
Modified:
    sis/branches/JDK7/   (props changed)
    sis/branches/JDK7/CHANGES
    sis/branches/JDK7/core/sis-build-helper/pom.xml
    sis/branches/JDK7/core/sis-build-helper/src/main/java/org/apache/sis/util/resources/ResourceCompilerMojo.java
    sis/branches/JDK7/ide-project/NetBeans/build.xml

Propchange: sis/branches/JDK7/
------------------------------------------------------------------------------
  Merged /sis/trunk:r1519089-1519674

Modified: sis/branches/JDK7/CHANGES
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/CHANGES?rev=1519676&r1=1519675&r2=1519676&view=diff
==============================================================================
--- sis/branches/JDK7/CHANGES (original)
+++ sis/branches/JDK7/CHANGES Tue Sep  3 13:34:58 2013
@@ -1,5 +1,11 @@
 Apache SIS Change Log
 ======================
+Release 0.4 - Current Development
+
+* SIS-133 ResourceCompilerMojo should execute only when properties files are modified
+          (Olivier Nouguier via mattmann)
+
+* SIS-132 Better support for eclipse IDE (Olivier Nouguier via mattmann)
 
 Release 0.3 - 06/29/2013
 

Modified: sis/branches/JDK7/core/sis-build-helper/pom.xml
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-build-helper/pom.xml?rev=1519676&r1=1519675&r2=1519676&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-build-helper/pom.xml (original)
+++ sis/branches/JDK7/core/sis-build-helper/pom.xml Tue Sep  3 13:34:58 2013
@@ -66,7 +66,16 @@ Define Maven Mojos and Javadoc taglets f
     </developer>
   </developers>
   <contributors>
-    <!-- To prevent inheritance from parent pom.xml -->
+    <contributor>
+      <name>Olivier Nouguier</name>
+      <email>olivier.nouguier@geomatys.com</email>
+      <organization>Geomatys</organization>
+      <organizationUrl>http://www.geomatys.com</organizationUrl>
+      <timezone>+1</timezone>
+      <roles>
+        <role>developer</role>
+      </roles>
+    </contributor>
   </contributors>
 
 
@@ -84,6 +93,11 @@ Define Maven Mojos and Javadoc taglets f
       <artifactId>maven-plugin-api</artifactId>
       <version>3.0.5</version>
     </dependency>
+     <dependency>
+      <groupId>org.sonatype.plexus</groupId>
+      <artifactId>plexus-build-api</artifactId>
+      <version>0.0.7</version>
+    </dependency>
     <dependency>
       <groupId>org.apache.commons</groupId>
       <artifactId>commons-compress</artifactId>

Modified: sis/branches/JDK7/core/sis-build-helper/src/main/java/org/apache/sis/util/resources/ResourceCompilerMojo.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-build-helper/src/main/java/org/apache/sis/util/resources/ResourceCompilerMojo.java?rev=1519676&r1=1519675&r2=1519676&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-build-helper/src/main/java/org/apache/sis/util/resources/ResourceCompilerMojo.java
[UTF-8] (original)
+++ sis/branches/JDK7/core/sis-build-helper/src/main/java/org/apache/sis/util/resources/ResourceCompilerMojo.java
[UTF-8] Tue Sep  3 13:34:58 2013
@@ -19,8 +19,13 @@ package org.apache.sis.util.resources;
 import java.io.File;
 import java.io.FilenameFilter;
 import java.util.List;
+
+import org.apache.maven.model.Resource;
 import org.apache.maven.plugin.AbstractMojo;
 import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.project.MavenProject;
+import org.codehaus.plexus.util.Scanner;
+import org.sonatype.plexus.build.incremental.BuildContext;
 
 
 /**
@@ -28,9 +33,10 @@ import org.apache.maven.plugin.MojoExecu
  * See the <code><a href="{@website}/sis-build-helper/index.html">sis-build-helper</a></code>
module
  * for more information.
  *
- * @author Martin Desruisseaux (Geomatys)
+ * @author  Martin Desruisseaux (Geomatys)
+ * @author  Olivier Nouguier (Geomatys)
  * @since   0.3 (derived from geotk-3.00)
- * @version 0.3
+ * @version 0.4
  * @module
  *
  * @goal compile-resources
@@ -38,6 +44,25 @@ import org.apache.maven.plugin.MojoExecu
  */
 public class ResourceCompilerMojo extends AbstractMojo implements FilenameFilter {
     /**
+     * Project information (name, version, URL).
+     *
+     * @parameter expression="${project}"
+     * @required
+     * @readonly
+     */
+    private MavenProject project;
+
+    /**
+     * A handler for the Eclipse workspace, used for declaring new resources.
+     * When Maven is run from the command line, this object does nothing.
+     *
+     * @see <a href="http://wiki.eclipse.org/M2E_compatible_maven_plugins">M2E compatible
maven plugins</a>
+     *
+     * @component
+     */
+    private BuildContext buildContext;
+
+    /**
      * The source directories containing the sources to be compiled.
      *
      * @parameter property="project.compileSourceRoots"
@@ -49,10 +74,17 @@ public class ResourceCompilerMojo extend
     /**
      * Directory containing the generated class files.
      *
-     * @parameter property="project.build.outputDirectory"
+     * <p><b>Note:</b> at the time of writing, we found no well-established
convention for generated resources.
+     * The conventions that we found were rather for generated sources. In the later case,
the conventions use
+     * a different directory for each Maven plugin, e.g. <code>"generated-sources/xxx"</code>.
But in our case
+     * (for resources), such separation seems of limited use since the resources are copied
verbatim in the JAR
+     * file, so preventing clash in the <code>generated-resources</code> directory
would not prevent clash in
+     * the JAR file anyway.</p>
+     *
+     * @parameter default-value="${project.build.directory}/generated-resources"
      * @required
      */
-    private String outputDirectory;
+    private File outputDirectory;
 
     /**
      * The <code>compileSourceRoots</code> named "java" as a <code>File</code>.
@@ -60,25 +92,38 @@ public class ResourceCompilerMojo extend
     private File javaDirectoryFile;
 
     /**
-     * The <code>outputDirectory</code> as a <code>File</code>.
-     */
-    private File outputDirectoryFile;
-
-    /**
      * Executes the mojo.
      *
      * @throws MojoExecutionException if the plugin execution failed.
      */
     @Override
-    @SuppressWarnings({"unchecked","rawtypes"}) // Generic array creation.
     public void execute() throws MojoExecutionException {
+        final boolean isIncremental = buildContext.isIncremental();
+    	declareOutputDirectory();
+
         int errors = 0;
-        outputDirectoryFile = new File(outputDirectory);
         for (final String sourceDirectory : compileSourceRoots) {
             final File directory = new File(sourceDirectory);
             if (directory.getName().equals("java")) {
+                /*
+                 * Check if we can skip the resources compilation (Eclipse environment only).
+                 *
+                 * Scanner.getIncludedFiles() returns an array of modified files. For now
we ignore the array
+                 * content and unconditionally re-compile all resource files as soon as at
least one file has
+                 * been modified. This is okay for now since changes in resource files are
rare and compiling
+                 * them is very fast.
+                 */
+                if (!isIncremental) {
+                    Scanner scanner = buildContext.newScanner(directory);
+                    scanner.setIncludes(new String[] {"*.properties"});
+                    scanner.scan();
+                    if (scanner.getIncludedFiles() == null) {
+                        continue;
+                    }
+                }
                 javaDirectoryFile = directory;
                 errors += processAllResourceDirectories(directory);
+                buildContext.refresh(directory);
             }
         }
         if (errors != 0) {
@@ -87,6 +132,15 @@ public class ResourceCompilerMojo extend
     }
 
     /**
+     * Declares {@link #outputDirectory} as resource, for inclusion by Maven in the JAR file.
+     */
+    private void declareOutputDirectory() {
+        final Resource resource = new Resource();
+        resource.setDirectory(outputDirectory.getPath());
+        project.addResource(resource);
+    }
+
+    /**
      * Recursively scans the directories for a sub-package named "resources",
      * then invokes the resource compiler for that directory.
      */
@@ -134,7 +188,7 @@ public class ResourceCompilerMojo extend
      */
     private final class Compiler extends IndexedResourceCompiler {
         public Compiler(File[] resourcesToProcess) {
-            super(javaDirectoryFile, outputDirectoryFile, resourcesToProcess);
+            super(javaDirectoryFile, outputDirectory, resourcesToProcess);
         }
 
         /**

Modified: sis/branches/JDK7/ide-project/NetBeans/build.xml
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/ide-project/NetBeans/build.xml?rev=1519676&r1=1519675&r2=1519676&view=diff
==============================================================================
--- sis/branches/JDK7/ide-project/NetBeans/build.xml (original)
+++ sis/branches/JDK7/ide-project/NetBeans/build.xml Tue Sep  3 13:34:58 2013
@@ -33,7 +33,7 @@
   -->
   <target name="-post-compile">
     <copy todir="${build.classes.dir}/org/apache/sis/util/resources">
-      <fileset dir="${project.root}/core/sis-utility/target/classes/org/apache/sis/util/resources">
+      <fileset dir="${project.root}/core/sis-utility/target/generated-resources/org/apache/sis/util/resources">
         <include name="*.utf"/>
       </fileset>
     </copy>



Mime
View raw message