gintool / gin

GI in No Time - a Simple Microframework for Genetic Improvement
MIT License
43 stars 20 forks source link

Bug fix for parallel Sampler execution with Maven projects #50

Closed GiovaniGuizzo closed 3 years ago

GiovaniGuizzo commented 3 years ago

This pull request has two additions.

The first and most important one is a bug fix for parallel executions with Maven projects. Before this fix, the standard procedure to find the dependencies of a Maven project would be to execute the dependency plugin and save the results in a file called dependencies.txt in the project's base directory (code). Then the program would remove the temporary dependency file right after. The failure happened when more than one job would try to write to the same file at the same time, or try to read the file that was just deleted by a different job. With this fix, the dependency file is created as a temporary file in the System's temp directory.

The second addition is the automatic search for the maven home directory when calling Sample.setup() (code), and only when the user does not specify a maven home directory for a maven project. With this addition, the program will first look up the environment variables MAVEN_HOME, MVN_HOME, a directory in PATH with mvnor mvn.cmd, or fallback to the default one /usr/local/ (code).

I also added the tests for finding the classpath of maven projects.