You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Christian Weber <CW...@DIaLOGIKa.de> on 2008/01/30 14:51:34 UTC

Writing the output of a command execution into a Maven Variable, so that it can be used later

Hi all,

i have a Problem in writing the Output of a Command-Execution into a Maven Variable, so that it can be used later. I successfully have executed the following into a maven-antrun-plugin:

-- Code Snippet
			<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-antrun-plugin</artifactId>
				<executions>
					<execution>
						<id>validate</id>
						<phase>validate</phase>
						<configuration>
							<tasks>
								<exec executable="glib-config" outputproperty="Test.Testvariable">
									<arg value="--version"/>
								</exec>
								<echo message="Content of Testvariable: ${Test.Testvariable}"/>
							</tasks>
						</configuration>
						<goals>
							<goal>run</goal>
						</goals>
					</execution>
				</executions>
			</plugin>
--

With this Piece of Code i'm able to retrieve the Output of the "glib-config --version" Command and display it in the followed "echo message..." Line.
But how do i write it into a Maven Variable, so that i have Access to it in later Steps. For example i want to call this Code in the Parent POM File and recall the Variable in a Child POM File.

Is there maybe another Way to accomplish this?

Regards,
	Christian

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


Re: Writing the output of a command execution into a Maven Variable, so that it can be used later

Posted by Wayne Fay <wa...@gmail.com>.
You can do this with a "real" Mojo by attaching the variable to Maven
Project. But you can't do this in a simple Antrun plugin config. So
you'll need to write some Java or Groovy etc.

Wayne

On 1/30/08, Christian Weber <CW...@dialogika.de> wrote:
> Hi all,
>
> i have a Problem in writing the Output of a Command-Execution into a Maven Variable, so that it can be used later. I successfully have executed the following into a maven-antrun-plugin:
>
> -- Code Snippet
>                        <plugin>
>                                <groupId>org.apache.maven.plugins</groupId>
>                                <artifactId>maven-antrun-plugin</artifactId>
>                                <executions>
>                                        <execution>
>                                                <id>validate</id>
>                                                <phase>validate</phase>
>                                                <configuration>
>                                                        <tasks>
>                                                                <exec executable="glib-config" outputproperty="Test.Testvariable">
>                                                                        <arg value="--version"/>
>                                                                </exec>
>                                                                <echo message="Content of Testvariable: ${Test.Testvariable}"/>
>                                                        </tasks>
>                                                </configuration>
>                                                <goals>
>                                                        <goal>run</goal>
>                                                </goals>
>                                        </execution>
>                                </executions>
>                        </plugin>
> --
>
> With this Piece of Code i'm able to retrieve the Output of the "glib-config --version" Command and display it in the followed "echo message..." Line.
> But how do i write it into a Maven Variable, so that i have Access to it in later Steps. For example i want to call this Code in the Parent POM File and recall the Variable in a Child POM File.
>
> Is there maybe another Way to accomplish this?
>
> Regards,
>        Christian
>
> ---------------------------------------------------------------------
> 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