use of org.eclipse.m2e.model.edit.pom.util.PomResourceImpl in project m2e-core by eclipse-m2e.
the class RenameRefactoring method checkInitialConditions.
@Override
public RefactoringStatus checkInitialConditions(IProgressMonitor pm) throws CoreException, OperationCanceledException {
PomResourceImpl resource = AbstractPomRefactoring.loadResource(file);
try {
Model model = (Model) resource.getContents().get(0);
this.oldArtifactId = model.getArtifactId();
this.oldGroupId = model.getGroupId();
this.oldVersion = model.getVersion();
} finally {
resource.unload();
}
RefactoringStatus res = new RefactoringStatus();
return res;
}
use of org.eclipse.m2e.model.edit.pom.util.PomResourceImpl in project m2e-core by eclipse-m2e.
the class AbstractPomRefactoring method loadResource.
public static PomResourceImpl loadResource(IFile pomFile) throws CoreException {
String path = pomFile.getFullPath().toOSString();
URI uri = URI.createPlatformResourceURI(path, true);
try {
Resource resource = new PomResourceFactoryImpl().createResource(uri);
resource.load(new HashMap<>());
return (PomResourceImpl) resource;
} catch (Exception ex) {
String msg = NLS.bind("Can't load model {0}", pomFile);
log.error(msg, ex);
throw new CoreException(new Status(IStatus.ERROR, Activator.PLUGIN_ID, -1, msg, ex));
}
}
use of org.eclipse.m2e.model.edit.pom.util.PomResourceImpl in project m2e-core-tests by tesla.
the class MavenModelEditTest method testManyChange.
@Test
public void testManyChange() throws Exception {
PomResourceImpl resource = loadModel("many.xml");
Model model = resource.getModel();
// Dependency dependency = model.getDependencies().getDependencyArray(0);
Dependency dependency = model.getDependencies().get(0);
dependency.setArtifactId("changed-maven-lifecycle");
assertEquals(loadFile("many_change.xml"), MavenModelUtil.toString(resource));
resource.unload();
}
use of org.eclipse.m2e.model.edit.pom.util.PomResourceImpl in project m2e-core-tests by tesla.
the class MavenModelEditTest method testManybuildinRoundtrip.
@Test
public void testManybuildinRoundtrip() throws Exception {
PomResourceImpl resource = loadModel("manybuiltin.xml");
assertEquals(loadFile("manybuiltin.xml"), MavenModelUtil.toString(resource));
resource.unload();
}
use of org.eclipse.m2e.model.edit.pom.util.PomResourceImpl in project m2e-core-tests by tesla.
the class MavenModelEditTest method testManyRoundtrip.
@Test
public void testManyRoundtrip() throws Exception {
PomResourceImpl resource = loadModel("many.xml");
assertEquals(loadFile("many.xml"), MavenModelUtil.toString(resource));
resource.unload();
}
Aggregations