make plugin to be triggered on each module POST-MAKE

I want to make a plugin to be triggered on post-make of each module in order to create a jar of the module and copy it to a designated location.
I am failing to find how to be triggerred when a module is compiled

Thanks

10 comments
Comment actions Permalink

Why do you need to write a plugin for that? The existing artifacts feature can do this for you.

0
Comment actions Permalink

Because I have many modules in my project, I dont want to created all artifacts manually.
I didnt see anyway to create all the jars automatically

0
Comment actions Permalink

When you select the "Build | Build Artifacts..." menu item, the top choice in the popup that appears builds all the artifacts defined in your project.

0
Comment actions Permalink

yole wrote:

When you select the "Build | Build Artifacts..." menu item, the top choice in the popup that appears builds all the artifacts defined in your project.

I still don't understand why this popup was changed in v11. It used to be very easy to select different artifacts by holding Control key (and your selection would be remembered).
Right now, you can either select one or all artifacts.

0
Comment actions Permalink

You didn't understand what I need.
My problem is not the execution of the artifacts (I coul select on every artifact the checkbox of execute on Make)
I dont want to CREATE the artifact manually. I wanted to make plugin that would build and package all the module on make, but maybe what I really need is a plugin to create all the artifacts...

I'll explain a little more:
We have a project that depends on Maven. When something changes (for example a new project is added), I want a new artifact to be created automatically that would make a jar of the project and put it in my webserver directory.
Thats why I wanted the plugin.

Maybe something similar already exists?

0
Comment actions Permalink

Then you can write a plugin that would create the artifact definitions automatically for you. Use the ArtifactManager API for this purpose.

0
Comment actions Permalink

Great thanks.
And what hook should  trigger my plugin? I though maybe when make is called.
Im just new to Intellij plugins not sure how to get a list of all my projects also...

0
Comment actions Permalink

I would watch for changes in the root model (add a listener to the ProjectTopics.PROJECT_ROOTS topic). To get the list of all modules in your project, use ModuleManager and ModuleRootManager classes.

0
Comment actions Permalink

Thank you for the great help guys.

It was pretty easy to develop the plugin after your input. It is comlete and working :)

0
Comment actions Permalink

One last question,
It seems my jars are empty.

How do I make them have the "complie module output" definition - same as when i create the artifact manually?

                        Artifact artifact = ArtifactManager.getInstance(project)                                                   .addArtifact(artifactName,                                                                JarArtifactType.getInstance(),                                                                new ArchivePackagingElement(archiveFileName));                ArtifactImpl artifactImpl = (ArtifactImpl) artifact;                artifactImpl.setBuildOnMake(true);                artifactImpl.setOutputPath(libsDir);                     



Thanks
0

Please sign in to leave a comment.