Spring Data ElasticSearch override version - spring

i upgraded springboot version 2.6.6 from 2.5.7.
and i'm using spring-data-elasticsearch.
i want to keep spring-data-elasticsearch version ( i'm using 4.2.7 )
so, i configured this.
implementation("org.springframework.data:spring-data-elasticsearch:4.2.7") --> it doesn't work
but my library still using version 4.3.3.
how can i overriding downgrade elastic version?
it's fine to upgrading a version
implementation("org.springframework.data:spring-data-elasticsearch:4.3.4") --> it works
here is my gradle settings
root
buildscript {
ext {
spring_boot_version = '2.6.6'
spring_data_elasticsearch_version = '4.2.7'
query_dsl_version = '4.3.1'
lombok_version = '1.18.12'
poi_version = '4.1.2'
}
}
plugins {
id 'java-library'
id 'org.springframework.boot' version "${spring_boot_version}"
}
subprojects {
version = '1.0.0-SNAPSHOT'
apply plugin: 'idea'
apply plugin: 'java-library'
apply plugin: 'maven-publish'
apply plugin: "org.springframework.boot"
apply plugin: 'groovy'
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
repositories {
mavenLocal()
mavenCentral()
}
configurations.all {
resolutionStrategy {
cacheChangingModulesFor 0, 'seconds'
}
}
dependencies {
implementation platform("org.springframework.boot:spring-boot-dependencies:${spring_boot_version}")
annotationProcessor platform("org.springframework.boot:spring-boot-dependencies:${spring_boot_version}")
testAnnotationProcessor platform("org.springframework.boot:spring-boot-dependencies:${spring_boot_version}")
testImplementation("org.springframework.boot:spring-boot-starter-test") {
exclude group: 'org.junit.vintage', module: 'junit-vintage-engine'
}
annotationProcessor("com.querydsl:querydsl-apt:${query_dsl_version}:jpa")
annotationProcessor("com.querydsl:querydsl-apt:${query_dsl_version}:general")
annotationProcessor("org.projectlombok:lombok")
annotationProcessor('javax.persistence:javax.persistence-api:2.2')
annotationProcessor('javax.annotation:javax.annotation-api:1.3.2')
testAnnotationProcessor("org.projectlombok:lombok")
testImplementation('org.spockframework:spock-core:2.0-M4-groovy-3.0')
testImplementation('org.spockframework:spock-spring:2.0-M4-groovy-3.0')
}
compileJava.dependsOn(processResources)
}
submodule
dependencies {
implementation("org.springframework.data:spring-data-elasticsearch:4.2.7")
}

Related

Gradle application build does not include own jar

I'm using gradle to build an application in Kotlin.
When I run the distTar task it successfully builds a tar file but fails to include the application itself.
My build.gradle files looks like this (Somewhat shrunk down because it's from a multi module project originally):
plugins {
id 'org.jetbrains.kotlin.jvm' version '1.3.41' apply false
id 'org.jetbrains.kotlin.kapt' version '1.3.41' apply false
id 'org.jetbrains.kotlin.plugin.spring' version '1.3.41' apply false
id 'org.jetbrains.kotlin.plugin.allopen' version '1.3.41' apply false
id 'org.springframework.boot' version '2.1.7.RELEASE' apply false
}
apply plugin: 'idea'
apply plugin: 'io.spring.dependency-management'
apply plugin: 'org.jetbrains.kotlin.jvm'
apply plugin: 'org.jetbrains.kotlin.kapt'
apply plugin: 'org.jetbrains.kotlin.plugin.allopen'
apply plugin: 'org.jetbrains.kotlin.plugin.spring'
apply plugin: 'org.springframework.boot'
apply plugin: 'application'
repositories {
mavenCentral()
jcenter()
maven { url 'https://jitpack.io' }
}
sourceCompatibility = '1.8.0'
compileKotlin {
kotlinOptions {
freeCompilerArgs = ["-Xjsr305=strict"]
jvmTarget = "1.8"
}
}
compileTestKotlin {
kotlinOptions {
freeCompilerArgs = ["-Xjsr305=strict"]
jvmTarget = "1.8"
}
}
dependencies {
api 'org.jetbrains.kotlin:kotlin-stdlib-jdk8'
api 'org.jetbrains.kotlin:kotlin-reflect'
// a whole load more of dependencies
testImplementation 'org.jetbrains.kotlin:kotlin-test'
testImplementation 'org.jetbrains.kotlin:kotlin-test-junit'
}
distTar {
archiveFileName = 'core.tar'
}
mainClassName = 'core.Application'
The final tar archive includes a lib folder with all my dependencies but not the application jar itself.

Gradle build doesn't add version to package

I'm creating a REST microservice using Spring Boot 2.0.0.M7 with Gradle 4.2.
When I build from Eclipse or run from console ./gradlew build, the produced package in build/libs is named $app.jar instead of $app-$version.jar.
What am I missing? my build.gradle is the same as the Spring Boot Docker GS guide, and this problem prevent docker image to be built because the jar can't be found.
Here is my build.gradle file:
buildscript {
ext {
springBootVersion = '2.0.0.M7'
springCloudVersion = 'Finchley.M5'
gradleDockerVersion = '0.13.0'
}
repositories {
mavenCentral()
maven { url 'https://plugins.gradle.org/m2/' }
maven { url 'https://repo.spring.io/snapshot' }
maven { url 'https://repo.spring.io/milestone' }
maven { url 'https://repo.spring.io/libs-milestone' }
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
classpath("gradle.plugin.com.palantir.gradle.docker:gradle-docker:${gradleDockerVersion}")
}
}
apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'com.palantir.docker'
apply plugin: 'org.springframework.boot'
apply plugin: 'io.spring.dependency-management'
jar {
baseName = 'networks'
version = '0.9'
}
group = 'test'
sourceCompatibility = 1.8
targetCompatibility = 1.8
repositories {
mavenCentral()
maven { url 'https://repo.spring.io/snapshot' }
maven { url 'https://repo.spring.io/milestone' }
maven { url 'https://repo.spring.io/libs-milestone' }
}
dependencyManagement {
imports {
mavenBom "org.springframework.cloud:spring-cloud-dependencies:${springCloudVersion}"
}
}
dependencies {
compile 'org.springframework.boot:spring-boot-starter-web'
compile 'org.springframework.boot:spring-boot-starter-data-jpa'
compile 'org.springframework.boot:spring-boot-starter-data-rest'
compile 'org.springframework.boot:spring-boot-starter-json'
compile 'org.springframework.boot:spring-boot-starter-actuator'
compile 'org.springframework.cloud:spring-cloud-starter-netflix-eureka-client'
runtime 'org.springframework.boot:spring-boot-devtools'
runtime 'org.postgresql:postgresql'
testCompile 'org.springframework.boot:spring-boot-starter-test'
testCompile 'junit:junit'
}
docker {
name "${project.group}/${jar.baseName}"
files jar.archivePath
buildArgs(['JAR_FILE': "${jar.archiveName}"])
}
The version should be specified outside jar:
apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'com.palantir.docker'
apply plugin: 'org.springframework.boot'
apply plugin: 'io.spring.dependency-management'
version = "0.9"
jar {
baseName = 'networks'
}

gradle spring boot force dependency

I am using spring boot gradle plugin 2.0.0.M3 and I would want to include spring-data-elasticsearch:3.0.0.RC2 in the final jar
Below is my build.gradle
buildscript {
ext {
springBootVersion = '2.0.0.M3'
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
}
}
plugins {
id "io.spring.dependency-management" version "1.0.3.RELEASE"
}
apply plugin: 'org.springframework.boot'
apply plugin: 'maven-publish'
apply plugin: 'java'
dependencyManagement {
imports {
mavenBom 'org.springframework.cloud:spring-cloud-starter-parent:Finchley.M2'
}
}
group='mygroup'
version='1.0.0'
configurations.all {
exclude group: 'javax.servlet.jsp', module: 'jsp-api'
exclude group: 'org.mortbay.jetty'
resolutionStrategy {
force("org.springframework.data:spring-data-elasticsearch:3.0.0.RC2")
}
}
But the force resolution is not working . Instead of spring-data-elasticsearch-3.0.0.RC2 , spring-data-elasticsearch-3.0.0.M4 is pulled.
Below is the dependency detail
org.springframework.data:spring-data-elasticsearch:3.0.0.RC2 -> 3.0.0.M4
Will force resolution not work in Spring boot ?
It works if the dependency is mentioned in the usual way
configurations.all {
resolutionStrategy {
force("org.springframework.data:spring-data-elasticsearch:3.0.0.RC2")
}
}
dependencies {
compile("org.springframework.boot:spring-boot-starter-data-jpa")
compile "org.springframework.data:spring-data-elasticsearch:3.0.0.RC2"
}

Using Spring.IO dependency management, how can I override the version of a particular jar?

I'm making use of the aws java sdk that relies on a jackson version that is greater than what is in the spring bom, I need to be able to override the version (to use a version more compatible with the aws sdk). How can I override the version of a particular jar?
buildscript {
repositories {
maven { url "https://mvnrepo.----.net/nexus/content/groups/public/" }
}
dependencies {
classpath 'io.spring.gradle:dependency-management-plugin:0.5.3.RELEASE'
}
}
apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'idea'
apply plugin: 'io.spring.dependency-management'
sourceCompatibility = 1.8
targetCompatibility = 1.8
version = 1.0
repositories {
maven { url "https://mvnrepo.-----.net/nexus/content/groups/public/"}
}
dependencyManagement {
imports {
mavenBom 'io.spring.platform:platform-bom:1.1.4.RELEASE'
}
}
dependencies {
compile 'org.springframework:spring-context',
'org.springframework:spring-core',
'org.springframework:spring-test',
'com.amazonaws:aws-java-sdk-dynamodb:1.10.+',
'com.amazonaws:aws-java-sdk-s3:1.10.+',
'com.amazonaws:aws-java-sdk-sns:1.10.+',
'com.amazonaws:aws-java-sdk-logs:1.10.+',
'com.google.code.gson:gson',
'joda-time:joda-time',
'org.slf4j:slf4j-api'
testCompile 'junit:junit:4.12',
'org.mockito:mockito-core:1.+'
}
task wrapper(type: Wrapper) {
gradleVersion = '2.7'
}
dependencyManagement {
imports {
mavenBom 'io.spring.platform:platform-bom:1.1.4.RELEASE'
}
dependencies {
dependency 'com.fasterxml.jackson.core:jackson-core:2.6.3'
dependency 'com.fasterxml.jackson.core:jackson-databind:2.6.3'
dependency 'com.fasterxml.jackson.core:jackson-annotations:2.6.3'
}
}

Spring Batch with Grails

im currently using grails 3.0.3 along with gradle 2.5 and hoping to generate a plugin that will use Spring Batch. I've just created a plugin via the command line, and update the build.gradle with just the
compile "org.springframework.boot:spring-boot-starter-batch"
However the batch folder does not seem to downloaded to the local .m2 cache and therefore the import org.springframework.batch libs not available.
The following is the build.gradle. Just wondering if anybody could suggest the reasons why?
Thanks
buildscript {
ext {
grailsVersion = project.grailsVersion
}
repositories {
mavenLocal()
mavenCentral()
maven { url "https://repo.grails.org/grails/core" }
}
dependencies {
classpath "org.grails:grails-gradle-plugin:$grailsVersion"
}
}
plugins {
id "io.spring.dependency-management" version "0.5.2.RELEASE"
id "com.jfrog.bintray" version "1.2"
}
version "0.1-SNAPSHOT"
group "org.grails.plugins"
apply plugin: 'maven-publish'
apply plugin: 'eclipse'
apply plugin: 'idea'
apply plugin: "spring-boot"
apply plugin: "org.grails.grails-plugin"
apply plugin: "org.grails.grails-gsp"
// Used for publishing to central repository, remove if not needed
apply from:'https://raw.githubusercontent.com/grails/grails-profile-repository/master/profiles/plugin/templates/grailsCentralPublishing.gradle'
apply from:'https://raw.githubusercontent.com/grails/grails-profile-repository/master/profiles/plugin/templates/bintrayPublishing.gradle'
ext {
grailsVersion = project.grailsVersion
gradleWrapperVersion = project.gradleWrapperVersion
}
sourceCompatibility = 1.7
targetCompatibility = 1.7
repositories {
mavenLocal()
mavenCentral()
maven { url "https://repo.grails.org/grails/core" }
}
dependencyManagement {
imports {
mavenBom "org.grails:grails-bom:$grailsVersion"
}
applyMavenExclusions false
}
dependencies {
provided 'org.springframework.boot:spring-boot-starter-logging'
provided "org.springframework.boot:spring-boot-starter-actuator"
provided "org.springframework.boot:spring-boot-autoconfigure"
provided "org.springframework.boot:spring-boot-starter-tomcat"
provided "org.grails:grails-web-boot"
provided "org.grails:grails-dependencies"
provided 'javax.servlet:javax.servlet-api:3.1.0'
testCompile "org.grails:grails-plugin-testing"
console "org.grails:grails-console"
//compile "org.springframework.boot:spring-boot-starter-batch:1.2.5.RELEASE"
compile "org.springframework.boot:spring-boot-starter-batch"
}
task wrapper(type: Wrapper) {
gradleVersion = gradleWrapperVersion
}

Resources