Gradle with ajc doesn't read Lombok annotations - java

I am trying to add ajc compiler to my gradle project as gradle plugin. Unfortunately, during compilation it shows me massive amount of errors due to Lombok.
build.gradle:
group 'com.kmb.bank'
version '0.0.1-SNAPSHOT'
project.ext {
aspectjVersion = '1.9.2'
}
buildscript {
repositories {
maven {
url "https://plugins.gradle.org/m2/"
}
}
dependencies {
classpath "gradle.plugin.aspectj:gradle-aspectj:0.1.6"
}
}
apply plugin: 'java'
apply plugin: 'org.springframework.boot'
apply plugin: 'io.spring.dependency-management'
apply plugin: "aspectj.gradle"
sourceCompatibility = 11
targetCompatibility = 11
repositories {
mavenCentral()
}
dependencies {
compile group: 'com.fasterxml.jackson.core', name: 'jackson-databind', version: '2.9.7'
testCompile group: 'junit', name: 'junit', version: '4.12'
compile group: 'commons-codec', name: 'commons-codec', version: '1.11'
implementation('org.springframework.boot:spring-boot-starter-amqp')
implementation('org.springframework.boot:spring-boot-starter-web')
compile("org.springframework.boot:spring-boot-starter-thymeleaf")
compile ('org.springframework.boot:spring-boot-starter-security')
compile("org.springframework.boot:spring-boot-starter-data-mongodb")
compile group: 'org.springframework.boot', name: 'spring-boot-starter- aop', version: '2.1.1.RELEASE'
}
It shows me errors that there are no getter, setters for every model.

This is working for me:
plugins {
id 'java'
id "io.freefair.aspectj.post-compile-weaving" version "4.1.4"
}
group 'com.amdocs'
version '1.0.0-SNAPSHOT'
repositories {
mavenCentral()
}
dependencies {
testCompile group: 'junit', name: 'junit', version: '4.12'
compile group: 'org.projectlombok', name: 'lombok', version: '1.18.10'
annotationProcessor "org.projectlombok:lombok:1.18.10"
}

Related

JavaFx build problem "Main class not found"

I need to create an executable file for my program (.exe). However when running the executable I get the message com / abstudio / printersreports / Launcher not found -Failed to launch JVM. Program works in IDE
My gradle file
plugins {
id 'java'
id 'application'
id 'idea'
}
sourceCompatibility = JavaVersion.VERSION_1_8
group 'org.example'
version '1.0-SNAPSHOT'
repositories {
mavenCentral()
}
jar {
manifest {
attributes(
'Main-Class': 'com.abstudio.printersreports.Launcher'
)
}
}
sourceSets.main {
java {
srcDir 'src/main/java' //assume that your source codes are inside this path
}
resources {
srcDirs = ['src/main/java', 'src/main/resources']
exclude "**/*.java"
}
}
compileJava.options.encoding = 'UTF-8'
tasks.withType(JavaCompile) {
options.encoding = 'UTF-8'
}
dependencies {
testCompile group: 'junit', name: 'junit', version: '4.12'
// https://mvnrepository.com/artifact/com.jfoenix/jfoenix
implementation group: 'com.jfoenix', name: 'jfoenix', version: '8.0.10'
compile 'com.jfoenix:jfoenix:8.0.10'
compile group: 'de.jensd', name: 'fontawesomefx', version: '8.1'
// https://mvnrepository.com/artifact/mysql/mysql-connector-java
compile group: 'mysql', name: 'mysql-connector-java', version: '8.0.22'
// https://mvnrepository.com/artifact/com.itextpdf/itextpdf
compile group: 'com.itextpdf', name: 'itextpdf', version: '5.5.13.2'
compile group: 'org.apache.derby', name: 'derby', version: '10.14.1.0'
// https://mvnrepository.com/artifact/org.controlsfx/controlsfx
compile group: 'org.controlsfx', name: 'controlsfx', version: '8.40.18'
compile "com.google.zxing:core:3.3.0"
compile 'com.google.zxing:javase:3.3.0'
}
mainClassName = 'com.abstudio.printersreports.Launcher'
Artifacts looks like this

Syntax Error in query Hibernate OGM 5.4.1 final when jar but running from eclipse, working fine build jar from gradle

When I hit the API from postman, Data needs to be fetched from Mongodb but it's not able to fetch the records from mongodb via hibernate ogm since it's showing error as syntax error in query hibenrateExpection via jar file. but when I try to run it in eclipse, it's able to fetch the records from mongodb. Could someone experienced this issue?
plugins {
id 'org.springframework.boot' version '2.2.6.RELEASE'
id 'io.spring.dependency-management' version '1.0.9.RELEASE'
id 'java'
}
apply plugin: 'java'
apply plugin: 'eclipse'
group = 'com.local.java.programs'
version = '0.0.1'
sourceCompatibility = '11'
configurations {
compileOnly {
extendsFrom annotationProcessor
}
all {
exclude group: 'org.springframework.boot', module: 'spring-boot-starter-logging'
}
}
repositories {
mavenCentral()
}
dependencies {
implementation 'org.springframework.boot:spring-boot-starter-actuator'
// implementation 'org.springframework.boot:spring-boot-starter-data-mongodb-reactive'
implementation 'org.springframework.boot:spring-boot-starter-web'
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'
// https://mvnrepository.com/artifact/org.hibernate.ogm/hibernate-ogm-mongodb
compile group: 'org.hibernate.ogm', name: 'hibernate-ogm-mongodb', version: '5.4.1.Final'
// https://mvnrepository.com/artifact/org.hibernate/hibernate-core
compile group: 'org.hibernate', name: 'hibernate-core', version: '5.3.16.Final'
compile('org.springframework.boot:spring-boot-starter-log4j2')
compile'org.springframework.boot:spring-boot-starter-data-mongodb'
compile 'org.springframework.boot:spring-boot-starter-security'
compile 'org.springframework.boot:spring-boot-starter-mail'
// https://mvnrepository.com/artifact/io.jsonwebtoken/jjwt
compile group: 'io.jsonwebtoken', name: 'jjwt', version: '0.9.1'
// https://mvnrepository.com/artifact/javax.xml.bind/jaxb-api
compile group: 'javax.xml.bind', name: 'jaxb-api', version: '2.3.1'
// https://mvnrepository.com/artifact/org.springframework/spring-webflux
compile group: 'org.springframework', name: 'spring-webflux'
// https://mvnrepository.com/artifact/org.apache.httpcomponents/httpclient
compile group: 'org.apache.httpcomponents', name: 'httpclient', version: '4.5.12'
// https://mvnrepository.com/artifact/io.projectreactor/reactor-test
testCompile group: 'io.projectreactor', name: 'reactor-test', version: '3.3.5.RELEASE'
// https://mvnrepository.com/artifact/org.json/json
compile group: 'org.json', name: 'json', version: '20200518'
}
test {
useJUnitPlatform()
}

Spring cloud starter config dependency causes ApplicationContextException

I'm trying to add the spring-cloud-starter-config dependency to my project (I've already got the spring configuration server itself up and running).
When I add the compile('org.springframework.cloud:spring-cloud-starter-config') dependency to my build.gradle file my application won't start anymore; instead it throws:
project_name | org.springframework.context.ApplicationContextException: Unable to start embedded container; nested exception is org.springframework.context.ApplicationContextException: Unable to start EmbeddedWebApplicationContext due to missing EmbeddedServletContainerFactory bean.
project_name | at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.onRefresh(EmbeddedWebApplicationContext.java:137)
project_name | at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:537)
project_name | at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:122)
It's running inside a docker container, the docker file is as follows:
FROM openjdk:8-jdk-alpine
ARG JAR_FILE
ADD ${JAR_FILE} /project-name.jar
ARG PROPS
ADD ${PROPS} /application.properties
# Expose web port
EXPOSE 8090
# Remote debugging port for intelliJ == address
EXPOSE 50505
ENTRYPOINT [ "java", "-Xrunjdwp:transport=dt_socket,address=50505,suspend=n,server=y", "-jar", \
"/project-name.jar", "--spring.config.location=file:/project-name/application.properties"]
And the build.gradle:
buildscript {
ext {
springBootVersion = '1.5.12.RELEASE'
}
repositories {
mavenCentral()
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
classpath 'org.owasp:dependency-check-gradle:3.3.1'
}
}
plugins {
id 'de.aaschmid.cpd' version '1.1'
id "com.github.johnrengelman.shadow" version "2.0.3"
}
group 'groupname'
apply plugin: 'java'
apply plugin: 'jacoco'
apply plugin: 'checkstyle'
apply plugin: 'pmd'
apply plugin: 'findbugs'
apply plugin: 'cpd'
apply plugin: 'org.springframework.boot'
apply plugin: 'io.spring.dependency-management'
apply plugin: 'com.github.johnrengelman.shadow'
apply plugin: 'org.owasp.dependencycheck'
sourceCompatibility = 1.8
repositories {
jcenter()
mavenCentral()
}
dependencies {
//compile('org.springframework.boot:spring-boot-starter')
compile("org.springframework.boot:spring-boot-starter-web")
compile('org.springframework.cloud:spring-cloud-starter-config')
compile 'org.elasticsearch.client:elasticsearch-rest-high-level-client:5.6.8'
compile 'org.elasticsearch:elasticsearch:5.6.8'
compile 'org.elasticsearch:elasticsearch:5.6.8:javadoc'
compile 'org.elasticsearch.client:elasticsearch-rest-high-level-client:5.6.8:javadoc'
compile 'org.elasticsearch.client:elasticsearch-rest-high-level-client:5.6.8:sources'
// https://mvnrepository.com/artifact/com.google.code.gson/gson
compile group: 'com.google.code.gson', name: 'gson', version: '2.8.5'
// https://mvnrepository.com/artifact/org.apache.httpcomponents/httpcore-nio
compile group: 'org.apache.httpcomponents', name: 'httpcore-nio', version: '4.4.9'
// https://mvnrepository.com/artifact/javax.validation/validation-api
compile group: 'javax.validation', name: 'validation-api', version: '2.0.1.Final'
// https://mvnrepository.com/artifact/org.hibernate.validator/hibernate-validator
compile group: 'org.hibernate.validator', name: 'hibernate-validator', version: '6.0.9.Final'
// https://mvnrepository.com/artifact/commons-io/commons-io
compile group: 'commons-io', name: 'commons-io', version: '2.6'
// https://mvnrepository.com/artifact/commons-configuration/commons-configuration
compile group: 'commons-configuration', name: 'commons-configuration', version: '1.10'
// https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-configuration-processor
compile group: 'org.springframework.boot', name: 'spring-boot-configuration-processor', version: '1.5.12.RELEASE'
testCompile('org.springframework.boot:spring-boot-starter-test')
// https://mvnrepository.com/artifact/org.mockito/mockito-all
testCompile group: 'org.mockito', name: 'mockito-all', version: '1.10.19'
testCompile group: 'junit', name: 'junit', version: '4.12'
// testCompile 'info.cukes:gherkin:2.12.2'
}
dependencyManagement {
imports {
mavenBom "org.springframework.cloud:spring-cloud-dependencies:Edgware.SR4"
}
}
repositories {
maven {
url 'https://repo.spring.io/libs-milestone'
}
maven {
url 'https://repo.spring.io/libs-snapshot'
}
}
jar {
manifest {
attributes(
'Main-Class': 'com.altran.project.MainApplication'
)
}
}
shadowJar {
// make more dynamic?
baseName = 'project-name'
archiveName = "${baseName}-${version}.${extension}"
}
Any ideas why this spring-cloud dependency causes this issue?

Idea debug or run

When I try to run the gradle project from Idea I've an error
FAILURE: Build failed with an exception.
What went wrong: Task 'run Application' not found in root project 'app-search'.
Try: Run gradle tasks to get a list of available tasks. Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. CREATE IMAGE BUILD FAILED
Total time: 0.153 secs Task 'run SearchApplication' not found in root
project 'app-search'.
Please how to solve it.?
This is the main part of my build.gradle
apply plugin: 'application'
apply plugin: 'java'
apply plugin: 'docker'
apply plugin: 'com.github.johnrengelman.shadow'
sourceCompatibility = 1.8
ext {
dropwizardVersion = '1.1.2'
mainClass = "com.jobservice.search.AppLauncher"
mapstructVersion = '1.1.0.Final'
}
mainClassName = mainClass
repositories {
mavenLocal()
jcenter()
mavenCentral()
}
buildscript {
repositories { jcenter() }
dependencies {
classpath 'se.transmode.gradle:gradle-docker:1.2'
classpath 'com.github.jengelman.gradle.plugins:shadow:1.2.4'
}
}
// add logging into test stream
test {
testLogging.showStandardStreams = true
}
dependencies {
compile group: 'org.bouncycastle', name: 'bcprov-jdk16', version: '1.46'
compile group: 'ch.qos.logback', name: 'logback-classic', version: '1.2.1'
compile group: 'org.slf4j', name: 'slf4j-ext', version: '1.7.25'
compile group: 'org.slf4j', name: 'slf4j-simple', version: '1.7.25'
compile 'com.google.inject:guice:3.0'
compile group: 'io.swagger', name: 'swagger-jersey2-jaxrs', version: '1.5.15'
compile group: 'io.swagger', name: 'swagger-annotations', version: '1.5.15'
compile group: 'com.hubspot.dropwizard', name: 'dropwizard-guice', version: '1.0.6.0'
compile group: 'org.liquibase', name: 'liquibase-core', version: '3.5.3'
compile (
'io.dropwizard:dropwizard-core:' + dropwizardVersion,
'io.dropwizard:dropwizard-hibernate:' + dropwizardVersion,
'org.postgresql:postgresql:9.4.1208.jre7',
'io.dropwizard:dropwizard-testing:' + dropwizardVersion
)
compile 'org.mapstruct:mapstruct-jdk8:' + mapstructVersion
compile group: 'org.apache.commons', name: 'commons-collections4', version: '4.1'
testCompile group: 'junit', name: 'junit', version: '4.12'
testCompile group: 'org.hamcrest', name: 'hamcrest-junit', version: '2.0.0.0'
testCompile 'org.mockito:mockito-core:2.0.54-beta'
testCompile group: 'com.h2database', name: 'h2', version: '1.4.194'
testCompile('org.glassfish.jersey.test-framework.providers:jersey-test-framework-provider-grizzly2:2.23.2') {
exclude group: 'javax.servlet', module: 'javax.servlet-api'
exclude group: 'junit', module: 'junit'
}
}
// Configure the shadow jar task
shadowJar {
classifier = 'dist'
baseName = 'jobs-search'
version = "1.0"
mergeServiceFiles()
manifest {
attributes 'Main-Class': mainClassName
}
version = ''
}
jar {
manifest {
attributes 'Main-Class': mainClassName
}
}

Caused by: java.lang.ClassNotFoundException: org.springframework.http.converter.xml.MappingJackson2XmlHttpMessageConverter

I am using spring Boot.I created Spring boot gradle application.I got following error.
Caused by: java.lang.ClassNotFoundException: org.springframework.http.converter.xml.MappingJackson2XmlHttpMessageConverter
build.gradle
buildscript {
ext {
springBootVersion = '1.3.2.RELEASE'
}
repositories {
mavenCentral()
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:1.3.2.RELEASE")
}
}
apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'spring-boot'
jar {
baseName = 'demo'
version = '0.0.1-SNAPSHOT'
}
sourceCompatibility = 1.7
targetCompatibility = 1.7
repositories {
mavenCentral()
}
dependencies {
compile('org.springframework.boot:spring-boot-starter-data-mongodb')
testCompile('org.springframework.boot:spring-boot-starter-test')
compile group: 'org.springframework', name: 'spring-web', version: '4.0.0.RELEASE'
compile group: 'org.codehaus.jackson', name: 'jackson-mapper-asl', version: '1.9.12'
compile group: 'org.codehaus.jackson', name: 'jackson-core-asl', version: '1.9.12'
compile group: 'com.fasterxml.jackson.core', name: 'jackson-core', version: '2.2.2'
compile group: 'com.fasterxml.jackson.core', name: 'jackson-databind', version: '2.2.2'
compile group: 'com.fasterxml.jackson.core', name: 'jackson-annotations', version: '2.2.2'
}
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.7'
}
}
task wrapper(type: Wrapper) {
gradleVersion = '2.9'
}
Am I missing any dependency in build.gradle?
How to solve this?
You are including two different versions of the jackson lib. For Spring 4+ use the com.fasterxml.jackson.core like you have. Remove the two org.codehaus.jackson dependencies.

Categories

Resources