When running my tests I have to declare a Java agent (for EclipseLink). I would however prefer not to hard-code the JAR reference but rather resolve the physical location of an already declared dependency?
‘iterator().next()’ gives just the first file. You’ll want something like ‘configurations.javaAgentOpenJpa.asPath’, depending on the exact syntax expected by the ‘-javaagent’ switch.
Hi Thanks for all your help! While the javaagent is being invoked now I still seem to have a Gradle issue for which I have no explanation.
In Eclipse (Project imported using STS) I run all my tests successfully. I have tests that run using OpenJPA, EclipseLink and Hibernate. In Eclipse I provide the following VM arguments to allow for runtime intrumentation of my JPA classes.
This works perfectly in Eclipse. However, I don’t seem to get the same to work with plain Gradle. I am getting:
<openjpa-2.2.0-r422266:1244990 fatal user error> org.apache.openjpa.util.MetaDataException: The type “class org.springframework.integration.jpa.test.entity.StudentReadStatus” has not been enhanced.
Please fix the formatting or repost. ‘compileTestJava’ shouldn’t be configured inside ‘test’. Instead of ‘files.iterator().next()’, you should use ‘singleFile’. You also forgot the ‘doFirst’, which will cause problems. Make sure you try with rc-1.
Well, I better don’t write Markdown at 2am in the morning…
Anyway, upgrading to Gradle 1.0-rc-1 fixes my issues. I wonder what was going on, it looks like the classpath was not resolved correctly. Anyway, it is working now. Regarding your recommendation for using configurations.javaAgentOpenJpa.singleFile: That causes the following error:
Expected configuration ‘:spring-integration-jpa:javaAgentOpenJpa’ to contain exactly one file, however, it contains 10 files.
I only need the first file in the collection, which resolves to /path/to/openjpa-2.2.0.jar. Since you discourage using configurations.javaAgentOpenJpa.files.iterator().next(), what shall I use instead?
In in the interim, the following configuration using Gradle 1.0-rc-1 works now:
rc-1 contains a fix regarding Java agents. If you only need the first file, a cleaner solution would be to make sure that the configuration resolves to just that file. Otherwise, you’ll have to stick to your approach.