How to trigger build jar action from a plugin?

To automatize the process we need a plug-in that builds up jar file and sign this jar file using signJar function with the parameter of the name of built jar file.

first builds jar file of the current project then sign it using signJar function (need to send built jar file name) (signJar is another class by itself in the same project.)

We are using 8.1.4 version.

plug-in can be alike hello world plug-in in the plug-in development page of intellij. I searched how do i trigger actions of the ide (like make project build jar etc ) from the plug-in but i couldn't find.

Any help appreciated.

4 comments
Comment actions Permalink

Actually there was no API to trigger 'Build Jars' action in IDEA 8.1.4.
However you can use CompilerManager.getInstance(project).make() method to compile the project, then build a jar containing classes from module output
directory using Java API and apply your function to that jar.

--
Nikolay Chashnikov
Software Developer
JetBrains, Inc
http://www.jetbrains.com
"Develop with pleasure!"

0
Comment actions Permalink

We run the code (CompilerManager.getInstance(project).make() ),  it works.

There is a checkbox (   Build jars on make  ) when you click buil jar command .
I want to ask what if we change the default value of  this "build jars on make" checkbox from the source code of the intellij.

Is it possible and where can i find its default value in the source?

RunManager.xml code is like this...
<component>
<option name="SHOW_SETTINGS_BEFORE_RUNNING" value="true" />
<option name="COMPILE_BEFORE_RUNNING" value="true" />
  <activeType name="Application" />
....
Can i find options for "build jars on make" checkbox like these above? and can i change these values?


I think the control flag in version 9 and 10 are these:
com.intellij.packaging.artifacts.ModifiableArtifact.setBuildOnMake ();
com.intellij.packaging.artifacts.Artifact.isBuildOnMake ()

Thanks.

0
Comment actions Permalink

You can change "Build Jars on make" setting using BuildJarProjectSettings.getInstance(project).setBuildJarOnMake(...) method. Note that
BuildJarProjectSettings is not part of the Open API so you need to add idea.jar to IDEA SDK classes list.

--
Nikolay Chashnikov
Software Developer
JetBrains, Inc
http://www.jetbrains.com
"Develop with pleasure!"

0
Comment actions Permalink

Thanks a lot. It worked. We get the jar files that we want.

I will quote your answers on other platforms. ( linked in, stackoverflow )

0

Please sign in to leave a comment.