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

I want to transfer all my java projects (223 projects) to a gradle project . I am using the Gradle Eclipse plugin developed by the SpringSource STS team.

Currently, all my java projects are organized like this:

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 (through Configure → "Convert to Gradle Project ..."), all java source folders become packages.

In addition, the fact is that all declared packages in Java classes must be changed. For example, Eclipse will tell me that: The declared package "some.package.test.tools.A" does not match the expected package "tests.some.package.test.tools.A"

Eclipse gives me the ability to change the package declaration for a class. But I have to do this 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 the java source folder) into a Gradle project without affecting all packages (I would like to avoid the operation consisting of modifiyng all classes)

Thanks in advance for your help or any advice.

Naike.

+6
source share
2 answers

You will need to write Gradle build script (s) and, among other things, declare the structure of the source directory. (You do not need to change the structure of the source directory or any package instructions.) Convert to Gradle Project will not do this for you. This is just a way to activate support for the Gradle project, which will make the Eclipse usage information contained in the Gradle build scripts allow you to build Gradle from the IDE, etc.

+5
source

I think the best way to do this is to change the "source folder" by following these steps:

  • Open project settings
  • Open Java build path.
  • In the "Source" tab there is "Source folders on the build path." You can configure it so that "src" is the source folder, not "/" (because, I think, this has changed after the project was migrated).

I hope this helps!

0
source

Source: https://habr.com/ru/post/945479/


All Articles