You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Randy Xu <r...@post.harvard.edu> on 2005/01/03 17:58:54 UTC
What is the variable scoping in Maven?
Thanks for the quick reply to my last question about referencing
maven.depedency.classpath in maven.xml
Does anyone know if there's a definitive guide to varibale scoping in
Maven? Right now, I'm unsure how to proceed with my multi-project
setup. It confuses me. I have the following directories/projects based
on a sample multi-project I saw online (app is not the actual name of my
application):
* maven.root - the multiproject root
* app-lib
* app-jms (depends on lib)
* app-gui (depends on lib, jms)
Each of the projects has a maven.properties and project.xml. The version
is currently 1.0-dev.
app-jms has a maven.xml to run a post-processor as a preGoal before jar:jar
Each subproject's project.xml extends maven.root:
<extend>${basedir}/../maven.root/project.xml</extend>
Most of the external dependencies are in maven.root, while 'internal'
dependencies are defined in each subproject. For example, app-jms will
have:
<dependency>
<groupId>com.mystuff.myapp</groupId>
<artifactId>app-lib</artifactId>
<version>1.0-dev</version>
<type>jar</type>
</dependency>
</dependencies>
My project.properties in maven.root is:
maven.multiproject.basedir=${basedir}/../
maven.multiproject.includes=*/project.xml
maven.multiproject.excludes=maven.root/project.xml
maven.repo.remote=http://192.168.12.113/,http://www.ibiblio.org/maven/
My project.properties in jms is like:
maven.multiproject.type = jar
maven.jar.override = on
maven.jar.app-lib = ../lib/target/app-lib-1.0-dev.jar
Questions:
1) Are project.properties settings inherited when project.xml is inherited?
2) Can/how (do) we define variables in project.xml? I assume those are
inherited.
3) Can project.xml members be references in project.xml? I really don't
like hardcoding the filenames of the internal subproject dependencies in
project.properties and project.xml. For example can I do something like
the following (this currently doesn't work):
<dependency>
<groupId>com.blah.app</groupId>
<artifactId>app-lib</artifactId>
<version>${pom.version}</version>
<type>jar</type>
<jar>${basedir}/../app-lib/target/app-lib-${pom.version}.jar</jar>
</dependency>
3b) Or better yet, not even define the <jar/> but just have it know
that it's in
${basedir}/../${artifactId}/target/${artifactId}-${pom.version}.jar
4) Can/how (do) I reference all of this in maven.xml? I'd like it so
when the jars are built that they are copied over to a top level
directory '/deploy' So based on the answer to question 1, it may work
to put maven.deploy.dir in maven.root/project.properties right? And is
there a way I can tell it exactly to include app-lib-1.0-dev.jar without
resorting to *.jar?
<postGoal name="jar:jar">
<copy todir="${maven.deploy.dir}>
<fileset dir="${basedir}/target/">
<include name="*.jar">
</fileset>
</copy>
-Randy X
r@post.harvard.edu
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org
Re: What is the variable scoping in Maven?
Posted by "Jefferson K. French" <je...@frenches.org>.
On Mon, 03 Jan 2005, at 11:58:54 [GMT -0500] Randy Xu wrote:
> 1) Are project.properties settings inherited when project.xml is inherited?
Yes
> 2) Can/how (do) we define variables in project.xml? I assume those are
> inherited.
I don't know about defining them, but you can use variables in
project.xml. For instance, I have this in mine:
<developerConnection>
scm:cvs:pserver:${maven.username}@myhost:/home/cvs:myproj
</developerConnection>
> 3) Can project.xml members be references in project.xml? I really don't
> like hardcoding the filenames of the internal subproject dependencies in
> project.properties and project.xml. For example can I do something like
> the following (this currently doesn't work):
> <dependency>
> <groupId>com.blah.app</groupId>
> <artifactId>app-lib</artifactId>
> <version>${pom.version}</version>
> <type>jar</type>
> <jar>${basedir}/../app-lib/target/app-lib-${pom.version}.jar</jar>
> </dependency>
> 3b) Or better yet, not even define the <jar/> but just have it know
> that it's in
> ${basedir}/../${artifactId}/target/${artifactId}-${pom.version}.jar
You don't need the <jar> element. If you do a multiproject:install,
your artifacts will get installed in your local repo. Your
<dependency> (without the <jar>) then tells Maven to find that jar in
your local repo, so you don't need to give an exact path.
> 4) Can/how (do) I reference all of this in maven.xml? I'd like it so
> when the jars are built that they are copied over to a top level
> directory '/deploy' So based on the answer to question 1, it may work
> to put maven.deploy.dir in maven.root/project.properties right? And is
> there a way I can tell it exactly to include app-lib-1.0-dev.jar without
> resorting to *.jar?
> <postGoal name="jar:jar">
> <copy todir="${maven.deploy.dir}>
> <fileset dir="${basedir}/target/">
> <include name="*.jar">
> </fileset>
> </copy>
If you just want to bundle all your jars for distribution (say into a
zip), you can create another subproject that references the other
artifacts in its dependency list. Then you can copy them from your
local repo to a temp location before zipping. For an idea of how to do
this, check out the war plugin and search for 'war.bundle'.
Jeff
--
mailto:jeff@frenches.org
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org