summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexander Silgidjian2011-07-07 13:05:02 (EDT)
committerKaloyan Raev2011-07-07 13:05:02 (EDT)
commit8c0ee3537a8f1d57403c486189e8039ddae33c14 (patch)
treef34a2fb9c040c1caf3703063e895e4fbeebce29d
parentbe85a0e2f47a7d667d9a107d55edbf622702a8ea (diff)
downloadorg.eclipse.libra-8c0ee3537a8f1d57403c486189e8039ddae33c14.zip
org.eclipse.libra-8c0ee3537a8f1d57403c486189e8039ddae33c14.tar.gz
org.eclipse.libra-8c0ee3537a8f1d57403c486189e8039ddae33c14.tar.bz2
[350040] Incorrect build.properties for Persistent Bundles
-rw-r--r--plugins/org.eclipse.libra.facet/src/org/eclipse/libra/facet/OSGiBundleFacetInstallDelegate.java34
-rw-r--r--tests/org.eclipse.libra.facet.test/resources/testJPA.zip_bin0 -> 3761 bytes
-rw-r--r--tests/org.eclipse.libra.facet.test/src/org/eclipse/libra/facet/test/WabConversionTest.java44
3 files changed, 56 insertions, 22 deletions
diff --git a/plugins/org.eclipse.libra.facet/src/org/eclipse/libra/facet/OSGiBundleFacetInstallDelegate.java b/plugins/org.eclipse.libra.facet/src/org/eclipse/libra/facet/OSGiBundleFacetInstallDelegate.java
index 1a6c262..71d283f 100644
--- a/plugins/org.eclipse.libra.facet/src/org/eclipse/libra/facet/OSGiBundleFacetInstallDelegate.java
+++ b/plugins/org.eclipse.libra.facet/src/org/eclipse/libra/facet/OSGiBundleFacetInstallDelegate.java
@@ -277,23 +277,23 @@ public class OSGiBundleFacetInstallDelegate implements IDelegate {
IProject project = bundleProjectDescription.getProject();
IBundleClasspathEntry[] bundleClasspath = bundleProjectDescription.getBundleClasspath();
- if (OSGiBundleFacetUtils.isWebProject(project)) {
- IJavaProject javaProject = JavaCore.create(project);
- if (bundleClasspath == null) {
- IBundleProjectService bundleProjectService = Activator.getDefault().getBundleProjectService();
-
- IPath source = getRelativePath(project, getJavaSourceFolderPaths(javaProject)[0]);
- IPath binary = getRelativePath(project, javaProject.getOutputLocation());
- IPath library = new Path(WEB_INF_CLASSES);
-
- IBundleClasspathEntry webInfClasses = bundleProjectService.newBundleClasspathEntry(
- source, binary, library);
- bundleClasspath = new IBundleClasspathEntry[] { webInfClasses };
- } else {
- // TODO
- }
- }
-
+ IJavaProject javaProject = JavaCore.create(project);
+ if (bundleClasspath == null) {
+ IBundleProjectService bundleProjectService = Activator.getDefault().getBundleProjectService();
+
+ IPath source = getRelativePath(project, getJavaSourceFolderPaths(javaProject)[0]);
+ IPath binary = getRelativePath(project, javaProject.getOutputLocation());
+ IPath library = (OSGiBundleFacetUtils.isWebProject(project))
+ ? new Path(WEB_INF_CLASSES) // add WEB-INF/classes for WABs
+ : null; // add . for other OSGi bundles
+
+ IBundleClasspathEntry classpath = bundleProjectService.newBundleClasspathEntry(
+ source, binary, library);
+ bundleClasspath = new IBundleClasspathEntry[] { classpath };
+ } else {
+ // TODO
+ }
+
// don't modify bin.includes by default
return bundleClasspath;
}
diff --git a/tests/org.eclipse.libra.facet.test/resources/testJPA.zip_ b/tests/org.eclipse.libra.facet.test/resources/testJPA.zip_
new file mode 100644
index 0000000..9c79b30
--- /dev/null
+++ b/tests/org.eclipse.libra.facet.test/resources/testJPA.zip_
Binary files differ
diff --git a/tests/org.eclipse.libra.facet.test/src/org/eclipse/libra/facet/test/WabConversionTest.java b/tests/org.eclipse.libra.facet.test/src/org/eclipse/libra/facet/test/WabConversionTest.java
index 0570d5c..23300c6 100644
--- a/tests/org.eclipse.libra.facet.test/src/org/eclipse/libra/facet/test/WabConversionTest.java
+++ b/tests/org.eclipse.libra.facet.test/src/org/eclipse/libra/facet/test/WabConversionTest.java
@@ -52,10 +52,12 @@ import org.junit.Test;
public class WabConversionTest {
private static final NullProgressMonitor monitor = new NullProgressMonitor();
private static final String WEB_PRJ_LOCATION = "resources/testWeb.zip_";
- private static final String JAVA_PRJ_LOCATION = "resources/testJava.zip_";
+ private static final String JAVA_PRJ_LOCATION = "resources/testJava.zip_";
+ private static final String JPA_PRJ_LOCATION = "resources/testJPA.zip_";
private static final String SIMPLE_PRJ_LOCATION = "resources/testSimple.zip_";
private static final String WEB_PRJ_NAME = "testWeb";
- private static final String JAVA_PRJ_NAME = "testJava";
+ private static final String JAVA_PRJ_NAME = "testJava";
+ private static final String JPA_PRJ_NAME = "testJPA";
private static final String SIMPLE_PRJ_NAME = "testSimple";
private static final String WEB_REFERRING_JAVA_PRJ_LOCATION = "resources/testWebReferringJava.zip_";
private static final String WEB_REFERRING_JAVA_PRJ_NAME = "testWebReferringJava";
@@ -169,7 +171,18 @@ public class WabConversionTest {
IBundleProjectDescription description = bundleProjectService.getDescription(webProject);
checkWebProject(webProject, WEB_PRJ_NAME, "TestWeb", null, "1.0.0.qualifier", new String[] {"test", "test1"}, "/" + WEB_PRJ_NAME, description);
- }
+ }
+
+ @Test
+ public void convertJPAProject() throws Exception {
+ IProject jpaProject = importProjectInWorkspace(JPA_PRJ_LOCATION, JPA_PRJ_NAME);
+ new ConvertProjectsToBundlesOperation(new IProject[]{jpaProject}).run(monitor);
+
+ IBundleProjectService bundleProjectService = Activator.getDefault().getBundleProjectService();
+ IBundleProjectDescription description = bundleProjectService.getDescription(jpaProject);
+
+ checkJPAProject(jpaProject, JPA_PRJ_NAME, "TestJPA", null, "1.0.0.qualifier", new String[] {"test"}, description);
+ }
@Test
public void convertWebProjectCustomHeders() throws Exception {
@@ -269,8 +282,8 @@ public class WabConversionTest {
Assert.assertFalse(buildPropertiesFile.exists());
}
- private void checkWebProject(IProject project, String expectedSymbolicName, String expectedBundleName, String expectedVendor, String expectedVersion, String[] expectedPackageImports, String expectedWebContextPath, IBundleProjectDescription description) throws JavaModelException {
- checkJavaProject(project, expectedSymbolicName, expectedBundleName, expectedVendor, expectedVersion, expectedPackageImports, description);
+ private void checkWebProject(IProject project, String expectedSymbolicName, String expectedBundleName, String expectedVendor, String expectedVersion, String[] expectedPackageExports, String expectedWebContextPath, IBundleProjectDescription description) throws JavaModelException {
+ checkJavaProject(project, expectedSymbolicName, expectedBundleName, expectedVendor, expectedVersion, expectedPackageExports, description);
checkWebPackageImports(description);
Assert.assertEquals("2", description.getHeader("Bundle-ManifestVersion"));
checkLaunchShortcuts(description);
@@ -283,6 +296,18 @@ public class WabConversionTest {
Assert.assertNull(bundleClasspath[0].getBinaryPath());
Assert.assertEquals("src/", bundleClasspath[0].getSourcePath().toPortableString());
Assert.assertEquals("WEB-INF/classes/", bundleClasspath[0].getLibrary().toPortableString());
+ }
+
+ private void checkJPAProject(IProject project, String expectedSymbolicName, String expectedBundleName, String expectedVendor, String expectedVersion, String[] expectedPackageExports, IBundleProjectDescription description) throws JavaModelException {
+ checkJavaProject(project, expectedSymbolicName, expectedBundleName, expectedVendor, expectedVersion, expectedPackageExports, description);
+ checkJPAPackageImports(description);
+ Assert.assertEquals("2", description.getHeader("Bundle-ManifestVersion"));
+ IBundleClasspathEntry[] bundleClasspath = description.getBundleClasspath();
+ Assert.assertEquals(1, bundleClasspath.length);
+ Assert.assertNull(bundleClasspath[0].getBinaryPath());
+ Assert.assertEquals("src/", bundleClasspath[0].getSourcePath().toPortableString());
+ IPath outputFolder = description.getDefaultOutputFolder();
+ Assert.assertEquals("build/classes", outputFolder.toString());
}
private void checkJavaProject(IProject project, String expectedSymbolicName, String expectedBundleName, String expectedVendor, String expectedVersion, String[] expectedPackageExports, IBundleProjectDescription description) throws JavaModelException {
@@ -346,6 +371,15 @@ public class WabConversionTest {
Assert.assertTrue(packageImportStrings.contains("javax.servlet.jsp.el"));
Assert.assertTrue(packageImportStrings.contains("javax.servlet.jsp.tagext"));
Assert.assertTrue(packageImportStrings.contains("javax.el"));
+ }
+
+ private void checkJPAPackageImports(IBundleProjectDescription description) {
+ IPackageImportDescription[] packageImports = description.getPackageImports();
+ List<String> packageImportStrings = new ArrayList<String>();
+ for (IPackageImportDescription currPackageImportDescription : packageImports) {
+ packageImportStrings.add(currPackageImportDescription.getName());
+ }
+ Assert.assertTrue(packageImportStrings.contains("javax.persistence"));
}
private OSGiBundleFacetInstallConfig setupOSGiBundleFacetInstallConfig(String symbolicName, String bundleName, String vendor, String version) throws CoreException {