Build and access jar in run configuration
Answered
I'm writing a plugin for IntelliJ.
I'm currently writing a Run Configuration that extends ModuleBasedConfiguration and I'd like to create for the selected module a jar and to access the location where the jar has been created.
Where can I find a tutorial on this topic?
Please sign in to leave a comment.
There's builtin functionality in IntelliJ IDEA for this - Artifacts. https://www.jetbrains.com/help/idea/artifacts.html
In Run configuration, you can add "Build Artifacts" to "Before Launch" section of Run Configuration to trigger rebuild.
Ok, and how can I do it in Java when I create the run configuration?
Please see com.intellij.packaging.artifacts.ArtifactManager & com.intellij.execution.RunManagerEx#setBeforeRunTasks(com.intellij.execution.configurations.RunConfiguration, java.util.List<com.intellij.execution.BeforeRunTask>)
Ok, my run configuration extends
In the constructor I get the list of Before Run configs using
and I add mine into that list. Then always in the constructor I do:
However, for such a reason I don't get, later on RunManagerImpl calls readBeforeRunTasks and my task disappear.
I miss something, but I'm struggling to understand what exactly.
Any hint?
Please see com.intellij.packaging.impl.run.BuildArtifactsBeforeRunTaskProvider#setBuildArtifactBeforeRun
Thanks, problem solved