Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Convert Eclipse java project (with java source folder) to gradle project

I want to migrate all my java projects (223 projects) to gradle project. I'm using the Gradle Eclipse plugin, developed by the SpringSource STS team.

Currently, all my java projets is strutured like that:

MyProjet/
+- src/log
    +- some.package.log
    +- some.package.log.A
+- src/tools/core
    +- some.package
    +- some.package.tools.B
    +- some.package.tools.C
+- src/tools/graph
    +- some.package.graph
+- src/tests
    +- some.package.test.D
+- src/someModule

+- otherDirectories

src/log, src/tools/core, src/tools/graph, src/tests and src/someModule are java source folders.

After converting the project to gradle (via Configure -> "Convert to Gradle Project..."), all java source folders become packages.

Also, the matter is that all declared packages in java classes must be modified. For example, Eclipse tell me that: The declared package "some.package.test.tools.A" does not match the expected package "tests.some.package.test.tools.A"

Eclipse give me the possibility to change the package declaration of a class. But I must do that for all classes (sometimes more than 100 classes for one project).

I want to know if there is a way to convert a java project (with java source folder) to a gradle project, without impacting all packages (I would like to avoid the operation that consist in modifiyng all classes)

Thank you in advance for help or any advices.

Naike.

like image 769
naike Avatar asked May 21 '13 08:05

naike


1 Answers

You'll have to write Gradle build script(s) and, among other things, declare your source directory structure there. (You don't have to change the source directory structure or any package statements.) "Convert to Gradle Project" won't do this for you. It's merely a way to activate Gradle support for the project, which will make Eclipse use information contained in the Gradle build scripts, allow you to execute a Gradle build from the IDE, etc.

like image 60
Peter Niederwieser Avatar answered Sep 28 '22 17:09

Peter Niederwieser