Hi,
Thanks for the suggestions. I did try configuring the reserve-network-port
goal in my pom.xml so that it sets the randomly selected port into the
property jetty.proxy.port. Then I used the properties maven plugin to write
this property to the file
${project.build.testOutputDirectory}/integration-autogen-maven.properties.
This seems to work well but fails when the property is being written to the
file. The error is "Caused by:
org.apache.maven.plugin.PluginExecutionException: A type incompatibility
occured while executing
org.codehaus.mojo:properties-maven-plugin:1.0-alpha-2:write-project-properties:
java.lang.Long cannot be cast to java.lang.String".
It looks like the properties plugin is failing to convert the reserved port
63174 into a String to write to a file, but I am not able to figure out why.
The relevant snippet from pom.xml and the error stacktrace from Jenkins is
appended below for your reference. I am inches close to getting this done
and a little help from you would make my day.
Thank you!
------------------------------------------------------------------------------
---------------------------------- pom.xml
-----------------------------------
------------------------------------------------------------------------------
...
...
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>1.8</version>
<executions>
<execution>
<id>reserve-network-port</id>
<goals>
<goal>reserve-network-port</goal>
</goals>
<phase>test</phase>
<configuration>
<portNames>
<portName>jetty.proxy.port</portName>
</portNames>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>properties-maven-plugin</artifactId>
<version>1.0-alpha-2</version>
<executions>
<execution>
<id>e1</id>
<phase>test</phase>
<goals>
<goal>set-system-properties</goal>
</goals>
<configuration>
<properties>
<property>
<name>jetty.proxy.port</name>
<value>${jetty.proxy.port}</value>
</property>
</properties>
</configuration>
</execution>
<execution>
<id>e2</id>
<phase>test</phase>
<goals>
<goal>write-project-properties</goal>
</goals>
<configuration>
<outputFile>${project.build.testOutputDirectory}/integration-autogen-maven.properties</outputFile>
</configuration>
</execution>
</executions>
</plugin>
...
...
------------------------------------------------------------------------------
----------------------------- Jenkins Console Log
-----------------------------
------------------------------------------------------------------------------
[JENKINS] Recording test results
[INFO]
[INFO] --- build-helper-maven-plugin:1.8:reserve-network-port
(reserve-network-port) @ b-c-p ---
[INFO] Reserved port 63174 for jetty.proxy.port
[INFO]
[INFO] --- properties-maven-plugin:1.0-alpha-2:set-system-properties (e1) @
b-c-p ---
[INFO] Set 1 system property
[INFO]
[INFO] --- properties-maven-plugin:1.0-alpha-2:write-project-properties (e2)
@ b-c-p ---
[INFO]
------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO]
------------------------------------------------------------------------
[INFO] Total time: 17:00.380s
[INFO] Finished at: Mon Aug 19 18:15:37 IST 2013
[INFO] Final Memory: 75M/188M
[INFO]
------------------------------------------------------------------------
[JENKINS] Archiving D:\.(path removed)...pom
Waiting for Jenkins to finish collecting data
mavenExecutionResult exceptions not empty
message : Failed to execute goal
org.codehaus.mojo:properties-maven-plugin:1.0-alpha-2:write-project-properties
(e2) on project b-c-p: A type incompatibility occured while executing
org.codehaus.mojo:properties-maven-plugin:1.0-alpha-2:write-project-properties:
java.lang.Long cannot be cast to java.lang.String
-----------------------------------------------------
realm = plugin>org.codehaus.mojo:properties-maven-plugin:1.0-alpha-2
strategy = org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy
urls[0] =
file:/D:/_dev/mavenRepo/maven2/org/codehaus/mojo/properties-maven-plugin/1.0-alpha-2/properties-maven-plugin-1.0-alpha-2.jar
urls[1] =
file:/D:/_dev/mavenRepo/maven2/org/codehaus/plexus/plexus-utils/1.5.6/plexus-utils-1.5.6.jar
Number of foreign imports: 1
import: Entry[import from realm
ClassRealm[project>com.j.r:r-p-pom:1.6.0-SNAPSHOT, parent:
ClassRealm[maven.api, parent: null]]]
-----------------------------------------------------
cause : A type incompatibility occured while executing
org.codehaus.mojo:properties-maven-plugin:1.0-alpha-2:write-project-properties:
java.lang.Long cannot be cast to java.lang.String
-----------------------------------------------------
realm = plugin>org.codehaus.mojo:properties-maven-plugin:1.0-alpha-2
strategy = org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy
urls[0] =
file:/D:/_dev/mavenRepo/maven2/org/codehaus/mojo/properties-maven-plugin/1.0-alpha-2/properties-maven-plugin-1.0-alpha-2.jar
urls[1] =
file:/D:/_dev/mavenRepo/maven2/org/codehaus/plexus/plexus-utils/1.5.6/plexus-utils-1.5.6.jar
Number of foreign imports: 1
import: Entry[import from realm
ClassRealm[project>com.j.r:r-p-pom:13.6.0-SNAPSHOT, parent:
ClassRealm[maven.api, parent: null]]]
-----------------------------------------------------
Stack trace :
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute
goal
org.codehaus.mojo:properties-maven-plugin:1.0-alpha-2:write-project-properties
(e2) on project b-c-p: A type incompatibility occured while executing
org.codehaus.mojo:properties-maven-plugin:1.0-alpha-2:write-project-properties:
java.lang.Long cannot be cast to java.lang.String
-----------------------------------------------------
realm = plugin>org.codehaus.mojo:properties-maven-plugin:1.0-alpha-2
strategy = org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy
urls[0] =
file:/D:/_dev/mavenRepo/maven2/org/codehaus/mojo/properties-maven-plugin/1.0-alpha-2/properties-maven-plugin-1.0-alpha-2.jar
urls[1] =
file:/D:/_dev/mavenRepo/maven2/org/codehaus/plexus/plexus-utils/1.5.6/plexus-utils-1.5.6.jar
Number of foreign imports: 1
import: Entry[import from realm
ClassRealm[project>com.j.r:r-p-pom:13.6.0-SNAPSHOT, parent:
ClassRealm[maven.api, parent: null]]]
-----------------------------------------------------
at
org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:211)
at
org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:148)
at
org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:140)
at
org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:84)
at
org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59)
at
org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183)
at
org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:316)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:153)
at
org.jvnet.hudson.maven3.launcher.Maven3Launcher.main(Maven3Launcher.java:79)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at
org.codehaus.plexus.classworlds.launcher.Launcher.launchStandard(Launcher.java:329)
at
org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:239)
at org.jvnet.hudson.maven3.agent.Maven3Main.launch(Maven3Main.java:158)
at hudson.maven.Maven3Builder.call(Maven3Builder.java:100)
at hudson.maven.Maven3Builder.call(Maven3Builder.java:66)
at hudson.remoting.UserRequest.perform(UserRequest.java:118)
at hudson.remoting.UserRequest.perform(UserRequest.java:48)
at hudson.remoting.Request$2.run(Request.java:326)
at
hudson.remoting.InterceptingExecutorService$1.call(InterceptingExecutorService.java:72)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
at java.util.concurrent.FutureTask.run(FutureTask.java:138)
at
java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:662)
Caused by: org.apache.maven.plugin.PluginExecutionException: A type
incompatibility occured while executing
org.codehaus.mojo:properties-maven-plugin:1.0-alpha-2:write-project-properties:
java.lang.Long cannot be cast to java.lang.String
-----------------------------------------------------
realm = plugin>org.codehaus.mojo:properties-maven-plugin:1.0-alpha-2
strategy = org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy
urls[0] =
file:/D:/_dev/mavenRepo/maven2/org/codehaus/mojo/properties-maven-plugin/1.0-alpha-2/properties-maven-plugin-1.0-alpha-2.jar
urls[1] =
file:/D:/_dev/mavenRepo/maven2/org/codehaus/plexus/plexus-utils/1.5.6/plexus-utils-1.5.6.jar
Number of foreign imports: 1
import: Entry[import from realm
ClassRealm[project>com.j.r:r-p-pom:13.6.0-SNAPSHOT, parent:
ClassRealm[maven.api, parent: null]]]
-----------------------------------------------------
at
org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:155)
at
org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:195)
... 27 more
Caused by: java.lang.ClassCastException: java.lang.Long cannot be cast to
java.lang.String
at java.util.Properties.store0(Properties.java:812)
at java.util.Properties.store(Properties.java:796)
at
org.codehaus.mojo.properties.AbstractWritePropertiesMojo.writeProperties(AbstractWritePropertiesMojo.java:61)
at
org.codehaus.mojo.properties.WriteProjectProperties.execute(WriteProjectProperties.java:59)
at
org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:107)
... 28 more
channel stopped
Finished: FAILURE
--
View this message in context:
http://maven.40175.n5.nabble.com/How-to-pass-the-contents-of-a-file-as-the-value-of-a-command-line-parameter-when-invoking-a-maven-gol-tp5767482p5768217.html
Sent from the Maven - Users mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]