Classes are being created without packages in Netbeans - java

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

Related

How do I fix this error: Task 'wrapper' not found in project ':app'

All my projects report this error? Is there a setting or option I need to change to resolve this error?
app: failed At 9/30/2021 2:47 PM with 1 error
Task 'wrapper' not found in project ':app'.
Task 'wrapper' not found in project ':app'
* Try:
Run gradle tasks to get a list of available tasks.
Run with --stacktrace option to get the stack
This is because your build.gradle file doesn't have a wrapper task. Add this code to build.gradle:
task wrapper(type: Wrapper){
gradleVersion = '7.2'
}
You can replace 7.2 with the gradle version you want, then run gradle wrapper task.
maybe your project's structure is :
yourProjectDir:
--> app:
--> build.gradle
--> otherModule1:
--> otherModule2:
--> build.gradle
The correct way to open the project is :
Click build.gradle in the root directory 'yourProjectDir', not build.gradle in the 'app' dir.

react-native run-android error "Task :app:javaPreCompileDebug FAILED"

EDIT: This issue was solved by forcing the gradle not to jetify my native library. This is done by adding in gradle.properties
android.jetifier.blacklist = your-causing-issues-library
For more details you can read the official docs or this post
I need to use some native code in a react native project. The native code is provided in a .jar file by the hardware manufacturer. In a clean project (react-native init), with this .jar file inside /android/app/libs folder, this error shows as soon as I try to run "react native run-android".
==============
Error is as follow:
Task :app:javaPreCompileDebug FAILED
6 actionable tasks: 6 executed
FAILURE: Build failed with an exception.
What went wrong:
Execution failed for task ':app:javaPreCompileDebug'.
Could not resolve all files for configuration
':app:debugCompileClasspath'.
Failed to transform file 'iMagPayV5.1.4.jar' to match attributes {artifactType=android-classes, org.gradle.usage=java-runtime-jars}
Execution failed for JetifyTransform:
/home/buonapasta/Desktop/React-Native/samples/project/android/app/libs/iMagPayV5.1.4.jar.
Failed to transform '/home/buonapasta/Desktop/React-Native/samples/project/android/app/libs/iMagPayV5.1.4.jar' using Jetifier. Reason: 10. (Run with --stacktrace for more details.)
==============
Help is appreciated in advance!!
(Sorry if some information is incomplete).
React Native version 0.60.4 running on Ubuntu 18.04.
I've tried to include some other .jar files in a clean project without inconvenience, but as soon as I include this particular .jar everything blows.
Also, this library is working on an Android Studio project.
The .jar can be found on
https://github.com/GPaoloni/imagpay-framework
android/app/build.gradle looks like this:
...
dependencies {
implementation fileTree(dir: "libs", include: ["*.jar"])
implementation "com.facebook.react:react-native:+" // From node_modules
if (enableHermes) {
def hermesPath = "../../node_modules/hermesvm/android/";
debugImplementation files(hermesPath + "hermes-debug.aar")
releaseImplementation files(hermesPath + "hermes-release.aar")
} else {
implementation jscFlavor
}
}
// Run this once to be able to run the application with BUCK
// puts all compile dependencies into folder libs for BUCK to use
task copyDownloadableDepsToLibs(type: Copy) {
from configurations.compile
into 'libs'
}
android/build.gradle:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext {
buildToolsVersion = "28.0.3"
minSdkVersion = 16
compileSdkVersion = 28
targetSdkVersion = 28
supportLibVersion = "28.0.0"
}
repositories {
google()
jcenter()
}
dependencies {
classpath("com.android.tools.build:gradle:3.4.1")
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
mavenLocal()
maven {
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
url("$rootDir/../node_modules/react-native/android")
}
maven {
// Android JSC is installed from npm
url("$rootDir/../node_modules/jsc-android/dist")
}
google()
jcenter()
}
}
I just want being able to include the .jar library (to be used by a native activity).
==============
Update:
I've tried doing like sugested:
npm install --save-dev jetifier
npx jetify
But the error still the same.
Reading the npm page of jetifier, in the "Usage for jar/zip/aar files" section:
npm install jetifier
npx jetifier-standalone <your arguments here>
Runing this gives me the following error:
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 10
at org.objectweb.asm.ClassReader.readFrameType(ClassReader.java:2313)
at org.objectweb.asm.ClassReader.readFrame(ClassReader.java:2269)
at org.objectweb.asm.ClassReader.readCode(ClassReader.java:1448)
at org.objectweb.asm.ClassReader.readMethod(ClassReader.java:1126)
at org.objectweb.asm.ClassReader.accept(ClassReader.java:698)
at org.objectweb.asm.ClassReader.accept(ClassReader.java:500)
at com.android.tools.build.jetifier.processor.transform.bytecode.ByteCodeTransformer.runTransform(ByteCodeTransformer.kt:39)
at com.android.tools.build.jetifier.processor.Processor.visit(Processor.kt:443)
at com.android.tools.build.jetifier.processor.archive.ArchiveFile.accept(ArchiveFile.kt:49)
at com.android.tools.build.jetifier.processor.Processor.visit(Processor.kt:425)
at com.android.tools.build.jetifier.processor.archive.Archive.accept(Archive.kt:76)
at com.android.tools.build.jetifier.processor.Processor.transformLibrary(Processor.kt:421)
at com.android.tools.build.jetifier.processor.Processor.transform(Processor.kt:247)
at com.android.tools.build.jetifier.processor.Processor.transform$default(Processor.kt:234)
at com.android.tools.build.jetifier.standalone.Main.run(Main.kt:157)
at com.android.tools.build.jetifier.standalone.Main$Companion.main(Main.kt:109)
at com.android.tools.build.jetifier.standalone.Main.main(Main.kt)
Try executing these line by line.
1. yarn
2. yarn start
On a new terminal tab
1. react-native run-android
Check whether 'jetifier' running output is displayed on the terminal.
Something similar to this.
"Running jetifier to migrate libraries to AndroidX. You can disable it using "--no-jetifier" flag."
If not run these before executing 'react-native run-android'
1. npm install --save-dev jetifier
2. npx jetify
I am using VS Code and installed prettier and format on-save. For some reason, when I saved page, he formatted wrong and I had this error, when discarded changes, it started working well, u can try this, as prevention.

Unable to run Gradle app engine tasks

I'm really confused about converting an old Google App Engine project to Gradle.
I'm trying to follow the instructions on this page. It advises to start with this build script:
buildscript { // Configuration for building
repositories {
jcenter() // Bintray's repository - a fast Maven Central mirror & more
mavenCentral()
}
dependencies {
classpath 'com.google.cloud.tools:appengine-gradle-plugin:+' // latest App Engine Gradle tasks
}
}
repositories { // repositories for Jar's you access in your code
maven {
url 'https://maven-central.storage.googleapis.com' // Google's mirror of Maven Central
// url 'https://oss.sonatype.org/content/repositories/snapshots' // SNAPSHOT Repository (if needed)
}
jcenter()
mavenCentral()
}
apply plugin: 'java' // standard Java tasks
apply plugin: 'war' // standard Web Archive plugin
apply plugin: 'com.google.cloud.tools.appengine' // App Engine tasks
dependencies {
providedCompile group: 'javax.servlet', name: 'servlet-api', version:'2.5'
compile 'com.google.appengine:appengine:+'
// Add your dependencies here.
}
appengine { // App Engine tasks configuration
run { // local (dev_appserver) configuration (standard environments only)
port = 8080 // default
}
deploy { // deploy configuration
stopPreviousVersion = true // default - stop the current version
promote = true // default - & make this the current version
}
}
group = 'com.example.appengine' // Generated output GroupId
version = '1.0-SNAPSHOT' // Version in generated output
sourceCompatibility = 1.7 // App Engine Standard uses Java 7
targetCompatibility = 1.7 // App Engine Standard uses Java 7
However it doesn't work:
$ gradle appengineRun
FAILURE: Build failed with an exception.
* Where:
Build file '/path/to/myproject/build.gradle' line: 32
* What went wrong:
A problem occurred evaluating root project 'myproject'.
> Could not find method run() for arguments [build_c1i62diotjttavcmtjg1zqlbd$_run_closure3$_closure5#33f17289] on root project 'myproject' of type org.gradle.api.Project.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
Shouldn't the dependencies be downloaded to make the custom appengine task configuration work?
Please have a look at the sources of the plugin. When the core plugin is applied it decides whether to apply a flexible or standard appengine plugin. Since there's probably no src/main/webapp/WEB-INF/appengine-web.xml flexible plugin is applied which does not create the extension that fails (FYI, this extension is created here). To fix the problem run:
mkdir -p src/main/webapp/WEB-INF
and then:
touch src/main/webapp/WEB-INF/appengine-web.xml
in console where build.gradle is located. This will solve the problem. Poor documentation :/

Getting NoClassDefFoundError while running PMD task from Gradle

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
}

Build a project using gradle FAILURE: Build failed with an exception

I am trying to build an opensource project using gradle, but when I run the "gradle clean" command within my local repository directory the following error message appears.
FAILURE: Build failed with an exception.
Where:
Build file '/home/muhammad/OpenSource/iotsys/iotsys/build.gradle' line: 3
What went wrong:
A problem occurred evaluating root project 'iotsys'.
Plugin with id 'maven-publish' not found.
Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
my "build.gradle" file look like this
allprojects {
apply plugin: 'java'
apply plugin: 'maven-publish'
apply plugin: 'maven'
group = 'at.ac.tuwien.auto.iotsys'
version = '0.1'
sourceCompatibility = 1.6
repositories(){
mavenCentral()
mavenRepo url: 'https://repository.jboss.org/nexus/content/repositories/releases/', name: 'JBoss Releases'
mavenRepo url: 'https://repository.jboss.org/nexus/content/groups/public/', name: 'JBoss Public' }}
I am new to gradle and maven. Can any one please help me to solve this issue?
The solution is very very simple you just have to run the studio with administrator privileges..
STEPS : -
Right click on the studio icon.
Run as Administrator.
That's it Enjoy..!

Categories

Resources