Gradle Plugin with external mvn dependencies

plugins

(Mike Winkelmann) #1

Hi,
I am new with gradle and have a little problem with some dependencies. I have build a plugin which will encapsulates an api - lets say ebay. So I will build a plugin which will do a http call to ebay during the build process with a task.
So my structure is:
my-plugin-project(with a new task - e.g. ebayHttpCall)
–ebay-api(maven)
— org/springframework/web:3.2.1(maven)

When I will use my plugin in another gradle project, this will say that he couldn’t found org/springframework/web/client/RestTemplate.

my plugins build.gradle looks like:

plugins {
id 'java-gradle-plugin’
id 'groovy’
id 'maven’
id 'maven-publish’
id ‘signing’
}

group = 'test.my.plugin’
version = ‘1.0.0-SNAPSHOT’

repositories {
jcenter()
mavenCentral()
mavenLocal()
}

dependencies {
compile ‘org.slf4j:slf4j-api:1.7.21’

compile 'org.projectlombok:lombok:1.16.10'
compile 'ebay-api:1.0'
testCompile 'junit:junit:4.12'

}

task sourcesJar(type: Jar, dependsOn:classes) {
classifier = 'sources’
from sourceSets.main.allSource
}

javadoc {
exclude "/internal/"
options.memberLevel = org.gradle.external.javadoc.JavadocMemberLevel.PROTECTED
title “Special gradle plugin”
}

task javadocJar(type: Jar, dependsOn:javadoc) {
classifier 'javadoc’
from javadoc.destinationDir
}

// add javadoc/source jar tasks as artifacts
artifacts {
archives jar
archives sourcesJar
archives javadocJar
}

task publishLocal(type: Upload) {
configuration = configurations.archives
repositories {
mavenDeployer {
repository(url: uri(‘repo’))
}
}
}

my test gradle projects build.gradle looks like:

apply plugin: 'test.my.plugin.gradle.plugins’
apply plugin: 'java’
apply plugin: 'groovy’
apply plugin: ‘maven’

repositories {
jcenter()
mavenCentral()
mavenLocal()
}

buildscript {
repositories {
jcenter()
mavenCentral()
mavenLocal()
}
dependencies {
classpath ‘test.my.plugin:special-ebay-plugin:1.0.0-SNAPSHOT’
}
}

When I call
(plugin-project): gradle clean build install
(test-project): gradle clean build
(test-prject): gradle ebayHttpCall

Thereafter I will get this error:

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':ebayHttpCall'.
> org/springframework/web/client/RestTemplate

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

BUILD FAILED

I don’t know why he couldn’t resolve the spring-web dependency. Or is that a dependency-version-conflict prob.


(Stefan Oehme) #2

I don’t see a fundamental problem in these snippets that would explain the exception. Can you please share a reproducible example project on GitHub?


(Michael Münzer) #3

I got the same problem. Have you found a solution?