In Eclipse, can I create a single source folder for multiple output folders?

Summary

A brief description of why someone would like to try this. In the Maven project, I have the need to run tests with classes in target/classes and the need to debug (using the Eclipse Servers plugin) tomcat in the Eclipse IDE, which loads classes and a number of other collected resources in target/<name-version-package>/WEB-INF/classes . When my main source folder has the output set in the WEB-INF/classes , tomcat debugging works fine in the IDE. When ouptut is changed to target/classes , the tests also work fine, since the test resources are correctly compiled and loaded out of the package context.

Problem

The problem is that I need to manually change the output file of the main source directory based on the task (testing or debugging in tomcat). Configuration and assembly changes would be prohibitively complex based on other configuration files, etc., to just get around this.

Therefore, is there an easy way to tell Eclipse to output the source to two directories? Thus, incremental assembly of Maven files from Java files will be copied to both places, and I will not have such a fragile configuration.

+4
source share
4 answers

An easier way would be to create classes in one directory and create a custom Maven target (possibly using the antrun plugin) copy them to another directory.

Here is a concrete example of copying resources using Maven (and Antrun)

+1
source

Perhaps try setting up Maven and Eclipse to use separate output folders .

0
source

I do not think that it is possible to make Eclipse to compile sources in several locations.

In such situations, I created another project inside the workspace into which I link sources from different places. So, I will have the main project that is used for deployment. Then I will have another project that is used for something else, in this case testing. In your case, another project will link the sources from the main project.

The only problem I ran into is that I did not find out how to link sources using relative paths.

To link the source folders, you must use the Project properties โ†’ Java build path โ†’ Source โ†’ Source Source.

Most likely, you will need some resources from the main project. You can create the same directory structure inside another project by creating link folders. When creating a folder in a project, you can choose from the additional options "Link to a folder in the file system".

0
source

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


All Articles