• Post Reply Bookmark Topic Watch Topic
  • New Topic

Can not set user property of a goal from command line (Maven)  RSS feed

 
Quazi Irfan
Ranch Hand
Posts: 104
1
Java Netbeans IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am trying to set the user property of Verbose property of Compile goal of Compiler plugin. I am using the following command in the command line to do it,

mvn compiler:compile -Dmaven.compiler.verbose=true

But I get the following error,


This is the content of my pom.xml,


Can anybody tell me how can I set this maven.compiler.verbose property from command line?
 
Stephan van Hulst
Saloon Keeper
Posts: 7932
143
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Are you sure that's the exact command you typed? When I run the command with your POM it works just fine for me.
 
Knute Snortum
Sheriff
Posts: 4210
124
Chrome Eclipse IDE Java Postgres Database VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It worked for me after I put something to compile in src\main\java and added this to the pom:
 
Quazi Irfan
Ranch Hand
Posts: 104
1
Java Netbeans IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Just tried with a fresh new maven project, with maven.compiler.source and maven.compiler.target properties, but still I am getting the same error. Here is the console output,



Content of the new pom,


Here is the link to the project. https://www.dropbox.com/s/bvs0lhkuyq6ztpe/mavenTestProject2.zip?dl=0

It's a fresh new Maven project.
 
Rob Spoor
Sheriff
Posts: 21117
85
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Perhaps there is an issue with your Maven installation. I've tried the same command as well, both with Maven 3.5.0 and with Maven 3.3.9, and I don't get any errors.
 
Quazi Irfan
Ranch Hand
Posts: 104
1
Java Netbeans IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I was using Maven 3.3.9. Tried again with Maven 3.5.0, but the result is the same...
 
Stephan van Hulst
Saloon Keeper
Posts: 7932
143
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Very strange. Could it be a problem with your system's default encoding?

Anyway, what happens when you surround the entire switch in double quotes?
 
Knute Snortum
Sheriff
Posts: 4210
124
Chrome Eclipse IDE Java Postgres Database VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I wonder if what looks like the dash isn't a dash.
 
Stephan van Hulst
Saloon Keeper
Posts: 7932
143
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Even so, why would it break the command line argument before the period?
 
Quazi Irfan
Ranch Hand
Posts: 104
1
Java Netbeans IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Stephan van Hulst wrote:Very strange. Could it be a problem with your system's default encoding?

Anyway, what happens when you surround the entire switch in double quotes?


IT WORKED! IT WORKED!

 
Stephan van Hulst
Saloon Keeper
Posts: 7932
143
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Great. :)

It's strange that you need to do this though. It's as if your command prompt interprets -Dmaven.compiler.verbose=true as two different arguments. I'm assuming that you're using CMD? If you right click on the command prompt frame and select "Properties", what does it say the "Current code page" is?
 
Rob Spoor
Sheriff
Posts: 21117
85
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's a PowerShell issue. I tried with both Git Bash and Command Prompt before, and it worked just fine. I tried with PowerShell just now and I get the same error.
 
Rob Spoor
Sheriff
Posts: 21117
85
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Stephan van Hulst wrote:I'm assuming that you're using CMD?

That's what I thought at first as well, but the PS in the prompt indicates it's PowerShell.
 
Quazi Irfan
Ranch Hand
Posts: 104
1
Java Netbeans IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Rob Spoor wrote:It's a PowerShell issue. I tried with both Git Bash and Command Prompt before, and it worked just fine. I tried with PowerShell just now and I get the same error.


Yes, It's a powershell issue. I just tried again with cmd and git bash, and it works just fine without the quotation mark character.

I feel like a fool for using Powershell. :/
 
Quazi Irfan
Ranch Hand
Posts: 104
1
Java Netbeans IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Stephan van Hulst wrote:Great. :)

It's strange that you need to do this though. It's as if your command prompt interprets -Dmaven.compiler.verbose=true as two different arguments. I'm assuming that you're using CMD? If you right click on the command prompt frame and select "Properties", what does it say the "Current code page" is?


Out of curiosity, how did you figure out that a string is expected here?

Here is a screenshot from Powershell. The color coding might reveal how Powershell is interpreting the mvn command.
 
Knute Snortum
Sheriff
Posts: 4210
124
Chrome Eclipse IDE Java Postgres Database VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm guessing, but I think PowerShell thinks the dot is an operator or some special character.  Quoting the entire argument removes any special meaning for the characters.

[Edit] Yup, it's called dot notation.
 
Stephan van Hulst
Saloon Keeper
Posts: 7932
143
  • Likes 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Quazi Irfan wrote:Out of curiosity, how did you figure out that a string is expected here?

Double quotes do not mean 'String' in your shell. Double quotes just keep keep pieces of text together so they form one single argument. Maven complained about .compiler.verose=true, so it obviously got separated from -Dmaven. We put double quotes around the entire thing to let the shell know it's one argument. In CMD, you would do the same thing if you want to provide a path that contains spaces:
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!