maven-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Randy Xu...@post.harvard.edu>
Subject What is the variable scoping in Maven?
Date Mon, 03 Jan 2005 16:58:54 GMT
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


Mime
View raw message