Skip to content
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,29 @@ protected List<String> getBuildArgs() throws MojoExecutionException {

if (buildArgs != null && !buildArgs.isEmpty()) {
for (String buildArg : buildArgs) {
cliArgs.addAll(Arrays.asList(buildArg.split("\\s+")));
if(buildArg.startsWith("\\Q") ||
buildArg.startsWith("-H:ConfigurationFileDirectories")) {
cliArgs.add(buildArg);
continue;
}
String[] args = buildArg.split("\\s+");
int i=0;
while(i < args.length) {
String a =args[i];
if (a.charAt(0) == System.getProperty("user.home").charAt(0)) {
StringBuilder path = new StringBuilder(a);
i++;
while( i< args.length && args[i].toLowerCase().charAt(0) <= 'z' &&
args[i].toLowerCase().charAt(0) >= 'a') {
path.append(" ").append(args[i]);
i++;
}
cliArgs.add(path.toString());
} else {
cliArgs.add(a);
i++;
}
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,15 @@ import org.eclipse.jetty.server.handler.ResourceHandler
import spock.lang.Specification
import spock.lang.TempDir

import java.nio.file.FileVisitResult
import java.nio.file.Files
import java.nio.file.Path
import java.nio.file.SimpleFileVisitor
import java.nio.file.StandardCopyOption
import java.nio.file.attribute.BasicFileAttributes

abstract class AbstractGraalVMMavenFunctionalTest extends Specification {
@TempDir
Copy link
Contributor

@dnestoro dnestoro Aug 9, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why you have removed @TempDir annotation and then proceeded with deleting files manually in the cleanup function?

Copy link
Member Author

@houcine7 houcine7 Aug 9, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In my local when I work with Tempdir all tests are passing, because windows avoids tempDir path whitespace with a certain encoding (C:\Users\Lahoucine~\AppData\Temp) so no parsing errors will result if I have withespaces in my path.


Path testDirectory

Path testOrigin;
Expand All @@ -71,6 +74,13 @@ abstract class AbstractGraalVMMavenFunctionalTest extends Specification {
boolean IS_MAC = System.getProperty("os.name", "unknown").contains("Mac");

def setup() {
var home_dir = Path.of(System.getProperty("user.home"))
testDirectory = home_dir.resolve("tests")

if (Files.notExists(testDirectory)) {
Files.createDirectory(testDirectory)
}

executor = new IsolatedMavenExecutor(
new File(System.getProperty("java.executable")),
testDirectory.resolve("m2-home").toFile(),
Expand All @@ -79,6 +89,21 @@ abstract class AbstractGraalVMMavenFunctionalTest extends Specification {
}

def cleanup() {

//cleanup test directory and all it's sub directories
Files.walkFileTree(testDirectory, new SimpleFileVisitor<Path>() {
@Override
FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException {
Files.delete(file);
return FileVisitResult.CONTINUE;
}
@Override
FileVisitResult postVisitDirectory(Path dir, IOException exc) throws IOException {
Files.delete(dir);
return FileVisitResult.CONTINUE;
}
});

if (server != null) {
server.stop()
server.destroy()
Expand Down Expand Up @@ -158,7 +183,7 @@ abstract class AbstractGraalVMMavenFunctionalTest extends Specification {
var resultingSystemProperties = [
"common.repo.uri": System.getProperty("common.repo.uri"),
"seed.repo.uri": System.getProperty("seed.repo.uri"),
"maven.repo.local": testDirectory.resolve("local-repo").toFile().absolutePath
"maven.repo.local": testDirectory.resolve("local repo").toFile().absolutePath
]
resultingSystemProperties.putAll(systemProperties)

Expand Down