use of org.eclipse.m2e.model.edit.pom.util.PomResourceFactoryImpl in project m2e-core-tests by tesla.
the class ExcludeArtifactRefactoringTest 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);
throw new CoreException(new Status(IStatus.ERROR, "test", -1, msg, ex));
}
}
use of org.eclipse.m2e.model.edit.pom.util.PomResourceFactoryImpl in project m2e-core-tests by tesla.
the class MavenModelUtil method createResource.
// XXX find if there is a way around this without creating resources in workspace
public static PomResourceImpl createResource(IProject project, String pomFileName, String content) throws Exception {
IProgressMonitor monitor = new NullProgressMonitor();
ByteArrayInputStream is = new ByteArrayInputStream(content.getBytes(StandardCharsets.UTF_8));
IFile pomFile = project.getFile(pomFileName);
if (!pomFile.exists()) {
pomFile.create(is, true, monitor);
} else {
pomFile.setContents(is, true, false, monitor);
}
// ProjectResourceSet
String path = pomFile.getFullPath().toOSString();
URI uri = URI.createPlatformResourceURI(path, true);
PomResourceFactoryImpl factory = new PomResourceFactoryImpl();
PomResourceImpl resource = (PomResourceImpl) factory.createResource(uri);
resource.load(Collections.EMPTY_MAP);
return resource;
}
use of org.eclipse.m2e.model.edit.pom.util.PomResourceFactoryImpl 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));
}
}
Aggregations