unable to create a executable spring boot jar by the bootJar task - spring-boot

basically I need to create a spring boot jar to run system spring-server service on my server
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
ext {
spring_boot_version = '1.5.7.RELEASE'
spring_version = '4.3.11.RELEASE'
}
repositories {
mavenLocal()
jcenter()
mavenCentral()
maven { url 'https://dl.bintray.com/kotlin/exposed' }
maven { url 'https://jitpack.io' }
maven { url 'https://ci-artifactory.corda.r3cev.com/artifactory/corda-releases' }
}
apply plugin: 'kotlin'
apply plugin: 'java'
apply plugin: 'net.corda.plugins.cordformation'
apply plugin: 'net.corda.plugins.quasar-utils'
bootJar {
basName = 'corda-webserver'
version = '1.0.0'
}
How can I achieve this is there something wrong with gradle dependencies or plugins?
I tried springboot task as well

So there's not enough information here to be sure of what the issue could be; so here are a few ideas.
Start by cleaning gradle cache. ./gradlew clean
Obviously the issue here is dependencies, you need to make sure gradle is able to build your project, and download dependencies.
./gradlew deployNodes (if you're using one of the corda sample projects) will build all of the files locally and should pull in the dependencies for you.
R3 now uses software.r3.com as the 'official' link to the artifact repository, you may want to take a look there and maybe look at whether the downloads are still good.
good luck!

Related

Gradle doesn't find plugins: org.jetbrains.kotlin.jvm and kotlin2js

I'm a beginner in gradle, using version 4.8.
Whatever I do , the plugins are never found. I get this error message:
Plugin [id: 'org.jetbrains.kotlin.jvm', version: '1.3.20'] was not found in any of the following sources:
Gradle Core Plugins (plugin is not in 'org.gradle' namespace)
Plugin Repositories (could not resolve plugin artifact 'org.jetbrains.kotlin.jvm:org.jetbrains.kotlin.jvm.gradle.plugin:1.3.20')
Searched in the following repositories:
Gradle Central Plugin Repository
No matter how many repositories I add, it seems it is only looking in "Gradle Central Plugin Repository"
My gradle.build file:
buildscript {
repositories {
mavenCentral()
maven {
url "https://plugins.gradle.org/m2/"
}
}
dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.3.20"
classpath "org.jetbrains.kotlin.jvm:kotlin-gradle-plugin:1.3.20"
}
}
plugins {
id 'java'
id 'org.jetbrains.kotlin.jvm' version '1.3.20'
id 'kotlin2js' version '1.3.20'
}
Can you help me?
Try the following gradle.build configuration:
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.3.20"
}
}
plugins {
id 'java'
}
apply plugin: 'kotlin2js'
repositories {
mavenCentral()
}
When you include the plugin by id, it seems Gradle wants to retrieve the plugin from the Gradle plugin portal, but the Kotlin plugin is not there, it's part of the buildscript dependency. Using it with the apply plugin works. You can also find a slightly different working example here.
I had similar problem because i forgot about proxy settings like systemProp.https.proxyHost and systemProp.http.proxyHost and etc. that was set in ~/.gradle/gradle.properties.
I fixed configuration and plugin was successfully dowlnloaded
Check gradle.properties and try to add correct proxy settings if you behind firewall or escape this settings if you not.
you need to add repository mavenCentral() to the buildscript dependencies.
for example: kotlin-gradle-plugin:1.3.20. also the documentation hints for that.
Go to your project and then to the Gradle script. In Gradle, Go to Setting.Gradle and change the Fist Bitray Url to https://plugins.gradle.org/m2/.

Why gradle always downloads plugins in https://plugins.gradle.org/m2/

Gradle provides offline mode to build with local cache which is friendly without internet access. But I found on my new project, gradle always tries to download plugins in https://plugins.gradle.org/m2/. No matter how many times I run the build, the next build still tries to download:
09:23:13.132 Download https://plugins.gradle.org/m2/gradle/plugin/com/ewerk/gradle/plugins/querydsl-plugin/1.0.6/querydsl-plugin-1.0.6.jar
here is my build.gradle
apply plugin: "com.ewerk.gradle.plugins.querydsl"
apply plugin: 'spring-boot'
buildscript {
repositories {
mavenCentral()
maven {
url "https://plugins.gradle.org/m2/"
}
}
dependencies {
classpath "org.springframework.boot:spring-boot-gradle-plugin:1.3.5.RELEASE"
classpath "gradle.plugin.com.ewerk.gradle.plugins:querydsl-plugin:1.0.6"
}
}
Is it possible to use cache instead?

How to configure Gradle to find local SNAPSHOT resource?

I'm trying to do some work with the springfox project which has been broken up into two separate projects: the springfox runtime, and a suite of demos.
In order to investigate the behavior of certain configurations, I need to change the module in springfox/springfox-petstore, and compile that into springfox-demos/springfox-java-swagger.
In springfox, I built and published a new version of springfox-petstore, and validated that it exists correctly in ~/.m2/repository/io/springfox/springfox-petstore/2.2.2-SNAPSHOT.
Next, in springfox-demos I added mavenLocal() as a repository, and added the springfox-petstore-2.2.2-SNAPSHOT as a changing=true dependency.
When I attempt to build the springfox-demos runtime, I get the following error:
* What went wrong:
A problem occurred configuring project ':spring-java-swagger'.
> Could not resolve all dependencies for configuration ':spring-java-swagger:runtimeCopy'.
> Could not find io.springfox:springfox-petstore:2.2.2-SNAPSHOT.
Searched in the following locations:
https://jcenter.bintray.com/io/springfox/springfox-petstore/2.2.2-SNAPSHOT/maven-metadata.xml
https://jcenter.bintray.com/io/springfox/springfox-petstore/2.2.2-SNAPSHOT/springfox-petstore-2.2.2-SNAPSHOT.pom
https://jcenter.bintray.com/io/springfox/springfox-petstore/2.2.2-SNAPSHOT/springfox-petstore-2.2.2-SNAPSHOT.jar
http://oss.jfrog.org/artifactory/oss-snapshot-local/io/springfox/springfox-petstore/2.2.2-SNAPSHOT/maven-metadata.xml
http://oss.jfrog.org/artifactory/oss-snapshot-local/io/springfox/springfox-petstore/2.2.2-SNAPSHOT/springfox-petstore-2.2.2-SNAPSHOT.pom
http://oss.jfrog.org/artifactory/oss-snapshot-local/io/springfox/springfox-petstore/2.2.2-SNAPSHOT/springfox-petstore-2.2.2-SNAPSHOT.jar
Required by:
springfox-demos:spring-java-swagger:unspecified
I've tried a variety of combinations of build tasks but I can't seem to get Gradle to honor my request for using the local maven repo with a -SNAPSHOT artifact.
Here is the top-level build.gradle:
buildscript {
repositories {
mavenLocal()
jcenter()
}
dependencies {
classpath "com.github.adrianbk:gradle-jvmsrc-plugin:0.6.1"
classpath 'com.ofg:uptodate-gradle-plugin:1.6.0'
}
}
apply from: "$rootDir/gradle/dependencies.gradle"
subprojects {
apply plugin: 'com.github.adrianbk.jvmsrc'
jvmsrc {
packageName "springfoxdemo"
}
apply plugin: 'java'
apply plugin: 'com.ofg.uptodate'
repositories {
jcenter()
maven { url 'http://oss.jfrog.org/artifactory/oss-snapshot-local/' }
}
sourceCompatibility = 1.7
targetCompatibility = 1.7
configurations.all {
//Dont cache snapshots
resolutionStrategy.cacheChangingModulesFor 0, 'seconds'
}
}
wrapper {
gradleVersion = "2.4"
}
So it appears that the top-level build.gradle can have more than one repositories{} block. I had correctly added the mavenLocal() to one, but missed the other. Once adding the mavenLocal() to the second block, all worked well.

Gradle fails to resolve spring dependency

I am trying to build my project with the following build.gradle file.
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath('org.springframework.boot:spring-boot-gradle-plugin:1.2.1.RELEASE')
}
}
apply plugin: 'java'
apply plugin: 'idea'
apply plugin: 'spring-boot'
repositories {
maven {
url 'https://repo.spring.io/milestone'
}
mavenCentral()
}
dependencies {
compile('org.springframework.boot:spring-boot-starter-web')
compile('org.springframework.boot:spring-boot-starter-data-mongodb:1.2.2.RELEASE')
compile('org.springframework.data:spring-data-mongodb:1.7.0.RC1')
compile('org.springframework.cloud:spring-cloud-spring-service-connector')
compile('org.springframework.cloud:spring-cloud-cloudfoundry-connector')
compile 'org.springframework:spring-test:4.1.5.RELEASE'
compile 'de.grundid.opendatalab:geojson-jackson:1.3'
compile 'com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.5.1'
compile 'org.apache.httpcomponents:httpclient:4.4'
testCompile('junit:junit')
}
task wrapper(type: Wrapper) {
gradleVersion = '2.3'
}
I added the milestone repository because I need the spring-data-mongodb 1.7.0.RC1 dependency. However, there seems to be something wrong with the references of the parent-poms because gradle is unable to fetch the following dependency: org.springframework.data.build:spring-data-parent:1.6.0.RC1
It exits with the following error:
Could not find org.springframework.data.build:spring-data-parent:1.6.0.RC1.
Searched in the following locations:
https://repo.spring.io/milestone/org/springframework/data/build/spring-data-parent/1.6.0.RC1/spring-data-parent-1.6.0.RC1.pom
https://repo.spring.io/milestone/org/springframework/data/build/spring-data-parent/1.6.0.RC1/spring-data-parent-1.6.0.RC1.jar
https://repo1.maven.org/maven2/org/springframework/data/build/spring-data-parent/1.6.0.RC1/spring-data-parent-1.6.0.RC1.pom
https://repo1.maven.org/maven2/org/springframework/data/build/spring-data-parent/1.6.0.RC1/spring-data-parent-1.6.0.RC1.jar
The output of the gradlew build --debug command can be found here: http://pastebin.com/seYRMFQP
The command additionally produced the following output to stdout: http://pastebin.com/atcWQsKF
I already tried to clean my local gradle cache but it did not resolve the problem.
Sorry for the inconvenience, the artifact is currently misplaced in the release repository, though it should be in milestone.
We'll move it to milestone asap. Until that happens please add the release repository url 'https://repo.spring.io/release' to your build.
seems the repositories you defined in your build do not contain the libraries you're looking for. but it seems the lib is available in jcenter. to add jcenter add the following snippet to your build.gradle file:
repositories {
jcenter()
}
cheers,
René

Using jettyRunWar or jettyRun in Gradle with a Spring Boot app results in just a directory listing in the browser

I'm using Gradle and Spring Boot for the first time. I decided to create a project that actually builds a WAR archive and I'm using the Gradle Jetty plugin. If I run the jettyRun or jettyRunWar tasks, in my browser all I'm seeing is a directory listing, not my actual application.
For example, the jettyRunWar task results in a directory listing like this:
META-INF/
WEB-INF/
dist/
The dist/ directory contains my static files.
Maybe I'm missing something fundamental since I'm using Gradle and Spring Boot for the first time.
I'm trying to test my app while making changes to my static files without restarting the app. Here is my build.gradle file.
buildscript {
repositories {
maven { url "http://repo.spring.io/libs-snapshot" }
mavenLocal()
}
dependencies {
classpath "org.springframework.boot:spring-boot-gradle-plugin:0.5.0.M6"
}
}
apply plugin: "java"
apply plugin: "idea"
apply plugin: "spring-boot"
apply plugin: "war"
war {
baseName = "mis-support-client"
version = "1.0.0-SNAPSHOT"
includes = ["dist/**"]
}
repositories {
mavenCentral()
maven { url "http://repo.spring.io/libs-snapshot" }
}
dependencies {
testCompile "junit:junit:4.11"
compile ("org.springframework.boot:spring-boot-starter-web:0.5.0.M7") {
exclude module: "spring-boot-starter-tomcat"
}
compile "org.springframework.boot:spring-boot-starter-jetty:0.5.0.M7"
compile "org.springframework.boot:spring-boot-starter-security:0.5.0.M7"
compile "org.springframework.boot:spring-boot-starter-websocket:0.5.0.M7"
compile "javax.inject:javax.inject:1"
compile "org.codehaus.jackson:jackson-mapper-asl:1.9.12"
compile "org.apache.httpcomponents:httpclient:4.3.1"
compile "commons-io:commons-io:2.4"
}
task wrapper (type: Wrapper) {
gradleVersion = "1.8"
}
Did you try ./gradlew bootRun instead? Normal Spring Boot project has server embedded for easier usage :)
This task requires gradle plugin:
apply plugin: 'spring-boot'
Features
Embed Tomcat or Jetty directly (no need to deploy WAR files)
Task
Execution tasks
---------------
bootRun - Run the executable JAR/WAR

Resources