I am getting NoClassDefFoundError while running PMD task via Gradle.
I am having pmd-5.1.1.jar, commons-io-1.4.jar as well as all the other jars in WebContent/WEB-INF/lib directory. My java files are in the directory src\com\company\project
Gradle Build file
apply plugin: 'java'
apply plugin: 'war'
apply plugin: 'pmd'
sourceSets.main.java.srcDirs = ['src']
webAppDirName = 'WebContent'
repositories {
flatDir { dirs "WebContent/WEB-INF/lib" }
}
dependencies {
providedCompile fileTree(dir: "WebContent/WEB-INF/lib", include: '*.jar')
}
war {
archiveName "ROOT.war"
}
Error Log
C:\MyWorkspace\MyProject>gradle build
:compileJava UP-TO-DATE
:processResources UP-TO-DATE
:classes UP-TO-DATE
:war UP-TO-DATE
:assemble UP-TO-DATE
:pmdMain FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':pmdMain'.
> java.lang.NoClassDefFoundError: org/apache/commons/io/IOUtils
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug
option to get more log output.
BUILD FAILED
Total time: 5.275 secs
This is the first time I am trying Gradle. I am able to build as well as generate WAR but PMD is failing me. Can someone please tell me what am I doing wrong? Thanks in advance :)
I know that You've already found the answer but FYI I'm adding solution to the problem.
Basically You have non standard project structure. First of all, web content should be placed under src/main/webapp (sources under src/main/java and so on). Secondly You should not put diagnostics tools (pmd) under WEB-INF/lib. There's no need to have this jars deployed along with the whole application to the application server.
There was also no declaration of maven repo, so the dependencies could not be resolved (commons-io, asm, jaxen, etc.) and the were missing dependencies under pmd classpath (commons-io, etc.) - note the pmd scope in dependencies block.
Here you can find two projects - with standard and non-standard project layout. Both are configured correctly.
At last found the issue. I needed to resolve pmd and all it's transitive dependencies from a remote repo like Maven Central.
repositories {
mavenCentral()
}
pmd {
toolVersion = "5.1.1"
ignoreFailures = true
}
Related
everytime that I try to use LibGDX and netbeans I am struggling to just to get started.
create class
class created
I am not sure if the photos are going to be visible since I just created my account and my reputation is low but let me explain myself in case they will not.
So I created another project using LibGDX this is the result I got:
Executing 'C:\.....\ProTest/gradlew.bat clean --no-daemon' To honour
> the JVM settings for this build a new JVM will be forked. Please
> consider using the daemon:
> https://docs.gradle.org/6.7.1/userguide/gradle_daemon.html. Daemon
> will be stopped at the end of the build stopping after processing
> > Task :android:clean UP-TO-DATE
> > Task :core:clean UP-TO-DATE
> > Task :desktop:clean UP-TO-DATE
> > Task :html:clean
> > Task :ios:clean UP-TO-DATE Warning: Failed to parse host SSTap Warning: Failed to parse host SSTap Deprecated Gradle features were
> used in this build, making it incompatible with Gradle 7.0. Use
> '--warning-mode all' to show the individual deprecation warnings. See
> https://docs.gradle.org/6.7.1/userguide/command_line_interface.html#sec:command_line_warnings
> BUILD SUCCESSFUL in 21s 5 actionable tasks: 1 executed, 4 up-to-date
> Done! To import in Eclipse: File -> Import -> Gradle -> Existing
> Gradle Project To import to Intellij IDEA: File -> Open ->
> build.gradle To import to NetBeans: File -> Open Project...
After that I opened Netbeans and Opened the project, trustgradle execution...
And I opened core, desktop and IOs without any problem from the subprojects created.
I went to the desktop project and inside has a class called "DesktopLauncher"
the code inside is
> package com.supa.testa.desktop; import
> com.badlogic.gdx.backends.lwjgl.LwjglApplication; import
> com.badlogic.gdx.backends.lwjgl.LwjglApplicationConfiguration; public
> class DesktopLauncher { public static void main (String[] arg) {
> LwjglApplicationConfiguration config = new
> LwjglApplicationConfiguration(); new LwjglApplication(new Testo (),
> config); } }
and I created a class in the path "com.supa.testa" but it was created without mentioned the package on the top, I thought that by using extends Game will be fixed somehow as I cannot find the error and even write down the package path by myself... the code for the class "Testo" now looks like this:
package com.supa.testa;
import com.badlogic.gdx.Game;
public class Testo extends Game{
#Override
public void create() {
}
}
So I cameb back to the DesktopLauncher class and tried to create a class by using the "bulb" I dont know the name (help me with that please) and another class with the same name "Testo" was created in another path but again without the package on the top and it implemented the ApplicaitonListener by itself
import com.badlogic.gdx.ApplicationListener;
public class Testo implements ApplicationListener {
public Testo() {
}
}
then I came back to DesktopLauncher did the same and I could be doing that over and over again
it will go as "Testo_1" "Testo_2" and the class will never have a package and it will never be recognized
I tried to build and clean the project from the desktop, the core, the project itself, clean, build separately
Open and closed netbeans
create different projects (this was the last one)
The last thing I have tried, I pressed "Ctrl + Space bar" after the code:
new LwjglApplication(new .....
and the classes that appear are from other projects
When I created a project with LibGDX I am having this issue randomly
But now I can't get rid of it haha
I am not sure if its related with the Daemon
And in another of the tests I did the "LwjglApplicationConfiguration" library from badlogicgames seems like did not loaded because I was unable to use, did not appear at all, even after writing it manually it will not work (same as for the packages :( )
Have a nice day :D
Reedit:
I tried to create another project the previous was using Desktop, Android, IOs and Html
I tried only with desktop and the packages are working properly
I tried with Desktop and Html and this is what I got
Generating app in C:......
Executing 'C:\........ setup\ProTestD__H/gradlew.bat clean --no-daemon'
To honour the JVM settings for this build a new JVM will be forked. Please consider using the daemon: https://docs.gradle.org/6.7.1/userguide/gradle_daemon.html.
Daemon will be stopped at the end of the build stopping after processing
FAILURE: Build failed with an exception.
* What went wrong:
A problem occurred configuring root project 'ProTestD__H'.
> Could not resolve all artifacts for configuration ':classpath'.
> Could not download commons-logging-1.1.1.jar (commons-logging:commons-logging:1.1.1)
> Could not get resource 'https://repo.maven.apache.org/maven2/commons-logging/commons-logging/1.1.1/commons-logging-1.1.1.jar'.
> Could not HEAD 'https://repo.maven.apache.org/maven2/commons-logging/commons-logging/1.1.1/commons-logging-1.1.1.jar'.
> SSTap
* 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
BUILD FAILED in 13s
Done!
To import in Eclipse: File -> Import -> Gradle -> Existing Gradle Project
To import to Intellij IDEA: File -> Open -> build.gradle
To import to NetBeans: File -> Open Project...
After that I opened the project to try to:
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.
In the Run gradle "--stacktrace":
enter image description here
enter image description here
enter image description here
enter image description here
and the code still going Im not sure if the photos will be uploaded and it is a lot so I cannot copy paste it here, I will try to past what I think is important
FAILURE: Build failed with an exception.
What went wrong: A problem occurred configuring root project 'ProTestD__H'.
Could not resolve all artifacts for configuration ':classpath'.
Could not download commons-logging-1.1.1.jar (commons-logging:commons-logging:1.1.1)
> Could not get resource 'ttps://repo.maven.apache.org/maven2/commons-logging/commons-logging/1.1.1/commons-logging-1.1.1.jar'.
> Could not HEAD 'ttps://repo.maven.apache.org/maven2/commons-logging/commons-logging/1.1.1/commons-logging-1.1.1.jar'.
> SSTap
Try: Run with --info or --debug option to get more log output. Run with --scan to get full insights.
Exception is: org.gradle.api.ProjectConfigurationException: A problem occurred configuring root project 'ProTestD__H'. at
org.gradle.configuration.project.LifecycleProjectEvaluator.wrapException(LifecycleProjectEvaluator.java:75)
Caused by:
org.gradle.api.internal.artifacts.ivyservice.DefaultLenientConfiguration$ArtifactResolveException:
Could not resolve all artifacts for configuration ':classpath'.
Caused by: org.gradle.internal.resolve.ArtifactResolveException: Could
not download commons-logging-1.1.1.jar
(commons-logging:commons-logging:1.1.1)
Caused by: org.gradle.api.resources.ResourceException: Could not get
resource
'ttps://repo.maven.apache.org/maven2/commons-logging/commons-logging/1.1.1/commons-logging-1.1.1.jar'.
Caused by:
org.gradle.internal.resource.transport.http.HttpRequestException:
Could not HEAD
'ttps://repo.maven.apache.org/maven2/commons-logging/commons-logging/1.1.1/commons-logging-1.1.1.jar'.
Caused by: java.net.UnknownHostException: SSTap
Using "--info" got:
FAILURE: Build failed with an exception.
What went wrong: A problem occurred configuring root project 'ProTestD__H'.
Could not resolve all artifacts for configuration ':classpath'.
Could not download commons-logging-1.1.1.jar (commons-logging:commons-logging:1.1.1)
> Could not get resource 'ttps://repo.maven.apache.org/maven2/commons-logging/commons-logging/1.1.1/commons-logging-1.1.1.jar'.
> Could not HEAD 'ttps://repo.maven.apache.org/maven2/commons-logging/commons-logging/1.1.1/commons-logging-1.1.1.jar'.
> SSTap
Try: Run with --stacktrace option to get the stack trace. Run with --debug option to get more log output. Run with --scan to get full insights.
Using "--scan" got this:
.\gradlew.bat --configure-on-demand -w --scan -x check
FAILURE: Build failed with an exception.
Where: Auto-applied by using --scan
What went wrong: Plugin [id: 'com.gradle.enterprise', version: '3.4.1', artifact: 'com.gradle:gradle-enterprise-gradle-plugin:3.4.1']
was not found in any of the following sources:
Gradle Core Plugins (plugin is not in 'org.gradle' namespace)
Plugin Repositories (could not resolve plugin artifact 'com.gradle:gradle-enterprise-gradle-plugin:3.4.1') Searched in the
following repositories:
Gradle Central Plugin Repository
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 ttps://help.gradle.org
BUILD FAILED in 2s
And i got this when trying to resolve and trust the project
SSTap<br/>Could not HEAD 'https://repo.maven.apache.org/maven2/commons-logging/commons-logging/1.1.1/commons-logging-1.1.1.jar'.<br/>Could not get resource 'https://repo.maven.apache.org/maven2/commons-logging/commons-logging/1.1.1/commons-logging-1.1.1.jar'.<br/>Could not download commons-logging-1.1.1.jar (commons-logging:commons-logging:1.1.1)<br/>Could not resolve all artifacts for configuration ':classpath'.<br/>A problem occurred configuring root project 'ProTestD__H'.<br/>A problem occurred configuring root project 'ProTestD__H'.<br/>Could not run build action using connection to Gradle installation 'C:\......\.gradle\wrapper\dists\gradle-6.7.1-bin\bwlcbys1h7rz3272sye1xwiv6\gradle-6.7.1'.
I also tried to follow the tutorials in LibGDX tutorials LibGDX tutorials
When trying to run the project in android by using the desktop folder
I got the "Warning: Class 'com.my.game.desktop.DesktopLauncher' not found in module 'Test'" I applied, tried to run and got:
Could not install Gradle distribution from 'https://services.gradle.org/distributions/gradle-6.7.1-bin.zip'.
This is my build.gradle
buildscript {
repositories {
mavenLocal()
mavenCentral()
gradlePluginPortal()
maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
google()
}
dependencies {
classpath 'org.wisepersist:gwt-gradle-plugin:1.0.13'
classpath 'org.gretty:gretty:3.0.2'
classpath 'com.android.tools.build:gradle:3.5.4'
classpath 'com.mobidevelop.robovm:robovm-gradle-plugin:2.3.12'
} }
allprojects {
apply plugin: "eclipse"
version = '1.0'
ext {
appName = "Kiya"
gdxVersion = '1.10.0'
roboVMVersion = '2.3.12'
box2DLightsVersion = '1.5'
ashleyVersion = '1.7.3'
aiVersion = '1.8.2'
gdxControllersVersion = '2.1.0'
}
repositories {
mavenLocal()
mavenCentral()
google()
gradlePluginPortal()
maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
maven { url "https://oss.sonatype.org/content/repositories/releases/" }
} }
project(":desktop") {
apply plugin: "java-library"
dependencies {
implementation project(":core")
api "com.badlogicgames.gdx:gdx-backend-lwjgl:$gdxVersion"
api "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-desktop"
api "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-desktop"
} }
project(":android") {
apply plugin: "com.android.application"
configurations { natives }
dependencies {
implementation project(":core")
api "com.badlogicgames.gdx:gdx-backend-android:$gdxVersion"
natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-armeabi-v7a"
natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-arm64-v8a"
natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-x86"
natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-x86_64"
api "com.badlogicgames.gdx:gdx-box2d:$gdxVersion"
natives "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-armeabi-v7a"
natives "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-arm64-v8a"
natives "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-x86"
natives "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-x86_64"
} }
project(":ios") {
apply plugin: "java-library"
apply plugin: "robovm"
dependencies {
implementation project(":core")
api "com.mobidevelop.robovm:robovm-rt:$roboVMVersion"
api "com.mobidevelop.robovm:robovm-cocoatouch:$roboVMVersion"
api "com.badlogicgames.gdx:gdx-backend-robovm:$gdxVersion"
api "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-ios"
api "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-ios"
} }
project(":html") {
apply plugin: "java-library"
apply plugin: "gwt"
apply plugin: "war"
apply plugin: "org.gretty"
dependencies {
implementation project(":core")
api "com.badlogicgames.gdx:gdx-backend-gwt:$gdxVersion"
api "com.badlogicgames.gdx:gdx:$gdxVersion:sources"
api "com.badlogicgames.gdx:gdx-backend-gwt:$gdxVersion:sources"
api "com.badlogicgames.gdx:gdx-box2d:$gdxVersion:sources"
api "com.badlogicgames.gdx:gdx-box2d-gwt:$gdxVersion:sources"
} }
project(":core") {
apply plugin: "java-library"
dependencies {
api "com.badlogicgames.gdx:gdx:$gdxVersion"
api "com.badlogicgames.gdx:gdx-box2d:$gdxVersion"
} }
Not sure if I understood the question correctly, but if your problem is, that the DesctopLauncher doesn't know the class Testo you just need to import it: import com.supa.testa.Testo
Also you should place your Game classes (and packages) like Testo in the core project, since it will be used in all projects (desctop and ios).
You should have a look at the libGDX tutorials.
Especially Setup and Hello World should contain what you are searching for.
I have this other post... Removing the proxy and host from Netbeans I just fixed it.... and even tho the packages are stillnot visible in core or desktop project, if I create a class in core and put some code in it and run it from Desktoplauncher it works even tho it shows an error cannot find symbol(class), but the projects runs perfectly... for now O_O
The classes are still created without package and if the package is created(typed) by myself it shows error but now it works. Even if it is a project that uses ScreenAdapter
This is what I did....
I went into my gradle.properties file found in C:\Users\User. gradle inside looks like this:
## For more details on how to configure your build environment visit
# http://www.gradle.org/docs/current/userguide/build_environment.html
#
# Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings.
# Default value: -Xmx1024m -XX:MaxPermSize=256m
# org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
#
# When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. More details, visit
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
# org.gradle.parallel=true
#Sat Dec 25 18:51:22 CST 2021
systemProp.http.proxyHost=SSTap
systemProp.https.proxyHost=SSTap
systemProp.https.proxyPort=25378
systemProp.http.proxyPort=25378
systemProp.https.nonProxyHosts=127.0.0.1
systemProp.http.nonProxyHosts=127.0.0.1
I removed the last 6 rows,created a new project using Desktop, Android, IOs, HTML in LibGDX , trusted all the projects with gradle, classes have no packages when created, if I create them or import them by myself (in desktop project). And even if it says "cannot find symbol"(class) within the core path e.g. import com.pokedemon.game.Hello; the code runs
Overview
There is an issue when attempting to migrate a Kotlin AppEngine project from an old MacBook Pro (MBP) to a new MBP, when running the Main method and building a .jar file locally.
The Main method in IntelliJ fails intermittently on the new MBP. The old .jar runs as expected on the new MBP, and the new .jar runs as expected on the old MBP.
Expected
Run existing local .jar file from Kotlin project on the old MBP.
Clone Kotlin project from GitHub repository into local IntelliJ project on new MBP.
Build .jar on new MBP.
Run .jar on new MBP.
Host .jar on Google AppEngine instance.
Observed
Running .jar on existing MBP works as expected.
Running main method with the same code runs intermittently on the new MBP after the GitHub repo is cloned locally.
Error
The Main method runs on the old MBP as expected, but not on the new MBP with the following error.
Exception in thread "Timer-0" com.google.cloud.storage.StorageException: 401 Unauthorized
at com.google.cloud.storage.spi.v1.HttpStorageRpc.translate(HttpStorageRpc.java:229)
at com.google.cloud.storage.spi.v1.HttpStorageRpc.create(HttpStorageRpc.java:310)
at com.google.cloud.storage.StorageImpl$3.call(StorageImpl.java:196)
at com.google.cloud.storage.StorageImpl$3.call(StorageImpl.java:193)
at com.google.api.gax.retrying.DirectRetryingExecutor.submit(DirectRetryingExecutor.java:105)
at com.google.cloud.RetryHelper.run(RetryHelper.java:76)
at com.google.cloud.RetryHelper.runWithRetries(RetryHelper.java:50)
at com.google.cloud.storage.StorageImpl.internalCreate(StorageImpl.java:192)
at com.google.cloud.storage.StorageImpl.create(StorageImpl.java:154)
at content.SaveContentKt.saveContent(SaveContent.kt:38)
at content.ContentTasks.generateContent(ContentTasks.kt:55)
at content.ContentTasks.run(ContentTasks.kt:41)
at java.base/java.util.TimerThread.mainLoop(Timer.java:556)
at java.base/java.util.TimerThread.run(Timer.java:506)
Caused by: com.google.api.client.googleapis.json.GoogleJsonResponseException: 401 Unauthorized
at com.google.api.client.googleapis.json.GoogleJsonResponseException.from(GoogleJsonResponseException.java:150)
at com.google.api.client.googleapis.services.json.AbstractGoogleJsonClientRequest.newExceptionOnError(AbstractGoogleJsonClientRequest.java:113)
at com.google.api.client.googleapis.services.json.AbstractGoogleJsonClientRequest.newExceptionOnError(AbstractGoogleJsonClientRequest.java:40)
at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.executeUnparsed(AbstractGoogleClientRequest.java:554)
at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.executeUnparsed(AbstractGoogleClientRequest.java:474)
at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.execute(AbstractGoogleClientRequest.java:591)
at com.google.cloud.storage.spi.v1.HttpStorageRpc.create(HttpStorageRpc.java:307)
... 12 more
Configuration
The gradle-wrapper.properties Gradle, IntelliJ Preferences Gradle JVM, Project SDK, Run/Debug Configurations JRE, and Project language level versions are the same across both machines.
Preferences > Gradle
Use Gradle from: 'gradle-wrapper.properties' file
Gradle JVM: Library/Java/JavaVirtualMachines/12.0.1
File > Project Structure... > Project
Project SDK: 12.0.1
Project language level: 11
Running .jar file: Project Structure > Project Settings > Artifacts > Add > JAR > From modules with dependencies...
Module: coinverse-media.main
Main Class: Initialization
Lastly, build artifact and run .jar file.
build.gradle
buildscript {
ext.kotlin_version = '1.3.61'
repositories {
mavenCentral()
}
dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
plugins {
id 'java'
id 'org.jetbrains.kotlin.jvm' version '1.2.51'
}
version '1.0-SNAPSHOT'
sourceCompatibility = 1.8
repositories {
mavenCentral()
}
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8"
implementation 'com.squareup.retrofit2:retrofit:2.7.0'
implementation 'com.squareup.retrofit2:converter-gson:2.7.0'
implementation 'com.squareup.retrofit2:adapter-rxjava:2.7.0'
implementation 'com.google.firebase:firebase-admin:6.12.0'
implementation 'com.google.cloud:google-cloud-storage:1.102.0'
implementation 'com.google.apis:google-api-services-youtube:v3-rev20190827-1.30.1'
}
compileKotlin {
kotlinOptions.jvmTarget = "1.8"
}
compileTestKotlin {
kotlinOptions.jvmTarget = "1.8"
}
Attempted Solutions
Invalidate Caches / Restart...: This appears to fix the issue for a few times running the Main method, then the error continues to show.
./gradlew clean build
Gradle > Reimport All Gradle Projects
Updating to the latest Gradle version.
Ensure existing MBP and new MBP are running on the same IntelliJ/Project/Run configurations.
Potentially related build dependency conflict issue: Guava Dependency Breaking Jar Built With Kotlin.
Build Data
Build scan results
Stack trace
6:09:42 PM: Executing task 'assemble'...
Task :compileKotlin UP-TO-DATE
Task :compileJava NO-SOURCE
Task :processResources NO-SOURCE
Task :classes UP-TO-DATE
Task :inspectClassesForKotlinIC UP-TO-DATE
Task :jar UP-TO-DATE
Task :assemble UP-TO-DATE
BUILD SUCCESSFUL in 75ms
3 actionable tasks: 3 up-to-date
6:09:42 PM: Task execution finished 'assemble'.
Hidden files
I have a simple project I'm trying to publish to Maven via BinTray, but have been getting an error.
I have followed a guide to publish to bintray, and appear to have BinTray all set up, as well as access to Sonatype. Signing/etc, all appears to be good.
When I run "./gradlew bintrayUpload" I get an error, but the artifacts do show up on bintray. However I get various POM errors.
adams-MBP:UsedUtil adamhammer2$ ./gradlew clean install
:clean
:compileJava
warning: [options] bootstrap class path not set in conjunction with -source 1.7
Note: /Users/adamhammer2/git/UsedUtil/src/main/java/com/mysaasa/usedutil/CallKeyGenerator.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
1 warning
:processResources UP-TO-DATE
:classes
:jar
:javadoc
:javadocJar
:sourcesJar
:install
BUILD SUCCESSFUL
Total time: 7.233 secs
adams-MBP:UsedUtil adamhammer2$ ./gradlew bintrayUpload
:compileJava UP-TO-DATE
:processResources UP-TO-DATE
:classes UP-TO-DATE
:jar UP-TO-DATE
:javadoc UP-TO-DATE
:javadocJar UP-TO-DATE
:sourcesJar UP-TO-DATE
:install
:bintrayUpload FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':bintrayUpload'.
> Could not upload to 'https://api.bintray.com/content/adamhammer/maven/used-util/0.9.1/com/mysaasa/used_util/UsedUtil/0.9.1/UsedUtil-0.9.1.pom': HTTP/1.1 400 Bad Request [message:Unable to upload files: Maven group, artifact or version defined in the pom file do not match the file path 'com/mysaasa/used_util/UsedUtil/0.9.1/UsedUtil-0.9.1.pom']
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
Total time: 12.923 secs
Github project is https://github.com/ahammer/UsedUtil
build.gradle file is
buildscript {
repositories {
mavenCentral()
jcenter()
}
dependencies {
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.4'
classpath 'com.github.dcendents:android-maven-gradle-plugin:1.3'
}
}
apply plugin: 'java'
sourceCompatibility = 1.7
repositories {
mavenCentral()
}
dependencies {
testCompile group: 'junit', name: 'junit', version: '4.+'
}
ext {
bintrayRepo = 'maven'
bintrayName = 'used-util'
publishedGroupId = 'com.mysaasa.used_util'
libraryName = 'UsedUtil'
artifact = 'usedutil'
libraryDescription = 'A Library for tracking usage in java projects'
siteUrl = 'http://ahammer.github.io/UsedUtil'
gitUrl = 'https://github.com/ahammer/UsedUtil.git'
libraryVersion = '0.9.1'
developerId = 'adamhammer'
developerName = 'Adam Hammer'
developerEmail = 'adamhammer2#gmail.com'
licenseName = 'The Apache Software License, Version 2.0'
licenseUrl = 'http://www.apache.org/licenses/LICENSE-2.0.txt'
allLicenses = ["Apache-2.0"]
}
apply from: 'https://raw.githubusercontent.com/nuuneoi/JCenter/master/installv1.gradle'
apply from: 'https://raw.githubusercontent.com/nuuneoi/JCenter/master/bintrayv1.gradle'
After publishing I get the error, however in BinTray it registers the upload. When I click add to JCenter however I get another error "- Add a POM file to the latest version of your package."
Instead of using the 3rd party script and out of date plugin, I followed the guide
here https://github.com/bintray/gradle-bintray-plugin
This generated a proper pom file and published to bintray and made my package compatible with jcenter.
For a working build.gradle, you can look at my github for the working version.
One can run gradlew dependencies to learn about dependencies of module tasks. It there a way to find transitive dependencies of buildscript dependencies?
Example:
classpath 'com.android.tools.build:gradle:1.0.0' depends directly on:
com.android.tools.build builder
com.android.tools.lint lint
net.sf.proguard proguard-gradle
tools.base project-test-lib
As can be seen on MVNRepository. But this artifacts have their own dependencies. Is there and way to find those out without manually traversing whole dependency tree?
As a clarification, the classpath I'm talking about is defined by:
buildscript {
repositories {}
dependencies { .... }
}
Beginning with Gradle 2.10 you can now get information on buildscript dependencies via
gradle buildEnvironment
With older versions you'll have to explicitly define a task of type DependencyReportTask configured with your build script configuration.
task buildscriptDependencies(type: DependencyReportTask) {
configurations = [buildscript.configurations.classpath]
}
I think you're looking for Gradle's DependencyInsightReportTask
You can use this command:
gradle dependencyInsight --dependency gradle
There is awesome tutorial by Udacity, Gradle for Android, but you can watch this video for more explanation.
I am actually using the newly released Gradle 2, but having the same issues as described in the previous post.
I am also a newb trying to follow the example given in the Spring guide (http://spring.io/guides/gs/gradle/#scratch) but after my first compile, there were no classes.
I have tried various configurations of tree structure including adding the structure and code suggested in the above thread:
"I guess the source file path is src/org/gradle/example/simple/HelloWorld.java. (The diagram shows something different.) That doesn't match Gradle's default, so you'll have to reconfigure it: sourceSets.main.java.srcDirs = ["src"] – Peter Niederwieser Dec 7 '12 at 1:23 "
adding the line: sourceSets.main.java.srcDirs = ["src"] allows the code to compile, however, I still have no classes.
Here is the successful build.
:compileJava UP-TO-DATE
:processResources UP-TO-DATE
:classes UP-TO-DATE
:jar UP-TO-DATE
:assemble UP-TO-DATE
:compileTestJava UP-TO-DATE
:processTestResources UP-TO-DATE
:testClasses UP-TO-DATE
:test UP-TO-DATE
:check UP-TO-DATE
:build UP-TO-DATE
BUILD SUCCESSFUL
Total time: 4.468 secs
Here is the build file:
apply plugin: 'java'
sourceSets.main.java.srcDirs=["src"]
repositories {
mavenLocal()
mavenCentral()
}
dependencies {
compile "joda-time:joda-time:2.2"
}
jar {
baseName = 'gs-gradle'
version = '0.1.0'
}
task wrapper(type:Wrapper) {
gradleVersion = '1.11'
}
apply plugin: 'application'
mainClassName = 'hello.HelloWorld'
Where are my classes? Please help.
After I got stuck with the same problem, I hacked around for a bit before I understood the reason for this behavior.
My project structure was like so
MyProject
- src
- main
- java
- hello
HelloWorld.java
build.gradle
The problem was that the build.gradle is supposed to be under the Project-Root folder i.e. MyProject and not under the hello folder !!!
Changed it so that my Project structure looks like below, ran the gradle build and saw that classes folder was created:
MyProject
- src
- main
- java
- hello
HelloWorld.java
build.gradle
When you think about it, the build.gradle is used to build the complete project and not just the classes within one folder and should rightfully sit under the project-root folder.