I've written some custom gradle scripts for running user tests, and they're running fine with a command line invocation like.
./gradlew -b custom01.gradle
Now I'm trying to figure out how to run these in Eclipse and it's a bit more complicated. When I set up a Run Configuration, it complains that the task isn't found in the project .
Any suggestions on how to run a specific gradle file from within Eclipse ?
Related
I am trying to set up a Java project in Eclipse which uses Gradle for its builds plus some self-defined Groovy code for the builds (placed - as usual - under buildSrc).
So I first created a Java project from the existing code and then additionally assigned the "Gradle nature" to the project. Since then I keep getting this error message:
Could not run phased build action using Gradle installation 'C:\opt\gradle-5.4.1'.
Execution failed for task ':buildSrc:compileGroovy'.
Compilation failed; see the compiler error output for details.
What is this message trying to tell me???
This issue was raised several times in the past. To solve it:
Delete all the files in the .gradle directory in your project and under your username, e.g.:
C:\Users\username\.gradle
Restart your computer.
Run Eclipse as administrator.
Build the project.
Finally, if you have any script which runs Gradle in addition to the installation /distribution of Gradle that Eclipse knows - do NOT use the script. It seems to confuse Eclipse regarding the location of Gradle.
I'm working on an Eclipse microprofile application, and I would like to create a run configuration that executes these 3 commands in order:
mvn clean package
mvn package
java -jar target/myApp.jar
How can I do this? I have this:
Where and how can I set what I want?
I'm not sure that from the m2 plugin, you be able to accomplish the task of running multiple maven goals within a single run configuration.
However, as a workaround, you can add a batch file within your maven project directory with the following entries
call cls
%cd%
call mvn clean install
call java -jar target/myApp.jar
Running the above script can help you with running multiple maven commands in a synchronized manner.
First, you have to create a Maven Build launch configuration for each of the first two commands. The third command (java -jar target/myApp.jar) can be done with an External Tools Configuration of the type Program.
Then, create a Launch Group with all these three launch configurations.
I'm a Cucumber and Eclipse beginner and have a few questions and hope you can help me to get through this: I created a sample cucumber test scenario, a sample test steps and a cucumber runner. The scenarios runs fine within eclipse IDE (Neon). I used Maven as the dependency manager. I also installed the Maven command line module. The step code is Java.
Here is the (basic) question: How do I create a jar file from my cucumber test scenario so that execute it via command line so that I can bring the test scenario to Jenkins CI? Is there anything I need to do with Maven BEFORE I can build the jar file?
Thanks a lot folks!
If you run Cucumber using the JUnit runner, then all you have to do to run from a command line is to execute Maven and make sure you invoke a life cycle phase that includes running the unit tests. One way would be
mvn test
An example that might get you up and running can be found at
https://github.com/cucumber/cucumber-java-skeleton
When I run the build command in netbeans with the gradle plugin, all the tests run and the build fails if any of them fail. How can I change this behaviour?
If build action is bind to build task then this is expected behavior. You can modify your project to execute something like assemble or jar when build action is invoked. build depends on test while those others don't and they still build enough for you to execute the application.
I'm converting our build from Ant to Gradle. Our first step is to add the Gradle build files so we can start using Gradle as our build tool. This lets us use our existing build scripts to build using Ant and convert them to Gradle over time. I want to simply have Gradle call the existing Ant build files. Our projects are all NetBeans projects, which have build.xml and nbproject/build-impl.xml files. Some of the projects require NetBeans build properties, which can be found at ~/.netbeans/6.5.1/build.properties. I have the NetBeans user.properties.file property successfully set to ~/.netbeans/6.5.1/build.properties.
When I build with Ant, I invoke this:
ant -Duser.properties.file=~/.netbeans/6.5.1/build.properties dist
This executes the dist target, which depends on the init target which depends on the targets listed below:
pre-init, init-private, init-userdir, init-user, init-project, do-init, post-init, init-check, -init-taskdefs
The targets listed above are executed in the order specified. When I invoke 'gradle dist', it invokes the init Ant target, but then it executes the targets listed above in reverse order, starting with -init-taskdefs. There are required properties which are setup in the targets before the -init-taskdefs target which aren't being setup when run from gradle.
Really, all I want to do right now is to use gradle to invoke Ant to build my projects. What's the best way to do this since using gradle to build using Ant build.xml files doesn't seem to work as expected? Do I have to resort to using exec? (I hope not).
I found trying to use Gradle's integration of Ant with a Netbeans project was too difficult and error prone. Instead, I use Gradle's exec() command. Below is an example, lifted from my code that builds a NetBeans Project named 'Common Library'.
task commonLibrary {
doLast {
ant.echo("Building Common Library")
exec () {
workingDir = "../netbeans/nb/CommonLibrary"
executable = "ant"
args = ['clean', 'jar']
}
}
}
I realize that wasn't the answer you were hoping for, but posted it as a possible solution for other people, particular people who aren't in a position to start reworking their build.xml files.