bosch-io / iot-things-examples

Examples for the Bosch IoT Things cloud service
https://developer.bosch-iot-suite.com/service/things/
Other
65 stars 33 forks source link

Gradle Example #2

Closed AndreiD closed 7 years ago

AndreiD commented 7 years ago

Thanks for enabling the issues.

What: I'm trying to do: Import the libraries with Gradle instead of Maven Why: Gradle is much nicer to read and also supports custom things

What I do:

+buildscript {

Standard gradle way ?

on gradlew build I get

+FAILURE: Build failed with an exception. + +* What went wrong: +Could not resolve all dependencies for configuration 'detachedConfiguration5'. +> Could not find com.bosch.iot.things:things-client:3.0.0.RC8.

Why is it searching on maven.org and not on bosch-si.com ?

My guess. I'm setting up something wrong, but what and how to correct it, I don't know.

yfcai commented 7 years ago

Hi, thanks for trying IoT-Things. Just to understand what's happening, could you perform the following steps and report Gradle's behavior?

  1. Save the code below as build.gradle in an empty directory.
  2. Run gradle list.
configurations {
  testDependencies {
    transitive = true
  }
}

dependencies {
  testDependencies("com.bosch.iot.things:things-client:3.0.0.RC8"){
    repositories {
      mavenCentral()
      maven {
        url "https://maven.bosch-si.com/content/repositories/bosch-releases"
      }
    }
  }
}

task list {
  doLast{
    configurations.testDependencies.each{
      File file -> println file.name
    }
  }
}

(I'm trying to build a minimal-working-example to reproduce the error.)

AndreiD commented 7 years ago

here's the output.

To honour the JVM settings for this build a new JVM will be forked. Please consider using the daemon: https://docs.gradle.org/2.14.1/userguide/gradle_daemon.html.
:list
Download https://repo1.maven.org/maven2/io/projectreactor/reactor-core/2.0.7.RELEASE/reactor-core-2.0.7.RELEASE.pom
Download https://repo1.maven.org/maven2/io/projectreactor/reactor-bus/2.0.7.RELEASE/reactor-bus-2.0.7.RELEASE.pom
Download https://repo1.maven.org/maven2/org/slf4j/slf4j-api/1.7.13/slf4j-api-1.7.13.pom
Download https://repo1.maven.org/maven2/org/slf4j/slf4j-parent/1.7.13/slf4j-parent-1.7.13.pom
Download https://repo1.maven.org/maven2/io/projectreactor/reactor-core/2.0.7.RELEASE/reactor-core-2.0.7.RELEASE.jar
Download https://repo1.maven.org/maven2/io/projectreactor/reactor-bus/2.0.7.RELEASE/reactor-bus-2.0.7.RELEASE.jar
things-client-3.0.0.RC8.jar
cr-json-1.7.0.jar
cr-model-5.0.0.jar
cr-commands-2.0.0.jar
things-client-api-4.0.1.jar
things-protocol-adapter-1.0.2.jar
iot-hub-client-2.0.0.jar
async-http-client-2.0.15.jar
reactor-core-2.0.7.RELEASE.jar
reactor-bus-2.0.7.RELEASE.jar
minimal-json-0.9.4.jar
iot-hub-model-2.0.0.jar
iot-hub-internal-model-2.0.0.jar
iot-hub-api-2.0.0.jar
stomp-common-3.0.1.jar
reactive-streams-1.0.0.jar
async-http-client-netty-utils-2.0.15.jar
netty-codec-http-4.0.41.Final.jar
netty-transport-native-epoll-4.0.41.Final-linux-x86_64.jar
netty-resolver-dns-2.0.15.jar
netty-reactive-streams-1.0.7.jar
javassist-3.20.0-GA.jar
netty-buffer-4.0.41.Final.jar
netty-codec-4.0.41.Final.jar
netty-handler-4.0.41.Final.jar
netty-common-4.0.41.Final.jar
netty-transport-4.0.41.Final.jar
netty-resolver-2.0.15.jar
netty-codec-dns-2.0.15.jar
slf4j-api-1.7.21.jar

BUILD SUCCESSFUL

Total time: 12.38 secs
AndreiD commented 7 years ago

I managed to make it work like this.

group 'com.mex'
version '1.0-SNAPSHOT'

buildscript {
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath("org.springframework.boot:spring-boot-gradle-plugin:1.4.3.RELEASE")
    }
}

apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'org.springframework.boot'

jar {
    baseName = 'superprinter_v2'
    version = '0.1.0'
}

springBoot {
    executable = true
}

repositories {
    mavenCentral()
}

dependencies {
    compile "org.springframework.boot:spring-boot-starter"
    compileOnly "org.projectlombok:lombok:1.16.12"
    compile ("com.bosch.iot.things:things-client:3.0.0.RC8") {
        repositories {
            mavenCentral()
            maven {
                url "https://maven.bosch-si.com/content/repositories/bosch-releases"
            }
        }
    }
}

I didn't know you can specify the repositories inside the dependencies.