Configure build.gradle in eclipse project

1

Good morning!

I have the following question: Can I set up a build.gradle file within an eclipse project? This for dependency management, something like maven .

I have been consulting this link in the which I can add a plugin to eclipse to start working with gradle, but I do not want to create a gradle project, since I already have a project (java web) and I want to manage the dependencies with gradle.

Also install gradle on my pc following Graa documentation .

Update

These are the dependencies I want to add:

Update II

Currently my gradle looks like this:

apply plugin: 'eclipse'
apply plugin: 'java'

repositories{

}

dependencies{

}

Another one of my doubts is about the nomenclature to be used (currently it is gradle 3.5), taking as reference you have two ways: form 1 , form 2

Update III

Following Chuidiang's answer, add my missing dependencies and run the following command with closed eclipse:

gradle cleanEclipse eclipse

But I get the following error:

Starting a Gradle Daemon (subsequent builds will be faster)
:cleanEclipseClasspath
:cleanEclipseJdt
:cleanEclipseProject
:cleanEclipse
:eclipseClasspath
[Fatal Error] apache-18.pom:419:6: El destino de la instrucci¾n de procesamiento
 que coincide con "[xX][mM][lL]" no estß permitido.
[Fatal Error] apache-18.pom:419:6: El destino de la instrucci¾n de procesamiento
 que coincide con "[xX][mM][lL]" no estß permitido.

This alludes to my pom.xml and looking for that it was due to some character not allowed , in addition to running gradle cleanEclipse eclipse it takes a long time to try to resolve the dependencies (1:30 hours).

I hope you have explained me well.

Thank you.

    
asked by 5frags 05.05.2017 в 23:33
source

2 answers

0

The solution I found was the following:

Install my gradle (version 3.5) as well as maven (3.5).

Afterwards by cmd (windows) I put myself in the direction of my project up to the height of my pom.xml, where I executed the following line:

gradle init

With executing it I got the structure of my project but now with gradle, my build.gradle took all the settings of my pom.xml in automatic.

Here you can see how to install gradle on your machine

Here for the installation of Maven on your machine.

I hope and serve someone.

    
answered by 10.05.2017 / 01:15
source
0

In the build.gradle file add

apply plugin: "eclipse"

and then, from the command window in the directory where your project is and your build.gradle, execute

gradle eclipse

That should create the project files from eclipse. Then, in eclipse, simply "import existing project" and look for the directory.

Greetings.

    
answered by 06.05.2017 в 14:50