Where are gradle tasks defined - gradlew

I have a gradle project.
When I type "gradlew tasks" i see a bunch of tasks.
Where are these tasks? How do i see where they are defined?

gradle help --task <taskname>
Will give you information about a given task.

Related

How do I separate gradle unit tests from integration tests in the same source set?

The problem is that we are an IntelliJ shop and this issue has been a thorn in our sides. It basically means that everything has to be in ./test/ in order to work. ./it/ isn't acceptable because IntelliJ picks it up as the wrong kind of source every time you try to do anything. So.... how do I separate integration tests from unit tests so that they can be run separately in Gradle if they are in the same source set? Anyone have an example?
We use the *Test*.java and *ITCase*.java naming conventions, if that helps. Anothing thing we were thinking of is some kind of use of JUnit's #Category annotation.
P.S. Please vote for this issue. It will be a thorn in the side of any IntelliJ shop considering Gradle that has integration tests in a different directory from unit tests.
I can't speak to IntelliJ configuration, but in build.gradle, if you have:
test {
if (! project.hasProperty("ITCASE")) {
exclude "**/*ITCase*"
}
}
then the following command-line would include the integration tests:
gradle test -PITCASE=true
then and the standard would exclude them:
gradle test

gradle test phases?

Is there a way to build custom test phases in gradle?
I have a series of tests, namely
/unit
/local
/remote
which is running JUnit managed tests for a couple different purposes. I'd love to be able to run these as test phases, such as gradle test:unit, or something like that. Ideally, I could also specify a description for each test phase, so gradle tasks describes the role of each of the tests.
Is this possible? If so, how?
I tried this:
sourceSets {
unit {
java.srcDir file('src/test/groovy/local')
resources.srcDir file('src/local/resources')
}
}
dependencies {...}
task unitTest(type: Test){
testClassesDir = sourceSets.local.output.classesDir
classpath = sourceSets.local.runtimeClasspath
}
...as copied from withIntegrationTests in the provided samples, but when I run gradle unitTest, no tests run.
You just need to add three Test tasks (testUnit, testLocal, testRemote) and configure them accordingly. (Instead of introducing testUnit, you could also reuse the test task that comes with the Java plugin.) If the sources are in different source folders, it also makes sense to add additional source sets. For the details, have a look at samples/java/withIntegrationTests in the full Gradle distribution.

Is there post-build event in IntelliJ IDEA?

Is there post-build event in IntelliJ IDEA (11 in my case) ? Oddly I couldn't find it via googling.
I want to perform binary enhancement for my OpenJPA entities before it builds output artifact.
Couldn't get enough votes to close :(
It works via Ant. Right click on the target in the Ant Panel and specify the condition (After Compilation).

Anyone had any luck integrating SQL unit tests to run with CI build tool?

Goal is to run a few queries against a database on each new build? Has anyone had any luck without having to put sql in java classes or creating entire new schemas to hold stored procs? Ideally you can include some SQLs in separate files that get run as soon as the build completes.
Might be using maven,bamboo but would love to hear any experiences/successes/difficulties that people have encountered.
You don't say what tools you use for writing you SQL unit tests. If you're using Steven Feuerstein's utplsql tool you should read this artcle on Continuous Integration with Oracle PL/SQL, utPLSQL and Hudson. And even if you're not it might provide some useful insights.
Maybe Team City (Jetbrains) is what you're looking for. It has various build runners, including but not limited to Ant, MS Build, NUnit, Maven and Command Line.
Just configure a TC-project to listen to your svn/git/hg repository for changes, then run a build: first compilation and if successful then Maven (or whatever). Or which-ever way you want to do it.
/mikkel

Maven make phase conditional

I want to make some phases optional say if compile fails or test fails and complete other phases like checkstyle, findbugs. Can i do that in maven, i have done it in ant not sure how to go about in maven
Maven has no means to dynamically add or remove goals or lifecycle phases. Yes, you could probably achieve functionality like that by writing a plugin and using the <extension> mechanism, but you would be breaking standard conventions.
But all plugins you talk about have parameters you can set to not fail the build:
compiler:compile has the failOnError parameter
surefire:test has the testFailureIgnore parameter
findbugs:check has the failOnError parameter
checkstyle:check has the failsOnError parameter
My suggestion would be to have a profile where you add configurations with all of these parameters, so you can toggle all of them with a single command.
You will probably need to write your own small plugin for Maven in order to handle this. You may want to see this thread:
http://www.mail-archive.com/users#maven.apache.org/msg95552.html
Maven encourage you to play with "goal-to-phase assignments", instead of explicit instructions about when to run what. Maven lifecycle is your roadmap, which you can't change. And on every milestone (phase) in this roadmap you can do certain operations (goals). In other words, you have to forget Ant and start using Maven :)