You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by de...@apache.org on 2011/02/05 01:20:57 UTC
svn commit: r1067355 - in
/maven/plugins/trunk/maven-remote-resources-plugin/src/site: apt/examples/
apt/examples/sharing-resources.apt.vm apt/index.apt site.xml
Author: dennisl
Date: Sat Feb 5 00:20:57 2011
New Revision: 1067355
URL: http://svn.apache.org/viewvc?rev=1067355&view=rev
Log:
o Add an example on how to share resources between modules in a multi module build.
Added:
maven/plugins/trunk/maven-remote-resources-plugin/src/site/apt/examples/
maven/plugins/trunk/maven-remote-resources-plugin/src/site/apt/examples/sharing-resources.apt.vm (with props)
Modified:
maven/plugins/trunk/maven-remote-resources-plugin/src/site/apt/index.apt
maven/plugins/trunk/maven-remote-resources-plugin/src/site/site.xml
Added: maven/plugins/trunk/maven-remote-resources-plugin/src/site/apt/examples/sharing-resources.apt.vm
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-remote-resources-plugin/src/site/apt/examples/sharing-resources.apt.vm?rev=1067355&view=auto
==============================================================================
--- maven/plugins/trunk/maven-remote-resources-plugin/src/site/apt/examples/sharing-resources.apt.vm (added)
+++ maven/plugins/trunk/maven-remote-resources-plugin/src/site/apt/examples/sharing-resources.apt.vm Sat Feb 5 00:20:57 2011
@@ -0,0 +1,170 @@
+ ------
+ Sharing Resources
+ ------
+ Dennis Lundberg
+ ------
+ 2011-02-05
+ ------
+
+~~ 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.
+
+Sharing Resources
+
+ The Remote Resources Plugin can also be used to share resources between
+ modules in a multi module build. In the following example we have a set of
+ files that are used to set up a test environment for a database. We want to
+ reuse these resources in several modules in our project.
+
+
+* Set up a module for the resources to be shared
+
+ Create a new module called <<<shared-resources>>>. Put the files in a
+ directory layout like the one below, making sure that your resource files are
+ in the <<<src/main/resources>>> directory:
+
+-------------------
+shared-resources
+|
++- src
+| |
+| `- main
+| |
+| `- resources
+| |
+| +- database.ddl
+| |
+| `- database.sql
+|
+`- pom.xml
+-------------------
+
+ The POM for <<<shared-resources>>> should look like this:
+
+-------------------
+<project>
+ ...
+ <groupId>org.test</groupId>
+ <artifactId>shared-resources</artifactId>
+ ...
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-remote-resources-plugin</artifactId>
+ <version>${project.version}</version>
+ <executions>
+ <execution>
+ <goals>
+ <goal>bundle</goal>
+ </goals>
+ </execution>
+ </executions>
+ <configuration>
+ <includes>
+ <include>**/*.ddl</include>
+ <include>**/*.sql</include>
+ </includes>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ ...
+</project>
+-------------------
+
+ This will bundle the shared resources in a JAR file during the
+ <<<generate-resources>>> phase. This means that others modules can consume
+ these resources in any phase after that.
+
+
+* Configure other modules to use the shared module
+
+ To use the shared resources in another module you need to configure the plugin
+ as follows:
+
+-------------------
+<project>
+ ...
+ <groupId>org.test</groupId>
+ <artifactId>resource-consumer</artifactId>
+ ...
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-remote-resources-plugin</artifactId>
+ <version>${project.version}</version>
+ <configuration>
+ <resourceBundles>
+ <resourceBundle>org.test:shared-resources:\${project.version}</resourceBundle>
+ </resourceBundles>
+ </configuration>
+ <executions>
+ <execution>
+ <goals>
+ <goal>process</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ ...
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>sql-maven-plugin</artifactId>
+ <version>1.4</version>
+ ...
+ <!-- Not showing dependencies or configuration here for brevity -->
+ ...
+ <executions>
+ <execution>
+ <id>create-schema</id>
+ <phase>process-test-resources</phase>
+ <goals>
+ <goal>execute</goal>
+ </goals>
+ <configuration>
+ <autocommit>true</autocommit>
+ <srcFiles>
+ <srcFile>\${project.build.directory}/maven-shared-archive-resources/database.ddl</srcFile>
+ <srcFile>\${project.build.directory}/maven-shared-archive-resources/database.sql</srcFile>
+ </srcFiles>
+ </configuration>
+ </execution>
+ ...
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+ ...
+ <dependencies>
+ <dependency>
+ <groupId>\${project.groupId}</groupId>
+ <artifactId>shared-resources</artifactId>
+ <version>\${project.version}</version>
+ </dependency>
+ </dependencies>
+</project>
+-------------------
+
+ This will retrieve the bundled resources of the <<<shared-resources>>>
+ module, process each resource in the bundle and put them in the
+ <<<\${project.build.directory}/shared-resources>>> directory of the
+ <<<resource-consumer>>> module.
+
+ That means we can use those files in the SQL Maven Plugin to set up the
+ database schema using a DDL file, and add some data to the database using an
+ SQL file.
Propchange: maven/plugins/trunk/maven-remote-resources-plugin/src/site/apt/examples/sharing-resources.apt.vm
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/plugins/trunk/maven-remote-resources-plugin/src/site/apt/examples/sharing-resources.apt.vm
------------------------------------------------------------------------------
svn:keywords = Date Revision Author Id
Modified: maven/plugins/trunk/maven-remote-resources-plugin/src/site/apt/index.apt
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-remote-resources-plugin/src/site/apt/index.apt?rev=1067355&r1=1067354&r2=1067355&view=diff
==============================================================================
--- maven/plugins/trunk/maven-remote-resources-plugin/src/site/apt/index.apt (original)
+++ maven/plugins/trunk/maven-remote-resources-plugin/src/site/apt/index.apt Sat Feb 5 00:20:57 2011
@@ -70,9 +70,9 @@ Maven Remote Resources Plugin
{{{./source-repository.html}source repository}} and will find supplementary information in the
{{{http://maven.apache.org/guides/development/guide-helping.html}guide to helping with Maven}}.
-~~* Examples
-~~
-~~ To provide you with better understanding of some usages of the Remote Resources Plugin,
-~~ you can take a look at the following examples:
-~~
-~~ * {{{./examples/example.html}Sample Example}}
+* Examples
+
+ To provide you with better understanding of some usages of the Remote Resources Plugin,
+ you can take a look at the following examples:
+
+ * {{{./examples/sharing-resources.html}Sharing Resources Example}}
Modified: maven/plugins/trunk/maven-remote-resources-plugin/src/site/site.xml
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-remote-resources-plugin/src/site/site.xml?rev=1067355&r1=1067354&r2=1067355&view=diff
==============================================================================
--- maven/plugins/trunk/maven-remote-resources-plugin/src/site/site.xml (original)
+++ maven/plugins/trunk/maven-remote-resources-plugin/src/site/site.xml Sat Feb 5 00:20:57 2011
@@ -27,10 +27,13 @@ under the License.
<item name="Introduction" href="index.html"/>
<item name="Goals" href="plugin-info.html"/>
<item name="Usage" href="usage.html"/>
- <item name="Advanced Usage">
- <item name="Supplemental Models" href="supplemental-models.html"/>
- </item>
<item name="FAQ" href="faq.html"/>
</menu>
+ <menu name="Examples">
+ <item name="Sharing Resources" href="examples/sharing-resources.html"/>
+ </menu>
+ <menu name="Advanced Usage">
+ <item name="Supplemental Models" href="supplemental-models.html"/>
+ </menu>
</body>
</project>