Bug 192575 - [patch] java/junit: fix build of 4.11 with openjdk8
Summary: [patch] java/junit: fix build of 4.11 with openjdk8
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Only Me
Assignee: Danilo Egea Gondolfo
Depends on:
Blocks: 199819
  Show dependency treegraph
Reported: 2014-08-11 09:00 UTC by Kevin Bowling
Modified: 2015-05-02 18:56 UTC (History)
4 users (show)

See Also:

[patch] java/junit fix build with openjdk8 (2.21 KB, patch)
2014-08-11 09:00 UTC, Kevin Bowling
no flags Details | Diff
junit 4.12 (2.97 KB, patch)
2015-02-20 22:54 UTC, Danilo Egea Gondolfo
no flags Details | Diff
new patch (2.50 KB, patch)
2015-04-29 00:15 UTC, Danilo Egea Gondolfo
no flags Details | Diff
patch_junit_hamcrest_libreoffice (6.25 KB, patch)
2015-04-29 18:43 UTC, Danilo Egea Gondolfo
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Kevin Bowling freebsd_committer 2014-08-11 09:00:59 UTC
Created attachment 145654 [details]
[patch] java/junit fix build with openjdk8

If OpenJDK8 is set as the default compiler, this build fails with:

I started looking at porting junit 4.12-beta-1, but they switched the build from ant to maven so it will be a bit of work.

For now, I backported https://github.com/junit-team/junit/commit/88f7a12d472b1157639db5148b29c8a8825802a3 and it seems to work ok.
Comment 1 John Marino freebsd_committer 2014-08-11 09:34:35 UTC
over to maintainer
Comment 2 Greg Lewis freebsd_committer 2015-02-15 19:57:07 UTC
I concur that this fixes the build with OpenJDK8.  Better would be updating the port to JUnit 4.12 though.

I have to ask, why are we bothering to build JUnit like this?  It would be much easier to just download the the JARs and install them into the appropriate directory and then we wouldn't need to worry about the build process at all.

However, if we don't want to update to JUnit 4.12, then committing would remove one of the issues of a change in default from openjdk7 (EOL in April) to openjdk8.
Comment 3 Danilo Egea Gondolfo freebsd_committer 2015-02-20 22:54:17 UTC
Created attachment 153253 [details]
junit 4.12
Comment 4 Danilo Egea Gondolfo freebsd_committer 2015-02-20 22:57:02 UTC
I've updated the port to 4.12. As glewis suggested I'm using the binary now. Maybe there is more sites to add to MASTER_SITES. Can you test it?
Comment 5 Kurt Jaeger freebsd_committer 2015-04-28 16:35:47 UTC
The patch does not apply cleanly, there's a Makefile.rej left over.

It also fails to build.
Comment 6 Danilo Egea Gondolfo freebsd_committer 2015-04-29 00:15:50 UTC
Created attachment 156082 [details]
new patch
Comment 7 Danilo Egea Gondolfo freebsd_committer 2015-04-29 00:17:42 UTC
I've simplified the Makefile and tested with poudriere. That looks good to you?
Comment 8 Kurt Jaeger freebsd_committer 2015-04-29 05:32:53 UTC
Test-building right now. Will take some time...
Comment 9 Kurt Jaeger freebsd_committer 2015-04-29 06:18:40 UTC
It builds fine, but libreoffice fails to build with it:

checking for standalone hamcrest jar.... configure: error: junit does not contain hamcrest; please use a junit jar that includes hamcrest, install a hamcrest jar in the default location (/usr/share/java),
                          specify its path with --with-hamcrest=..., or disable junit with --without-junit
Comment 10 Danilo Egea Gondolfo freebsd_committer 2015-04-29 13:26:38 UTC
Hmm, probably we'll need to create a hamcrest port and set it as a junit dependency. I'll check it. Thanks!
Comment 11 John Marino freebsd_committer 2015-04-29 17:23:50 UTC
fwiw, at least on DF, junit won't even build with openjdk7 now (since the last update to openjdk7).  I actually think the latest openjdk7 is a regression, I had more than one new failure with it.
Comment 12 Danilo Egea Gondolfo freebsd_committer 2015-04-29 18:43:09 UTC
Created attachment 156114 [details]
Comment 13 Danilo Egea Gondolfo freebsd_committer 2015-04-29 18:44:48 UTC
I've created the hamcrest port. This change solves the previous problem. What do you think?
Comment 14 Kurt Jaeger freebsd_committer 2015-04-29 20:35:23 UTC
hamcrest builds fine, thanks. In the future, please: new ports
as shar in a new PR, seperate from other stuff 8-}

I'm testing...
Comment 15 Kurt Jaeger freebsd_committer 2015-04-29 20:44:14 UTC
The patch to the libreoffice makefile references hamcrest, but
does not add the build_depends or run_depends ?
Comment 16 John Marino freebsd_committer 2015-04-29 20:47:58 UTC
libreoffice built for me even though junit failed (on DragonFly).  However, IIRC, libreoffice is a highly patched and restricted port so maybe DF is just immune ...
Comment 17 Danilo Egea Gondolfo freebsd_committer 2015-04-29 20:52:35 UTC
Is it necessary? Because hamcrest is a dependency of junit, and junit is a dependency of libreoffice.
Comment 18 Kurt Jaeger freebsd_committer 2015-04-29 20:57:32 UTC
If hamcrest is a build_dep for junit, where in the makefile of junit is this
listed ?
Comment 19 Danilo Egea Gondolfo freebsd_committer 2015-04-29 20:59:20 UTC
There is a LIB_DEPENDS in my last (messy) patch.
Comment 20 John Marino freebsd_committer 2015-04-29 21:10:04 UTC
to correct myself, libreoffice is *NOT* heavily patched in dports, it's almost stock.

It built because JAVA is not a default option, and the JAVA option is what pulls in junit.  I don't see why libreoffice would fail by default...
Comment 21 Kurt Jaeger freebsd_committer 2015-05-01 14:54:58 UTC
I'm still testing this. One run with libreoffice and java still caused some
build failure, I need to investigate more.
Comment 22 Kurt Jaeger freebsd_committer 2015-05-02 06:58:40 UTC
test finished, looks fine.
Comment 23 commit-hook freebsd_committer 2015-05-02 07:06:33 UTC
A commit references this bug:

Author: pi
Date: Sat May  2 07:05:59 UTC 2015
New revision: 385166
URL: https://svnweb.freebsd.org/changeset/ports/385166

  New port: java/hamcrest

  Provides a library of matcher objects (also known as
  constraints or predicates) allowing 'match' rules to
  be defined declaratively, to be used in other frameworks.
  Typical scenarios include testing frameworks, mocking libraries
  and UI validation rules.

  WWW: http://hamcrest.org/

  PR:		192575
  Submitted by:	danilo

Comment 24 Kurt Jaeger freebsd_committer 2015-05-02 07:08:54 UTC
The lib-depends did not work:

/!\ junit-4.12: Makefile errors /!\

All LIB_DEPENDS should use the new format and start out with lib. (libfoo.so vs foo.so)

*** Error code 1


So I changed it to a run-depends.
Comment 25 Kurt Jaeger freebsd_committer 2015-05-02 07:13:34 UTC
(In reply to Danilo Egea Gondolfo from comment #7)

I'm testing the dependend ports now for the junit update:

Comment 26 Kurt Jaeger freebsd_committer 2015-05-02 14:39:18 UTC
Most ports worked, two failed (openoffice-devel fail is unrelated):


I'm not sure the failures are hamcrest/junit-related, so if I do not
hear anything else, I'll commit the junit update in a few hours or so.
Comment 27 commit-hook freebsd_committer 2015-05-02 18:01:33 UTC
A commit references this bug:

Author: pi
Date: Sat May  2 18:01:00 UTC 2015
New revision: 385202
URL: https://svnweb.freebsd.org/changeset/ports/385202

  java/junit: 4.11 -> 4.12


  Moved from building from source with ant to using the binary jar file,
  as the new build mechanism is based on maven. java/hamcrest was split
  from 4.12.

  PR:		192575
  Submitted by:	danilo (maintainer), kevin.bowling@kev009.com

Comment 28 Kurt Jaeger freebsd_committer 2015-05-02 18:13:00 UTC
Committed, thanks for the fixed and the hamcrest port.
Comment 29 Danilo Egea Gondolfo freebsd_committer 2015-05-02 18:56:17 UTC
java/berkeley-db works with this change in build.xml:

     <path id="unittest.classpath">
       <path refid="class.path"/>
      <pathelement location="${env.JAVALIBDIR}/junit.jar"/>
      <pathelement location="${env.JAVALIBDIR}/hamcrest.jar"/>
       <pathelement location="${unittest.destdir}"/>