• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

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

 
Ranch Hand
Posts: 125
1
IntelliJ IDE Chrome
  • 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?
 
Saloon Keeper
Posts: 12154
258
  • 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.
 
Sheriff
Posts: 7108
184
Eclipse IDE Postgres Database VI Editor Chrome Java Ubuntu
  • 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: 125
1
IntelliJ IDE Chrome
  • 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.
 
Sheriff
Posts: 21972
106
Eclipse IDE Spring VI Editor Chrome Java Ubuntu 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: 125
1
IntelliJ IDE Chrome
  • 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: 12154
258
  • 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: 7108
184
Eclipse IDE Postgres Database VI Editor Chrome Java Ubuntu
  • 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: 12154
258
  • 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: 125
1
IntelliJ IDE Chrome
  • 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: 12154
258
  • 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: 21972
106
Eclipse IDE Spring VI Editor Chrome Java Ubuntu 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: 21972
106
Eclipse IDE Spring VI Editor Chrome Java Ubuntu 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: 125
1
IntelliJ IDE Chrome
  • 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: 125
1
IntelliJ IDE Chrome
  • 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: 7108
184
Eclipse IDE Postgres Database VI Editor Chrome Java Ubuntu
  • 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: 12154
258
  • 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:
 
And will you succeed? Yes you will indeed! (98 and 3/4 % guaranteed) - Seuss. tiny ad:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
    Bookmark Topic Watch Topic
  • New Topic