ttt307307 / junitparams

Automatically exported from code.google.com/p/junitparams
0 stars 0 forks source link

add OSGI metadata to your jar #35

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
Repository management servers like sonatype nexus have the ability to extract 
osgi metadata from jar files(when downloaded from maven central) to provide 
eclipse p2 repository locations which can be used e.g. as source for tager 
platforms or software installation.

What steps will reproduce the problem?
1. there are no OSGi headers in your manifest.mf file, so nexus does not 
generate p2 metadata

What is the expected output? What do you see instead?
1. no metadata generated
2. try to reproduce with an eclipse .target file which references you jar file 
locally (eg. as "Directory") entry
3. look at the "Target Platform" View or try to reference your library as 
dependency from any plugin project

What version of the product are you using? On what operating system?
JUnitParams-0.9.0

Please provide any additional information below.

please see this blog post for information what is needed
http://blog.osgi.org/2013/01/get-help-adding-osgi-metadata-to-your.html

i'm willing to test any changes you make (after my vancancy which lasts until 
04.02.2013 ;))

Original issue reported on code.google.com by prace...@googlemail.com on 24 Jan 2013 at 12:49

GoogleCodeExporter commented 8 years ago
Added, you can build and check the development version.

Original comment by lipinski...@gmail.com on 13 Mar 2013 at 1:15

GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
Thanks for adding the osgi headers to the manifest, but i think they are not 
(completly) correct.
Currently i can create a dependency to you library, but when running a junit 
test i get the following exception:

java.lang.TypeNotPresentException: Type [unknown] not present
    at sun.reflect.annotation.TypeNotPresentExceptionProxy.generateException(TypeNotPresentExceptionProxy.java:46)
    at sun.reflect.annotation.AnnotationInvocationHandler.invoke(AnnotationInvocationHandler.java:75)
    at com.sun.proxy.$Proxy9.value(Unknown Source)
    at org.junit.internal.builders.AnnotatedBuilder.runnerForClass(AnnotatedBuilder.java:24)
    at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:57)
    at org.junit.internal.builders.AllDefaultPossibilitiesBuilder.runnerForClass(AllDefaultPossibilitiesBuilder.java:29)
    at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:57)
    at org.junit.internal.requests.ClassRequest.getRunner(ClassRequest.java:24)
    at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.<init>(JUnit4TestReference.java:33)
    at org.eclipse.jdt.internal.junit4.runner.JUnit4TestClassReference.<init>(JUnit4TestClassReference.java:25)
    at org.eclipse.jdt.internal.junit4.runner.JUnit4TestLoader.createTest(JUnit4TestLoader.java:48)
    at org.eclipse.jdt.internal.junit4.runner.JUnit4TestLoader.loadTests(JUnit4TestLoader.java:38)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:452)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
    at org.eclipse.swtbot.eclipse.core.RemotePluginTestRunner.main(RemotePluginTestRunner.java:64)
    at org.eclipse.swtbot.eclipse.core.UITestApplication.runTests(UITestApplication.java:117)
    at org.eclipse.ui.internal.testing.WorkbenchTestable$1.run(WorkbenchTestable.java:71)
    at java.lang.Thread.run(Thread.java:722)
Caused by: java.lang.NoClassDefFoundError: 
org/junit/runners/BlockJUnit4ClassRunner
    at java.lang.ClassLoader.defineClass1(Native Method)
    at java.lang.ClassLoader.defineClass(ClassLoader.java:791)
    at 

the important point is NoClassDefFoundError: 
org/junit/runners/BlockJUnit4ClassRunner
you bundle does not define a (direct) dependency to the org.junit bundle.

you could just an add an "import package" to the junit packages you need or 
directly define a dependency to the org.junit bundle (not recommended)

your curretn usage of the uses directive in the export package line does not 
seem correct to me, since you are not importing the referenced package.

excerpt from
http://blog.springsource.org/2008/10/20/understanding-the-osgi-uses-directive/

<snip>
Note that the package, or packages, named in a "uses" directive are either 
exported or imported by the bundle manifest containing the "uses" directive. So 
the following manifest
is valid:

…
export-package: p;uses:="q,r", q
import-package: r
…

whereas the following manifest is invalid (because it neither exports nor 
imports the package q):

…
export-package: p;uses:="q,r"
import-package: r
…
</snip>

Original comment by prace...@googlemail.com on 14 Mar 2013 at 1:34

GoogleCodeExporter commented 8 years ago

Original comment by lipinski...@gmail.com on 18 Mar 2013 at 11:31

GoogleCodeExporter commented 8 years ago
i tried with the following in the manifest

Import-Package: org.junit;version="4.8",
 org.junit.runner;version="4.8"

but that didn't work too. 

I'll have to grab the source and see what the problem is. 

Original comment by prace...@googlemail.com on 19 Mar 2013 at 8:03

GoogleCodeExporter commented 8 years ago
Please replace the current MANIFEST.MF file with the one attached.

The Tests do not work for me so I had to do an 
mvn -DskipTests=true clean verify

The resulting .jar file worked for me as a OSGI Bundle. 
Worked for running as plain JUnit Test as well as running as Plugin-Tests (Test 
Suites etc.)

Another cool enhancement would be to have a (Eclipse compatible)-Source Bundle 
as described here:
http://rajakannappan.blogspot.de/2010/03/automating-eclipse-source-bundle.html

but that's another task. That also shows how the MANIFEST.MF file could be 
generated in version changes ....

Original comment by prace...@googlemail.com on 13 Jan 2014 at 1:51

Attachments:

GoogleCodeExporter commented 8 years ago
Fixed - will be available with 1.0.4

Original comment by lipinski...@gmail.com on 28 Jul 2014 at 1:00

GoogleCodeExporter commented 8 years ago
Great! Please make sure to set the correct version number in the MANIFEST.MF 
file for

Export-Package: junitparams;version="1.0.0";uses:="org.junit"
Bundle-Version: 1.0.0

In the latest 1.0.2 release it's still 1.0.0 which leads to problems when 
dependencies are resolved.

Thanks!

Original comment by prace...@googlemail.com on 28 Jul 2014 at 2:02

GoogleCodeExporter commented 8 years ago
The version will now be generated, so this will not happen anymore.

Original comment by lipinski...@gmail.com on 28 Jul 2014 at 2:03