SPI in build script dependency not found

Hi,

I have been trying to hack a simple invocation of EclipseLink’s schema generation tool via the JPA 2.1 interface in my Gradle Build file.

I did this:

import javax.persistence.Persistence
  buildscript {
 repositories {
  mavenCentral()
 }
 dependencies {
  classpath "org.eclipse.persistence:org.eclipse.persistence.jpa:2.5.2"
 }
}
  task generateSchemaJPA << {
 Persistence.generateSchema("default", null);
}

However this does not work: the Persistence class implementation cannot find its own META-INF/services/javax.persistence.spi.PersistenceProvider file (included in the org.eclipse.persistence.jpa dependecy!):

Caused by: javax.persistence.PersistenceException: No Persistence provider to generate schema named default
 at build_72io0veabsmbapuhlgstwc028$_run_closure8.doCall(/home/test/build.gradle:109)
 at org.gradle.api.internal.AbstractTask$ClosureTaskAction.execute(AbstractTask.java:548)
 at org.gradle.api.internal.AbstractTask$ClosureTaskAction.execute(AbstractTask.java:529)
 at org.gradle.api.internal.tasks.TaskMutator$1.execute(TaskMutator.java:77)
 at org.gradle.api.internal.tasks.TaskMutator$1.execute(TaskMutator.java:73)
 at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeAction(ExecuteActionsTaskExecuter.java:80)
 at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:61)

What am I doing wrong?