What are the Maven dependency parameters for the Java Gradle API?
Asked Answered
C

5

12

I'm writing a Gradle plugin in Java. In order to use the IDE for developing (especially code completion), I need to add to the pom.xml file of the project the dependency information for the org.gradle.api.* classes.

Where can I find it?

I tried mvnrepository.com, but couldn't find it there.

Closeup answered 14/1, 2015 at 18:54 Comment(2)
The Gradle project does not publish all core libraries to a publicly-available repository (e.g. you might need org.gradle.gradle-model which is not published). There's no guarantee that you'll be able to build a Gradle plugin with Maven.Princeling
@BenjaminMuschko is it still a thing? How in that case one supposed to resolve this dependencies while working in IDE?Flatus
E
12

I found this artifact after a longer search: https://mvnrepository.com/artifact/org.gradle/gradle-core/2.2.1

<dependency>
  <groupId>org.gradle</groupId>
  <artifactId>gradle-core</artifactId>
  <version>2.2.1</version>
</dependency>

The artifact is available in following repository: http://repo.springsource.org/libs-release-remote/

<repository>
  <id>Spring Source Libs</id>
  <url>http://repo.springsource.org/libs-release-remote/</url>
</repository>

Add the repository to the repositories section in your pom.xml as well as the artifact as dependency. I tested it with a Maven project in my Eclipse workspace - the org.gradle.api.* classes are available and I can also browse the gradle-core sources.

Elvinaelvira answered 17/1, 2015 at 12:12 Comment(0)
C
3

Use this:

dependencies {
  //we will use the Groovy version that ships with Gradle:
  compile localGroovy()

  //our plugin requires Gradle API interfaces and classes to compile:
  compile gradleApi()
}
Consortium answered 14/1, 2015 at 19:0 Comment(6)
Thanks, but that's not the question. I can successfully build the plugin with Gradle, but I want to be able to build it with Maven so that IntelliJ Idea can resolve Gradle API classes and support code completion.Closeup
He's looking for pom.xml dependency.Fisk
Sorry, i slipped through that... Why would you write a Gradle plugin in Maven? :S IntelliJ has Gradle support as well.Consortium
IntelliJ has Gradle support as well: Then how can I make IntelliJ Idea recognize the classes org.gradle.api.*? I have already a Maven plugin, which does code quality checks. Now I want to create a Gradle plugin, which does the same checks in Gradle. See github.com/teamed/qulice .Closeup
By Gradle support i meant you can create a Gradle project, add the block i posted, and IntelliJ should compile the project.Consortium
Why don't you just download the sources JAR from gradle.org e.g. gradle-2.2.1-src.zip and attach it to your project?Princeling
F
3

If you want to use the official Gradle Releases repository in a Maven pom try this:

<dependencies>
    <dependency>
        <groupId>org.gradle</groupId>
        <artifactId>gradle-core</artifactId>
        <version>3.4.1</version>
    </dependency>
    <dependency>
        <groupId>org.gradle</groupId>
        <artifactId>gradle-tooling-api</artifactId>
        <version>3.4.1</version>
    </dependency>
    <dependency>
        <groupId>org.gradle</groupId>
        <artifactId>gradle-base-services</artifactId>
        <version>3.4.1</version>
    </dependency>
    <dependency>
        <groupId>org.gradle</groupId>
        <artifactId>gradle-base-services-groovy</artifactId>
        <version>3.4.1</version>
    </dependency>
    <dependency>
        <groupId>org.codehaus.groovy</groupId>
        <artifactId>groovy-all</artifactId>
        <version>2.4.10</version>
    </dependency>
</dependencies>

<repositories>
    <repository>
        <id>repo.gradle.org</id>
        <url>https://repo.gradle.org/gradle/libs-releases-local/</url>
    </repository>
</repositories>
Fluorine answered 28/3, 2017 at 16:45 Comment(0)
T
2

For those who are reading this in 2016 (and maybe later).

The artifacts are available in the JCenter: org.gradle:gradle-core, no need to add any "custom" repositories.

So, all you need to do is:

repositories {
    jcenter()
}

dependencies {
    compile 'org.gradle:gradle-core:2.14.1'
    // compile 'org.codehaus.groovy:groovy-all:2.4.4'
}
Tomsk answered 9/8, 2016 at 23:28 Comment(0)
F
1

From my experience, as of Summer'19 the most recent artifact are published in following repository:

repositories {
    maven {
        url "https://repo.gradle.org/gradle/libs-releases-local"
    }
}

dependencies {
    compileOnly "org.gradle:gradle-core:5.5.1"
}
Flatus answered 13/7, 2019 at 14:30 Comment(2)
Only up to version 6.1.1 at the moment :(Byandby
This is sad. I'm currently searching for gradle-core-7.5.1, but it's not included in repo.gradle.org/ui/native/libs-releases-local nor in repo.gradle.org/ui/native/libs-releases - the highest version is still 6.1.1.Elvinaelvira

© 2022 - 2024 — McMap. All rights reserved.