问题
a newb question here: I have a build.gradle file with apply plugin: java
in it, and associated with a java project/package. when I run gradle build
from the command line I get:
: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.312 secs
but when I check the build folder, there are no classes. What am I doing wrong ?
I have: lib, reports, test-results & tmp under the folder but no classes. The src code is a class with a main method with 'Hello world' printed to console...
My tree looks like this:
.
├── build
│ ├── libs
│ │ └── gradle-sandbox.jar
│ ├── reports
│ │ └── tests
│ │ ├── base-style.css
│ │ ├── css3-pie-1.0beta3.htc
│ │ ├── index.html
│ │ ├── report.js
│ │ └── style.css
│ ├── test-results
│ └── tmp
│ └── jar
│ └── MANIFEST.MF
├── build.gradle
└── src
└── org
└── gradle
└── example
└── simple
├── HelloWorld.java
└── package-info.java
回答1:
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.
回答2:
I had a similar issue where all of my classes were in src/main/java but none of the classes were showing up in the jar.
Issue was I was using Groovy. Adjusting it to src/main/groovy resolved the issue.
回答3:
I had similar issue where I was already following the above hierarchy but also putted build.gradle inside the srcm/main/java/{{my project}}. Moving build.gradle to the project's root directory worked for me.
Let me know if it'll work for anyone else.
来源:https://stackoverflow.com/questions/13754199/gradle-1-3-build-gradle-not-building-classes