Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIgor Fedorenko2017-11-19 23:26:34 +0000
committerIgor Fedorenko2018-05-21 13:17:14 +0000
commitb68b8b26d23c41b94abd1b02a1864ab52038f6c1 (patch)
tree0a61500c5afc9f8c56a4e65b308d5f1b81bcb3b0 /org.eclipse.m2e.binaryproject.tests
parent4c27b30f5335de0e98805a42ff83622a854daedd (diff)
downloadm2e-core-b68b8b26d23c41b94abd1b02a1864ab52038f6c1.tar.gz
m2e-core-b68b8b26d23c41b94abd1b02a1864ab52038f6c1.tar.xz
m2e-core-b68b8b26d23c41b94abd1b02a1864ab52038f6c1.zip
Bug 384065: advanced sourcelookup support
Change-Id: Ib145445c60c686bbbc187f252b32591535ac740d Signed-off-by: Igor Fedorenko <igor@ifedorenko.com>
Diffstat (limited to 'org.eclipse.m2e.binaryproject.tests')
-rw-r--r--org.eclipse.m2e.binaryproject.tests/META-INF/MANIFEST.MF18
-rw-r--r--org.eclipse.m2e.binaryproject.tests/build.properties4
-rw-r--r--org.eclipse.m2e.binaryproject.tests/plugin_customization.ini10
-rw-r--r--org.eclipse.m2e.binaryproject.tests/pom.xml21
-rw-r--r--org.eclipse.m2e.binaryproject.tests/src/org/eclipse/m2e/binaryproject/tests/BinaryProjectTest.java66
5 files changed, 119 insertions, 0 deletions
diff --git a/org.eclipse.m2e.binaryproject.tests/META-INF/MANIFEST.MF b/org.eclipse.m2e.binaryproject.tests/META-INF/MANIFEST.MF
new file mode 100644
index 00000000..e1f79f6a
--- /dev/null
+++ b/org.eclipse.m2e.binaryproject.tests/META-INF/MANIFEST.MF
@@ -0,0 +1,18 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: %Bundle-Name
+Bundle-SymbolicName: org.eclipse.m2e.binaryproject.tests;singleton:=true
+Bundle-Version: 1.9.0.qualifier
+Bundle-Vendor: %Bundle-Vendor
+Require-Bundle: org.eclipse.m2e.core;bundle-version="[1.9.0,1.10.0)",
+ org.eclipse.m2e.maven.runtime;bundle-version="[1.9.0,1.10.0)",
+ org.eclipse.m2e.binaryproject;bundle-version="[1.9.0,1.10.0)",
+ org.slf4j.api;bundle-version="1.6.1",
+ org.junit;bundle-version="4.0.0",
+ org.eclipse.m2e.tests.common;bundle-version="[1.9.0,1.10.0)",
+ org.eclipse.equinox.common;bundle-version="3.6.100",
+ org.eclipse.core.resources;bundle-version="3.8.0",
+ org.eclipse.m2e.jdt;bundle-version="[1.9.0,1.10.0)",
+ org.eclipse.jdt.core;bundle-version="3.8.1",
+ org.eclipse.core.runtime;bundle-version="3.8.0"
+Bundle-RequiredExecutionEnvironment: JavaSE-1.8
diff --git a/org.eclipse.m2e.binaryproject.tests/build.properties b/org.eclipse.m2e.binaryproject.tests/build.properties
new file mode 100644
index 00000000..ced5f40e
--- /dev/null
+++ b/org.eclipse.m2e.binaryproject.tests/build.properties
@@ -0,0 +1,4 @@
+source.. = src/
+output.. = target/classes
+bin.includes = META-INF/,\
+ .
diff --git a/org.eclipse.m2e.binaryproject.tests/plugin_customization.ini b/org.eclipse.m2e.binaryproject.tests/plugin_customization.ini
new file mode 100644
index 00000000..cb717545
--- /dev/null
+++ b/org.eclipse.m2e.binaryproject.tests/plugin_customization.ini
@@ -0,0 +1,10 @@
+# Copyright (c) 2010-2011 Sonatype, Inc.
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Eclipse Public License v1.0
+# which accompanies this distribution, and is available at
+# http://www.eclipse.org/legal/epl-v10.html
+
+#
+# Add "-pluginCustomization plugin_customization.ini" to your Eclipse command line to apply these settings
+#
+org.eclipse.m2e.core/eclipse.m2.updateIndexes=false
diff --git a/org.eclipse.m2e.binaryproject.tests/pom.xml b/org.eclipse.m2e.binaryproject.tests/pom.xml
new file mode 100644
index 00000000..9d9e8254
--- /dev/null
+++ b/org.eclipse.m2e.binaryproject.tests/pom.xml
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Copyright (c) 2012 Igor Fedorenko
+ All rights reserved. This program and the accompanying materials
+ are made available under the terms of the Eclipse Public License v1.0
+ which accompanies this distribution, and is available at
+ http://www.eclipse.org/legal/epl-v10.html
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.eclipse.m2e</groupId>
+ <artifactId>m2e-core</artifactId>
+ <version>1.9.0-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>org.eclipse.m2e.binaryproject.tests</artifactId>
+ <packaging>eclipse-test-plugin</packaging>
+</project> \ No newline at end of file
diff --git a/org.eclipse.m2e.binaryproject.tests/src/org/eclipse/m2e/binaryproject/tests/BinaryProjectTest.java b/org.eclipse.m2e.binaryproject.tests/src/org/eclipse/m2e/binaryproject/tests/BinaryProjectTest.java
new file mode 100644
index 00000000..001d5098
--- /dev/null
+++ b/org.eclipse.m2e.binaryproject.tests/src/org/eclipse/m2e/binaryproject/tests/BinaryProjectTest.java
@@ -0,0 +1,66 @@
+/*******************************************************************************
+ * Copyright (c) 2012 Igor Fedorenko
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Igor Fedorenko - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.m2e.binaryproject.tests;
+
+import org.eclipse.core.resources.ICommand;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.jdt.core.IClasspathEntry;
+import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jdt.core.JavaCore;
+import org.eclipse.m2e.binaryproject.internal.BinaryProjectPlugin;
+import org.eclipse.m2e.core.MavenPlugin;
+import org.eclipse.m2e.core.internal.IMavenConstants;
+import org.eclipse.m2e.core.project.IMavenProjectFacade;
+import org.eclipse.m2e.jdt.internal.BuildPathManager;
+import org.eclipse.m2e.tests.common.AbstractMavenProjectTestCase;
+import org.eclipse.m2e.tests.common.ClasspathHelpers;
+
+@SuppressWarnings({"restriction"})
+public class BinaryProjectTest extends AbstractMavenProjectTestCase {
+ IProgressMonitor monitor = new NullProgressMonitor();
+
+ public void testBasic() throws Exception {
+ IProject project =
+ BinaryProjectPlugin.getInstance().create("org.apache.maven", "maven-core", "3.0.4", null, monitor);
+
+ assertTrue(project.hasNature(IMavenConstants.NATURE_ID));
+ assertTrue(project.hasNature(JavaCore.NATURE_ID));
+ assertNotNull(BuildPathManager.getMaven2ClasspathContainer(JavaCore.create(project)));
+ assertFalse(hasBuilder(project, JavaCore.BUILDER_ID));
+
+ IMavenProjectFacade facade = MavenPlugin.getMavenProjectRegistry().create(project, monitor);
+
+ assertNotNull(facade);
+ assertEquals(BinaryProjectPlugin.LIFECYCLE_MAPPING_ID, facade.getLifecycleMappingId());
+
+ IJavaProject javaProject = JavaCore.create(project);
+
+ ClasspathHelpers.assertClasspath(new String[] {"org.eclipse.jdt.launching.JRE_CONTAINER/.*",
+ "org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER", ".*/maven-core-3.0.4.jar"}, javaProject.getRawClasspath());
+
+ IClasspathEntry[] mavenClasspath = BuildPathManager.getMaven2ClasspathContainer(javaProject).getClasspathEntries();
+
+ assertTrue(mavenClasspath.length > 0);
+ }
+
+ private boolean hasBuilder(IProject project, String builderId) throws CoreException {
+ for (ICommand command : project.getDescription().getBuildSpec()) {
+ if (builderId.equals(command.getBuilderName())) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+}

Back to the top