void (final Project project, final Artifact parent, final Artifact toAdd) { WriteAction.runAndWait(() -> { final ModifiableArtifactModel model = ArtifactManager.getInstance(project).createModifiableModel(); final PackagingElement<?> artifactElement = PackagingElementFactory.getInstance().createArtifactElement(toAdd, project); model.getOrCreateModifiableArtifact(parent).getRootElement().addOrFindChild(artifactElement); model.commit(); }); }