Win a copy of Head First Android this week in the Android forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Rob Spoor
  • Bear Bibeault
Saloon Keepers:
  • Jesse Silverman
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • Al Hobbs
  • salvin francis

Gradle not satisfied with anything

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I posted about this issue already here: https://discuss.gradle.org/t/gradle-not-satisfied-with-anything/33825
I need quick support, but nobody even gave a hint over there, so I am trying out my luck here. I hope somebody can help me with this urgent issue.
Content of the original post:

I am trying to build a Docker image and try to use provided Gradle to build content.
Building with Gradle 4.4 fails with
```
exec /usr/local/openjdk-8/bin/java -Dorg.gradle.appname=gradlew -classpath /path/to/gradle-wrapper.jar org.gradle.wrapper.GradleWrapperMain wrapper                                                                                                            
Error: Could not find or load main class org.gradle.wrapper.GradleWrapperMain
```
This happens every single time I try to build with the already included `gradlew` and `gradle-wrapper.jar`.
After trying every fix out there provided on the internet and still failing I downloaded Gradle 4.4 manually, changed `gradlew` to use this one instead, just to be extra sure that the provided jar is not faulty. Then this happens:
```
exec /usr/local/openjdk-8/bin/java -Dorg.gradle.appname=gradlew -classpath /path/to/gradle-wrapper.jar org.gradle.wrapper.GradleWrapperMain wrapper      
Exception in thread "main" java.lang.NoClassDefFoundError: org/gradle/cli/CommandLineParser                                                
       at org.gradle.wrapper.GradleWrapperMain.main(GradleWrapperMain.java:41)                                                            
Caused by: java.lang.ClassNotFoundException: org.gradle.cli.CommandLineParser                                                              
       at java.net.URLClassLoader.findClass(URLClassLoader.java:382)                                                                      
       at java.lang.ClassLoader.loadClass(ClassLoader.java:418)                                                                          
       at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:352)                                                                  
       at java.lang.ClassLoader.loadClass(ClassLoader.java:351)                                                                          
       ... 1 more        
```
The specific part of the Dockerfile that is involved in the problem. The error occurs on the last line seen in this snippet:
```
...

FROM openjdk:8 as apps
COPY settings.gradle /src/settings.gradle
COPY shared /src/shared/
COPY login /src/login/
RUN cd /src/login; ./gradlew installDist;

...
```

The only two relevant lines in the aforeseen `settings.gradle` are here:
```
include ':shared'
project(':shared').projectDir = new File(settingsDir, './shared')

...

include 'login'
```
This is the `build.gradle` in the _shared_ folder:
```
apply plugin: 'java'
apply plugin: 'idea'
apply plugin: 'kotlin'

sourceCompatibility = 1.8
version = 0.1

repositories {
   jcenter()
}

dependencies {
   compile "org.jetbrains.kotlin:kotlin-stdlib-jre8:$kotlin_version"

   compile 'org.slf4j:slf4j-api:1.7.7'
   compile 'org.mongodb:mongodb-driver:3.0.2'
   compile 'org.mongodb.morphia:morphia:1.0.0'
   compile 'org.apache.commons:commons-email:1.4'
   compile 'org.apache.httpcomponents:httpclient-osgi:4.5'
   compile 'commons-lang:commons-lang:2.6'
   compile 'commons-net:commons-net:3.3'
   compile 'commons-io:commons-io:2.4'
   compile 'com.google.inject:guice:4.0'
   compile 'com.spotify:docker-client:3.3.5'
   compile 'joda-time:joda-time:2.8.2'

   /**
    * ==== There are some transitive dependencies issues between master, minion and shared ====
    * Update 2019-07-15: master now declares its own dependcy on jackson and excludes the
    * one provided by :shared
    */

   // minon requires 2.6.x
   compile 'com.fasterxml.jackson.core:jackson-databind:2.6.0'
   compile "com.fasterxml.jackson.module:jackson-module-kotlin:2.6.7"
}

buildscript {
   ext.kotlin_version = '1.2.41'
   repositories {
       mavenCentral()
   }
   dependencies {
       classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
   }
}

sourceSets {
   main.java.srcDirs += 'src/main/kotlin'
}
I am trying to build a Docker image and try to use provided Gradle to build content.
Building with Gradle 4.4 fails with
```
exec /usr/local/openjdk-8/bin/java -Dorg.gradle.appname=gradlew -classpath /path/to/gradle-wrapper.jar org.gradle.wrapper.GradleWrapperMain wrapper                                                                                                            
Error: Could not find or load main class org.gradle.wrapper.GradleWrapperMain
```
This happens every single time I try to build with the already included `gradlew` and `gradle-wrapper.jar`.
After trying every fix out there provided on the internet and still failing I downloaded Gradle 4.4 manually, changed `gradlew` to use this one instead, just to be extra sure that the provided jar is not faulty. Then this happens:
```
exec /usr/local/openjdk-8/bin/java -Dorg.gradle.appname=gradlew -classpath /path/to/gradle-wrapper.jar org.gradle.wrapper.GradleWrapperMain wrapper      
Exception in thread "main" java.lang.NoClassDefFoundError: org/gradle/cli/CommandLineParser                                                
       at org.gradle.wrapper.GradleWrapperMain.main(GradleWrapperMain.java:41)                                                            
Caused by: java.lang.ClassNotFoundException: org.gradle.cli.CommandLineParser                                                              
       at java.net.URLClassLoader.findClass(URLClassLoader.java:382)                                                                      
       at java.lang.ClassLoader.loadClass(ClassLoader.java:418)                                                                          
       at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:352)                                                                  
       at java.lang.ClassLoader.loadClass(ClassLoader.java:351)                                                                          
       ... 1 more        
```
The specific part of the Dockerfile that is involved in the problem. The error occurs on the last line seen in this snippet:
```
...

FROM openjdk:8 as apps
COPY settings.gradle /src/settings.gradle
COPY shared /src/shared/
COPY login /src/login/
RUN cd /src/login; ./gradlew installDist;

...
```

The only two relevant lines in the aforeseen `settings.gradle` are here:
```
include ':shared'
project(':shared').projectDir = new File(settingsDir, './shared')

...

include 'login'
```
This is the `build.gradle` in the _shared_ folder:
```
apply plugin: 'java'
apply plugin: 'idea'
apply plugin: 'kotlin'

sourceCompatibility = 1.8
version = 0.1

repositories {
   jcenter()
}

dependencies {
   compile "org.jetbrains.kotlin:kotlin-stdlib-jre8:$kotlin_version"

   compile 'org.slf4j:slf4j-api:1.7.7'
   compile 'org.mongodb:mongodb-driver:3.0.2'
   compile 'org.mongodb.morphia:morphia:1.0.0'
   compile 'org.apache.commons:commons-email:1.4'
   compile 'org.apache.httpcomponents:httpclient-osgi:4.5'
   compile 'commons-lang:commons-lang:2.6'
   compile 'commons-net:commons-net:3.3'
   compile 'commons-io:commons-io:2.4'
   compile 'com.google.inject:guice:4.0'
   compile 'com.spotify:docker-client:3.3.5'
   compile 'joda-time:joda-time:2.8.2'

   /**
    * ==== There are some transitive dependencies issues between master, minion and shared ====
    * Update 2019-07-15: master now declares its own dependcy on jackson and excludes the
    * one provided by :shared
    */

   // minon requires 2.6.x
   compile 'com.fasterxml.jackson.core:jackson-databind:2.6.0'
   compile "com.fasterxml.jackson.module:jackson-module-kotlin:2.6.7"
}

buildscript {
   ext.kotlin_version = '1.2.41'
   repositories {
       mavenCentral()
   }
   dependencies {
       classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
   }
}

sourceSets {
   main.java.srcDirs += 'src/main/kotlin'
}
```
This is the `build.gradle` in the _login_ folder:
```
buildscript {
   ext.kotlin_version = '1.2.41'

   repositories {
       mavenCentral()
   }
   dependencies {
       classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
   }
}

group 'group.group'
version '1.0'

apply plugin: 'java'
apply plugin: 'kotlin'
apply plugin: 'application'

sourceCompatibility = 1.8

repositories {
   mavenCentral()
   jcenter()
}

mainClassName = "nonexistent"

dependencies {
   compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"

   compileOnly 'org.apache.httpcomponents:httpclient:4.3.6'
   compileOnly 'javax.servlet:javax.servlet-api:3.1.0'
   compileOnly files("libs/abcam.jar")

   testCompile group: 'junit', name: 'junit', version: '4.12'
}

compileKotlin {
   kotlinOptions.jvmTarget = "1.8"
}
compileTestKotlin {
   kotlinOptions.jvmTarget = "1.8"
}
```

Before you answer, please note:
* The gradle-wrapper.jar is **definitely** checked out in the VCS and I downloaded one manually, anyway.
* Before I tried to build the image, **it has already been working in the past**. Yet, it suddenly does not, anymore.
* `./gradlew jar` or any of the other proposed fixes did not work or even change anything noticably.
 
reply
    Bookmark Topic Watch Topic
  • New Topic