You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by John Casey <jd...@commonjava.org> on 2005/09/21 18:55:58 UTC

Re: [m2] first attempt at maven with single-source

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

What about a plugin that generates those pom files somehow? you'd need a
map of interdependencies, I guess...but rather than instantiating a
bunch of 'ghost' POMs on the fly, a generator plugin could give you
something to put in version control and track history on...

Just a thought.

- -john

Ashley Williams wrote:
| I believe with just a few pom.xml tweaks I've managed to get  something
| of a single source project to work with maven. It could be  that a few
| bug fixes since Maven alpha have helped since the last  time I tried but
| here's what I did.
|
| 1. Designed a bogus project consisting of a gui artifact that depends
| on a util artifact each with a single class: Main.java and Util.java
| respectively. Additionally the gui component uses a resource file
| called gui.properties. I then arranged this project into the  following
| directory structure:
|
| com
| --------acme [pom.xml]
| ----------------util [Util.java, pom.xml]
| ----------------gui [Main.java, pom.xml]
| ------------------------resources [gui.properties]
|
|
| 2. The gui and util poms only declare the acme/pom as a parent and
| don't even have their own build section. The acme/pom.xml parent
| contains the necessary tweaks that the child poms inherit, namely
| inside the build section:
|
| acme/pom.xml:
|
| <project>
|   <modelVersion>4.0.0</modelVersion>
|   <groupId>com.acme</groupId>
|   <artifactId>app</artifactId>
|   <packaging>pom</packaging>
|   <version>1.0-SNAPSHOT</version>
|   <name>Acme Application</name>
|   <modules>
|     <module>util</module>
|     <module>gui</module>
|   </modules>
|   <build>
|     <sourceDirectory>.</sourceDirectory>
|     <resources>
|       <resource>
|         <directory>resources</directory>
|       </resource>
|     </resources>
|   </build>
| </project>
| ~
|
| In other words the java files and resources/ directory are to be  found
| in the same directory as the pom.xml file for any given  artifact project.
|
| 3. I ran the install phase as follows:
|
|  > cd com/acme
|  > m2 install
|
| which caused the target directories to be generated also at the same
| level as each pom - for example com/acme/util/target and com/acme/gui/
| target.
|
| 4. I examined the jar files in each target directory for example "jar
| tvf com/acme/gui/target/gui-1.0-SNAPSHOT.jar" resulted in:
|
| META-INF/
| META-INF/MANIFEST.MF
| META-INF/maven/
| META-INF/maven/com.acme/
| META-INF/maven/com.acme/gui/
| META-INF/maven/com.acme/gui/pom.xml
| com/
| com/acme/
| com/acme/gui/
| com/acme/gui/Main.class
| gui.properties
| META-INF/maven/com.acme/gui/pom.properties
|
| which looks fine. I also ran "m2 site:site" as a random goal and that
| seemed to work too, ie a target/site directory was created with all  the
| files correctly generated underneath.
|
| ***************************
|
| My conclusions are that it seems too easy so far and that I've missed  a
| howler - if somebody could point it out?? Also in the acme/pom.xml  file
| I would still need to add the equivalent test tags, eg
| <testResourceDirectory>.
|
| Would it be possible to encapsulate these tweaks and any others that
| become apparent into a plugin so I could do something like the
| following in any application (root) pom:
|
| <build>
|   <plugins>
|     <plugin>
|       <groupId>com.maven.plugins</groupId>
|       <artifactId>project-structure</artifactId>
|       <version>1.0</version>
|       <configuration>
|         <method>one-tree</method>
|       </configuration>
|     </plugin>
|   </plugins>
| </build>
|
| Thanks
| AW
|
| ---------------------------------------------------------------------
| To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
| For additional commands, e-mail: users-help@maven.apache.org
|
|
|
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.6 (GNU/Linux)

iD8DBQFDMZCeK3h2CZwO/4URAkF8AJ9f2rxxfq+da4VUDlnkI8fWMm+0UgCggFeg
MdvAC60sLpKhVf1+qQuqqB0=
=C8AE
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org