You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Ryan Stewart <rd...@gmail.com> on 2010/01/19 16:00:16 UTC

Property loaded by plugin not available to gwt:run

I'm using the properties-maven-plugin to load properties from a file and
trying to use one of these properties in configuring the GWT plugin. GWT has
a "run" goal, which has executePhase=compile. When I invoke gwt:run, the
value of the property in question is null instead of the value from the
file. With an antrun execution bound to compile, I can see that the property
is, indeed, set. Is the gwt:run goal running in some other context than the
antrun goal bound to the compile phase? What's making the property
unavailable?

I'm including below the pom.xml, properties file, and output of running the
gwt:run goal. In the pom, you can see it's configured to 1) read a property
from build.properties, 2) echo the property using antrun, and 3) use the
property in the gwt plugin's configuration. I purposely set the value to
"1${...}" for this example so the null will show very clearly in the output.
In the output, you see that the antrun execution gets the correct value of
"8080", but in the gwt plugin, "1${...}" gets converted to "1null".

Can anyone tell me why it behaves this way?

pom.xml:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>foo</groupId>
    <artifactId>bar</artifactId>
    <version>1.0-SNAPSHOT</version>
    <packaging>war</packaging>
    <build>
        <sourceDirectory>src</sourceDirectory>
        <plugins>
            <plugin>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>2.0.2</version>
                <configuration>
                    <excludes>
                        <exclude>**/*.java</exclude>
                    </excludes>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>properties-maven-plugin</artifactId>
                <version>1.0-alpha-2</version>
                <executions>
                    <execution>
                        <phase>initialize</phase>
                        <goals>
                            <goal>read-project-properties</goal>
                        </goals>
                        <configuration>
                            <files>
                                <file>build.properties</file>
                            </files>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <artifactId>maven-antrun-plugin</artifactId>
                <version>1.3</version>
                <executions>
                    <execution>
                        <phase>compile</phase>
                        <goals>
                            <goal>run</goal>
                        </goals>
                        <configuration>
                            <tasks>
                                <echo message="This should be just before
the gwt:run."/>
                                <echo message="The tomcat.httpPort property
is now: ${tomcat.httpPort}"/>
                            </tasks>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>gwt-maven-plugin</artifactId>
                <version>1.1</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>compile</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <runTarget>foo</runTarget>
                    <port>1${tomcat.httpPort}</port>
                </configuration>
            </plugin>
        </plugins>
    </build>
</project>



build.properties:
$ cat build.properties 
tomcat.httpPort=8080



output:
$ mvn gwt:run
[INFO] Scanning for projects...
[INFO]
------------------------------------------------------------------------
[INFO] Building Unnamed - foo:bar:war:1.0-SNAPSHOT
[INFO]    task-segment: [gwt:run]
[INFO]
------------------------------------------------------------------------
[INFO] Preparing gwt:run
[INFO] [properties:read-project-properties {execution: read-ant-properties}]
[INFO] [resources:resources {execution: default-resources}]
[WARNING] Using platform encoding (UTF-8 actually) to copy filtered
resources, i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory
/home/ryan/dev/projects/radar.git/src/main/resources
[INFO] [compiler:compile {execution: default-compile}]
[INFO] Nothing to compile - all classes are up to date
[INFO] [antrun:run {execution: test}]
[INFO] Executing tasks
     [echo] This should be just before the gwt:run.
     [echo] The tomcat.httpPort property is now: 8080
[INFO] Executed tasks
[INFO]
------------------------------------------------------------------------
[ERROR] BUILD ERROR
[INFO]
------------------------------------------------------------------------
[INFO] Failed to configure plugin parameters for:
org.codehaus.mojo:gwt-maven-plugin:1.1



Cause: Not a number: '1null'
[INFO]
------------------------------------------------------------------------
[INFO] For more information, run Maven with the -e switch
[INFO]
------------------------------------------------------------------------
[INFO] Total time: 2 seconds
[INFO] Finished at: Tue Jan 19 08:33:21 CST 2010
[INFO] Final Memory: 25M/285M
[INFO]
------------------------------------------------------------------------

-- 
View this message in context: http://old.nabble.com/Property-loaded-by-plugin-not-available-to-gwt%3Arun-tp27227122p27227122.html
Sent from the Maven - Users mailing list archive at Nabble.com.


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


Re: Property loaded by plugin not available to gwt:run

Posted by Justin Edelson <ju...@gmail.com>.
On Thu, Jan 21, 2010 at 2:46 PM, Ryan Stewart <rd...@gmail.com> wrote:

>
>
> That's certainly what I would prefer, but I'm working with a legacy
> "profile" system that was built in Ant and which everyone is used to
> working
> a particular way. I was hoping I could just reuse the system and have Maven
> load its properties from it. It's all based on properties files, so it
> would
> be extremely convenient if it would just work. If I have to convert the
> whole thing into Maven profiles, it would take many hours of work and
> probably change the way things work enough that people would complain. It
> seems to work fine for everything so far except this one use case, so I
> suspect it has something to do with the executePhase setting of the goal.
>

According to http://maven.apache.org/developers/mojo-api-specification.html,
@execute phase="compile", Maven will "...first invoke a parallel lifecycle,
ending at the given phase. ... The execution of [the lifecycle] will not
affect the current project, but instead make available the
${executedProject} expression if required." (emphasis on the last sentence)

So, what you are seeing appears to be the expected behavior. There should be
a way to workaround this, but it will require some code changes.

Justin

Re: Property loaded by plugin not available to gwt:run

Posted by Ryan Stewart <rd...@gmail.com>.

Wayne Fay wrote:
> 
> properties-m-p is a bit of a hack. The Maven team is pretty clear
> about where properties should go -- in pom.xml, profiles.xml, or
> settings.xml files ONLY.
> 
That's good to know.


Wayne Fay wrote:
> 
> Is there a good reason for not simply putting the port directly in the
> pom? Or even in a profile?
> 
That's certainly what I would prefer, but I'm working with a legacy
"profile" system that was built in Ant and which everyone is used to working
a particular way. I was hoping I could just reuse the system and have Maven
load its properties from it. It's all based on properties files, so it would
be extremely convenient if it would just work. If I have to convert the
whole thing into Maven profiles, it would take many hours of work and
probably change the way things work enough that people would complain. It
seems to work fine for everything so far except this one use case, so I
suspect it has something to do with the executePhase setting of the goal.
-- 
View this message in context: http://old.nabble.com/Property-loaded-by-plugin-not-available-to-gwt%3Arun-tp27227122p27263433.html
Sent from the Maven - Users mailing list archive at Nabble.com.


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


Re: Property loaded by plugin not available to gwt:run

Posted by Wayne Fay <wa...@gmail.com>.
> POM causes it to be picked up by the plugin just fine. It's when the
> property is loaded by the other plugin that there's a problem. For some
> reason, maven doesn't seem to treat this the same as a property declared in
> the POM.

properties-m-p is a bit of a hack. The Maven team is pretty clear
about where properties should go -- in pom.xml, profiles.xml, or
settings.xml files ONLY.

>                    <port>1${tomcat.httpPort}</port>

Is there a good reason for not simply putting the port directly in the
pom? Or even in a profile?

Wayne

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


Re: Property loaded by plugin not available to gwt:run

Posted by Ryan Stewart <rd...@gmail.com>.

Anders Hammar wrote:
> 
> What happens if you execute
> mvn compile
> Does it work?
> 
That works fine even when compile runs as a prerequisite of gwt:run. You can
see that in the output, too, and immediately after the compile phase, my
test antrun execution runs, printing out the properly-loaded property. Then
immediately after, the gwt plugin doesn't see the property:
[...]
[INFO] [compiler:compile {execution: default-compile}]
[INFO] Nothing to compile - all classes are up to date
[INFO] [antrun:run {execution: test}]
[INFO] Executing tasks
     [echo] This should be just before the gwt:run.
     [echo] The tomcat.httpPort property is now: 8080
[INFO] Executed tasks
[INFO]
------------------------------------------------------------------------
[ERROR] BUILD ERROR
[INFO]
------------------------------------------------------------------------
[INFO] Failed to configure plugin parameters for:
org.codehaus.mojo:gwt-maven-plugin:1.1

Cause: Not a number: '1null'
[INFO]
------------------------------------------------------------------------ 
[...]


Anders Hammar wrote:
> 
> What version of maven are you using? Have you tried with 3.0-alpha?
> 
I'm using 2.2.1. I haven't tried 3. If I don't think of something else
soon--I've been diverted to something else temporarily--I'll give that a
try.


Anders Hammar wrote:
> 
> Maybe the gwt-maven-plugin User mailing list can provide better support.
> Or
> maybe someone else has more indepth knowledge of plugins and knows exactly
> how it works. Your idea sounds as it could be the problem here.
> 
It isn't a problem with the GWT plugin. Setting the property directly in the
POM causes it to be picked up by the plugin just fine. It's when the
property is loaded by the other plugin that there's a problem. For some
reason, maven doesn't seem to treat this the same as a property declared in
the POM.
-- 
View this message in context: http://old.nabble.com/Property-loaded-by-plugin-not-available-to-gwt%3Arun-tp27227122p27259980.html
Sent from the Maven - Users mailing list archive at Nabble.com.


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


Re: Property loaded by plugin not available to gwt:run

Posted by Anders Hammar <an...@hammar.net>.
Ok, you're right about the compile phase. I'm sorry I jumped to conclusion,
but most posts about these things are caused by running a specific goal
instead of the lifecycle.

What happens if you execute
mvn compile
Does it work?

What version of maven are you using? Have you tried with 3.0-alpha?

Maybe the gwt-maven-plugin User mailing list can provide better support. Or
maybe someone else has more indepth knowledge of plugins and knows exactly
how it works. Your idea sounds as it could be the problem here.

/Anders

On Thu, Jan 21, 2010 at 02:54, Ryan Stewart <rd...@gmail.com> wrote:

>
>
> Anders Hammar wrote:
> >
> > When you execute
> > mvn gwt:run
> > you're not executing the maven lifecycle - just that goal of the gwt
> > plugin.
> > Thus, the plugin bindings you've specified are not executed. Try
> > mvn install
> > instead.
> >
>
> No, as I mentioned in my original post, the gwt:run goal causes the compile
> phase to execute, meaning that the properties plugin does execute. You can
> see it in the output I included. I'm thinking that maybe running it in this
> way, the gwt plugin is executed somehow "outside" of the lifecycle that the
> compile phase is executed in.
> --
> View this message in context:
> http://old.nabble.com/Property-loaded-by-plugin-not-available-to-gwt%3Arun-tp27227122p27251689.html
> Sent from the Maven - Users mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
>

Re: Property loaded by plugin not available to gwt:run

Posted by Ryan Stewart <rd...@gmail.com>.

Anders Hammar wrote:
> 
> When you execute
> mvn gwt:run
> you're not executing the maven lifecycle - just that goal of the gwt
> plugin.
> Thus, the plugin bindings you've specified are not executed. Try
> mvn install
> instead.
> 

No, as I mentioned in my original post, the gwt:run goal causes the compile
phase to execute, meaning that the properties plugin does execute. You can
see it in the output I included. I'm thinking that maybe running it in this
way, the gwt plugin is executed somehow "outside" of the lifecycle that the
compile phase is executed in.
-- 
View this message in context: http://old.nabble.com/Property-loaded-by-plugin-not-available-to-gwt%3Arun-tp27227122p27251689.html
Sent from the Maven - Users mailing list archive at Nabble.com.


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


Re: Property loaded by plugin not available to gwt:run

Posted by Anders Hammar <an...@hammar.net>.
When you execute
mvn gwt:run
you're not executing the maven lifecycle - just that goal of the gwt plugin.
Thus, the plugin bindings you've specified are not executed. Try
mvn install
instead.

/Anders

On Tue, Jan 19, 2010 at 16:00, Ryan Stewart <rd...@gmail.com> wrote:

>
> I'm using the properties-maven-plugin to load properties from a file and
> trying to use one of these properties in configuring the GWT plugin. GWT
> has
> a "run" goal, which has executePhase=compile. When I invoke gwt:run, the
> value of the property in question is null instead of the value from the
> file. With an antrun execution bound to compile, I can see that the
> property
> is, indeed, set. Is the gwt:run goal running in some other context than the
> antrun goal bound to the compile phase? What's making the property
> unavailable?
>
> I'm including below the pom.xml, properties file, and output of running the
> gwt:run goal. In the pom, you can see it's configured to 1) read a property
> from build.properties, 2) echo the property using antrun, and 3) use the
> property in the gwt plugin's configuration. I purposely set the value to
> "1${...}" for this example so the null will show very clearly in the
> output.
> In the output, you see that the antrun execution gets the correct value of
> "8080", but in the gwt plugin, "1${...}" gets converted to "1null".
>
> Can anyone tell me why it behaves this way?
>
> pom.xml:
> <?xml version="1.0" encoding="UTF-8"?>
> <project xmlns="http://maven.apache.org/POM/4.0.0"
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
> http://maven.apache.org/xsd/maven-4.0.0.xsd">
>    <modelVersion>4.0.0</modelVersion>
>    <groupId>foo</groupId>
>    <artifactId>bar</artifactId>
>    <version>1.0-SNAPSHOT</version>
>    <packaging>war</packaging>
>    <build>
>        <sourceDirectory>src</sourceDirectory>
>        <plugins>
>            <plugin>
>                <artifactId>maven-compiler-plugin</artifactId>
>                <version>2.0.2</version>
>                <configuration>
>                    <excludes>
>                        <exclude>**/*.java</exclude>
>                    </excludes>
>                </configuration>
>            </plugin>
>            <plugin>
>                <groupId>org.codehaus.mojo</groupId>
>                <artifactId>properties-maven-plugin</artifactId>
>                <version>1.0-alpha-2</version>
>                <executions>
>                    <execution>
>                        <phase>initialize</phase>
>                        <goals>
>                            <goal>read-project-properties</goal>
>                        </goals>
>                        <configuration>
>                            <files>
>                                <file>build.properties</file>
>                            </files>
>                        </configuration>
>                    </execution>
>                </executions>
>            </plugin>
>            <plugin>
>                <artifactId>maven-antrun-plugin</artifactId>
>                <version>1.3</version>
>                <executions>
>                    <execution>
>                        <phase>compile</phase>
>                        <goals>
>                            <goal>run</goal>
>                        </goals>
>                        <configuration>
>                            <tasks>
>                                <echo message="This should be just before
> the gwt:run."/>
>                                <echo message="The tomcat.httpPort property
> is now: ${tomcat.httpPort}"/>
>                            </tasks>
>                        </configuration>
>                    </execution>
>                </executions>
>            </plugin>
>            <plugin>
>                <groupId>org.codehaus.mojo</groupId>
>                <artifactId>gwt-maven-plugin</artifactId>
>                <version>1.1</version>
>                <executions>
>                    <execution>
>                        <goals>
>                            <goal>compile</goal>
>                        </goals>
>                    </execution>
>                </executions>
>                <configuration>
>                    <runTarget>foo</runTarget>
>                    <port>1${tomcat.httpPort}</port>
>                </configuration>
>            </plugin>
>        </plugins>
>    </build>
> </project>
>
>
>
> build.properties:
> $ cat build.properties
> tomcat.httpPort=8080
>
>
>
> output:
> $ mvn gwt:run
> [INFO] Scanning for projects...
> [INFO]
> ------------------------------------------------------------------------
> [INFO] Building Unnamed - foo:bar:war:1.0-SNAPSHOT
> [INFO]    task-segment: [gwt:run]
> [INFO]
> ------------------------------------------------------------------------
> [INFO] Preparing gwt:run
> [INFO] [properties:read-project-properties {execution:
> read-ant-properties}]
> [INFO] [resources:resources {execution: default-resources}]
> [WARNING] Using platform encoding (UTF-8 actually) to copy filtered
> resources, i.e. build is platform dependent!
> [INFO] skip non existing resourceDirectory
> /home/ryan/dev/projects/radar.git/src/main/resources
> [INFO] [compiler:compile {execution: default-compile}]
> [INFO] Nothing to compile - all classes are up to date
> [INFO] [antrun:run {execution: test}]
> [INFO] Executing tasks
>     [echo] This should be just before the gwt:run.
>     [echo] The tomcat.httpPort property is now: 8080
> [INFO] Executed tasks
> [INFO]
> ------------------------------------------------------------------------
> [ERROR] BUILD ERROR
> [INFO]
> ------------------------------------------------------------------------
> [INFO] Failed to configure plugin parameters for:
> org.codehaus.mojo:gwt-maven-plugin:1.1
>
>
>
> Cause: Not a number: '1null'
> [INFO]
> ------------------------------------------------------------------------
> [INFO] For more information, run Maven with the -e switch
> [INFO]
> ------------------------------------------------------------------------
> [INFO] Total time: 2 seconds
> [INFO] Finished at: Tue Jan 19 08:33:21 CST 2010
> [INFO] Final Memory: 25M/285M
> [INFO]
> ------------------------------------------------------------------------
>
> --
> View this message in context:
> http://old.nabble.com/Property-loaded-by-plugin-not-available-to-gwt%3Arun-tp27227122p27227122.html
> Sent from the Maven - Users mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
>