简体   繁体   中英

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.

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.

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!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM