Running Spring Boot Application on WebSphere 9 - java

I've a Spring Boot Application with main class:
#SpringBootApplication
public class MyApplication extends SpringBootServletInitializer{
public static void main(String[] args) {
SpringApplication.run(MyApplication .class, args);
}
#Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder application){
return application.sources(applicationClass);
}
private static Class<MyApplication > applicationClass = MyApplication .class;
}
With gradle.build:
version '1.0'
// dependencies for command line
buildscript {
ext {
springBootVersion = '1.4.3.RELEASE'
dependencyManagementVersion = '0.6.0.RELEASE'
}
repositories {
jcenter()
}
dependencies {
classpath "org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}"
classpath "io.spring.gradle:dependency-management-plugin:${dependencyManagementVersion}"
}
}
apply plugin: "io.spring.dependency-management"
apply plugin: 'java'
apply plugin: 'org.springframework.boot'
apply plugin: 'war'
apply plugin: 'eclipse'
apply plugin: 'idea'
// JDK 8
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
repositories {
jcenter()
}
ext {
springCloudVersion = 'Brixton.SR4'
springBootVersion = '1.4.3.RELEASE'
swaggerVersion = '2.4.0'
jodaTimeVersion = '2.9.4'
jacksonJodaVersion = '2.5.1'
junitVersion = '4.12'
springWsTestVersion = '2.2.3.RELEASE'
lombokVersion = '1.16.10'
jsonPathVersion = '2.2.0'
ehcacheVersion = '3.2.0'
javaxCacheVersion = '1.0.0'
}
dependencyManagement {
imports {
mavenBom "org.springframework.cloud:spring-cloud-dependencies:${springCloudVersion}"
mavenBom "org.springframework.boot:spring-boot-starter-parent:${springBootVersion}"
}
}
sourceSets {
test {
java {
srcDir 'src/test/unit/java'
}
resources {
srcDir 'src/test/unit/resources'
}
}
}
tasks.withType(JavaExec) {
if (System.getProperty("DEBUG", 'false') == 'true') {
jvmArgs '-Xdebug', '-Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5006'
}
}
dependencies {
// https://mvnrepository.com/artifact/javax/javaee-api
compile group: 'javax', name: 'javaee-api', version: '7.0'
/* core libraries */
compile('org.springframework.cloud:spring-cloud-starter-config') {
exclude group: 'org.springframework.boot', module: 'spring-boot-starter-logging'
}
compile('org.springframework.boot:spring-boot-starter-web') {
exclude group: 'org.springframework.boot', module: 'spring-boot-starter-logging'
}
compile("org.springframework.boot:spring-boot-starter-hateoas"){
exclude group: 'org.springframework.boot', module: 'spring-boot-starter-logging'
}
compile 'org.springframework.ws:spring-ws-core'
// tag::actuator[]; for #RefreshScope
compile("org.springframework.boot:spring-boot-starter-actuator"){
exclude group: 'org.springframework.boot', module: 'spring-boot-starter-logging'
}
// end::actuator[]
// logging
compile('org.springframework.boot:spring-boot-starter-log4j2')
compile('com.fasterxml.jackson.dataformat:jackson-dataformat-yaml')
compile('com.fasterxml.jackson.core:jackson-databind')
// embedded server
providedRuntime ('org.springframework.boot:spring-boot-starter-tomcat')
// https://mvnrepository.com/artifact/org.projectlombok/lombok-maven
compile "org.projectlombok:lombok:${lombokVersion}"
// https://mvnrepository.com/artifact/com.jayway.jsonpath/json-path
// A Java DSL for reading JSON documents
compile "com.jayway.jsonpath:json-path:${jsonPathVersion}"
//for EhCache
// https://mvnrepository.com/artifact/org.ehcache/ehcache
compile "org.ehcache:ehcache:${ehcacheVersion}"
// https://mvnrepository.com/artifact/javax.cache/cache-api
compile "javax.cache:cache-api:${javaxCacheVersion}"
// utilities
compile "io.springfox:springfox-swagger2:${swaggerVersion}"
compile "io.springfox:springfox-swagger-ui:${swaggerVersion}"
compile "joda-time:joda-time:${jodaTimeVersion}"
compile "com.fasterxml.jackson.datatype:jackson-datatype-joda:${jacksonJodaVersion}"
compile ("org.springframework.boot:spring-boot-starter-aop") {
exclude group: 'org.springframework.boot', module: 'spring-boot-starter-logging'
}
compile "org.aspectj:aspectjweaver:1.8.8"
/* plugins */
/* test libraries */
// unit
testCompile "junit:junit:${junitVersion}"
testCompile "org.springframework.boot:spring-boot-starter-test"
testCompile "org.springframework.ws:spring-ws-test:${springWsTestVersion}"
}
war {
archiveName = "${project.name}.war"
manifest {
attributes 'Main-Class': 'com..content.MyApplication'
}
}
When I try to deploy the war file on WebSphere Application Server 9.0 Traditional, it starts but takes very long time. Without war file, server starts and stops very normally, but with application, server hangs.
Am I missing something?
Thank you for help!!

The startup delay is probably caused by CDI's implicit bean archive scanning. If you are not using CDI, you can disable implicit bean archives with com.ibm.ws.cdi.enableImplicitBeanArchives=false.
You can find a much more detailed explanation in this tech note:
Custom Properties for improving application startup in WebSphere Application Server

Related

Gradle Spring Boot Junit | Logging | Debugging

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

Issue with HTML character escaping in JAVA spring boot deployed on weblogic server. It works in TEST environment but not in PRODUCTION

In my spring boot application I have below code which has AnnotationConfigWebApplicationContext and i included FrameworkWebconfig class (from jar file) in that AnnotationConfigWebApplicationContext which is used for escaping special charaters in JSON response. But for some issues I had to remove that framework web config class and after that special charaters were not escaping in JSON response (as expected, in TEST environment). Same code when i run in PROD its not working it is still escaping those special characters. This application is deployed on Weblogic servers. I am not getting whats the issue here. Can someone please help me understand why this is happening?
#Configuration
public class Application implements WebApplicationInitializer {
....
private AnnotationConfigWebApplicationContext getContext() {
logger.info("Entering method : getContext");
AnnotationConfigWebApplicationContext context = new AnnotationConfigWebApplicationContext();
context.register(FrameworkPropertySourcesConfig.class);
//context.register(FrameworkWebConfig.class); //this line, after removing its working in TEST but not in prod
context.register(AppConfig.class);
logger.info("Exiting method : getContext");
return context;
}
.....
}
#EnableWebMvc
#Configuration
public class FrameworkWebConfig extends WebMvcConfigurerAdapter {
private MappingJackson2HttpMessageConverter buildHtmlEscapingJsonConverter() {
MappingJackson2HttpMessageConverter htmlEscapingConverter = new MappingJackson2HttpMessageConverter();
ObjectMapper objectMapper = new ObjectMapper();
objectMapper.getJsonFactory().setCharacterEscapes(new HTMLCharacterEscapes());
htmlEscapingConverter.setObjectMapper(objectMapper);
return htmlEscapingConverter;
}
public void configureDefaultServletHandling(DefaultServletHandlerConfigurer configurer) {
configurer.enable();
}
public void configureMessageConverters(List<HttpMessageConverter<?>> converters) {
super.configureMessageConverters(converters);
converters.add(this.buildHtmlEscapingJsonConverter());
}
#Bean
CommonsMultipartResolver multipartResolver() {
return new CommonsMultipartResolver();
}
}
Below is build.gradle file
buildscript {
ext {
springBootVersion = '1.2.5.RELEASE'
}
repositories {
mavenCentral()
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
classpath("io.spring.gradle:dependency-management-plugin:0.5.2.RELEASE")
}
}
plugins {
//id "org.sonarqube" version "2.5"
//gradle sonarqube
}
apply plugin: 'java'
apply plugin: 'eclipse-wtp'
apply plugin: 'spring-boot'
apply plugin: 'io.spring.dependency-management'
apply plugin: 'war'
//apply plugin: 'org.sonarqube'
war {
baseName = 'CServices'
webInf { from 'WEB-INF' }
}
sourceCompatibility = 1.7
targetCompatibility = 1.7
repositories {
mavenCentral()
}
configurations {
providedRuntime
providedCompile
exclude
jar
}
dependencies {
compile files('WEB-INF/lib/framework.jar')
compile files('WEB-INF/lib/wsclient.jar')
compile("org.springframework.boot:spring-boot-starter-redis")
compile("org.springframework.boot:spring-boot-starter-security")
compile("org.springframework.security.oauth:spring-security-oauth2:2.0.7.RELEASE")
compile("org.springframework.boot:spring-boot-starter-thymeleaf"){
exclude module: 'spring-boot-starter-tomcat'
}
compile("org.springframework.boot:spring-boot-starter-web"){
exclude module: 'spring-boot-starter-tomcat'
}
compile("org.springframework.ws:spring-ws-core")
compile("org.springframework:spring-tx")
compile("org.springframework:spring-jdbc")
compile("org.mybatis:mybatis:3.2.8")
compile("org.mybatis:mybatis-spring:1.2.3")
compile('org.springframework.boot:spring-boot-starter-mail')
compile("org.apache.poi:poi:3.9")
compile("org.apache.poi:poi-ooxml:3.9")
compile('commons-httpclient:commons-httpclient:3.1')
compile("org.apache.commons:commons-lang3:3.1")
compile('org.hsqldb:hsqldb:2.0.0')
compile('commons-fileupload:commons-fileupload:1.2')
compile('commons-io:commons-io:1.4')
compile('com.google.code.gson:gson:2.2.4')
compile('com.google.guava:guava:r05')
compile("org.apache.oltu.oauth2:org.apache.oltu.oauth2.client:1.0.1");
compile('org.json:json:20090211')
compile('org.projectlombok:lombok:1.18.10')
// https://mvnrepository.com/artifact/com.microsoft.sqlserver/mssql-jdbc
compile group: 'com.microsoft.sqlserver', name: 'mssql-jdbc', version: '6.1.0.jre7'
compile group: 'com.fasterxml.jackson.core', name: 'jackson-core', version: '2.9.0'
//compile "com.fasterxml.jackson.dataformat:jackson-dataformat-xml:2.9.0"
testCompile("org.springframework.boot:spring-boot-starter-test")
providedCompile 'javax.servlet:javax.servlet-api:3.0.1'
compile group: 'org.springframework', name: 'spring-mock', version: '2.0.8'
compile group: 'org.springframework.boot', name: 'spring-boot-starter-aop', version: '1.2.5.RELEASE'
compile('commons-beanutils:commons-beanutils:1.9.2')
// https://mvnrepository.com/artifact/io.springfox/springfox-swagger-ui
compile group: 'io.springfox', name: 'springfox-swagger-ui', version: '2.9.2'
// https://mvnrepository.com/artifact/io.springfox/springfox-swagger2
compile group: 'io.springfox', name: 'springfox-swagger2', version: '2.9.2'
// https://mvnrepository.com/artifact/com.google.guava/guava
compile group: 'com.google.guava', name: 'guava', version: '27.0-jre'
testCompile group: 'org.mockito', name: 'mockito-all', version: '1.8.4'
}
eclipse {
classpath {
containers.remove('org.eclipse.jdt.launching.JRE_CONTAINER')
containers 'org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8'
}
wtp {
component {
contextPath = '/cs'
}
}
project{
natures 'org.springsource.ide.eclipse.gradle.core.nature'
}
}
//task afterEclipseImport { dependsOn ':cs-java-framework:jar' }
//compileJava.dependsOn ':cs-java-framework:jar'
task wrapper(type: Wrapper) {
gradleVersion = '2.7'
}

Generate generated folder when starting springboot netty

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"
}

Build Gradle Local Dependency

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'])
}

Gradle Multiproject - OpenClover

I am trying to integrate Open Clover into my Gradle build process and was following the following guide:
When I added it to my build.gradle - I got the following error:
* * What went wrong:
A problem occurred evaluating root project 'Enjin-Coin-Java-SDK'.
> Could not find method cloverCompile() for arguments [org.openclover:clover:4.2.0] on object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler..
My build.gradle file is as follows:
buildscript {
repositories {
mavenCentral()
maven { url 'https://plugins.gradle.org/m2/' }
}
dependencies {
classpath 'org.openclover:clover:4.2.0'
}
}
plugins {
id 'com.github.johnrengelman.shadow' version '1.2.4'
id 'java'
}
sourceSets {
clover {
java {
srcDir "$buildDir/sources-instr"
}
}
}
apply from: 'gradle/util.gradle'
subprojects {
apply plugin: 'eclipse'
apply plugin: 'idea'
apply plugin: 'java'
apply plugin: 'maven'
apply plugin: 'com.github.johnrengelman.shadow'
group = 'com.myproject'
version = '0.0.1-SNAPSHOT'
idea {
module {
scopes.PROVIDED.plus += [configurations.shadow]
}
}
tasks.build.dependsOn(shadowJar)
artifacts.archives shadowJar
tasks.withType(AbstractCompile) {
classpath += configurations.shadow
}
ext {
mockito = '2.9.0'
junit = '4.12'
powermock = '1.7.3'
}
repositories {
mavenLocal()
mavenCentral()
}
dependencies {
// testCompile dependencies
testCompile group: 'org.mockito', name: 'mockito-core', version: mockito
testCompile group: 'junit', name: 'junit', version: junit
testCompile group: 'org.powermock', name: 'powermock-api-mockito2', version: powermock
testCompile group: 'org.powermock', name: 'powermock-module-junit4', version: powermock
cloverCompile 'org.openclover:clover:4.2.0'
}
jar {
archiveName = "${project.name}-slim.jar"
}
shadowJar {
archiveName = "${project.name}.jar"
}
install {
repositories.mavenInstaller {
pom.artifactId = "sdk-${project.name}"
}
}
}
configurations {
cloverRuntime
cloverRuntime.extendsFrom cloverCompile
}
task cloverInstr() {
inputs.files sourceSets.main.allJava
outputs.dir "$buildDir/sources-instr"
doFirst {
def argsList = ["--initstring", "${buildDir}/clover/clover.db", "-d", "${buildDir}/sources-instr"]
argsList.addAll(inputs.files.files.collect({ file ->
file.absolutePath
}))
String[] args = argsList.toArray()
com.atlassian.clover.CloverInstr.mainImpl(args)
}
}
cloverClasses.dependsOn cloverInstr
test {
def cloverClasspath = configurations.testRuntime + configurations.cloverRuntime + sourceSets.test.output + sourceSets.clover.output
classpath = cloverClasspath
}
task cloverReport {
inputs.dir "${buildDir}/clover"
outputs.dir "${reportsDir}/clover"
onlyIf {
file("${buildDir}/clover/clover.db").exists()
}
doFirst {
def argsList = ["--initstring", "${buildDir}/clover/clover.db",
"-o", "${reportsDir}/clover"]
String[] args = argsList.toArray()
com.atlassian.clover.reporters.html.HtmlReporter.runReport(args)
}
}
The contents of util.gradle are as follows
ext.scriptFile = {
String fileName ->
return new File(new File(rootDir, 'gradle'), fileName)
}
Can anyone offer any assistance in how to resolve this?
Use the following script to integrate clover into your project:
buildscript {
repositories {
mavenCentral()
maven { url 'https://plugins.gradle.org/m2/' }
jcenter()
}
}
plugins {
id 'com.github.johnrengelman.shadow' version '1.2.4'
id "com.bmuschko.clover" version "2.1.3"
}
apply from: 'gradle/util.gradle'
subprojects {
apply plugin: 'eclipse'
apply plugin: 'idea'
apply plugin: 'java'
apply plugin: 'maven'
apply plugin: 'com.github.johnrengelman.shadow'
apply plugin: 'com.bmuschko.clover'
group = 'com.myproject'
version = '0.0.1-SNAPSHOT'
idea {
module {
scopes.PROVIDED.plus += [configurations.shadow]
}
}
tasks.build.dependsOn(shadowJar)
artifacts.archives shadowJar
tasks.withType(AbstractCompile) {
classpath += configurations.shadow
}
ext {
mockito = '2.9.0'
junit = '4.12'
powermock = '1.7.3'
}
repositories {
mavenLocal()
mavenCentral()
}
dependencies {
// testCompile dependencies
testCompile group: 'org.mockito', name: 'mockito-core', version: mockito
testCompile group: 'junit', name: 'junit', version: junit
testCompile group: 'org.powermock', name: 'powermock-api-mockito2', version: powermock
testCompile group: 'org.powermock', name: 'powermock-module-junit4', version: powermock
clover 'org.openclover:clover:4.2.0'
}
jar {
archiveName = "${project.name}-slim.jar"
}
shadowJar {
archiveName = "${project.name}.jar"
}
install {
repositories.mavenInstaller {
pom.artifactId = "sdk-${project.name}"
}
}
}
There's no need for manual integration if ready-to-use plugin is available.

Categories