use of org.codehaus.plexus.util.xml.pull.XmlPullParserException in project BIMserver by opensourceBIM.
the class PluginBundleManager method loadPluginsFromEclipseProject.
public PluginBundle loadPluginsFromEclipseProject(Path projectRoot) throws PluginException {
try {
if (!Files.isDirectory(projectRoot)) {
throw new PluginException("No directory: " + projectRoot.toString());
}
final Path pluginFolder = projectRoot.resolve("plugin");
if (!Files.isDirectory(pluginFolder)) {
throw new PluginException("No 'plugin' directory found in " + projectRoot.toString());
}
Path pluginFile = pluginFolder.resolve("plugin.xml");
if (!Files.exists(pluginFile)) {
throw new PluginException("No 'plugin.xml' found in " + pluginFolder.toString());
}
PluginDescriptor pluginDescriptor = null;
try (InputStream newInputStream = Files.newInputStream(pluginFile)) {
pluginDescriptor = pluginManager.getPluginDescriptor(newInputStream);
}
Path pomFile = projectRoot.resolve("pom.xml");
if (!Files.exists(pomFile)) {
throw new PluginException("No pom.xml found in " + projectRoot);
}
// Path packageFile = projectRoot.resolve("package.json");
// if (Files.exists(packageFile)) {
// return loadJavaScriptProject(projectRoot, packageFile,
// pluginFolder, pluginDescriptor);
// } else if (Files.exists(pomFile)) {
PluginBundle pluginBundle = loadJavaProject(projectRoot, pomFile, pluginFolder, pluginDescriptor, false);
// } else {
// throw new PluginException("No pom.xml or package.json found in "
// + projectRoot.toString());
// }
List<SPluginInformation> plugins = new ArrayList<>();
pluginManager.processPluginDescriptor(pluginDescriptor, plugins);
for (SPluginInformation sPluginInformation : plugins) {
if (sPluginInformation.isEnabled()) {
// For local plugins, we assume to install for all users
sPluginInformation.setInstallForAllUsers(true);
sPluginInformation.setInstallForNewUsers(true);
PluginContext pluginContext = pluginBundle.getPluginContext(sPluginInformation.getIdentifier());
if (pluginContext == null) {
throw new PluginException("No plugin context found for " + sPluginInformation.getIdentifier());
}
}
}
try {
long pluginBundleVersionId = pluginManager.pluginBundleInstalled(pluginBundle);
for (SPluginInformation sPluginInformation : plugins) {
if (sPluginInformation.isEnabled()) {
PluginContext pluginContext = pluginBundle.getPluginContext(sPluginInformation.getIdentifier());
// PluginConfiguration pluginConfiguration = PluginConfiguration.fromDefaults(pluginContext.getPlugin().getSystemSettingsDefinition());
// pluginContext.initialize(pluginConfiguration);
pluginManager.pluginInstalled(pluginBundleVersionId, pluginContext, sPluginInformation);
}
}
} catch (Exception e) {
LOGGER.error("", e);
throw new PluginException(e);
}
return pluginBundle;
} catch (JAXBException e) {
throw new PluginException(e);
} catch (FileNotFoundException e) {
throw new PluginException(e);
} catch (IOException e) {
throw new PluginException(e);
} catch (XmlPullParserException e) {
throw new PluginException(e);
}
}
use of org.codehaus.plexus.util.xml.pull.XmlPullParserException in project indy by Commonjava.
the class ArchetypeCatalogMerger method merge.
public byte[] merge(final Collection<Transfer> sources, final Group group, final String path) {
final ArchetypeCatalog master = new ArchetypeCatalog();
final ArchetypeCatalogXpp3Reader reader = new ArchetypeCatalogXpp3Reader();
final FileReader fr = null;
boolean merged = false;
final Set<String> seen = new HashSet<String>();
for (final Transfer src : sources) {
try (InputStream stream = src.openInputStream()) {
final ArchetypeCatalog catalog = reader.read(stream, false);
for (final Archetype arch : catalog.getArchetypes()) {
final String key = arch.getGroupId() + ":" + arch.getArtifactId() + ":" + arch.getVersion();
if (seen.add(key)) {
master.addArchetype(arch);
}
}
merged = true;
} catch (final IOException e) {
final StoreKey key = getKey(src);
logger.error(String.format("Cannot read archetype catalog: %s from artifact-store: %s. Reason: %s", src.getPath(), key, e.getMessage()), e);
} catch (final XmlPullParserException e) {
final StoreKey key = getKey(src);
logger.error(String.format("Cannot parse archetype catalog: %s from artifact-store: %s. Reason: %s", src.getPath(), key, e.getMessage()), e);
} finally {
closeQuietly(fr);
}
}
if (merged) {
final ByteArrayOutputStream baos = new ByteArrayOutputStream();
try {
new ArchetypeCatalogXpp3Writer().write(baos, master);
return baos.toByteArray();
} catch (final IOException e) {
logger.error(String.format("Cannot write consolidated archetype catalog: %s to: %s. Reason: %s", path, group.getKey(), e.getMessage()), e);
}
}
return null;
}
use of org.codehaus.plexus.util.xml.pull.XmlPullParserException in project build-info by JFrogDev.
the class ProjectReader method readModel.
/**
* @return Construct a Maven {@link Model} from the pom.
*/
private Model readModel(File pom) throws IOException {
MavenXpp3Reader reader = new MavenXpp3Reader();
StringReader stringReader = null;
try {
stringReader = new StringReader(Files.toString(pom, Charset.forName("UTF-8")));
return reader.read(stringReader);
} catch (XmlPullParserException e) {
throw new IOException(e);
} finally {
IOUtils.closeQuietly(stringReader);
}
}
use of org.codehaus.plexus.util.xml.pull.XmlPullParserException in project maven-scm by apache.
the class VssCommandLineUtils method readSettings.
public static Settings readSettings() {
Settings settings = null;
File settingsFile = getScmConfFile();
if (settingsFile.exists()) {
VssXpp3Reader reader = new VssXpp3Reader();
try {
settings = reader.read(ReaderFactory.newXmlReader(settingsFile));
} catch (FileNotFoundException e) {
// nop
} catch (IOException e) {
// nop
} catch (XmlPullParserException e) {
String message = settingsFile.getAbsolutePath() + " isn't well formed. SKIPPED." + e.getMessage();
System.err.println(message);
}
}
// override settings with command line options
String vssDirectory = System.getProperty("vssDirectory");
if (StringUtils.isNotEmpty(vssDirectory)) {
if (settings == null) {
settings = new Settings();
}
settings.setVssDirectory(vssDirectory);
}
return settings;
}
use of org.codehaus.plexus.util.xml.pull.XmlPullParserException in project maven-scm by apache.
the class LocalScmMetadataUtils method readMetadata.
/**
* Reads metadata file from given directory.
*
* @param dir The directory that should contain the metadata file
* @return LocalScmMetadata or <tt>null</tt> in case of problems
*/
public LocalScmMetadata readMetadata(File dir) {
File metadataFile = new File(dir, FILENAME);
if (!metadataFile.exists()) {
return null;
}
LocalScmMetadata result = null;
Reader reader = null;
try {
reader = ReaderFactory.newXmlReader(metadataFile);
result = new LocalScmMetadataXpp3Reader().read(reader);
} catch (XmlPullParserException e) {
if (logger.isWarnEnabled()) {
logger.warn("Could not interpret .maven-scm-local - ignoring", e);
}
return null;
} catch (IOException e) {
if (logger.isWarnEnabled()) {
logger.warn("Could not Read .maven-scm-local - ignoring", e);
}
} finally {
IOUtil.close(reader);
}
return result;
}
Aggregations