How can I troubleshoot when "build" task isn't running my project?

How can I troubleshoot when “build” task isn’t running my project?

I have a build.gradle file here, but I broke it and it stopped running my project. It was working at one point and now I can’t figure out why it stopped working. https://github.com/djangofan/WebDriverTestingTemplate/blob/master/build.gradle

What does the error message say?

Here is the output:


Loading build.gradle configuration...
   _____
             _ _
  / ____|
           | | |
 | |
__ _ __ __ _
__| | | ___
 | | |_ | '__/ _' |/ _' | |/ _ \
 | |__| | | | (_| | (_| | |
__/
  \_____|_|
\__,_|\__,_|_|\___|
  Build output: build\classes\main
Resources output: build\resources\main
Version: 1.0.1
Main class: qa.webdriver.tests.GoogleTest
Project Name: WebDriver On Gradle
-----------------------------------
Starting Build
Settings evaluated using empty settings script.
Projects loaded. Root project using build file 'C:\Eclipse32\workspace\WebDriverTestingTemplate\build.gradle'.
Included projects: [root project 'WebDriverTestingTemplate']
Evaluating root project 'WebDriverTestingTemplate' using build file 'C:\Eclipse32\workspace\WebDriverTestingTemplate\build.gradle'.
All projects evaluated.
Selected primary tasks 'clean', 'build'
Tasks to be executed: [task ':clean', task ':compileJava', task ':processResources', task ':classes', task ':jar', task ':assemble', task ':compileTestJava', task ':processTestReso
urces', task ':testClasses', task ':test', task ':check', task ':build']
:clean
Task ':clean' has not declared any outputs, assuming that it is out-of-date.
:compileJava
:: loading settings :: url = jar:file:/C:/Dropbox/JAVA/gradle-1.2/lib/ivy-2.2.0.jar!/org/apache/ivy/core/settings/ivysettings.xml
Executing task ':compileJava' due to:
Output file C:\Eclipse32\workspace\WebDriverTestingTemplate\build\classes\main for task ':compileJava' has changed.
Output file C:\Eclipse32\workspace\WebDriverTestingTemplate\build\dependency-cache for task ':compileJava' has changed.
Output file C:\Eclipse32\workspace\WebDriverTestingTemplate\build\classes\main\qa\webdriver\util\ExtendedUtilities.class has been removed for task ':compileJava'.
Output file C:\Eclipse32\workspace\WebDriverTestingTemplate\build\classes\main\qa\webdriver\util\UtilityClass$1.class has been removed for task ':compileJava'.
Output file C:\Eclipse32\workspace\WebDriverTestingTemplate\build\classes\main\qa\webdriver\tests\GoogleTest.class has been removed for task ':compileJava'.
Output file C:\Eclipse32\workspace\WebDriverTestingTemplate\build\classes\main\qa\webdriver\util\GoogleSearchPage$1.class has been removed for task ':compileJava'.
Output file C:\Eclipse32\workspace\WebDriverTestingTemplate\build\classes\main\qa\webdriver\util\UtilityClass.class has been removed for task ':compileJava'.
Output file C:\Eclipse32\workspace\WebDriverTestingTemplate\build\classes\main\qa\webdriver\util\GoogleSearchPage.class has been removed for task ':compileJava'.
Compiling with JDK 6 Java compiler API.
:processResources
Executing task ':processResources' due to:
Output file C:\Eclipse32\workspace\WebDriverTestingTemplate\build\resources\main for task ':processResources' has changed.
Output file C:\Eclipse32\workspace\WebDriverTestingTemplate\build\resources\main\testdata.csv has been removed for task ':processResources'.
:classes
Skipping task ':classes' as it has no actions.
:jar
Executing task ':jar' due to:
Output file C:\Eclipse32\workspace\WebDriverTestingTemplate\build\libs\WebDriverTestingTemplate.jar for task ':jar' has changed.
Output file C:\Eclipse32\workspace\WebDriverTestingTemplate\build\libs\WebDriverTestingTemplate.jar has been removed for task ':jar'.
:assemble
Skipping task ':assemble' as it has no actions.
:compileTestJava
Skipping task ':compileTestJava' as it has no source files.
:compileTestJava UP-TO-DATE
:processTestResources
Skipping task ':processTestResources' as it has no source files.
:processTestResources UP-TO-DATE
:testClasses
Skipping task ':testClasses' as it has no actions.
:testClasses UP-TO-DATE
:test
file or directory 'C:\Eclipse32\workspace\WebDriverTestingTemplate\build\classes\test', not found
Executing task ':test' due to:
Output file C:\Eclipse32\workspace\WebDriverTestingTemplate\build\reports\tests for task ':test' has changed.
Output file C:\Eclipse32\workspace\WebDriverTestingTemplate\build\test-results for task ':test' has changed.
Output file C:\Eclipse32\workspace\WebDriverTestingTemplate\build\reports\tests\index.html has been removed for task ':test'.
Output file C:\Eclipse32\workspace\WebDriverTestingTemplate\build\reports\tests\report.js has been removed for task ':test'.
Output file C:\Eclipse32\workspace\WebDriverTestingTemplate\build\reports\tests\base-style.css has been removed for task ':test'.
Output file C:\Eclipse32\workspace\WebDriverTestingTemplate\build\reports\tests\style.css has been removed for task ':test'.
Output file C:\Eclipse32\workspace\WebDriverTestingTemplate\build\reports\tests\css3-pie-1.0beta3.htc has been removed for task ':test'.
file or directory 'C:\Eclipse32\workspace\WebDriverTestingTemplate\build\classes\test', not found
:check
Skipping task ':check' as it has no actions.
:build
Skipping task ':build' as it has no actions.
  BUILD SUCCESSFUL
  Total time: 4.69 secs
Closing gradle_run.bat script

After examining, it sorta appears that Gradle is asking me to define actions for “:build” ? It worked previously, before I broke my build script, and so this is hard to believe. Even if this is true, I don’t know how to define these. Am I on the right track?

NOTE: I just noticed Gradle built a build/reports/index.html file. Very nice. :slight_smile:

I think this is a normal output that you are seeing. The ‘build’ task does not have any actions by default, its purpose is to trigger other tasks that do the actual building.

Ok, I think I have this figured out.

I placed these two lines in my project and refreshed everything and now I have a “:run” task :

apply plugin:'application'
mainClassName = "qa.webdriver.tests.GoogleTest"

I am not sure how I had it working before without these two lines, but this seems to have something to do with it I think???

I get this error , which suggests to me that I need to make a test suite class with a main method in it:

:runjava.lang.NoSuchMethodError: main
Exception in thread "main"
FAILED
  FAILURE: Build failed with an exception.
  * What went wrong:
Execution failed for task ':run'.
> Process 'command 'C:\JDK1.6.0_31_x32\bin\java.exe'' finished with non-zero exit value 1

Now, I just discovered that Gradle can’t run the typical JUnit test suite, like this, probably because it doesn’t understand the annotations and works only with a main method??

@RunWith(Suite.class)
@SuiteClasses({ GoogleTest.class })
public class AllTests {
    // nothing yet
}

And so, my final solution was to invoke via JUnit to run the test suite class like this:

//@RunWith(Suite.class)
//@SuiteClasses({ GoogleTest.class })
public class AllTests {
    public static void main(String[] args) throws Exception {
                            JUnitCore.main("qa.webdriver.tests.GoogleTest");
                }
 }

The unfortunate side effect of this is that when I run the project from Eclipse, eclipse doesn’t show me the STOP button that it normally shows me during tests.

So, my ultimate goal might be to move my JUnit test over to the Gradle “test” location and try to get gradle to generate my JUnit results at “build/reports/tests/index.html” .

I am not sure how I am going to do this but I will start experimenting.

Can anyone answer me on how this can be more nicely integrated in Eclipse?

I’ll figure it out eventually, but it will take a while.

It’s the application plugin that ‘works on a main method’, not Gradle. A JUnit test (possibly annotated) can be run only through JUnit and the way to do that with Gradle is to place this test in ‘src/test/java’ and apply the java plugin. Gradle does not scan the regular production code under ‘src/main/java’ for JUnit tests so that’s why it does not detect them. While the application plugin can be configured with a class to run - it just searches for a main method and executes this class as a java application , it does not care about any JUnit annotations.

I haven’t done it yet but I am going to move my unit tests back over to src/test/java .

My entire project is a unit test and so I put the tests in the src/main/java directory, but by doing that it forced me to write the test runner main method that calls JUnit.

I think I will be able to work this all out but still a little disappointed that the Eclipse Gradle plugin doesn’t have the ability to control (or hook into) the JUnit tab in the Eclipse IDE.

In other words, it appears that Gradle instantiates its own JUnit runner and generates a html report from those tests but does so completely separately from Eclipse and the JUnit tab in Eclipse.

Therefore, once I run the Gradle build with Eclipse, the IDE doesn’t present a stop button and I am forced to wait until it runs its course.

I’ll edit and update my project sometime during this week, hopefully getting closer to my ultimate goal of “configuring Gradle the right way”.

Below is the outpout I am getting after running my task using gradle and ide i am using is eclipse:

Starting Build Settings evaluated using empty settings script. Projects loaded. Root project using build file ‘C:\workspace\Webservicespike\bui ld.gradle’. Included projects: [root project ‘Webservicespike’] Evaluating root project ‘Webservicespike’ using build file ‘C:\workspace\Webserv icespike\build.gradle’. Starting file lock listener thread. Compiling build file ‘C:\workspace\Webservicespike\build.gradle’ using BuildScri ptClasspathScriptTransformer. Build file ‘C:\workspace\Webservicespike\build.gradle’: line 11 The RepositoryHandler.mavenRepo() method has been deprecated and is scheduled to

be removed in Gradle 2.0. Please use the maven() method instead. All projects evaluated. Selected primary task ‘webservicetest’ Tasks to be executed: [task ‘:compileJava’, task ‘:processResources’, task ‘:cla sses’, task ‘:compileTestJava’, task ‘:processTestResources’, task ':testClasses ', task ‘:webservicetest’] :compileJava (Thread[Daemon,5,main]) started. :compileJava Skipping task ‘:compileJava’ as it has no source files. :compileJava UP-TO-DATE :compileJava (Thread[Daemon,5,main]) completed. Took 0.0 secs. :processResources (Thread[Daemon,5,main]) started. :processResources Skipping task ‘:processResources’ as it has no source files. :processResources UP-TO-DATE :processResources (Thread[Daemon,5,main]) completed. Took 0.0 secs. :classes (Thread[Daemon,5,main]) started. :classes Skipping task ‘:classes’ as it has no actions. :classes UP-TO-DATE :classes (Thread[Daemon,5,main]) completed. Took 0.0 secs. :compileTestJava (Thread[Daemon,5,main]) started. :compileTestJava Skipping task ‘:compileTestJava’ as it has no source files. :compileTestJava UP-TO-DATE :compileTestJava (Thread[Daemon,5,main]) completed. Took 0.0 secs. :processTestResources (Thread[Daemon,5,main]) started. :processTestResources Skipping task ‘:processTestResources’ as it has no source files. :processTestResources UP-TO-DATE :processTestResources (Thread[Daemon,5,main]) completed. Took 0.0 secs. :testClasses (Thread[Daemon,5,main]) started. :testClasses Skipping task ‘:testClasses’ as it has no actions. :testClasses UP-TO-DATE :testClasses (Thread[Daemon,5,main]) completed. Took 0.0 secs. :webservicetest (Thread[Daemon,5,main]) started. :webservicetest file or directory ‘C:\workspace\Webservicespike\build\classes\test’, not found Skipping task ‘:webservicetest’ as it has no source files. :webservicetest UP-TO-DATE :webservicetest (Thread[Daemon,5,main]) completed. Took 0.031 secs.

BUILD SUCCESSFUL

Please let me know, why no dependencies are getting resolved?

Please create a new thread. How do you tell that no dependencies got resolved?