You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Henri Yandell <fl...@gmail.com> on 2005/09/07 01:55:13 UTC

[m1] Using dependencies/dependency/properties in maven.xml

Having some problems using dependencies/dependency/properties in the
maven.xml file. Obviously I'm missing something basic :) Using maven
1.0.1.

In my POM, I have the following custom property set for a dependency:

    <dependency>
      <id>oscube</id>
      <version>0.2</version>
      <url>http://www.osjava.org/oscube/</url>
      <properties>
        <multidoc.url>http://dist.osjava.org/releases/multidoc-jnr</multidoc.url
>
      </properties>
    </dependency>

My custom maven.xml file then attempts to get this variable out. The
bad bit being that it doesn't get anything out, just finds an empty
string. The if statement is effectively working correctly, if the
property is not set then it isn't entered etc.

<?xml version="1.0"?>
<project xmlns:j="jelly:core" xmlns:ant="jelly:ant">

  <preGoal name="maven-javadoc-plugin:report">

    <!-- for-each dependency -->
    <j:forEach var="dep" items="${pom.dependencies}">
     <j:if test="${dep.getProperty('multidoc.url') != null}">
      <j:set var="maven.javadoc.links"
value="${maven.javadoc.links},${dep.getProperty('multidoc.url')}/${dep.getArtifactId()}/${dep.getVersion()}/"/>
     </j:if>
    </j:forEach>

  </preGoal>

</project>

Anyway, could anyone let me know what I've done wrong?

Thanks,

Hen

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


Re: [m1] Using dependencies/dependency/properties in maven.xml

Posted by "Henning P. Schmiedehausen" <hp...@intermeta.de>.
Brett Porter <br...@gmail.com> writes:

>------=_Part_7381_9162304.1126055177768
>Content-Type: text/plain; charset=ISO-8859-1
>Content-Transfer-Encoding: quoted-printable
>Content-Disposition: inline

>Looks like it is always going to be that way.

>http://svn.apache.org/viewcvs.cgi/maven/maven-1/core/tags/MAVEN_1_0_2/src/j=
>ava/org/apache/maven/project/BaseObject.java?rev=3D122513&view=3Dmarkup

>The curse of Betwixt and BaseObject. It seems that properties get put in th=
>e=20
>map with "" - hence true for exists, empty string for value.

Then I don't understand why it works for me with maven 1.0.2

	Regards
		Henning

-- 
Dipl.-Inf. (Univ.) Henning P. Schmiedehausen          INTERMETA GmbH
hps@intermeta.de        +49 9131 50 654 0   http://www.intermeta.de/

RedHat Certified Engineer -- Jakarta Turbine Development  -- hero for hire
   Linux, Java, perl, Solaris -- Consulting, Training, Development

		      4 - 8 - 15 - 16 - 23 - 42

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


Re: [m1] Using dependencies/dependency/properties in maven.xml

Posted by "Henning P. Schmiedehausen" <hp...@intermeta.de>.
Brett Porter <br...@gmail.com> writes:

>------=_Part_7381_9162304.1126055177768
>Content-Type: text/plain; charset=ISO-8859-1
>Content-Transfer-Encoding: quoted-printable
>Content-Disposition: inline

>Looks like it is always going to be that way.

>http://svn.apache.org/viewcvs.cgi/maven/maven-1/core/tags/MAVEN_1_0_2/src/j=
>ava/org/apache/maven/project/BaseObject.java?rev=3D122513&view=3Dmarkup

>The curse of Betwixt and BaseObject. It seems that properties get put in th=
>e=20
>map with "" - hence true for exists, empty string for value.

The problem is the ':' in the value. If you remove it, everything
works as expected.  That is a bug. IMHO.

Henri: Workaround: Remove the "http://" from your url, add it in
maven.xml.

	Best regards
		Henning

-- 
Dipl.-Inf. (Univ.) Henning P. Schmiedehausen          INTERMETA GmbH
hps@intermeta.de        +49 9131 50 654 0   http://www.intermeta.de/

RedHat Certified Engineer -- Jakarta Turbine Development  -- hero for hire
   Linux, Java, perl, Solaris -- Consulting, Training, Development

		      4 - 8 - 15 - 16 - 23 - 42

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


Re: [m1] Using dependencies/dependency/properties in maven.xml

Posted by Brett Porter <br...@gmail.com>.
Looks like it is always going to be that way.

http://svn.apache.org/viewcvs.cgi/maven/maven-1/core/tags/MAVEN_1_0_2/src/java/org/apache/maven/project/BaseObject.java?rev=122513&view=markup

The curse of Betwixt and BaseObject. It seems that properties get put in the 
map with "" - hence true for exists, empty string for value.

In 1.1-beta-1, properties are a straight map.

- Brett

On 9/7/05, Henri Yandell <fl...@gmail.com> wrote:
> 
> On 9/6/05, Brett Porter <br...@gmail.com> wrote:
> > Weird. I think we only ever test true/false existence in jelly and so we 
> may
> > not have realised there is a bug in that :)
> >
> > What about ${dep.getProperties().get('multidoc-jnr')} ?
> 
> No dice here either :)
> 
> I dumped the punctuation and went straight to 'multidoc'; messed with
> the getProperties etc, but never saw a value. Tried 1.0.2, no luck.
> Went to 1.1b1 and worked.
> 
> Hen
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
> 
>

Re: [m1] Using dependencies/dependency/properties in maven.xml

Posted by Henri Yandell <fl...@gmail.com>.
On 9/6/05, Brett Porter <br...@gmail.com> wrote:
> Weird. I think we only ever test true/false existence in jelly and so we may
> not have realised there is a bug in that :)
> 
> What about ${dep.getProperties().get('multidoc-jnr')} ?

No dice here either :)

I dumped the punctuation and went straight to 'multidoc'; messed with
the getProperties etc, but never saw a value. Tried 1.0.2, no luck.
Went to 1.1b1 and worked.

Hen

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


Re: [m1] Using dependencies/dependency/properties in maven.xml

Posted by Brett Porter <br...@gmail.com>.
Weird. I think we only ever test true/false existence in jelly and so we may 
not have realised there is a bug in that :)

What about ${dep.getProperties().get('multidoc-jnr')} ?

- Brett

On 9/7/05, Henri Yandell <fl...@gmail.com> wrote:
> 
> Nope, no luck.
> 
> It's bizarre. If I put the following inside the forEach I get a series
> of trues and falses, but if I try to print the value itself out I get
> an empty string.
> 
> <ant:echo message="DEP: '${dep.getProperty('multidoc.url') != null}'"/>
> <ant:echo message="DEP: '${dep.getProperty('multidoc.url')}'"/>
> 
> Gives:
> 
> maven-javadoc-plugin:report:
> [echo] DEP: 'true'
> [echo] DEP: ''
> [echo] DEP: 'true'
> [echo] DEP: ''
> [echo] DEP: 'false'
> [echo] DEP: ''
> [echo] DEP: 'false'
> [echo] DEP: ''
> [echo] DEP: 'false'
> [echo] DEP: ''
> [echo] DEP: 'false'
> [echo] DEP: ''
> [echo] DEP: 'true'
> [echo] DEP: ''
> [echo] DEP: 'true'
> [echo] DEP: ''
> [echo] DEP: 'true'
> [echo] DEP: ''
> 
> Thus my assumption that I'm missing something.
> 
> On 9/6/05, Brett Porter <br...@gmail.com> wrote:
> > Try...
> >
> > <j:forEach var="lib" items="${pom.artifacts}">
> > <j:set var="dep" value="${lib.dependency}"/>
> >
> > Off the top of my head I'm not sure why this particular case it isn't
> > working, but the above is the standard practice.
> >
> > - Brett
> >
> > On 9/7/05, Henri Yandell <fl...@gmail.com> wrote:
> > >
> > > Having some problems using dependencies/dependency/properties in the
> > > maven.xml file. Obviously I'm missing something basic :) Using maven
> > > 1.0.1.
> > >
> > > In my POM, I have the following custom property set for a dependency:
> > >
> > > <dependency>
> > > <id>oscube</id>
> > > <version>0.2</version>
> > > <url>http://www.osjava.org/oscube/</url>
> > > <properties>
> > > <multidoc.url>http://dist.osjava.org/releases/multidoc-jnr
> </multidoc.url
> > > >
> > > </properties>
> > > </dependency>
> > >
> > > My custom maven.xml file then attempts to get this variable out. The
> > > bad bit being that it doesn't get anything out, just finds an empty
> > > string. The if statement is effectively working correctly, if the
> > > property is not set then it isn't entered etc.
> > >
> > > <?xml version="1.0"?>
> > > <project xmlns:j="jelly:core" xmlns:ant="jelly:ant">
> > >
> > > <preGoal name="maven-javadoc-plugin:report">
> > >
> > > <!-- for-each dependency -->
> > > <j:forEach var="dep" items="${pom.dependencies}">
> > > <j:if test="${dep.getProperty('multidoc.url') != null}">
> > > <j:set var="maven.javadoc.links"
> > > value="${maven.javadoc.links},${dep.getProperty('multidoc.url')}/${
> > > dep.getArtifactId()}/${dep.getVersion()}/"/>
> > > </j:if>
> > > </j:forEach>
> > >
> > > </preGoal>
> > >
> > > </project>
> > >
> > > Anyway, could anyone let me know what I've done wrong?
> > >
> > > Thanks,
> > >
> > > Hen
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> > > For additional commands, e-mail: users-help@maven.apache.org
> > >
> > >
> >
> >
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
> 
>

Re: [m1] Using dependencies/dependency/properties in maven.xml

Posted by Henri Yandell <fl...@gmail.com>.
Nope, no luck.

It's bizarre. If I put the following inside the forEach I get a series
of trues and falses, but if I try to print the value itself out I get
an empty string.

        <ant:echo message="DEP: '${dep.getProperty('multidoc.url') != null}'"/>
        <ant:echo message="DEP: '${dep.getProperty('multidoc.url')}'"/>

Gives:

maven-javadoc-plugin:report:
    [echo] DEP: 'true'
    [echo] DEP: ''
    [echo] DEP: 'true'
    [echo] DEP: ''
    [echo] DEP: 'false'
    [echo] DEP: ''
    [echo] DEP: 'false'
    [echo] DEP: ''
    [echo] DEP: 'false'
    [echo] DEP: ''
    [echo] DEP: 'false'
    [echo] DEP: ''
    [echo] DEP: 'true'
    [echo] DEP: ''
    [echo] DEP: 'true'
    [echo] DEP: ''
    [echo] DEP: 'true'
    [echo] DEP: ''

Thus my assumption that I'm missing something.

On 9/6/05, Brett Porter <br...@gmail.com> wrote:
> Try...
> 
> <j:forEach var="lib" items="${pom.artifacts}">
> <j:set var="dep" value="${lib.dependency}"/>
> 
> Off the top of my head I'm not sure why this particular case it isn't
> working, but the above is the standard practice.
> 
> - Brett
> 
> On 9/7/05, Henri Yandell <fl...@gmail.com> wrote:
> >
> > Having some problems using dependencies/dependency/properties in the
> > maven.xml file. Obviously I'm missing something basic :) Using maven
> > 1.0.1.
> >
> > In my POM, I have the following custom property set for a dependency:
> >
> > <dependency>
> > <id>oscube</id>
> > <version>0.2</version>
> > <url>http://www.osjava.org/oscube/</url>
> > <properties>
> > <multidoc.url>http://dist.osjava.org/releases/multidoc-jnr</multidoc.url
> > >
> > </properties>
> > </dependency>
> >
> > My custom maven.xml file then attempts to get this variable out. The
> > bad bit being that it doesn't get anything out, just finds an empty
> > string. The if statement is effectively working correctly, if the
> > property is not set then it isn't entered etc.
> >
> > <?xml version="1.0"?>
> > <project xmlns:j="jelly:core" xmlns:ant="jelly:ant">
> >
> > <preGoal name="maven-javadoc-plugin:report">
> >
> > <!-- for-each dependency -->
> > <j:forEach var="dep" items="${pom.dependencies}">
> > <j:if test="${dep.getProperty('multidoc.url') != null}">
> > <j:set var="maven.javadoc.links"
> > value="${maven.javadoc.links},${dep.getProperty('multidoc.url')}/${
> > dep.getArtifactId()}/${dep.getVersion()}/"/>
> > </j:if>
> > </j:forEach>
> >
> > </preGoal>
> >
> > </project>
> >
> > Anyway, could anyone let me know what I've done wrong?
> >
> > Thanks,
> >
> > Hen
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> > For additional commands, e-mail: users-help@maven.apache.org
> >
> >
> 
>

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


Re: [m1] Using dependencies/dependency/properties in maven.xml

Posted by Brett Porter <br...@gmail.com>.
Try...

<j:forEach var="lib" items="${pom.artifacts}">
<j:set var="dep" value="${lib.dependency}"/>

Off the top of my head I'm not sure why this particular case it isn't 
working, but the above is the standard practice.

- Brett

On 9/7/05, Henri Yandell <fl...@gmail.com> wrote:
> 
> Having some problems using dependencies/dependency/properties in the
> maven.xml file. Obviously I'm missing something basic :) Using maven
> 1.0.1.
> 
> In my POM, I have the following custom property set for a dependency:
> 
> <dependency>
> <id>oscube</id>
> <version>0.2</version>
> <url>http://www.osjava.org/oscube/</url>
> <properties>
> <multidoc.url>http://dist.osjava.org/releases/multidoc-jnr</multidoc.url
> >
> </properties>
> </dependency>
> 
> My custom maven.xml file then attempts to get this variable out. The
> bad bit being that it doesn't get anything out, just finds an empty
> string. The if statement is effectively working correctly, if the
> property is not set then it isn't entered etc.
> 
> <?xml version="1.0"?>
> <project xmlns:j="jelly:core" xmlns:ant="jelly:ant">
> 
> <preGoal name="maven-javadoc-plugin:report">
> 
> <!-- for-each dependency -->
> <j:forEach var="dep" items="${pom.dependencies}">
> <j:if test="${dep.getProperty('multidoc.url') != null}">
> <j:set var="maven.javadoc.links"
> value="${maven.javadoc.links},${dep.getProperty('multidoc.url')}/${
> dep.getArtifactId()}/${dep.getVersion()}/"/>
> </j:if>
> </j:forEach>
> 
> </preGoal>
> 
> </project>
> 
> Anyway, could anyone let me know what I've done wrong?
> 
> Thanks,
> 
> Hen
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
> 
>

Re: [m1] Using dependencies/dependency/properties in maven.xml

Posted by "Henning P. Schmiedehausen" <hp...@intermeta.de>.
Henri Yandell <fl...@gmail.com> writes:

>On 9/6/05, Andy Glick <an...@acm.org> wrote:
>> Henri,
>> 
>> I'm the glick who conversed with you on the #maven irc. I got something similar to your example to work, I think, but I'm using Maven 1.1b1 rather than Maven 1.0.1. I'm not sure why your version isn't working.

>Me neither, but the 1.0.1 -> 1.1b1 move seems to fix it. 1.0.2 didn't
>work either. Must have been something that got fixed in Jelly I guess,
>so I could potentially fix it by throwing a new Jelly in, but I guess
>it won't hurt to start the move to 1.1b1 for osjava stuff.

Nope. It is not the maven version. That works fine for me (maven
1.0.2, JDK 1.3.1_16 or JDK 1.4.2_09, Fedora Core 3):

  <goal name="test">
    <!-- include listed dependencies -->
    <j:forEach var="dep" items="${pom.dependencies}">
      <j:if test="${dep.getProperty('dist.bundle') != null}">
        <echo>${dep.getProperty('dist.bundle')}</echo>
      </j:if>
    </j:forEach>
  </goal>

with project.xml

  <dependencies>
    <dependency>
      <groupId>avalon-framework</groupId>
      <artifactId>avalon-framework-api</artifactId>
      <version>4.3</version>
      <url>http://excalibur.apache.org/framework/index.html</url>
      <type>jar</type>
      <properties>
        <dist.bundle>true 1</dist.bundle>
      </properties>
    </dependency>
    <dependency>
      <groupId>avalon-framework</groupId>
      <artifactId>avalon-framework-impl</artifactId>
      <version>4.3</version>
      <url>http://excalibur.apache.org/framework/index.html</url>
      <type>jar</type>
      <properties>
        <dist.bundle>true 2</dist.bundle>
      </properties>
    </dependency>
    <dependency>
      <groupId>avalon-logkit</groupId>
      <artifactId>avalon-logkit</artifactId>
      <version>2.1</version>
      <url></url>
      <type>jar</type>
      <properties>
        <dist.bundle>true 3</dist.bundle>
      </properties>
    </dependency>
    <dependency>
      <groupId>commons-beanutils</groupId>
      <artifactId>commons-beanutils-core</artifactId>
      <version>1.7.0</version>
      <url>http://jakarta.apache.org/commons/beanutils/</url>
      <type>jar</type>
      <properties>
        <dist.bundle>true</dist.bundle>
      </properties>
    </dependency>
    <dependency>
      <groupId>commons-codec</groupId>
      <artifactId>commons-codec</artifactId>
      <version>1.3</version>
      <url>http://jakarta.apache.org/commons/codec/</url>
      <type>jar</type>
      <properties>
        <dist.bundle>true</dist.bundle>
      </properties>
    </dependency>
    <dependency>
      <groupId>commons-collections</groupId>
      <artifactId>commons-collections</artifactId>
      <version>3.1</version>
      <url>http://jakarta.apache.org/commons/collections/</url>
      <type>jar</type>
      <properties>
        <dist.bundle>true</dist.bundle>
      </properties>
    </dependency>
    <dependency>
      <groupId>commons-configuration</groupId>
      <artifactId>commons-configuration</artifactId>
      <version>1.1</version>
      <url>http://jakarta.apache.org/commons/configuration/</url>
      <type>jar</type>
      <properties>
        <dist.bundle>true</dist.bundle>
      </properties>
    </dependency>
  </dependencies>

% maven test
 __  __
|  \/  |__ _Apache__ ___
| |\/| / _` \ V / -_) ' \  ~ intelligent projects ~
|_|  |_\__,_|\_/\___|_||_|  v. 1.0.2

build:start:

test:
    [echo] true 1
    [echo] true 2
    [echo] true 3
    [echo] true
    [echo] true
    [echo] true
    [echo] true
    [echo] true
    [echo] true
    [echo] true
[...]

This is how I build dist:build-bin bundles for a number of projects
lately. And it worked / works everywhere.

So it might be a platform vs. jelly vs. maven vs. something else
problem. What platform and JDK are you using? I'd like to try that
building out on your platform.

	Best regards
		Henning



-- 
Dipl.-Inf. (Univ.) Henning P. Schmiedehausen          INTERMETA GmbH
hps@intermeta.de        +49 9131 50 654 0   http://www.intermeta.de/

RedHat Certified Engineer -- Jakarta Turbine Development  -- hero for hire
   Linux, Java, perl, Solaris -- Consulting, Training, Development

		      4 - 8 - 15 - 16 - 23 - 42

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


Re: [m1] Using dependencies/dependency/properties in maven.xml

Posted by Henri Yandell <fl...@gmail.com>.
On 9/6/05, Andy Glick <an...@acm.org> wrote:
> Henri,
> 
> I'm the glick who conversed with you on the #maven irc. I got something similar to your example to work, I think, but I'm using Maven 1.1b1 rather than Maven 1.0.1. I'm not sure why your version isn't working.

Me neither, but the 1.0.1 -> 1.1b1 move seems to fix it. 1.0.2 didn't
work either. Must have been something that got fixed in Jelly I guess,
so I could potentially fix it by throwing a new Jelly in, but I guess
it won't hurt to start the move to 1.1b1 for osjava stuff.

Thanks to the two of you for the help,

Hen

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


Re: [m1] Using dependencies/dependency/properties in maven.xml

Posted by Andy Glick <an...@acm.org>.
Henri,

I'm the glick who conversed with you on the #maven irc. I got something similar to your example to work, I think, but I'm using Maven 1.1b1 rather than Maven 1.0.1. I'm not sure why your version isn't working.

Here are my project.xml dependencies:

  <dependencies>
    <dependency>
      <groupId>springframework</groupId>
      <artifactId>spring</artifactId>
      <version>1.2.4</version>
      <properties>
        <scope>compile</scope>
      </properties>
    </dependency>
    <dependency>
      <!--
      <groupId>commons-logging</groupId>
      <artifactId>commons-logging</artifactId>
      -->
      <id>commons-logging</id>
      <version>1.0.4</version>
      <properties>
        <scope>compile</scope>
      </properties>
    </dependency>
    <dependency>
      <groupId>oro</groupId>
      <artifactId>oro</artifactId>
      <version>2.0.8</version>
      <properties>
        <scope>compile</scope>
      </properties>
    </dependency>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>3.8.1</version>
      <properties>
        <scope>test</scope>
      </properties>
    </dependency>
  </dependencies>


Here's my jelly code:

<project xmlns:j="jelly:core" xmlns:ant="jelly:ant">

  <goal name="get-dep-properties">
    <!-- for-each dependency -->
    <j:forEach var="dep" items="${pom.dependencies}">
     <j:if test="${dep.getProperty('scope') != null}">
       <echo message="${dep.getProperty('scope')}/${dep.getGroupId()}/${dep.getArtifactId()}/${dep.getVersion()}"/>
       <j:set var="maven.javadoc.links" value="${maven.javadoc.links},${dep.getProperty('scope')}/${dep.getGroupId()}/${dep.getArtifactId()}/${dep.getVersion()}/"/>
     </j:if>
    </j:forEach>

    <echo message="maven.javadoc.links = ${maven.javadoc.links}"/>
  </goal>

</project>



Here's my output:

get-dep-properties:
    [echo] compile/springframework/spring/1.2.4
    [echo] compile/commons-logging/commons-logging/1.0.4
    [echo] compile/oro/oro/2.0.8
    [echo] test/junit/junit/3.8.1
    [echo] maven.javadoc.links = ,compile/springframework/spring/1.2.4/,compile/commons-logging/commons-logging/1.0.4/,compile/oro/oro/2.0.8/,test/junit/junit/3.8.1/
BUILD SUCCESSFUL
Total time   : 2 seconds
Finished at  : Tuesday, September 6, 2005 8:32:39 PM EDT

If you want to review this some more, keep asking questions. :-)


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