You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@maven.apache.org by jv...@apache.org on 2005/10/04 22:17:30 UTC

svn commit: r294908 - /maven/components/trunk/maven-site/src/site/apt/guides/getting-started/index.apt

Author: jvanzyl
Date: Tue Oct  4 13:17:26 2005
New Revision: 294908

URL: http://svn.apache.org/viewcvs?rev=294908&view=rev
Log:
o show users how to package resources inside jars

Modified:
    maven/components/trunk/maven-site/src/site/apt/guides/getting-started/index.apt

Modified: maven/components/trunk/maven-site/src/site/apt/guides/getting-started/index.apt
URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-site/src/site/apt/guides/getting-started/index.apt?rev=294908&r1=294907&r2=294908&view=diff
==============================================================================
--- maven/components/trunk/maven-site/src/site/apt/guides/getting-started/index.apt (original)
+++ maven/components/trunk/maven-site/src/site/apt/guides/getting-started/index.apt Tue Oct  4 13:17:26 2005
@@ -373,8 +373,80 @@
 
 +----+
 
-~~* How do I package resources inside my JAR?
-~~  o EIDSL
+ We'll touch on one more common usecase that can be satisfied which requires no changes to the POM that we have
+ above which is packaging resources in JAR files. For this common task Maven again relies on the
+ {{{introduction-to-the-standard-directory-layout.html}Standard Directory Layout}} which means by using
+ standard Maven coventions you can package resources within JARs simply by placing resources in a standard
+ directory structure.
+
+ You see below in our example we have added the directory <<<${basedir}/src/main/resources>>> into which we place
+ any resources we wish to package in our JAR. The simple rule employed by Maven is this: any directories or files
+ placed within the <<<${basedir}/src/main/resources>>> directory are packaged in your JAR with the exact same
+ structure starting at the base of the JAR
+
++----+
+
+my-app
+|-- pom.xml
+`-- src
+    |-- main
+    |   |-- java
+    |   |   `-- com
+    |   |       `-- mycompany
+    |   |           `-- app
+    |   |               `-- App.java
+    |   `-- resources
+    |       `-- META-INF
+    |           `-- application.properties
+    `-- test
+        `-- java
+            `-- com
+                `-- mycompany
+                    `-- app
+                        `-- AppTest.java
++----+
+
+ So you can see in our example that we have a <<<META-INF>>> directory with an <<<application.properties>>> file
+ within that directory. If you unpacked the JAR that Maven created for you and took a look at it you would
+ see the following:
+
++----+
+
+|-- META-INF
+|   |-- MANIFEST.MF
+|   |-- application.properties
+|   `-- maven
+|       `-- com.mycompany.app
+|           `-- my-app
+|               |-- pom.properties
+|               `-- pom.xml
+`-- com
+    `-- mycompany
+        `-- app
+            `-- App.class
+
++----+
+
+ As you can see the contents of <<<${basedir}/src/main/resources>>> can be found starting at the base of the
+ JAR and you will see our <<<application.properties>>> file. You will also notice some other files there
+ like <<<META-INF/MANIFEST.MF>>> and a <<<pom.xml>>> and <<<pom.properties>>> file. These come standard with
+ generation of a JAR in Maven. You create your own manifest if you choose, but Maven will generate one by
+ default for you if you don't. You may also modify the entries in the default manifest which we will touch on
+ later. The <<<pom.xml>>> and <<<pom.properties>>> files are packaged up in the JAR so that each artifact
+ produced by Maven is self-describing and it also allows you to utilize the metadata in your own application
+ if the need arises. One simple use might be to retrieve the version of your application. Operating on the POM
+ file would require you to use some Maven utilities but the properties can be utilized using the standard
+ Java API and looks like the following:
+
++----+
+
+#Generated by Maven
+#Tue Oct 04 15:43:21 GMT-05:00 2005
+version=1.0-SNAPSHOT
+groupId=com.mycompany.app
+artifactId=my-app
+
++----+
 
 ~~* How do I filter resources against a properties file?
 
@@ -618,6 +690,10 @@
 ==
 
 example of generating sources
+
+==
+
+How to modify the manifest.
 
 +-----+
 



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