Search in sources :

Example 1 with MavenProjectAdapter

use of org.apache.sling.ide.eclipse.m2e.impl.helpers.MavenProjectAdapter in project sling by apache.

the class MavenProjectUtilsTest method inferDefaultProvisioningModelDirectories.

@Test
public void inferDefaultProvisioningModelDirectories() throws Exception {
    IPath modelsDir = Path.fromPortableString("src/main/provisioning");
    // create project
    final IProject launchpadProject = projectRule.getProject();
    MavenProjectAdapter project = new MavenProjectAdapter(launchpadProject);
    project.createOrUpdateFile(Path.fromPortableString("pom.xml"), getClass().getResourceAsStream("slingstart-simple-pom.xml"));
    project.ensureDirectoryExists(modelsDir);
    project.convertToMavenProject();
    // conversion should enable the slingstart configurator and set the provisioning model path
    new Poller(TimeUnit.MINUTES.toMillis(1)).pollUntil(new Callable<IPath>() {

        @Override
        public IPath call() throws Exception {
            return ProjectUtil.getProvisioningModelPath(launchpadProject);
        }
    }, equalTo(modelsDir));
}
Also used : IPath(org.eclipse.core.runtime.IPath) MavenProjectAdapter(org.apache.sling.ide.eclipse.m2e.impl.helpers.MavenProjectAdapter) IProject(org.eclipse.core.resources.IProject) Poller(org.apache.sling.ide.test.impl.helpers.Poller) Test(org.junit.Test)

Example 2 with MavenProjectAdapter

use of org.apache.sling.ide.eclipse.m2e.impl.helpers.MavenProjectAdapter in project sling by apache.

the class LegacyMavenBundleProjectTest method testLegacyMavenBundleProjectHasErrorMarker.

@Test
public void testLegacyMavenBundleProjectHasErrorMarker() throws Exception {
    // create project
    final IProject bundleProject = projectRule.getProject();
    MavenProjectAdapter project = new MavenProjectAdapter(bundleProject);
    project.createOrUpdateFile(Path.fromPortableString("pom.xml"), getClass().getResourceAsStream("legacy-pom.xml"));
    project.convertToMavenProject();
    // wait up to 1 minute for the build to succeed due to time needed to retrieve dependencies
    Poller markerPoller = new Poller(TimeUnit.MINUTES.toMillis(1));
    markerPoller.pollUntilSuccessful(new Runnable() {

        @Override
        public void run() {
            try {
                IMarker[] markers = bundleProject.findMarkers(null, true, IResource.DEPTH_ONE);
                for (IMarker marker : markers) {
                    if (marker.getAttribute(IMarker.SEVERITY, IMarker.SEVERITY_INFO) != IMarker.SEVERITY_ERROR) {
                        continue;
                    }
                    if (marker.getAttribute(IMarker.MESSAGE, "").startsWith("Missing m2e incremental build support")) {
                        return;
                    }
                }
                throw new RuntimeException("Did not find error message starting with 'Missing m2e incremental support'");
            } catch (CoreException e) {
                throw new RuntimeException(e);
            }
        }
    });
}
Also used : MavenProjectAdapter(org.apache.sling.ide.eclipse.m2e.impl.helpers.MavenProjectAdapter) CoreException(org.eclipse.core.runtime.CoreException) IMarker(org.eclipse.core.resources.IMarker) IProject(org.eclipse.core.resources.IProject) Poller(org.apache.sling.ide.test.impl.helpers.Poller) Test(org.junit.Test)

Aggregations

MavenProjectAdapter (org.apache.sling.ide.eclipse.m2e.impl.helpers.MavenProjectAdapter)2 Poller (org.apache.sling.ide.test.impl.helpers.Poller)2 IProject (org.eclipse.core.resources.IProject)2 Test (org.junit.Test)2 IMarker (org.eclipse.core.resources.IMarker)1 CoreException (org.eclipse.core.runtime.CoreException)1 IPath (org.eclipse.core.runtime.IPath)1