Creating a Jar Artifact

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)
                                                               new ArchivePackagingElement(archiveFileName));
               ArtifactImpl artifactImpl = (ArtifactImpl) artifact;



Use PackagingElementFactory.createModuleOutput() to create a 'module output' node and then call
ArtifactManager.addElementsToDirectory(artifact, "/", ...) to add put the created node in an artifact.

By the way it is not recommended to modify artifact properties by casting it to ArtifactImpl and calling setter methods directly.
Instead you should use ArtifactManager.createModifiableModel method, then obtain a modifiable copy of the artifact using
modifiableModel.getOrCreateModifiableArtifact method, set the necessary properties and call modifiableModel.commit().

Nikolay Chashnikov
Software Developer
JetBrains, Inc
"Develop with pleasure!"


Please sign in to leave a comment.