naike
naike

Reputation: 673

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.

Upvotes: 7

Views: 18925

Answers (2)

Peter Niederwieser
Peter Niederwieser

Reputation: 123996

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.

Upvotes: 5

Michal Borek
Michal Borek

Reputation: 4634

I think the best way you can do is to change "source folder" under, by doing following steps:

  1. Open Project preferences
  2. Open Java Build Path
  3. Under "Source" tab there is "Source folders on build path". You can customize it so that "src" is a source folder and not the "/" one (because I guess that has changed after project migration).

I hope that helps!

Upvotes: 0

Related Questions