Thanks Mark for the suggestion. Unfortunately it still treats 'arg2' as a unknown lifecycle phase.
I also tried saving the value as a system variable first, then passing it into maven's command. This still fails with the unknown lifecycle phase issue: export zzz='arg1 arg2' mvn clean install -DmavenArgLine=$zzz I could export the value as a system variable first, then use it within a pom.xml instead of setting it in the command line, but I'm still curious why maven interprets this different in unix compared to windows. -----Original Message----- From: Mark Eggers [mailto:[email protected]] Sent: Tuesday, November 25, 2014 11:52 AM To: Maven Users List Subject: Re: Linux Command Line System Property Issue -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Phillip, Try single quotes. Double quotes in bash allow special characters (including spaces) to be interpreted by the shell. Single quotes prevent the shell from being interpreted. mvn package -DmavenArgLine='arg1 arg2' Partial results: [INFO] --- maven-antrun-plugin:1.7:run (echo) @ FooLine --- [INFO] Executing tasks echo: [echo] arg1 arg2 My pom.xml (sorry for the line wrapping): <?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>org.mdeggers</groupId> <artifactId>FooLine</artifactId> <version>1.0-SNAPSHOT</version> <packaging>jar</packaging> <properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <maven.compiler.source>1.7</maven.compiler.source> <maven.compiler.target>1.7</maven.compiler.target> </properties> <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-antrun-plugin</artifactId> <version>1.7</version> <executions> <execution> <id>echo</id> <phase>generate-sources</phase> <goals> <goal>run</goal> </goals> </execution> </executions> <configuration> <target name="echo"> <echo>${mavenArgLine}</echo> </target> </configuration> </plugin> </plugins> </build> </project> My maven version (on Fedora 20, 64 bit - sorry for the line wrapping): Apache Maven 3.2.3 (33f8c3e1027c3ddde99d3cdebad2656a31e8fdf4; 2014-08-11T13:58:10-07:00) Maven home: /opt/Apache/maven Java version: 1.7.0_72, vendor: Oracle Corporation Java home: /opt/Sun/jdk1.7.0_72/jre Default locale: en_US, platform encoding: UTF-8 OS name: "linux", version: "3.17.3-200.fc20.x86_64", arch: "amd64", family: "unix" . . . just my two cents /mde/ On 11/25/2014 11:29 AM, Gribnau, Phillip wrote: > Hi, > > Thanks for the suggestion. I tried it but it doesn't work. For some > reason on linux it tries to process the second argument as a lifecycle > phase. I am using v3.2.1 btw. > > mvn clean install "-DmavenArgLine=arg1 arg2" -e 2>&1 > > [ERROR] Unknown lifecycle phase "arg2". You must specify a valid > lifecycle phase or a goal in the format <plugin-prefix>:<goal> or > <plugin-group-id>:<plugin-artifact-id>[:<plugin-version>]:<goal>. > Available lifecycle phases are: validate, initialize, > generate-sources, process-sources, generate-resources, > process-resources, compile, process-classes, generate-test-sources, > process-test-sources, generate-test-resources, process-test-resources, > test-compile, process-test-classes, test, prepare-package, package, > pre-integration-test, integration-test, post-integration-test, verify, > install, deploy, pre-site, site, post-site, site-deploy, pre-clean, > clean, post-clean. -> [Help 1] > > -----Original Message----- From: Adrien Rivard > [mailto:[email protected]] Sent: Tuesday, November 25, 2014 > 1:33 AM To: Maven Users List Subject: Re: Linux Command Line System > Property Issue > > Hi, > > Maybe try "-DmavenArgLine=arg1 arg2" It works on plain java but can''t > think of a way to test it quickly with maven. > > > On Tue, Nov 25, 2014 at 2:21 AM, Gribnau, Phillip > <[email protected]> wrote: > >> Hi Everyone, >> >> I am having trouble passing in a value via the command line on bash >> in linux, but I have it working correctly on windows. >> >> On the command line, if I pass in the following: >> -DmavenArgLine="arg1 arg2" >> >> The error on linux is: Unknown lifecycle phase "arg2" Windows is able >> to interpret this correctly and show "arg1 arg2" in the output, >> verified by using the following plugin: >> >> <plugin> <artifactId>maven-antrun-plugin</artifactId> >> <version>1.7</version> <executions> <execution> >> <phase>generate-sources</phase> <configuration> <tasks> >> <echo>${mavenArgLine}</echo> </tasks> </configuration> <goals> >> <goal>run</goal> </goals> </execution> </executions> </plugin> >> >> >> My need is that the value of mavenArgLine has to be given from the >> command line as the value can differ from different environments. Is >> there a way to pass in the value of mavenArgLine in linux with >> spaces? >> >> >> Thanks, Phillip >> >> > > > -- Adrien Rivard > > --------------------------------------------------------------------- > > To unsubscribe, e-mail: [email protected] > For additional commands, e-mail: [email protected] > -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQEcBAEBAgAGBQJUdN3XAAoJEEFGbsYNeTwtgbIH/2m3bzABZxPhgc7ZnfV4Buq2 X4owJ0MCkY84U7xVMZRmRx/9YUYb5lbKH9Evm/hxsM8vfWcPfYka4z51AcXbyRzy Q90a8PxaZQJootaTViYm8Wm+mATADtYIF3DDarptrlSB0GOCx2rlkJ/E9qBqr0Mv iLlNyHaQIILnafavqx7ahL1yTZldHaxhqKFMU3xrVW0CLch9W0CTkYpm1GspvztZ ffTlnOE86OI6TYS0/oxZWTs6RT7HdTYDSMaARpTkPNIjk62dewWPRhSiQp1ddeUD 95NdJDesX/vZjko6/BMczgDrSXmOOprqskg2OC2oRRD3EkY/OjWVFghJt/oqB0s= =cvwo -----END PGP SIGNATURE----- --- This email is free from viruses and malware because avast! Antivirus protection is active. http://www.avast.com --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
