I am introducing Junit tests in one of our projects but unfortunately am getting a null pointer exception but I can't tell where is it thrown, when trying to debug the debugger does not stop in my break point. I am testing a spring boot application
Can you assist I am not familiar with gradle maybe I missed a certain config, below is my gradle file
buildscript {
ext {
springBootVersion = '2.2.11.RELEASE'
}
repositories {
mavenCentral()
maven {
url "https://artifacts.company.com/artifactory/appsmav-main-maven-local/"
credentials {
username "${artifactory_user}"
password "${artifactory_password}"
}
}
maven {
url "https://plugins.gradle.org/m2/"
}
// flatDir {
// dirs '/Users/pabu/workspaces/intellij/companyikat7/PlantumlPlugin/build/libs'
// }
}
repositories { flatDir name: 'libs', dirs: "../build/libs" }
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
classpath 'org.junit.platform:junit-platform-gradle-plugin:1.0.0-RC3'
classpath 'org.reflections:reflections:0.9.11'
classpath 'io.company.gradle.plugins:PlantumlPlugin:1.0.7'
classpath "gradle.plugin.com.gorylenko.gradle-git-properties:gradle-git-properties:2.2.4"
classpath "gradle.plugin.com.github.viswaramamoorthy:gradle-util-plugins:0.1.0-RELEASE"
}
}
apply plugin: 'java'
apply plugin: 'idea'
apply plugin: 'org.springframework.boot'
apply plugin: 'io.spring.dependency-management'
apply plugin: 'war'
apply plugin: 'org.junit.platform.gradle.plugin'
apply plugin: 'io.company.gradle.plugins.plantuml'
apply plugin: 'com.gorylenko.gradle-git-properties'
apply plugin: "com.github.ManifestClasspath"
group = 'io.company'
version = '0.0.2'
sourceCompatibility = "11"
repositories {
jcenter()
mavenCentral()
maven {
url "https://artifacts.company.com/artifactory/appsmav-main-maven-local/"
credentials {
username "${artifactory_user}"
password "${artifactory_password}"
}
}
}
springBoot {
buildInfo {
properties {
artifact = 'company-core-service'
name = 'company'
}
}
}
configurations {
providedRuntime
compile.exclude module: 'slf4j-simple'
compile.exclude module: "spring-boot-starter-tomcat"
}
dependencies {
compile('org.springframework.boot:spring-boot-starter-actuator')
compile('org.springframework.boot:spring-boot-starter-data-jpa')
compile('org.springframework.boot:spring-boot-starter-jersey')
compile('org.springframework.boot:spring-boot-starter-security')
compile('org.springframework.boot:spring-boot-starter-web')
compile('org.springframework.boot:spring-boot-starter-jetty')
compileOnly('org.springframework.boot:spring-boot-devtools')
implementation 'org.springframework.boot:spring-boot-starter-webflux'
implementation 'org.springframework.boot:spring-boot-starter-actuator'
// https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter-freemarker
implementation group: 'org.springframework.boot', name: 'spring-boot-starter-freemarker', version: '2.5.3'
implementation 'io.micrometer:micrometer-core:1.5.7'
implementation 'io.micrometer:micrometer-registry-prometheus:1.5.7'
implementation 'io.sentry:sentry-spring-boot-starter:3.2.0'
implementation 'io.sentry:sentry-logback:3.2.0'
compile group: 'io.springfox', name: 'springfox-swagger2', version: '2.8.0'
compile group: 'io.springfox', name: 'springfox-swagger-ui', version: '2.8.0'
compile group: 'com.unboundid', name: 'unboundid-ldapsdk', version: '4.0.0'
runtime('org.postgresql:postgresql')
compile('io.company.commons:commons-utils:1.+') {
exclude group: 'org.slf4j'
}
compile('io.company.commons:commons-api:1.3.0') {
exclude group: 'org.slf4j'
}
// https://mvnrepository.com/artifact/org.springframework.retry/spring-retry
compile group: 'org.springframework.retry', name: 'spring-retry', version: '1.3.0'
// Azure Notification Hub SDK
compile group: 'com.windowsazure', name: 'Notification-Hubs-java-sdk', version: '0.1.0'
// https://mvnrepository.com/artifact/javax.json/javax.json-api
compile group: 'javax.json', name: 'javax.json-api', version: '1.1.4'
// https://mvnrepository.com/artifact/org.glassfish/javax.json
compile group: 'org.glassfish', name: 'javax.json', version: '1.1.4'
implementation 'com.sun.mail:javax.mail:1.6.2'
// compile project(":commons-api-local")
compile('io.company.commons:commons-io:1.3.0') {
exclude group: 'org.slf4j'
}
compile group: 'commons-io', name: 'commons-io', version: '2.6'
compile group: 'io.company.commons', name: 'commons-jwt', version: '1.0.8'
testCompile('org.springframework.boot:spring-boot-starter-test')
testCompile('org.springframework.security:spring-security-test')
// https://projectlombok.org
compileOnly 'org.projectlombok:lombok:1.18.4'
annotationProcessor 'org.projectlombok:lombok:1.18.4'
testImplementation('org.junit.jupiter:junit-jupiter:5.5.1')
}
test {
useJUnitPlatform {
excludeTags "integration"
}
testLogging.showStandardStreams(true);
testLogging {
events "passed", "skipped", "failed"
showExceptions true
exceptionFormat "full"
showCauses true
showStackTraces true
}
}
In the log below I can't tell where is the NullPointerException thrown
16:38:55.075 [main] DEBUG org.springframework.ui.freemarker.SpringTemplateLoader - Looking for FreeMarker template with name [DisruptionOverviewBody_en.ftlh]
16:38:55.076 [main] DEBUG org.springframework.ui.freemarker.SpringTemplateLoader - Looking for FreeMarker template with name [DisruptionOverviewBody.ftlh]
Failures (1):
JUnit Jupiter:DisruptionEventControllerTest:shouldCreateNewDisruptionEvent()
MethodSource [className = 'ui.controller.DisruptionEventControllerTest', methodName = 'shouldCreateNewDisruptionEvent', methodParameterTypes = '']
=> java.lang.NullPointerException
Test run finished after 1639 ms
Related
I have recently done the spring boot migration from 1.5.8 to 2.1.14-RELEASE and using gradle as a build script. I am using spring-boot-gradle-plugin and spring-boot-dependency-management plugins. We are creating 4 executable jars (eureka, oAuth, apiGateWay, abcApplication) using gradle tasks and packaging them in tar file. Before the migration, during the jars generation it was excluding some jars using customConfiguration of BootRepackage. Because of this our tar file size was 650mb. Now after the migration tar file size increased to 850mb. When I checked the tar file, it is adding all the jars from the runtimeclasspath. So the size got increased. Could you please help me to exclude the jars mentioned in the configurations property using BootJar. Right now we are using compile configuration for all of the dependencies in gradle. I have mentioned the complete gradle file.
buildscript {
repositories {
maven {
url '...'
...
}
}
ext {
springBootVersion = '2.1.14.RELEASE'
springCloudVersion = 'Greenwich.SR4'
springRetryVersion = "1.2.3.RELEASE"
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
classpath "org.jfrog.buildinfo:build-info-extractor-gradle:4.13.0"
}
ext['tomcat.version'] = '8.5.64'
ext['jackson.version'] = '2.11.2'
ext['hibernate.version'] = '5.4.24.Final'
ext['snakeyaml.version'] = '1.26'
}
apply plugin: 'java'
apply plugin: 'application'
apply plugin: 'eclipse'
apply plugin: 'org.springframework.boot'
apply plugin: 'idea'
apply plugin: "com.jfrog.artifactory"
apply plugin: 'io.spring.dependency-management'
sourceCompatibility = 1.8
ext {
excludeCLoudJar = '**spring-cloud-config-server*'
exludedJarsForEureka = ['**spring-cloud-config-server*', '**poi-ooxml*', '**guava*', '**ojdbc8*', '**springfox-swagger2*', '**springfox-swagger-ui*']
}
configurations.all {
resolutionStrategy {
force 'org.bouncycastle:bcpkix-jdk15on:1.64'
}
}
configurations {
all*.exclude group: 'aopalliance'
cloudconfigexclusion.exclude group: 'org.springframework.cloud', module: 'spring-cloud-config-server'
cloudconfigexclusion.extendsFrom(compile)
}
configurations {
eurekaconfiguration.exclude group: 'org.springframework.cloud', module: 'spring-cloud-config-server'
eurekaconfiguration.exclude group: 'org.springframework.cloud', module: 'spring-cloud-config-client'
eurekaconfiguration.exclude group: 'org.springframework.cloud', module: 'spring-cloud-starter-config'
eurekaconfiguration.exclude group: 'org.springframework.cloud', module: 'spring-cloud-starter-oauth2'
eurekaconfiguration.exclude group: 'org.springframework.cloud', module: 'spring-cloud-starter-zuul'
eurekaconfiguration.exclude group: 'org.springframework.boot', module: 'spring-boot-starter-data-jpa'
eurekaconfiguration.exclude group: 'org.springframework.boot', module: 'spring-boot-starter-aop'
eurekaconfiguration.exclude group: 'org.springframework.security', module: 'spring-security-config'
eurekaconfiguration.exclude group: 'org.springframework.security', module: 'spring-security-crypto'
eurekaconfiguration.exclude group: 'org.springframework.security', module: 'spring-security-core'
eurekaconfiguration.exclude group: 'org.springframework.security', module: 'spring-security-web'
eurekaconfiguration.exclude group: 'org.apache.poi'
eurekaconfiguration.exclude group: 'com.opencsv'
eurekaconfiguration.exclude group: 'org.springframework.retry'
eurekaconfiguration.exclude group: 'com.oracle', module: 'ojdbc8'
eurekaconfiguration.extendsFrom(compile)
}
configurations {
zuulconfiguration.exclude group: 'org.springframework.cloud', module: 'spring-cloud-config-server'
zuulconfiguration.exclude group: 'org.springframework.cloud', module: 'spring-cloud-config-client'
zuulconfiguration.exclude group: 'org.springframework.cloud', module: 'spring-cloud-starter-oauth2'
zuulconfiguration.exclude group: 'org.springframework.boot', module: 'spring-boot-starter-data-jpa'
zuulconfiguration.exclude group: 'org.springframework.security', module: 'spring-security-config'
zuulconfiguration.exclude group: 'org.springframework.security', module: 'spring-security-crypto'
zuulconfiguration.exclude group: 'org.springframework.security', module: 'spring-security-core'
zuulconfiguration.exclude group: 'org.springframework.security', module: 'spring-security-web'
zuulconfiguration.exclude group: 'org.apache.poi'
zuulconfiguration.exclude group: 'com.opencsv'
zuulconfiguration.exclude group: 'com.oracle', module: 'ojdbc8'
zuulconfiguration.extendsFrom(compile)
}
configurations {
cloudconfigconfiguration.exclude group: 'org.springframework.cloud', module: 'spring-cloud-starter-oauth2'
cloudconfigconfiguration.exclude group: 'org.springframework.cloud', module: 'spring-cloud-config-client'
cloudconfigconfiguration.exclude group: 'org.springframework.boot', module: 'spring-boot-starter-data-jpa'
cloudconfigconfiguration.exclude group: 'org.springframework.boot', module: 'spring-boot-starter-aop'
cloudconfigconfiguration.exclude group: 'org.springframework.security', module: 'spring-security-config'
cloudconfigconfiguration.exclude group: 'org.springframework.security', module: 'spring-security-crypto'
cloudconfigconfiguration.exclude group: 'org.springframework.security', module: 'spring-security-core'
cloudconfigconfiguration.exclude group: 'org.springframework.security', module: 'spring-security-web'
cloudconfigconfiguration.exclude group: 'org.apache.poi'
cloudconfigconfiguration.exclude group: 'com.opencsv'
cloudconfigconfiguration.exclude group: 'org.springframework.retry'
cloudconfigconfiguration.exclude group: 'com.oracle', module: 'ojdbc8'
cloudconfigconfiguration.extendsFrom(compile)
}
mainClassName = "..."
// During Migration changed from Jar to BootJar
task eurekaAppJar(type: BootJar) {
baseName = 'eurekaJar'
version = '0.0.1'
println sourceSets.main.output
manifest {
attributes 'Main-Class': "org.springframework.boot.loader.JarLauncher"
attributes 'Start-Class': "com.abc.abcCompany.service.eurekaApp.EurekaApplication"
attributes 'Implementation-Version': "001"
}
bootJar {
mainClassName = "com.abc.abcCompany.service.eurekaApp.EurekaApplication"
}
classpath sourceSets.main.runtimeClasspath
}
// During Migration changed from Jar to BootJar
task oAuthConfigJar(type: BootJar) {
baseName = 'oAuthConfigJar'
version = '0.0.1'
manifest {
attributes 'Main-Class': "org.springframework.boot.loader.JarLauncher"
attributes 'Start-Class': "com.abc.abcCompany.service.authserver.AuthServerApplication"
attributes 'Implementation-Version': "001"
}
springBoot {
mainClassName = "com.abcCompany.service.authserver.AuthServerApplication"
}
classpath sourceSets.main.runtimeClasspath
}
// During migration changed from BootRepackage to BootJar
task eurekaBoot(type: BootJar, dependsOn: eurekaAppJar) {
mainClassName = 'com.abc.abcCompany.service.eurekaApp.EurekaApplication'
// During migration commented the below code. The below code helped to exclude jars using BootRepackage
// customConfiguration = "eurekaconfiguration"
// withJarTask = eztrackerEurekaJar
}
// During migration changed from BootRepackage to BootJar
task oAuthConfigJarBoot(type: BootJar, dependsOn: oAuthConfigJar) {
mainClassName = 'com.abc.abcCompany.service.authserver.AuthServerApplication'
// During migration commented the below code. The below code helped to exclude jars using BootRepackage
// customConfiguration = "zuulconfiguration"
// withJarTask = eztrackerApiGatewayJar
}
dependencies {
runtime("org.springframework.boot:spring-boot-properties-migrator")
compile("org.springframework.cloud:spring-cloud-starter-netflix-eureka-server")
compile("org.springframework.cloud:spring-cloud-starter-netflix-eureka-client")
compile group: 'com.google.guava', name: 'guava', version: '30.0-jre'
compile("org.springframework.cloud:spring-cloud-starter-netflix-zuul")
implementation('org.springframework.cloud:spring-cloud-starter-oauth2')
implementation('org.springframework.boot:spring-boot-starter-data-jpa')
compile('org.springframework.boot:spring-boot-starter-web')
compile(group: 'com.oracle.jdbc', name: 'ojdbc8', version: '12.2.0.1')
compile("io.springfox:springfox-swagger2:2.9.2")
compile("io.springfox:springfox-swagger-ui:2.9.2")
testCompile('org.springframework.boot:spring-boot-starter-test')
compile("org.apache.poi:poi-ooxml:4.1.2")
compile 'com.opencsv:opencsv:5.2'
compile "javax.mail:mail:1.4.4"
compile("org.springframework.cloud:spring-cloud-config-server")
compile("org.springframework.cloud:spring-cloud-config-client:1.4.6.RELEASE") {
force = true
}
compile("org.springframework.boot:spring-boot-starter-actuator:${springBootVersion}")
compile("org.springframework.boot:spring-boot-starter-aop")
compile("org.springframework.retry:spring-retry:${springRetryVersion}")
compile("org.springframework.boot:spring-boot-starter-web-services")
compile('com.thoughtworks.xstream:xstream:1.4.10') {
force = true
}
compile('commons-io:commons-io:2.7') {
force = true
}
compile('io.netty:netty-transport:4.1.63.Final') {
force = true
}
compile('io.netty:netty-transport-native-epoll:4.1.63.Final') {
force = true
}
compile('org.dom4j:dom4j:2.1.3') {
force = true
}
compile("wsdl4j:wsdl4j:1.6.1")
compile('io.netty:netty-codec:4.1.63.Final') {
force = true
}
compile('org.apache.commons:commons-math3:3.6') {
force = true
}
compile('org.springframework:spring-expression:5.2.12.RELEASE') {
force = true
}
compile('io.netty:netty-codec-http:4.1.63.Final') {
force = true
}
compile('com.thoughtworks.xstream:xstream:1.4.16') {
force = true
}
compile('commons-beanutils:commons-beanutils:1.9.4') {
force = true
}
compile group: 'org.postgresql', name: 'postgresql', version: '42.2.13'
compile group: 'commons-dbcp', name: 'commons-dbcp', version: '1.4'
}
bootJar.enabled = false // disable default bootRepackage since we have custom repackage tasks
// bootJar.withJarTask = jar // use custom Jar repackaging using the generated jar from the jar tasks
bootJar.dependsOn = [oAuthConfigJarBoot, eurekaBoot, ...]
distTar() {
from('scripts') {
include '**/*'
into 'bin'
}
from(oAuthConfigJar.archivePath)
from(eurekaJar.archivePath)
from(abcApplicationApiGatewayJar.archivePath)
from(cloudConfigServerJar.archivePath)
archiveName 'abcApplicationService.tar'
}
dependencyManagement {
imports {
mavenBom "org.springframework.cloud:spring-cloud-dependencies:${springCloudVersion}"
}
}
Assuming that eurekaconfiguration contains all of the dependencies that should be packaged inside your eurekaAppJar, you can use it and the output of the main source set as eurekaAppJar's classpath:
task eurekaAppJar(type: BootJar) {
baseName = 'eurekaJar'
version = '0.0.1'
manifest {
attributes 'Main-Class': "org.springframework.boot.loader.JarLauncher"
attributes 'Start-Class': "com.abc.abcCompany.service.eurekaApp.EurekaApplication"
attributes 'Implementation-Version': "001"
}
bootJar {
mainClassName = "com.abc.abcCompany.service.eurekaApp.EurekaApplication"
}
classpath configurations.eurekaconfiguration.plus(sourceSets.main.output)
}
This will result in BOOT-INF/lib containing the jars of all of the dependencies in eurekaconfiguration and BOOT-INF classes containing the resources from src/main/resources and the classes produced by compiling everything in src/main/java.
I have root config gradle.build
plugins {
id 'org.springframework.boot' version '2.3.5.RELEASE'
id 'io.spring.dependency-management' version '1.0.10.RELEASE'
id 'java'
id 'idea'
}
idea {
project {
languageLevel = 14
}
module {
downloadJavadoc = true
downloadSources = true
}
}
allprojects {
group "ru.otus"
repositories {
mavenCentral()
maven { url 'https://repo.spring.io/milestone' }
maven { url 'https://repo.spring.io/snapshot' }
}
apply plugin: "io.spring.dependency-management"
dependencyManagement {
dependencies {
imports {
mavenBom("org.springframework.boot:spring-boot-dependencies:2.3.5.RELEASE")
}
dependency("org.projectlombok:lombok:1.18.16")
dependency("org.springframework.shell:spring-shell-starter:2.0.1.RELEASE")
dependency("org.springframework.boot:spring-boot-starter-data-jpa:2.3.5.RELEASE")
dependency("org.flywaydb:flyway-core:6.4.4")
dependency("org.postgresql:postgresql:42.2.16")
dependency("org.hamcrest:hamcrest-core:1.3")
dependency("org.springframework.boot:spring-boot-starter-test:2.3.5.RELEASE")
}
}
configurations.all {
resolutionStrategy {
failOnVersionConflict()
}
resolutionStrategy {
force("javax.servlet:servlet-api:2.4")
force("commons-logging:commons-logging:1.1.1")
force("commons-lang:commons-lang:2.5")
force("org.codehaus.jackson:jackson-core-asl:1.8.8")
force("org.codehaus.jackson:jackson-mapper-asl:1.8.3")
force("org.codehaus.jettison:jettison:1.1")
force("org.javassist:javassist:3.24.0-GA")
force("org.apiguardian:apiguardian-api:1.1.0")
force("org.opentest4j:opentest4j:1.2.0")
}
}
}
and have build.gradle in module
plugins {
id 'java'
}
version = '0.0.1-SNAPSHOT'
dependencies {
implementation group: 'org.springframework.shell', name: 'spring-shell-starter', version: '2.0.1.RELEASE'
implementation group: 'org.springframework.boot', name: 'spring-boot-starter', version: '2.3.5.RELEASE'
implementation group: 'org.flywaydb', name: 'flyway-core', version: '6.4.4'
testCompile group: 'org.hamcrest', name: 'hamcrest-core', version: '1.3'
testImplementation group: 'org.springframework.boot', name: 'spring-boot-starter-test', version: '2.3.5.RELEASE'
}
After download dependencies and add in models annotations like #Entity, #Table #Id and etc. i have an error: cannot find symbol
#Entity
^
symbol: class Entity
But i have spring-boot-starter-jpa in dependencies, i don't know why in module i can't use dependencies.
With dependencyManagement you only manage dependencies like version, overrides etc. you don't actually add dependencies to a project. For that use dependencies like you use in the other places.
I am studying spring webflux, but the generated folder is created when the server starts. Do you know why?
If you restart the server after deleting the generated folder, it will be created again.
The build.gradle file was configured as follows.
spring boot 2.2.7.RELEASE version and using jdk 8.
build.gradle
buildscript {
ext {
restDocsVersion = "2.0.2.RELEASE"
}
dependencies {
classpath "org.asciidoctor:asciidoctor-gradle-plugin:1.5.3"
}
}
plugins {
id "org.springframework.boot" version "2.2.7.RELEASE"
id "io.spring.dependency-management" version "1.0.9.RELEASE"
id "java"
id "groovy"
id "org.asciidoctor.convert" version "2.4.0"
}
ext {
snippetsDir = file("build/generated-snippets")
}
test {
useJUnitPlatform()
}
asciidoctor {
inputs.dir snippetsDir
dependsOn test
}
bootJar {
dependsOn asciidoctor
from("${asciidoctor.outputDir}/html5") {
into "static/docs"
}
dependsOn "copyDocs"
}
task copyDocs(type: Copy) {
from "${asciidoctor.outputDir}/html5"
into "src/main/resources/static/docs"
}
group = "com.example"
java {
sourceCompatibility = JavaVersion.VERSION_1_8
}
configurations {
compileOnly {
extendsFrom annotationProcessor
}
}
build {
dependsOn clean
}
repositories {
mavenCentral()
}
dependencies {
compile "org.springframework.boot:spring-boot-starter-aop"
compile "org.springframework.boot:spring-boot-starter-logging"
compile "org.springframework.boot:spring-boot-starter-webflux"
compile "org.springframework.boot:spring-boot-starter-data-redis-reactive"
compileOnly "org.projectlombok:lombok"
annotationProcessor "org.projectlombok:lombok"
testImplementation("org.springframework.boot:spring-boot-starter-test") {
exclude group: "org.junit.vintage", module: "junit-vintage-engine"
}
testImplementation "io.projectreactor:reactor-test"
annotationProcessor "org.springframework.boot:spring-boot-configuration-processor"
compile group: "com.fasterxml.jackson.core", name: "jackson-core", version: "2.9.8"
compile group: "com.fasterxml.jackson.core", name: "jackson-annotations", version: "2.9.8"
compile group: "com.fasterxml.jackson.core", name: "jackson-databind", version: "2.9.8"
compile group: "com.googlecode.json-simple", name: "json-simple", version: "1.1.1"
asciidoctor "org.springframework.restdocs:spring-restdocs-asciidoctor:${restDocsVersion}"
testCompile "org.springframework.restdocs:spring-restdocs-webtestclient:${restDocsVersion}"
compile group: "org.codehaus.groovy", name: "groovy-all", version: "2.5.8"
}
How do you declare a local dependency for gradle 4.10.3 to not use the github project and use your own custom build of the project? Open source project I'm trying to compile https://github.com/kami-blue/client
My build is at /Users/macbook/Desktop/baritone-master/dist/baritone-api-1.2.14.jar
I've tried changing the file path to it and commenting out the two compile commands but that didn't work.
//compile 'com.github.cabaletta:baritone:1.2.14'
//compile 'cabaletta:baritone-api:1.2'
include(dependency('/Users/macbook/Desktop/baritone-master/dist/baritone-api-1.2.14.jar'))
Using these either of these two methods do not work either:
implementation files('/Users/macbook/Desktop/baritone-master/dist/baritone-api-1.2.14.jar')
compile fileTree(dir: '/Users/macbook/Desktop/baritone-master/dist', include: ['*.jar'])
build.gradle file:
buildscript {
repositories {
jcenter()
maven {
name = 'forge'
url = 'http://files.minecraftforge.net/maven'
}
maven {
name = 'SpongePowered'
url = 'http://repo.spongepowered.org/maven'
}
}
dependencies {
classpath 'net.minecraftforge.gradle:ForgeGradle:2.3-SNAPSHOT'
classpath 'org.spongepowered:mixingradle:0.6-SNAPSHOT'
classpath 'com.github.jengelman.gradle.plugins:shadow:4.0.3'
classpath group: 'org.jetbrains.kotlin', name: 'kotlin-gradle-plugin', version: "${kotlin_version}" }
}
apply plugin: 'kotlin'
apply plugin: 'net.minecraftforge.gradle.forge'
apply plugin: 'org.spongepowered.mixin'
apply plugin: 'com.github.johnrengelman.shadow'
version project.modVersion
group project.modGroup // http://maven.apache.org/guides/mini/guide-naming-conventions.html
compileKotlin {
kotlinOptions {
jvmTarget = "1.8"
}
}
compileTestKotlin {
kotlinOptions {
jvmTarget = "1.8"
}
}
sourceCompatibility = targetCompatibility = '1.8'
compileJava {
sourceCompatibility = targetCompatibility = '1.8'
}
minecraft {
version = project.forgeVersion
runDir = 'run'
mappings = project.mcpVersion
coreMod = 'me.zeroeightsix.kami.mixin.MixinLoaderForge'
makeObfSourceJar = false
}
repositories {
maven {
name = 'spongepowered-repo'
url = 'http://repo.spongepowered.org/maven/'
}
maven {
name = 'impactdevelopment-repo'
url = 'https://impactdevelopment.github.io/maven/'
}
maven {
name = 'swt-repo'
url = "http://maven-eclipse.github.io/maven"
}
maven {
name = "jitpack.io"
url = "https://jitpack.io"
}
maven {
name = "forgelin-repo"
url "http://maven.shadowfacts.net/"
}
mavenCentral()
jcenter()
}
dependencies {
// mixin needs to be distributed with the mod, very important
compile("org.spongepowered:mixin:0.7.11-SNAPSHOT") { // do NOT update this to 8.0 or above, it breaks compatibility with future client
exclude module: 'launchwrapper'
exclude module: 'guava'
exclude module: 'gson'
exclude module: 'commons-io'
exclude module: 'log4j-core' // we want to exclude this as well because 0.7.11 includes it too new for MC
}
compile "com.github.ZeroMemes:Alpine:1.7"
compile group: 'net.jodah', name: 'typetools', version: '0.6.2'
compile group: 'org.yaml', name: 'snakeyaml', version: '1.26'
compile(group: 'org.reflections', name: 'reflections', version: '0.9.12') {
exclude group: 'com.google.guava', module: 'guava'
}
compile 'club.minnced:java-discord-rpc:2.0.2'
compile 'com.github.MrPowerGamerBR:TemmieWebhook:-SNAPSHOT'
compile 'com.github.kevinsawicki:http-request:http-request-6.0'
compile 'com.github.cabaletta:baritone:1.2.14'
compile 'cabaletta:baritone-api:1.2'
compile group: "net.shadowfacts", name: "Forgelin", version: "1.8.4"
compile group: "org.jetbrains.kotlin", name: "kotlin-stdlib", version: kotlin_version
compile group: "org.jetbrains.kotlin", name: "kotlin-stdlib-jdk7", version: kotlin_version
compile group: "org.jetbrains.kotlin", name: "kotlin-stdlib-jdk8", version: kotlin_version
compile group: "org.jetbrains.kotlin", name: "kotlin-reflect", version: kotlin_version
compile group: "org.jetbrains", name: "annotations", version: annotations_version
compile group: "org.jetbrains.kotlinx", name: "kotlinx-coroutines-core", version: coroutines_version
compile group: "org.jetbrains.kotlinx", name: "kotlinx-coroutines-jdk8", version: coroutines_version
}
processResources {
// this will ensure that this task is redone when the versions change.
inputs.property 'version', project.version
inputs.property 'mcversion', project.minecraft.version
// replace stuff in mcmod.info, nothing else
from(sourceSets.main.resources.srcDirs) {
include 'mcmod.info'
// replace version and mcversion
expand 'version': project.version, 'mcversion': project.minecraft.version
}
// copy everything else, thats not the mcmod.info
from(sourceSets.main.resources.srcDirs) {
exclude 'mcmod.info'
}
// move _at.cfg into META-INF
rename '(.+_at.cfg)', 'META-INF/$1'
}
shadowJar {
dependencies {
include(dependency('org.spongepowered:mixin'))
include(dependency('com.github.ZeroMemes:Alpine'))
include(dependency('club.minnced:java-discord-rpc'))
include(dependency('net.jodah:typetools'))
include(dependency('org.yaml:snakeyaml'))
include(dependency('org.reflections:reflections'))
include(dependency('org.javassist:javassist'))
include(dependency('com.github.MrPowerGamerBR:TemmieWebhook'))
include(dependency('com.github.kevinsawicki:http-request'))
include(dependency('cabaletta:baritone-api'))
include(dependency("org.jetbrains.kotlin:kotlin-stdlib:${kotlin_version}"))
include(dependency("org.jetbrains.kotlin:kotlin-stdlib-jdk7:${kotlin_version}"))
include(dependency("org.jetbrains.kotlin:kotlin-stdlib-jdk8:${kotlin_version}"))
include(dependency("org.jetbrains.kotlin:kotlin-reflect:${kotlin_version}"))
include(dependency("org.jetbrains:annotations:${annotations_version}"))
include(dependency("org.jetbrains.kotlinx:kotlinx-coroutines-core:${coroutines_version}"))
include(dependency("org.jetbrains.kotlinx:kotlinx-coroutines-jdk8:${coroutines_version}"))
include(dependency('net.shadowfacts:Forgelin'))
}
exclude 'dummyThing' // can someone explain why this is here
classifier = 'release'
}
mixin {
defaultObfuscationEnv searge
add sourceSets.main, 'mixins.kami.refmap.json'
}
reobf {
shadowJar {
mappingType = 'SEARGE'
classpath = sourceSets.main.compileClasspath
}
}
// Don't put baritone mixin here please c:
jar {
manifest {
attributes(
'MixinConfigs': 'mixins.kami.json',
'tweakClass': 'org.spongepowered.asm.launch.MixinTweaker',
'TweakOrder': 0,
'FMLCorePluginContainsFMLMod': 'true',
'FMLCorePlugin': 'me.zeroeightsix.kami.mixin.MixinLoaderForge',
'ForceLoadAsMod': 'true',
'FMLAT': 'kami_at.cfg'
)
}
}
build.dependsOn(shadowJar)
Please try this. Should fix your problem.
In this case gradle will try to use a relative path for a local jar dependency.
Read those documentaries for more information
dependencies {
implementation files('/Users/macbook/Desktop/baritone-master/dist/baritone-api-1.2.14.jar')
}
Additionally you can add all jars in X directory.
dependencies {
compile fileTree(dir: 'yourDirection', include: ['*.jar'])
}
I am using Intellij IDEA 2017.1.4. I am new to gradle. I have been given a multi modular spring project on Gradle. Problem is when I do "Refresh all gradle projects" (on the side pan of IDEA), it takes hours. Some times a day. It is necessary for me sometimes doing refresh due to addition of dependencies or something else.
Following is my root build.gradle file. Please help.
group 'tv.videoready'
version = "1.0.0-RELEASE"
description = "Mobile/Web API's Application"
buildscript {
ext {
springBootVersion = '1.4.0.RELEASE'
}
repositories {
mavenCentral()
maven {
url "https://plugins.gradle.org/m2/"
}
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
classpath("gradle.plugin.com.gorylenko.gradle-git-properties:gradle-git-properties:1.4.17")
}
}
apply plugin: 'idea'
apply plugin: "com.gorylenko.gradle-git-properties"
jar {
baseName = 'rest-api'
version = '1.0.0-RELEASE'
}
sourceCompatibility = 1.8
targetCompatibility = 1.8
repositories {
mavenCentral()
maven { url 'http://artifactory.videoready.tv/artifactory/libs-release-local' }
maven { url 'http://artifactory.videoready.tv/artifactory/libs-snapshot-local' }
}
gitProperties {
dateFormat = "d MMM yyyy HH:mm:ss Z"
dateFormatTimeZone = "UTC"
gitRepositoryRoot = new File("${project.rootDir}")
gitPropertiesDir = new File("${project.rootDir}/src/main/resources")
}
ext {
springBootVersion = "1.4.0.RELEASE"
mysqlConnectorVersion = '5.1.39'
swaggerVersion = '2.7.0'
}
dependencies {
// Actuator
compile("org.springframework.boot:spring-boot-starter-actuator:${springBootVersion}")
compile 'org.springframework.hateoas:spring-hateoas:0.20.0.RELEASE'
compile project(":login")
compile project(":config")
compile project(":device")
compile project(":password")
compile project(":sms")
compile project(":remote-record")
compile project(":otp")
compile project(":profile")
compile("de.codecentric:spring-boot-admin-starter-client:1.4.4")
}
allprojects {
apply plugin: 'java'
apply plugin: 'spring-boot'
sourceCompatibility = 1.8
targetCompatibility = 1.8
repositories {
mavenCentral()
maven { url 'http://artifactory.videoready.tv/artifactory/libs-release-local' }
maven { url 'http://artifactory.videoready.tv/artifactory/libs-snapshot-local' }
}
dependencies {
compile("org.springframework.boot:spring-boot-starter-data-jpa:${springBootVersion}")
compile("org.springframework.boot:spring-boot-starter-web:${springBootVersion}")
compile("org.springframework.boot:spring-boot-starter-jetty:${springBootVersion}")
compile("org.springframework.boot:spring-boot-starter-amqp:${springBootVersion}")
compile("mysql:mysql-connector-java:${mysqlConnectorVersion}")
compile group: 'org.hibernate', name: 'hibernate-validator', version: '4.3.2.Final'
//HTTP Client
compile group: 'org.apache.httpcomponents', name: 'httpcore', version: '4.4.5'
compile group: 'org.apache.httpcomponents', name: 'httpclient', version: '4.5.2'
compile(group: 'tv.videoready', name: 'module-logger', version: '2.0.2-RELEASE')
compile(group: 'tv.videoready', name: 'cors-filter', version: '1.0.0')
// compile(group: 'tv.videoready', name: 'common-sql-domains', version: '1.5.8-SNAPSHOT')
compile files("/home/divya/projects/tatasky/common-services/common-sql-domains/build/libs/ common-sql-domains-3.1.0-RELEASE.jar")
compile(group: 'tv.videoready', name: 'mm-domains', version: '3.1.4-SNAPSHOT')
compile(group: 'tv.videoready', name: 'common-constants', version: '1.4.10-SNAPSHOT')
compile(group: 'tv.videoready', name: 'domain-pojo-utils', version: '1.2.0-SNAPSHOT')
compile(group: 'tv.videoready', name: 'validation-util', version: '1.2.0-SNAPSHOT')
compile(group: 'tv.videoready', name: 'search-client', version: '1.4.4-SNAPSHOT'){
exclude(group: 'tv.videoready', module: 'common-constants')
exclude(group: 'tv.videoready', module: 'common-sql-domains')
exclude(group: 'tv.videoready', module: 'mm-domains')
}
compile(group: 'tv.videoready', name: 'common-pojo', version: '1.3.23-SNAPSHOT')
compile(group: 'tv.videoready', name: 'i-spy-client', version: '1.0.2-SNAPSHOT')
compile(group: 'tv.videoready', name: 'cache', version: '2.0.26-SNAPSHOT')
compile('com.hazelcast:hazelcast:3.7.5')
compile('com.hazelcast:hazelcast-client:3.7.5')
compile("io.springfox:springfox-swagger2:${swaggerVersion}")
compile("io.springfox:springfox-swagger-ui:${swaggerVersion}")
}
configurations {
compile.exclude module: ("spring-boot-starter-tomcat")
compile.exclude module: ("spring-boot-starter-logging")
}
sourceSets.main.resources {
srcDir '../src/main/resources'
}
}
subprojects {
group = 'tv.videoready'
version = '1.0.0-RELEASE'
}
processResources {
filesMatching("**/application.properties") {
expand(project.properties)
}
}
bootRun {
systemProperties = System.properties
systemProperty "log4j.configurationFactory", "tv.videoready.logger.LoggingConfigurationFactory"
systemProperty "mockRRM", true
systemProperty "dev.hazelcast.setup.enabled", "false"
systemProperty "dev.hazelcast.cluster.group.password", "hari"
systemProperty "hazelcast.cluster.group.password", "hari"
systemProperty "spring.config.location", "classpath:hazelcast-dev.properties"
systemProperty "jsse.enableSNIExtension", "false"
}