Re: passing compiler args via a properties file

2023-09-24 Thread Stanimir Stamenkov

Sun, 24 Sep 2023 20:01:14 +0200, /Thomas Broyer/:


ErrorProne itself doesn't support @file arguments, so I think the question
remains unanswered: can Maven load a property's value from a file?
(possibly through a plugin; I have looked at build-helper-maven-plugin and
apparently it doesn't support it)


There's also a "Properties Maven Plugin":

https://www.mojohaus.org/properties-maven-plugin/

--
Stanimir

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



Re: passing compiler args via a properties file

2023-09-24 Thread Thomas Broyer
On Sun, Sep 24, 2023 at 7:49 PM Stanimir Stamenkov
 wrote:

> I've just noticed you're providing multiple arguments in a single 
> element – I'm not sure if this is supposed to work like that.


It is; this is how -Xplugin: works; those are arguments to the ErrorProne
plugins, not to javac itself:
https://docs.oracle.com/en/java/javase/21/docs/specs/man/javac.html#option-Xplugin

This also means that using @file wouldn't really solve the problem, as the
whole -Xplugin:ErrorProne and its arguments would still have to be on a
single line.

ErrorProne itself doesn't support @file arguments, so I think the question
remains unanswered: can Maven load a property's value from a file?
(possibly through a plugin; I have looked at build-helper-maven-plugin and
apparently it doesn't support it)

-- 
Thomas Broyer
/tɔ.ma.bʁwa.je/ 


Re: passing compiler args via a properties file

2023-09-24 Thread Stanimir Stamenkov

Sun, 24 Sep 2023 18:04:51 +0200, /Delany/:


Thank you. Its not happening though. I also tried it from the pom, so
-Xplugin:ErrorProne
-XepExcludedPaths:.*/target/.* @${build.root}/ep.config


@files are Java 9+ feature for tools other than javadoc – just making 
sure you're not using Java 8 here.


If @file is specified it must exist, although it could be empty.  If the 
file doesn't exist the tool would fail.


I've just noticed you're providing multiple arguments in a single  
element – I'm not sure if this is supposed to work like that.  Maybe try:


  -Xplugin:ErrorProne
  -XepExcludedPaths:.*target.*
  @${build.root}/ep.config


Made more difficult by lack of visibility what's going on with the javac
processors.


mvn -X (--debug) could be overwhelming but could possibly provide 
insight of what's happening.


--
Stanimir

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



Re: passing compiler args via a properties file

2023-09-24 Thread Delany
Thank you. Its not happening though. I also tried it from the pom, so
-Xplugin:ErrorProne
-XepExcludedPaths:.*/target/.* @${build.root}/ep.config

Made more difficult by lack of visibility what's going on with the javac
processors.


On Sun, 24 Sept 2023 at 16:23, Stanimir Stamenkov
 wrote:

> [With some more context from the original message.]
>
> Sun, 24 Sep 2023 15:45:49 +0200, /Stanimir Stamenkov/:
> > Sun, 24 Sep 2023 15:45:49 +0200, /Delany/:
> >
> >> I can also quickly run a build to catch on issue
> >> that I'm trying to eradicate by adding
> >> -Dep="-XepDisableAllChecks -Xep:ReferenceEquality:ERROR"
> >>
> >> But having all those rules on one line makes reviewing changes a pain.
> >> I don't really want to config the whole build with the compiler
> arguments.
> >>
> >> Is there a way to specify these in a properties file and have each
> >> argument on its own line?
> >
> > Have you tried using @file (a-la javadoc options):
> >
> >
> https://docs.oracle.com/en/java/javase/17/docs/specs/man/javac.html#command-line-argument-files
>
> Maybe:
>
> -Dep=@myoptions
>
> And in "myoptions" file:
>
> -XepDisableAllChecks
> -Xep:ReferenceEquality:ERROR
>
> --
> Stanimir
>
> -
> To unsubscribe, e-mail: users-unsubscr...@maven.apache.org
> For additional commands, e-mail: users-h...@maven.apache.org
>
>


Re: passing compiler args via a properties file

2023-09-24 Thread Stanimir Stamenkov

[With some more context from the original message.]

Sun, 24 Sep 2023 15:45:49 +0200, /Stanimir Stamenkov/:

Sun, 24 Sep 2023 15:45:49 +0200, /Delany/:

I can also quickly run a build to catch on issue 
that I'm trying to eradicate by adding

-Dep="-XepDisableAllChecks -Xep:ReferenceEquality:ERROR"

But having all those rules on one line makes reviewing changes a pain.
I don't really want to config the whole build with the compiler arguments.

Is there a way to specify these in a properties file and have each 
argument on its own line?


Have you tried using @file (a-la javadoc options):

https://docs.oracle.com/en/java/javase/17/docs/specs/man/javac.html#command-line-argument-files


Maybe:

   -Dep=@myoptions

And in "myoptions" file:

-XepDisableAllChecks
-Xep:ReferenceEquality:ERROR

--
Stanimir

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



Re: passing compiler args via a properties file

2023-09-24 Thread Stanimir Stamenkov

Sun, 24 Sep 2023 15:45:49 +0200, /Delany/:


[...]
Is there a way to specify these in a properties file and have each argument 
on its own line?


Have you tried using @file (a-la javadoc options):

https://docs.oracle.com/en/java/javase/17/docs/specs/man/javac.html#command-line-argument-files

--
Stanimir

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



passing compiler args via a properties file

2023-09-24 Thread Delany
Hi,

Passing a few arguments to the compiler is done easily enough through the
pom,
but when there are many arguments it starts to gets hairy,
especially when I'm configuring a plugin in multiple levels of inheritance.

For example, there are many bugpatterns in errorprone
https://errorprone.info/docs/flags

I want my build pom to set the basic settings for the compiler


  -Xlint:all,-serial,-processing
  -XDcompilePolicy=byfile
  -Xplugin:ErrorProne -XepExcludedPaths:.*/target/.* ${ep}


And then my project can decide whether it want to override errorprone
default levels for specific rules

https://maven.apache.org/configure.html
I can add this one line to maven.config
-Dep=-Xep:ArgumentSelectionDefectChecker:WARN -Xep:AssertFalse:WARN
-Xep:EqualsHashCode:WARN -Xep:AvoidObjectArrays:WARN
-Xep:BareDotMetacharacter:WARN -Xep:CatchAndPrintStackTrace:WARN
-Xep:OperatorPrecedence:WARN -Xep:StatementSwitchToExpressionSwitch:WARN
-Xep:SuppressWarningsWithoutExplanation:WARN

And that does the job. I can also quickly run a build to catch on issue
that I'm trying to eradicate by adding
-Dep="-XepDisableAllChecks -Xep:ReferenceEquality:ERROR"

But having all those rules on one line makes reviewing changes a pain.
I don't really want to config the whole build with the compiler arguments.

Is there a way to specify these in a properties file and have each argument
on its own line?

Kind regards,
Delany