Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

intellij.systemProperties does not work #173

Closed
huoguangjin opened this issue Feb 12, 2017 · 2 comments
Closed

intellij.systemProperties does not work #173

huoguangjin opened this issue Feb 12, 2017 · 2 comments
Assignees
Milestone

Comments

@huoguangjin
Copy link
Contributor

huoguangjin commented Feb 12, 2017

According to README, I try to set system properties in this way (plugin version 0.2.1)

// other config...

def DEBUG_MODE = true

intellij {
    version 'IC-2016.2'
    pluginName 'MyPlugin'

    systemProperties = [
            "hello": "world"
    ]

    systemProperty "debug.mode", DEBUG_MODE
}

but I could not get the system properties

System.out.println("hello=" + System.getProperty("hello"));
System.out.println("debug.mode=" + Boolean.getBoolean("debug.mode"));

result:

hello=null
debug.mode=false

is there something wrong?

@huoguangjin
Copy link
Contributor Author

// other config...

def DEBUG_MODE = true

intellij {
    version 'IC-2016.2'
    pluginName 'MyPlugin'

    systemProperties = [
            "hello": "world"
    ]

    systemProperty "debug.mode", DEBUG_MODE
}

// add following lines
runIdea.doFirst {
    runIdea.systemProperties(runIdea.systemProperties)
    // or runIdea.systemProperties += [:]
}

🎉🎉 now it work!~

@huoguangjin
Copy link
Contributor Author

I check my idea.log file
there are some logs with keyword #com.intellij.idea.Main show the JVM Args options

I can get following properties from System.getProperties() correctly, but could not get the properties from intellij.systemProperties

apple.laf.useScreenMenuBar
idea.classpath.index.enabled
idea.config.path
idea.is.internal
idea.platform.prefix
idea.plugins.path
idea.required.plugins.id
idea.smooth.progress
idea.system.path

clone the repo(plugin version 0.2.1) and found:

// IntelliJPlugin.groovy
project.tasks.create(RUN_IDEA_TASK_NAME, RunIdeaTask).with {
    group = GROUP_NAME
    description = "Runs Intellij IDEA with installed plugin."
    conventionMapping.map("ideaDirectory", { Utils.ideaSdkDirectory(extension) })
    conventionMapping.map("systemProperties", { extension.systemProperties })

    // ...
}
// RunIdeaTask.groovy
def configureSystemProperties() {
    systemProperties(Utils.getIdeaSystemProperties(getConfigDirectory(), getSystemDirectory(), getPluginsDirectory(), getRequiredPluginIds()))
    def operatingSystem = OperatingSystem.current()
    if (operatingSystem.isMacOsX()) {
        systemProperty("idea.smooth.progress", false)
        systemProperty("apple.laf.useScreenMenuBar", true)
    } else if (operatingSystem.isUnix() && !getSystemProperties().containsKey("sun.awt.disablegrab")) {
        systemProperty("sun.awt.disablegrab", true)
    }
    systemProperty("idea.classpath.index.enabled", false)
    systemProperty("idea.is.internal", true)

    if (!getSystemProperties().containsKey('idea.platform.prefix')) {
        def matcher = Utils.VERSION_PATTERN.matcher(Utils.ideaBuildNumber(getIdeaDirectory()))
        if (matcher.find()) {
            def prefix = PREFIXES.get(matcher.group(1))
            if (prefix) {
                systemProperty('idea.platform.prefix', prefix)
            }
        }
    }
}

learn from Can gradle extensions handle lazy evaluation of a property? - Stack Overflow
It seems that conventionMapping.map("systemProperties", { extension.systemProperties }) will be covered by systemProperties(Utils.getIdeaSystemProperties(getConfigDirectory(), getSystemDirectory(), getPluginsDirectory(), getRequiredPluginIds()))

so the plugin setting intellij.systemProperties does not work...

add following lines in build.gradle, the problem get solved now 😃

runIdea.doFirst {
    runIdea.systemProperties(runIdea.systemProperties)
    // or runIdea.systemProperties += [:]
}

then I a make pull request, please check

@zolotov zolotov closed this as completed Feb 13, 2017
@zolotov zolotov self-assigned this Feb 13, 2017
@zolotov zolotov added this to the 0.2.2 milestone Feb 13, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants