[ 
https://issues.apache.org/jira/browse/GROOVY-10468?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17485614#comment-17485614
 ] 

Paul King commented on GROOVY-10468:
------------------------------------

For the "real life example", I found one solution on the Idea side and added 
that as a comment in the jetbrains tracker.

>From the Groovy side, we have the ability to set system properties on the 
>commandline for most of our tools (give or take the JAVA_OPTS trick often used 
>for Windows).

I was able to use a custom "spock.conf" file with the following contents:
{noformat}
// standard load commands here
property spock.iKnowWhatImDoing.disableGroovyVersionCheck=true
{noformat}
And starting Groovy with:
{noformat}
org.codehaus.groovy.tools.GroovyStarter --main groovy.ui.GroovyMain --conf 
spock.conf info/solidsoft/blog/spock2/migration/SimpleSpec.groovy
{noformat}
There is also a {{groovy.starter.conf.override}} system property that could be 
used to load such a configuration file - which is fine for Groovy, but going 
back to the Idea scenario, if you could set that property you could set the 
spock one directly.

With respect to {{CompilerConfiguration}} the class, it is stateful and 
different instances can have different values and happily work in parallel. 
System properties are a shared resource, so I wonder if trying to associate 
such properties with that class is the way to go?

I was thinking that perhaps we extend the configscript DSL to support setting 
such properties but I think that is already supported. I just tried having a 
config script:

{code:groovy}
System.setProperty('spock.iKnowWhatImDoing.disableGroovyVersionCheck', 'true')
{code}

And calling that with {{--configscript}} seems to achieve the desired outcome.


> Ability to define system properties for groovyc using CompilerConfiguration
> ---------------------------------------------------------------------------
>
>                 Key: GROOVY-10468
>                 URL: https://issues.apache.org/jira/browse/GROOVY-10468
>             Project: Groovy
>          Issue Type: New Feature
>          Components: Compiler
>    Affects Versions: 3.0.9, 4.0.0
>            Reporter: Marcin Zajaczkowski
>            Priority: Minor
>
> In some cases, it would be useful to be able to define system properties for 
> groovyc using CompilerConfiguration.
> The real life example is a limitation of Idea which doesn't allow to provide 
> system properties for groovyc (just for javac) - 
> [https://youtrack.jetbrains.com/issue/IDEA-287642] . As a result, Spock 
> 2.0-groovy-3.0 cannot be easily compiled in Idea if Maven project is imported.
> There are probably also some other situations where CompilerConfiguration 
> might be more handy than playing with Gradle/Maven/Ant/Netbeans 
> configurations.



--
This message was sent by Atlassian Jira
(v8.20.1#820001)

Reply via email to