Return-Path: X-Original-To: apmail-sis-commits-archive@www.apache.org Delivered-To: apmail-sis-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 7F6DD1006D for ; Tue, 3 Sep 2013 13:35:26 +0000 (UTC) Received: (qmail 94661 invoked by uid 500); 3 Sep 2013 13:35:26 -0000 Delivered-To: apmail-sis-commits-archive@sis.apache.org Received: (qmail 94632 invoked by uid 500); 3 Sep 2013 13:35:25 -0000 Mailing-List: contact commits-help@sis.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: sis-dev@sis.apache.org Delivered-To: mailing list commits@sis.apache.org Received: (qmail 94624 invoked by uid 99); 3 Sep 2013 13:35:25 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 03 Sep 2013 13:35:25 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 03 Sep 2013 13:35:22 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 3C3D423888CD; Tue, 3 Sep 2013 13:34:59 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit 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 -0000 To: commits@sis.apache.org From: desruisseaux@apache.org X-Mailer: svnmailer-1.0.9 Message-Id: <20130903133459.3C3D423888CD@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org 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 - + + Olivier Nouguier + olivier.nouguier@geomatys.com + Geomatys + http://www.geomatys.com + +1 + + developer + + @@ -84,6 +93,11 @@ Define Maven Mojos and Javadoc taglets f maven-plugin-api 3.0.5 + + org.sonatype.plexus + plexus-build-api + 0.0.7 + org.apache.commons commons-compress 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 sis-build-helper 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 M2E compatible maven plugins + * + * @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" + *

Note: 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. "generated-sources/xxx". 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 generated-resources directory would not prevent clash in + * the JAR file anyway.

+ * + * @parameter default-value="${project.build.directory}/generated-resources" * @required */ - private String outputDirectory; + private File outputDirectory; /** * The compileSourceRoots named "java" as a File. @@ -60,25 +92,38 @@ public class ResourceCompilerMojo extend private File javaDirectoryFile; /** - * The outputDirectory as a File. - */ - 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 @@ --> - +