Gradle 1.3: build.gradle not building classes
Without more information, it's hard to say. Maybe you put the source file into the wrong directory (default is src/main/java
). Or the internal caches got corrupted (shouldn't happen, but try to delete the .gradle
directory).
Do you get class files when you do gradle clean build
? Note that a clean build is required whenever you switch between Gradle versions.
Followup to Gradle 1.3: build.gradle not building classes
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.
Why there is no .class file in my jar file created by gradle?
You wrote
Of course there are many .java files under /src, but created jar file does not contains .class files.
Gradle, by convention, compiles Java source files from folder src/main/java
. Make sure to either put your files in that folder (preferred) or configure Gradle to look into src
only.
Further reading: Organizing Gradle Projects
Gradle migration 3.1.4 - 3.5.1; :app module doesn't compile; ClassNotFoundException: Didn't find class on path: DexPathList
I found an issue:
One of my packages name vas cvs
- seems it is after Gradle 3.2.+ it is reserved word.
Eclipse buildship not configuring classpath from gradle - worked and then broke
Found the problem!
Gradle 7.5.x + Buildship 3.1.6 seem to be broken. When I configured Eclipse (Preferences > Gradle > Specific version) to use 7.4.2 everything worked once again.
I normally have Eclipse Gradle configured to use gradle wrapper. I had upgraded gradle wrapper from 7.4.2 to 7.5.1 from the command line a month ago. Gradle worked fine from the command line but once my dev system rebooted I ran Gradle > Refresh Gradle Project which used 7.5.1 for the first time in eclipse.
Android Test Module (Gradle Plugin 1.3) doesn't work: debug-classes not found
I was also curious about separating app code and test code and i had hard time to figure it out. I look at the stack trace and found the DependencyManager (line 238) having a TODO to fix that in gradle.
1) You are right about the build flavors.You have to enter the correct variant
targetVariant '<flavor>Debug'
e.g.
targetVariant 'flavor1Debug'
2) You also need to change you targetProjectPath's module build.gradle. Add the following snippet:
android {
// ...
publishNonDefault true
// ...
}
which publishes all build variants! It its disabled by default due to some limitations of gradle.
Spring boot 1.3.3 is not building with gradle 3.0
Make sure that the build.gradle has the "wrapper" task as below:
task wrapper(type: Wrapper) {
gradleVersion = '2.9'
}
Run the "gradle wrapper" from the command line, it would create the gradle wrappers for unix and windows. Push them to source control so that,there are no manual steps.
gradle wrapper
git add gradlew gradlew.bat gradle
git commit -m "Adding gradle wrapper to git repo"
git push
So all the future builds can be using gradlew
$ ./gradlew build
:framework:compileJava
:framework:processResources
:framework:classes
:framework:jar
:compileJava
:processResources
:classes
:findMainClass
:jar
:bootRepackage
:assemble
:compileTestJava
:processTestResources UP-TO-DATE
:testClasses
:test
:check
:build
:framework:findMainClass
:framework:bootRepackage
:framework:assemble
:framework:compileTestJava
:framework:processTestResources UP-TO-DATE
:framework:testClasses
:framework:test
:framework:check
:framework:build
BUILD SUCCESSFUL
Total time: 42.712 secs
Thanks to answer from Vampire...
Related Topics
Unix Command to Convert Xls File into Xlsx File
How Limit Memory Usage for a Single Linux Process and Not Kill The Process
Register Hotkey with Only Modifiers in Linux
How to Change The Desktop Wallpaper on Linux from Within a Shell/Bash Script
Linux Nasm Move a Value in Al Up to Ax
Sigbus While Doing Memcpy from Mmap Ed Buffer Which Is in Ram as Identified by Mincore
Determining The Independent Cpu's (Specified with Affinity Id's) for Building Atlas
How to Link a Linux's Thread Tid and a Pthread_T "Thread Id"
Autostart Javafx Application on Raspberrypi
Bash Exit Script from Inside a Function
Embedded Linux Poll() Returns Constantly
Wmctrl: Moving a Fullscreen Window
Graphics Card Memory Usage in Linux
Accessing Apache2 Residing Inside Docker Container from Host Machine Web Browser
Sending Realtime Signal from a Kernel Module to User Space Fails
List of Available Wireless Networks with Golang (Under Linux)