void () { assertEmpty(getArtifacts()); ArtifactRootElementImpl myRoot = new ArtifactRootElementImpl(); myRoot.addFirstChild(new DirectoryPackagingElement("dir")); var artifact = addArtifact("MyArtifact", myRoot); ModifiableArtifactModel model = getArtifactManager().createModifiableModel(); ModifiableArtifact modifiableArtifact = model.getOrCreateModifiableArtifact(artifact); ((CompositePackagingElement<?>)modifiableArtifact.getRootElement().getChildren().get(0)).getChildren(); // This is important to access prev root element modifiableArtifact.setRootElement(new ArtifactRootElementImpl()); var found = model.getArtifactsByType(PlainArtifactType.getInstance()).stream().findFirst().get(); CompositePackagingElement<?> root = found.getRootElement(); ((CompositePackagingElement<?>)root.getChildren().get(0)).getChildren(); }