Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Maven project file for JUnit as OSGi bundle #472

Closed
wants to merge 26 commits into from

Conversation

Tibor17
Copy link
Contributor

@Tibor17 Tibor17 commented Aug 8, 2012

Upon discussion #368, I created maven project file.
Other e.g. maven runtime environment, and script running pom.xml may come if necessary.

@dsaff
Copy link
Member

dsaff commented Aug 9, 2012

Looks interesting. Can you get one of the reporters of the original OSGi bugs to confirm that this would meet their needs? Thanks.

@marcphilipp
Copy link
Member

What about the junit-dep POM? Shouldn't it also be updated?

@Tibor17
Copy link
Contributor Author

Tibor17 commented Aug 21, 2012

@marcphilipp
yes, it should be as well. Did you see the latest comment in #212?
Tomorrow i would like to update the build process again. Can you @marcphilipp @cschneider then check it out and bring new inputs? I think that there will be quite a lot in order to provide compatible outcome against the current build process.

@marcphilipp
Copy link
Member

@Tibor17 Sure, I can take a look in the next couple of days. Just ping
me when you have made your changes.

@Tibor17
Copy link
Contributor Author

Tibor17 commented Aug 23, 2012

I submitted new changes. I would like you doing comparison of content of *.jar and *.zip files produced by Ant and Maven.

Thus launch commands
ant zip
and
make all

The settings.xml in src/main/config must be configured in prior.

In order to simulate deployment (make all) to https://oss.sonatype.org and http://sourceforge.net
use ftp setup via FileZilla Server on
ftp://localhost/sonatype and ftp://localhost/sourceforge
for repository ids:
sonatype-nexus-staging
sourceforge-staging

The deployment to sourceforge creates junit/junit/ directories which I will fix next days.
Also I will continue on use of OSGi Felix in junit.

There are few things to discuss and we i expect different opinions..., but i had to make some decisions in pom.xml

<Bundle-SymbolicName>org.junit</Bundle-SymbolicName>
<Bundle-Name>${project.name}</Bundle-Name>
<Bundle-Version>${project.version}</Bundle-Version>
<Export-Package>org.hamcrest.*;version="${hamcrest.version}",junit.*;version="3.8.2",org.junit.*;version="${project.version}</Export-Package>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is 3.8.2 doing here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The packages have versions.
The junit.* packages have old version 3.8.2 that we are exporting.
Other bundle XYZ that imports this one junit bundle, and wants to import junit.* packages with version 3.8.2+ still can use. If the XYZ do not want to use these packages, then simply their import section Import-Package may omit junit.*.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Although 3.8.2 was the last release of the project without org.junit packages, I'd have thought that we're still providing a 4.9, 4.10, etc, version of the junit.framework packages. They're just not changing very fast.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dsaff pls see my latest update.
How we would proceed next?

junit.* packages keep the latest version
@dsaff
Copy link
Member

dsaff commented Sep 17, 2012

This latest change is OK to my eyeballs. @marcphilipp, are you planning to take a look?

@Tibor17
Copy link
Contributor Author

Tibor17 commented Sep 21, 2012

@dsaff after #332 is fixed and closed, so that junit-dep is gone, are you open for a real maven build process?
I may meanwhile open a pull request for junit mavenize.

@@ -5,6 +5,7 @@
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>@version@</version>
<packaging>bundle</packaging>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will this change how people can consume the Maven artifact?

Usually the will have declared a dependency to junit:junit like this:

<dependency>
    <groupId>junit</groupId>
    <artifactId>junit</artifactId>
    <version>4.10</version>
</dependency>

They probably won't have an explicit <type>jar</type> in their dependency declaration. Thus, type will point to its default value jar.

I'm worried that changing the packaging type from jar to bundle will force a lot of people to change their dependency declarations to this:

<dependency>
    <groupId>junit</groupId>
    <artifactId>junit</artifactId>
    <version>4.10</version>
    <type>bundle</type>
</dependency>

@Tibor17 Can you make sure that this will not be necessary?

I took a quick look at the Apache Felix documentation. Appararently there's a way to add OSGi metadata without changing the packaging type. For details please see:
http://felix.apache.org/site/apache-felix-maven-bundle-plugin-bnd.html#ApacheFelixMavenBundlePlugin%28BND%29-AddingOSGimetadatatoexistingprojectswithoutchangingthepackagingtype

Maybe that would be the less intrusive way to do it?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@marcphilipp

Today I will update my project and add new OSGi entries. I modified the entries and the itegration test work fine. I will maybe tomorrow extend the integration tests.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Tibor17 Good to hear! I think it might make sense to check-in those integration tests you setup. What do you think?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@marcphilipp
I know the a cool idea, i am happy what you have done for #332, and i am glad to release Mavn staff. But let's do it step by step. The 4-11 can have new big changes that we improve the JUnit.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One more thing I want to ask you @marcphilipp. I created #511, and on Monday i plan to create a similar pull request extended by osgi copied from my public repo.
Would you agree with me if we deploy these versions into https://oss.sonatype.org/content/repositories/snapshots
4.11-SNAPSHOT for #332
4.11.1-SNAPSHOT for #511
4.11.2-SNAPSHOT for OSGi + Maven pull request I will create on Monday morning

This way we may ask the community to test the release one by one, and improve.
After that we may ask the clients JetBrains IDEA, Eclipse, etc, to be prepared in advance for a new official release 4.11 in Maven central as non-snapshot.

One more thing, the hamcrest-core:1.3 is not OSGi, and it should be. Today I want to create a github pull request in JavaHamcrest for that.

@marcphilipp
Copy link
Member

@dsaff @Tibor17 Please see my inline comment.

Added new entries, and osgi framework dependency.
I will on Monday create a new pull request with Maven solution using OSGi integration tests as a copy of my public repo.
It seems we should use OSGi Activator to work properly in a real environment.
<Bundle-Activator>org.junit.osgi.JunitActivator</Bundle-Activator>
@marcphilipp
Copy link
Member

I like your approach of testing things one by one. However, let's put aside the topic of when and how to deploy to Maven central for now. First, I would like to get back on topic and discuss this pull request.

To be more specific: Can we please see how you've tested/verified this change? Does changing the POM template really have the desired effect of JUnit becoming consumable for both non-OSGi- and OSGi-clients? Doesn't the build.xml also need a change? Since we do not build JUnit using Maven, when will the maven-bundle-plugin get called?

@Tibor17
Copy link
Contributor Author

Tibor17 commented Sep 23, 2012

This is a good question. I mentioned an approach in other pull request, but it seems it was not clear.
The template like this is not enough because the ANT does not know how to handle it.
There is a way how to do that. The lifecycle of such change in build.xml will be just short, and therefore it makes sense to continue with the Maven build i made, because there is a significant work been done till now which works and that's important. That's the reason why, for me, this pull request makes sense only like presenting the configuration, but the real and final will be in a new pull request without this template on Monday -currently i am preparing files to push maybe at night or so.

@marcphilipp
Copy link
Member

IMHO, a pull request should present a sensible increment of functionality for reviewing and then merging.

I don't see the point in merging something that would, at the least, introduce something that is not used or, even worse, probably break our current Maven deployment from the Ant build file.

@dsaff What's your opinion on this?

@dsaff
Copy link
Member

dsaff commented Sep 24, 2012

I'm not planning to come up to speed on OSGi and maven enough to provide technical guidance on these questions. I think my time is better spent in the core code, which I can provide expertise on. The amount of uncertainty among people I respect on this thread makes me concerned that accepting this patch (and some of the related patches) would simply mean more bug reports in the future that I don't understand.

Is there any way for those concerned to set up an interim solution? Some kind of junit-osgi bundle that would depend on junit, but be maintained separate from it, and provide the packaging required by OSGi?

@Tibor17
Copy link
Contributor Author

Tibor17 commented Sep 25, 2012

@dsaff
i am facing the interim solution as BND library used in build.xml -does not change pom.xml in deployment to Maven central nor the packaging.
Would it be a good step @marcphilipp ? The bnd would only add extra manifest attributes which does not harm the library. This should be simple enough for maintenance.

@marcphilipp
Copy link
Member

As @dsaff mentioned we should try to get one of the original reporters of issue #212 on board. Thus, I added a couple of questions we should get answered before we can continue there.

Summing up, I think we should first release 4.11 as it is now to get more feedback on the Maven relocation of junit-dep and the new junit artifact.

@Tibor17 Are you ok with that?

@Tibor17
Copy link
Contributor Author

Tibor17 commented Sep 25, 2012

@marcphilipp we need @cschneider as the reporter of # 212.
@cschneider do you still have time to track this pull?

@Tibor17
Copy link
Contributor Author

Tibor17 commented Sep 27, 2012

@marcphilipp I am fine with deploying 4.11 first.

@dsaff
Copy link
Member

dsaff commented Oct 5, 2012

OK, we'll tackle this again once 4.11 is out the door. Thanks, everyone.

@dsaff
Copy link
Member

dsaff commented Nov 8, 2012

Explicitly added for consideration in the 4.12 milestone

@Tibor17
Copy link
Contributor Author

Tibor17 commented Nov 21, 2012

@dsaff
@marcphilipp
Regarding the milestone.
This pull is already designed in maven. To me it seems more convenient to proceed with #511 first. There we are on a right way. The only thing I have not done there yet is to update my branch in #511 -I will do this weekend.
Simply we may release beta-1 for maven part, and then next beta-2 for this pull.
Can we proceed like this?

@dsaff
Copy link
Member

dsaff commented Nov 21, 2012

Agreed that tackling #511 first is the right next step.

@dsaff
Copy link
Member

dsaff commented Dec 18, 2012

For anyone following this, work continues in #511, FYI.

@Tibor17
Copy link
Contributor Author

Tibor17 commented Jan 8, 2013

I will insert the felix plugin to the new pom.xml as soon as the junit mavenization is available
and revert the edited file build/maven/junit-pom-template.xml .

@Tibor17
Copy link
Contributor Author

Tibor17 commented Jul 18, 2013

@cschneider
@hwellmann

Please pay attention in this JUnit pull request with OSGi headers in JUnit bundle.
The JUnit committer closed another very trivial pull #701 which was about exactly the same solution having no integration tests.

I can clearly see that this pool can be closed with the same arguments as in #701.
So I am leaving this pull to be managed by @cschneider , @hwellmann and @dsaff .

@cschneider
Copy link

I am +1 for this pull request. Though I favor the simpler aproach of #701 without integration tests.

-->
<artifactId>maven-surefire-plugin</artifactId>
<version>2.12.3</version>
<version>2.14.1</version>

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2.15 is current. 2.14.1 munges names of failed tests AFAIK.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@Tibor17
Copy link
Contributor Author

Tibor17 commented Jul 27, 2013

@hwellmann
I submited profiles which looks nice, but I have a problem to find Pax 2.x version works in JDK 1.5.
The problem is that I am getting UnsupportedClassVersion Bad version number in .cla... in Pax 2.6.0 - 2.4.0. I think it is because of Guava 10 built with JDK 1.6. The latest Pax which uses Guava (r09) built by JDK 5 version is Pax 2.3.1 but it has issue PAXEXAM-291.
So what is the latest working Pax version which would work for us with JDK 1.5?

@hwellmann
Copy link

Pax Exam uses java.util.ServiceLoader ever since 2.0.0, and this requires a Java 6 Runtime. Earlier 2.x releases may have had Java 1.5 source or target compatibility defined in the POM, but that was misleading anyway.

In short, even if JUnit is compiled with 1.5 source and target level, you need a 1.6 or 1.7 runtime to test it with Pax Exam 2.x or 3.x in an OSGi environment.

@Tibor17
Copy link
Contributor Author

Tibor17 commented Jul 27, 2013

@hwellmann
Ok, I will try to find my code backup with Pax 1.x and use it.

@mohitkgupta
Copy link

+1 for Junit as OSGi bundle

@Tibor17
Copy link
Contributor Author

Tibor17 commented Aug 3, 2013

@hwellmann
Sorry for the delay. I used the same test code with Pax 1.2.4 at Java 5. The problem is that Pax 1 uses JUnit classes within com.springsource.org.junit which is in conflict with our JUnit library. The root cause of failed IT is that org.hamcrest.core.IsCollectionContaining cannot be loaded.
Is it possible to use some syntax to exclude Bundle-SymbolicName: com.springsource.org.junit from the container?
If not, then I have to keep only the pure OSGi-Framework tests.
Anyway I was glad that Pax 3.x was working nicely with Java 6.

@pholser
Copy link
Contributor

pholser commented Aug 5, 2013

+1 for Junit as OSGi bundle

@cmoulliard
Copy link

+1 for Junit as OSGi bundle

@dsaff
Copy link
Member

dsaff commented Sep 17, 2013

I'm closing this for now. I know that it's close to some of your hearts. Let's continue the discussion, if there's new points to be raised, on the mailing list, but leaving this as an open pull request isn't going to move things forward. Thanks.

@dsaff dsaff closed this Sep 17, 2013
@sarxos
Copy link

sarxos commented Nov 13, 2013

👍

It's very annoying when one have to generate OSGi bundle from JAR and put again in Maven repo - it's much better to have it already bundled in The Central Repository. We had to did this with many artifacts for our previous project, it was a pain.

@Tibor17
Copy link
Contributor Author

Tibor17 commented Nov 18, 2013

@sarxos
I agree with you. Several people here vote for this feature. The people on LinkedIn agreed with this request as well.
I am open for maintaining this feature in the future. Unfortunately I do not have commiter's rights to push this pull request in GitHub.

@dsaff
Copy link
Member

dsaff commented Nov 20, 2013

OK, I can make a deal. We need to get JUnit 4.12 out the door, but I don't have the day-to-day time to see it through, the masterful way that @marcphilipp did for JUnit 4.11.

If someone would volunteer to be release master for JUnit 4.12, producing betas, updating documentation, uploading jars, etc., who also wants to see the OSGi metadata changes, then I'd be willing to agree to the future maintenance of the OSGi metadata in exchange for the release help now.

Anyone want to step up?

@Tibor17
Copy link
Contributor Author

Tibor17 commented Dec 2, 2013

@ALL
I was quite for some time. Happy of moving the new release ahead.

@lonniev
Copy link

lonniev commented Jan 5, 2015

One year later, Happy New Year, and is there available an OSGi bundle at a public p2 site that has both junit 4 and hamcrest all included? This doesn't have to be bleeding edge recent, anything within ~2 years would probably be fine.

(I can bundle up my own bundle but seek the convenience of leaving this outside the scope of what my project has to actively manage.)

@hwellmann
Copy link

There are OSGi bundles for JUnit on Maven Central:

<dependency>
    <groupId>org.ops4j.pax.tipi</groupId>
    <artifactId>org.ops4j.pax.tipi.junit</artifactId>
    <version>4.12.0.1</version>
</dependency>

<dependency>
    <groupId>org.ops4j.pax.tipi</groupId>
    <artifactId>org.ops4j.pax.tipi.hamcrest.core</artifactId>
    <version>1.3.0.1</version>
</dependency>

No p2 support and not hamcrest-all, but maybe that helps.

@lonniev
Copy link

lonniev commented Jan 6, 2015

@hwellmann thanks--but, no, the key need is for the existence of the hamcrest-all packages as an OSGi bundle if only within a public p2 site. For any situation outside that scope, it is trivial to construct a local solution. The point is to avoid having to construct that local solution so that I and my team can remain focused--or, rather, return to a focus--on developing business logic versus maintaining packages for third-party capabilities.

(For the meantime, I took the pragmatic approach of simply adding yet another maven sub-module Tycho eclipse-plugin project to our project to bundle up the necessary hamcrest-all packages and of pushing that to our internal maven and p2 sites. Sigh.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet