You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Jean Luc <je...@gmail.com> on 2009/06/02 20:06:03 UTC

passing properties from filters to an ant task

Hello,

I'm trying to use an ant task (a wrapper for sqlplus,
http://incanto.sourceforge.net/usage-sqlplus.html) for a Maven build. It
works if I hardcode the parameters for the ant task in my pom.xml, but if I
try to use properties set through a filter, they are not read. There's
nothing atypical: database credentials are read through properties so they
can be overridden for each developer. If no overriding file is specified, a
common one is read. This part in itself works fine (it's used elsewhere in
the build). The problem is that the ant task does not see those properties
and thus the db login fails. The output from running mvn -X install is
further below.

Any hints would be much appreciated. Is there anything missing in order to
propagate Maven properties to ant tasks?

Thanks,
-jl


<build>
    <filters>
        <filter>${filter.db.props}</filter>
    </filters>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-antrun-plugin</artifactId>
            <executions>
                <execution>
                    <phase>pre-integration-test</phase>
                    <configuration>
                        <tasks>
                            <taskdef name="sqlplus"
classname="net.sf.incanto.Sqlplus" classpathref="maven.plugin.classpath"/>
                            <sqlplus
logon="${test.db.username}/${test.db.password}@sid" dir="database/scripts"
start="reinit.sql" failOnError="true" />
                        </tasks>
                    </configuration>
                    <goals>
                        <goal>run</goal>
                    </goals>
                </execution>
            </executions>
            <dependencies>
              <dependency>
                <groupId>net.sf</groupId>
                <artifactId>incanto</artifactId>
                <version>0.2.4</version>
              </dependency>
            </dependencies>
        </plugin>
    </plugins>

...

    <profiles>
        <profile>
            <id>user.test.db.props</id>
            <activation>

<file><exists>${user.home}/test.db.properties</exists></file>
            </activation>
            <properties>

<filter.db.props>${user.home}/test.db.properties</filter.db.props>
            </properties>
        </profile>
        <profile>
            <id>default.test.db.props</id>
            <activation>

<file><missing>${user.home}/test.db.properties</missing></file>
            </activation>
            <properties>

<filter.db.props>${common.test.filters}/test.db.properties</filter.db.props>
            </properties>
        </profile>




[DEBUG] Configuring mojo
'org.apache.maven.plugins:maven-antrun-plugin:1.3:run' -->
[DEBUG]   (f) pluginArtifacts = [net.sf:incanto:jar:0.2.4:compile,
org.codehaus.plexus:plexus-utils:jar:1.5.6:runtime,
org.apache.ant:ant-launcher:jar:1.7.1:runtime,
org.apache.ant:ant:jar:1.7.1:runtime,
org.apache.maven:maven-plugin-api:jar:2.0.4:runtime,
org.apache.maven:maven-project:jar:2.0.4:runtime,
org.apache.maven:maven-artifact:jar:2.0.4:runtime]
[DEBUG]   (f) tasks =
[DEBUG] -- end configuration --
[INFO] [antrun:run {execution: default}]
[DEBUG] Storing:
maven.dependency.commons-lang.commons-lang.jar.path=c:\dev\m2-repository\commons-lang\commons-lang\2.4\commons-lang-2.4.jar
Project base dir set to: C:\dev\mybuild
Adding reference: maven.dependency.classpath
Adding reference: maven.compile.classpath
Adding reference: maven.runtime.classpath
Adding reference: maven.test.classpath
Adding reference: maven.plugin.classpath
[INFO] Executing tasks
[DEBUG] getProperty(ns=null, name=ant.reuse.loader, user=false)
[antlib:org.apache.tools.ant] Could not load definitions from resource
org/apache/tools/ant/antlib.xml. It could not be found.
[DEBUG] getProperty(ns=null, name=test.db.username, user=false)
Property "test.db.username" has not been set
[DEBUG] getProperty(ns=null, name=test.db.password, user=false)
Property "test.db.password" has not been set
     [echo] mumu: ${test.db.username}/${test.db.password}@sid
[DEBUG] getProperty(ns=null, name=ant.reuse.loader, user=false)
[DEBUG] getProperty(ns=null, name=build.sysclasspath, user=false)
Class net.sf.incanto.Sqlplus loaded from parent loader (parentFirst)
 +Datatype sqlplus net.sf.incanto.Sqlplus
[DEBUG] getProperty(ns=null, name=test.db.username, user=false)
Property "test.db.username" has not been set
[DEBUG] getProperty(ns=null, name=test.db.password, user=false)
Property "test.db.password" has not been set
  [sqlplus] Executing 'sqlplus' with arguments:
[...]

Re: passing properties from filters to an ant task

Posted by Laurent Perez <ha...@gmail.com>.
Hi

Not sure if this could work, but did you try to explicitly pass the
property again to the task with a <property name="test.db.username"
value="${test.db.username}" /> within <tasks> ?

laurent


2009/6/2 Jean Luc <je...@gmail.com>:
> Hello,
>
> I'm trying to use an ant task (a wrapper for sqlplus,
> http://incanto.sourceforge.net/usage-sqlplus.html) for a Maven build. It
> works if I hardcode the parameters for the ant task in my pom.xml, but if I
> try to use properties set through a filter, they are not read. There's
> nothing atypical: database credentials are read through properties so they
> can be overridden for each developer. If no overriding file is specified, a
> common one is read. This part in itself works fine (it's used elsewhere in
> the build). The problem is that the ant task does not see those properties
> and thus the db login fails. The output from running mvn -X install is
> further below.
>
> Any hints would be much appreciated. Is there anything missing in order to
> propagate Maven properties to ant tasks?
>
> Thanks,
> -jl
>
>
> <build>
>    <filters>
>        <filter>${filter.db.props}</filter>
>    </filters>
>    <plugins>
>        <plugin>
>            <groupId>org.apache.maven.plugins</groupId>
>            <artifactId>maven-antrun-plugin</artifactId>
>            <executions>
>                <execution>
>                    <phase>pre-integration-test</phase>
>                    <configuration>
>                        <tasks>
>                            <taskdef name="sqlplus"
> classname="net.sf.incanto.Sqlplus" classpathref="maven.plugin.classpath"/>
>                            <sqlplus
> logon="${test.db.username}/${test.db.password}@sid" dir="database/scripts"
> start="reinit.sql" failOnError="true" />
>                        </tasks>
>                    </configuration>
>                    <goals>
>                        <goal>run</goal>
>                    </goals>
>                </execution>
>            </executions>
>            <dependencies>
>              <dependency>
>                <groupId>net.sf</groupId>
>                <artifactId>incanto</artifactId>
>                <version>0.2.4</version>
>              </dependency>
>            </dependencies>
>        </plugin>
>    </plugins>
>
> ...
>
>    <profiles>
>        <profile>
>            <id>user.test.db.props</id>
>            <activation>
>
> <file><exists>${user.home}/test.db.properties</exists></file>
>            </activation>
>            <properties>
>
> <filter.db.props>${user.home}/test.db.properties</filter.db.props>
>            </properties>
>        </profile>
>        <profile>
>            <id>default.test.db.props</id>
>            <activation>
>
> <file><missing>${user.home}/test.db.properties</missing></file>
>            </activation>
>            <properties>
>
> <filter.db.props>${common.test.filters}/test.db.properties</filter.db.props>
>            </properties>
>        </profile>
>
>
>
>
> [DEBUG] Configuring mojo
> 'org.apache.maven.plugins:maven-antrun-plugin:1.3:run' -->
> [DEBUG]   (f) pluginArtifacts = [net.sf:incanto:jar:0.2.4:compile,
> org.codehaus.plexus:plexus-utils:jar:1.5.6:runtime,
> org.apache.ant:ant-launcher:jar:1.7.1:runtime,
> org.apache.ant:ant:jar:1.7.1:runtime,
> org.apache.maven:maven-plugin-api:jar:2.0.4:runtime,
> org.apache.maven:maven-project:jar:2.0.4:runtime,
> org.apache.maven:maven-artifact:jar:2.0.4:runtime]
> [DEBUG]   (f) tasks =
> [DEBUG] -- end configuration --
> [INFO] [antrun:run {execution: default}]
> [DEBUG] Storing:
> maven.dependency.commons-lang.commons-lang.jar.path=c:\dev\m2-repository\commons-lang\commons-lang\2.4\commons-lang-2.4.jar
> Project base dir set to: C:\dev\mybuild
> Adding reference: maven.dependency.classpath
> Adding reference: maven.compile.classpath
> Adding reference: maven.runtime.classpath
> Adding reference: maven.test.classpath
> Adding reference: maven.plugin.classpath
> [INFO] Executing tasks
> [DEBUG] getProperty(ns=null, name=ant.reuse.loader, user=false)
> [antlib:org.apache.tools.ant] Could not load definitions from resource
> org/apache/tools/ant/antlib.xml. It could not be found.
> [DEBUG] getProperty(ns=null, name=test.db.username, user=false)
> Property "test.db.username" has not been set
> [DEBUG] getProperty(ns=null, name=test.db.password, user=false)
> Property "test.db.password" has not been set
>     [echo] mumu: ${test.db.username}/${test.db.password}@sid
> [DEBUG] getProperty(ns=null, name=ant.reuse.loader, user=false)
> [DEBUG] getProperty(ns=null, name=build.sysclasspath, user=false)
> Class net.sf.incanto.Sqlplus loaded from parent loader (parentFirst)
>  +Datatype sqlplus net.sf.incanto.Sqlplus
> [DEBUG] getProperty(ns=null, name=test.db.username, user=false)
> Property "test.db.username" has not been set
> [DEBUG] getProperty(ns=null, name=test.db.password, user=false)
> Property "test.db.password" has not been set
>  [sqlplus] Executing 'sqlplus' with arguments:
> [...]
>



-- 
<a href="http://in-pocket.blogspot.com">http://in-pocket.blogspot.com
- Mobile world, technology and more</a>

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