Search in sources :

Example 96 with Xpp3Dom

use of org.codehaus.plexus.util.xml.Xpp3Dom in project liferay-ide by liferay.

the class LiferayMavenProjectConfigurator method _checkValidVersion.

private MavenProblemInfo _checkValidVersion(Plugin plugin, Xpp3Dom config, String versionNodeName) {
    MavenProblemInfo retval = null;
    Version liferayVersion = null;
    String version = null;
    if (config != null) {
        // check for version config node
        Xpp3Dom versionNode = config.getChild(versionNodeName);
        if (versionNode != null) {
            version = versionNode.getValue();
            try {
                liferayVersion = new Version(MavenUtil.getVersion(version));
            } catch (IllegalArgumentException iae) {
            // bad version
            }
        }
    }
    if ((liferayVersion == null) || liferayVersion.equals(ILiferayConstants.EMPTY_VERSION)) {
        // could not get valid liferayVersion
        SourceLocation location = SourceLocationHelper.findLocation(plugin, SourceLocationHelper.CONFIGURATION);
        String problemMsg = NLS.bind(Msgs.unusableConfigValue, versionNodeName, version);
        retval = new MavenProblemInfo(problemMsg, IMarker.SEVERITY_WARNING, location);
    }
    return retval;
}
Also used : SourceLocation(org.eclipse.m2e.core.internal.markers.SourceLocation) Xpp3Dom(org.codehaus.plexus.util.xml.Xpp3Dom) Version(org.osgi.framework.Version) IProjectFacetVersion(org.eclipse.wst.common.project.facet.core.IProjectFacetVersion) MavenProblemInfo(org.eclipse.m2e.core.internal.markers.MavenProblemInfo)

Example 97 with Xpp3Dom

use of org.codehaus.plexus.util.xml.Xpp3Dom in project liferay-ide by liferay.

the class LiferayMavenProjectConfigurator method _checkValidConfigDir.

private MavenProblemInfo _checkValidConfigDir(Plugin liferayMavenPlugin, Xpp3Dom config, String configParam) {
    MavenProblemInfo retval = null;
    String message = null;
    String value = null;
    if (configParam != null) {
        if (config == null) {
            message = NLS.bind(Msgs.missingConfigValue, configParam);
        } else {
            Xpp3Dom dirNode = config.getChild(configParam);
            if (dirNode == null) {
                message = NLS.bind(Msgs.missingConfigValue, configParam);
            } else {
                value = dirNode.getValue();
                if (CoreUtil.isNullOrEmpty(value)) {
                    message = NLS.bind(Msgs.emptyConfigValue, configParam);
                } else {
                    File configDir = new File(value);
                    if (FileUtil.notExists(configDir) || !configDir.isDirectory()) {
                        message = NLS.bind(Msgs.unusableConfigValue, configParam, value);
                    }
                }
            }
        }
    }
    if (message != null) {
        SourceLocation location = SourceLocationHelper.findLocation(liferayMavenPlugin, SourceLocationHelper.CONFIGURATION);
        retval = new MavenProblemInfo(message, IMarker.SEVERITY_WARNING, location);
    }
    return retval;
}
Also used : SourceLocation(org.eclipse.m2e.core.internal.markers.SourceLocation) Xpp3Dom(org.codehaus.plexus.util.xml.Xpp3Dom) IFile(org.eclipse.core.resources.IFile) File(java.io.File) MavenProblemInfo(org.eclipse.m2e.core.internal.markers.MavenProblemInfo)

Example 98 with Xpp3Dom

use of org.codehaus.plexus.util.xml.Xpp3Dom in project liferay-ide by liferay.

the class MavenProjectBuilder method refreshSiblingProject.

public void refreshSiblingProject(IMavenProjectFacade projectFacade, IProgressMonitor monitor) throws CoreException {
    try {
        Plugin plugin6x = MavenUtil.getPlugin(projectFacade, ILiferayMavenConstants.LIFERAY_MAVEN_PLUGIN_KEY, monitor);
        if (plugin6x != null) {
            Xpp3Dom config = (Xpp3Dom) plugin6x.getConfiguration();
            Xpp3Dom apiBaseDir = config.getChild(ILiferayMavenConstants.PLUGIN_CONFIG_API_BASE_DIR);
            String apiBaseDirValue = apiBaseDir.getValue();
            IWorkspace workspace = ResourcesPlugin.getWorkspace();
            IFile apiBasePomFile = workspace.getRoot().getFileForLocation(new Path(apiBaseDirValue).append(IMavenConstants.POM_FILE_NAME));
            IMavenProjectFacade apiBaseFacade = this.projectManager.create(apiBasePomFile, true, monitor);
            apiBaseFacade.getProject().refreshLocal(IResource.DEPTH_INFINITE, monitor);
        } else {
            Plugin plugin7x = MavenUtil.getPlugin(projectFacade, ILiferayMavenConstants.SERVICE_BUILDER_PLUGIN_KEY, monitor);
            if (plugin7x != null) {
                Xpp3Dom config = (Xpp3Dom) plugin7x.getConfiguration();
                Xpp3Dom apiDirName = config.getChild("apiDirName");
                String apiDirNameValue = apiDirName.getValue();
                int startIndex = apiDirNameValue.indexOf("../");
                int endIndex = apiDirNameValue.indexOf("/src/main/java");
                String projectName = apiDirNameValue.substring(startIndex + 3, endIndex);
                IProject project = CoreUtil.getProject(projectName);
                if (project != null) {
                    project.refreshLocal(IResource.DEPTH_INFINITE, monitor);
                }
            }
        }
    } catch (Exception e) {
        LiferayMavenCore.logError("Could not refresh sibling service project.", e);
    }
}
Also used : IPath(org.eclipse.core.runtime.IPath) Path(org.eclipse.core.runtime.Path) Xpp3Dom(org.codehaus.plexus.util.xml.Xpp3Dom) IFile(org.eclipse.core.resources.IFile) IWorkspace(org.eclipse.core.resources.IWorkspace) IMavenProjectFacade(org.eclipse.m2e.core.project.IMavenProjectFacade) IProject(org.eclipse.core.resources.IProject) CoreException(org.eclipse.core.runtime.CoreException) DebugPlugin(org.eclipse.debug.core.DebugPlugin) ResourcesPlugin(org.eclipse.core.resources.ResourcesPlugin) Plugin(org.apache.maven.model.Plugin) MavenPlugin(org.eclipse.m2e.core.MavenPlugin)

Example 99 with Xpp3Dom

use of org.codehaus.plexus.util.xml.Xpp3Dom in project fabric8-maven-plugin by fabric8io.

the class BaseBoosterIT method addRedeploymentAnnotations.

/**
 * Appends some annotation properties to the fmp's configuration in test repository's pom
 * just to distinguish whether the application is re-deployed or not.
 *
 * @param testRepository
 * @throws Exception
 */
protected void addRedeploymentAnnotations(Repository testRepository, String relativePomPath, String annotationKey, String annotationValue, String fmpConfigFragmentFile) throws IOException, XmlPullParserException {
    File pomFile = new File(testRepository.getWorkTree().getAbsolutePath(), relativePomPath);
    Model model = readPomModelFromFile(pomFile);
    File pomFragment = new File(getClass().getResource(fmpConfigFragmentFile).getFile());
    String pomFragmentStr = String.format(FileUtils.readFileToString(pomFragment), annotationKey, annotationValue, annotationKey, annotationValue);
    Xpp3Dom configurationDom = Xpp3DomBuilder.build(new ByteArrayInputStream(pomFragmentStr.getBytes()), "UTF-8");
    int nOpenShiftProfile = getProfileIndexUsingFmp(model, fabric8MavenPluginKey);
    model.getProfiles().get(nOpenShiftProfile).getBuild().getPluginsAsMap().get(fabric8MavenPluginKey).setConfiguration(configurationDom);
    writePomModelToFile(pomFile, model);
}
Also used : Xpp3Dom(org.codehaus.plexus.util.xml.Xpp3Dom)

Example 100 with Xpp3Dom

use of org.codehaus.plexus.util.xml.Xpp3Dom in project fabric8-maven-plugin by fabric8io.

the class KarafHealthCheckEnricher method discoverKarafProbe.

// 
// Karaf has a readiness/health URL exposed if the fabric8-karaf-check feature is installed.
// 
private Probe discoverKarafProbe(String path, int initialDelay) {
    for (Plugin plugin : this.getProject().getBuildPlugins()) {
        if ("karaf-maven-plugin".equals(plugin.getArtifactId())) {
            Xpp3Dom configuration = (Xpp3Dom) plugin.getConfiguration();
            if (configuration == null)
                return null;
            Xpp3Dom startupFeatures = configuration.getChild("startupFeatures");
            if (startupFeatures == null)
                return null;
            for (Xpp3Dom feature : startupFeatures.getChildren("feature")) {
                if ("fabric8-karaf-checks".equals(feature.getValue())) {
                    // TODO: handle the case where the user changes the default port
                    return new ProbeBuilder().withNewHttpGet().withNewPort(DEFAULT_HEALTH_CHECK_PORT).withPath(path).endHttpGet().withInitialDelaySeconds(initialDelay).build();
                }
            }
        }
    }
    return null;
}
Also used : Xpp3Dom(org.codehaus.plexus.util.xml.Xpp3Dom) ProbeBuilder(io.fabric8.kubernetes.api.model.ProbeBuilder) Plugin(org.apache.maven.model.Plugin)

Aggregations

Xpp3Dom (org.codehaus.plexus.util.xml.Xpp3Dom)156 Plugin (org.apache.maven.model.Plugin)39 File (java.io.File)26 ArrayList (java.util.ArrayList)18 PluginExecution (org.apache.maven.model.PluginExecution)18 IOException (java.io.IOException)13 HashMap (java.util.HashMap)11 Test (org.junit.Test)11 MavenSession (org.apache.maven.execution.MavenSession)10 MavenProject (org.apache.maven.project.MavenProject)10 Model (org.apache.maven.model.Model)9 Reader (java.io.Reader)8 Build (org.apache.maven.model.Build)8 TargetPlatformConfiguration (org.eclipse.tycho.core.TargetPlatformConfiguration)8 BuildFailureException (org.eclipse.tycho.core.shared.BuildFailureException)8 MojoExecution (org.apache.maven.plugin.MojoExecution)7 XmlPullParserException (org.codehaus.plexus.util.xml.pull.XmlPullParserException)7 Map (java.util.Map)6 Dependency (org.apache.maven.model.Dependency)6 StringReader (java.io.StringReader)5