7

I want to create a jar file which I can upload on AWS, but every time I run the command gradle jar from command prompt I get the following error.

> Task :compileJava FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':compileJava'.
> Compilation failed; see the compiler error output for details.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or -- 
debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

I get 'Build Successful' whenever I run gradle clean in command prompt. Here is the content of build.gradle:

buildscript {
ext {
    springBootVersion = '2.0.4.RELEASE'
}
repositories {
    mavenCentral()
    maven {
        url "https://plugins.gradle.org/m2/"
    }
}
dependencies {
    classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
    classpath "net.ltgt.gradle:gradle-apt-plugin:0.18"
}
}



apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'org.springframework.boot'
apply plugin: 'io.spring.dependency-management'
apply plugin: 'net.ltgt.apt'

group = 'com.myproject.api'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = JavaVersion.VERSION_1_8


ext {
  lombokVersion = '1.16.20'
  mapstructVersion = '1.2.0.Final'
}

repositories {
    mavenCentral()
    mavenLocal()
    jcenter()
             flatDir {
                dirs 'libs'
        }
    

}

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-mail')
    compile('org.springframework.boot:spring-boot-starter-thymeleaf')
    compile('org.springframework.data:spring-data-jpa')
    compile('io.springfox:springfox-swagger2:2.9.2')
    compile('io.springfox:springfox-swagger-ui:2.9.2')
    compile group: 'commons-io', name: 'commons-io', version: '2.6'
 
    
    compile group: 'org.json', name: 'json', version: '20180813'
    compile files('libs/checksum_2.0.0.jar')

    compileOnly("org.projectlombok:lombok:${lombokVersion}")
    compileOnly("org.mapstruct:mapstruct-jdk8:${mapstructVersion}")
    compileOnly("org.mapstruct:mapstruct-processor:${mapstructVersion}")

    runtime('org.springframework.boot:spring-boot-devtools')
    runtime('mysql:mysql-connector-java')
    testCompile('org.springframework.boot:spring-boot-starter-test')
}


eclipse {
    classpath {
        file.whenMerged { cp ->
            cp.entries.add( new org.gradle.plugins.ide.eclipse.model.SourceFolder('build/generated/source/apt/ma 
   in', null) )
        }
    }
}

Do I need to add any plugins? Thanks in advance. Please help

JJD
  • 50,076
  • 60
  • 203
  • 339
iDeveloper
  • 940
  • 1
  • 10
  • 45
  • 1
    `> Compilation failed; see the compiler error output for details.` try to locate the source of the compilation error and fix it – M.Ricciuti Jun 03 '19 at 11:12
  • @M.Ricciuti I saw the source of the error it says: "Resolving global dependency management for project 'myproject-' Excluding [org.apache.tomcat:tomcat-annotations-api, ognl:ognl] Excluding [] Caching disabled for task ':compileJava' because: Build cache is disabled Task ':compileJava' is not up-to-date because: Task has failed previously. All input files are considered out-of-date for incremental task ':compileJava'. Full recompilation is required because no incremental change information is available. This is usually caused by clean builds or changing compiler arguments" – iDeveloper Jun 03 '19 at 11:34
  • 1
    The problem is not with gradle. The problem is with your Java code. It doesn't compile. Read the compilation errors you get from the compiler and fix them. That's what **Compilation failed; see the compiler error output for details.** means. – JB Nizet Jun 04 '19 at 07:04
  • @JBNizet I am new to programming. Could you please help me find compiler error output window in spring tool suite. – iDeveloper Jun 04 '19 at 07:18

2 Answers2

13

Open task manger and force stop Java(TM) Platform SE binary and delete

C:\Users\{current user}\.gradle\caches\jars-9\jars-9.lock file

Procrastinator
  • 2,526
  • 30
  • 27
  • 36
Khalid Kbashi
  • 131
  • 1
  • 4
7

I was using gradle clean and gradle build instead of gradlew clean and gradlew build.
gradle commands worked for me.

JJD
  • 50,076
  • 60
  • 203
  • 339
iDeveloper
  • 940
  • 1
  • 10
  • 45