// Path: stecker-plugin-loader/src/main/java/org/meridor/stecker/impl/FileSystemHelper.java
// public class FileSystemHelper {
// 
//     public static Path createTempDirectory() throws IOException {
//         return Files.createTempDirectory("test");
//     }
// 
//     public static void removeDirectory(Path directory) throws IOException {
//         Files.walkFileTree(directory, new SimpleFileVisitor<Path>() {
//             @Override
//             public FileVisitResult visitFile(Path file, BasicFileAttributes attributes) throws IOException {
//                 Files.delete(file);
//                 return FileVisitResult.CONTINUE;
//             }
// 
//             @Override
//             public FileVisitResult postVisitDirectory(Path dir, IOException e) throws IOException {
//                 Files.delete(dir);
//                 return FileVisitResult.CONTINUE;
//             }
//         });
//     }
// 
// }


import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.DefaultArtifact;
import org.apache.maven.artifact.handler.DefaultArtifactHandler;
import org.apache.maven.plugin.testing.MojoRule;
import org.apache.maven.project.MavenProject;
import org.junit.After;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.meridor.stecker.impl.FileSystemHelper;
import java.net.URISyntaxException;
import java.net.URL;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Optional;
import static com.marvinformatics.kiss.matchers.path.PathMatchers.exists;
import static com.marvinformatics.kiss.matchers.path.PathMatchers.isDirectory;
import static com.marvinformatics.kiss.matchers.path.PathMatchers.isRegularFile;
import static org.hamcrest.CoreMatchers.notNullValue;
import static org.junit.Assert.assertThat;
        Path generatedDataDir = targetDir.resolve("plugin-generator");
        assertThat(generatedDataDir, exists());
        assertThat(generatedDataDir, isDirectory());

        Path pluginFile = generatedDataDir.resolve("plugin-test-1.0.jar");
        assertThat(pluginFile, exists());
        assertThat(pluginFile, isRegularFile());

        Path pluginDataDir = generatedDataDir.resolve("data");
        assertThat(pluginDataDir, exists());
        assertThat(pluginDataDir, isDirectory());

        Path libDir = pluginDataDir.resolve("lib");
        assertThat(libDir, exists());
        assertThat(libDir, isDirectory());

        Path dependencyFile = libDir.resolve(ARTIFACT_FILE);
        assertThat(dependencyFile, exists());
        assertThat(dependencyFile, isRegularFile());

    }

    private Optional<Path> getResource(String resourceName) throws URISyntaxException {
        URL resource = getClass().getClassLoader().getResource(resourceName);
        return (resource != null) ? Optional.of(Paths.get(resource.toURI())) : Optional.empty();
    }

    @After
    public void removeData() throws Exception {
        if (targetDir != null && Files.exists(targetDir)) {
// Path: stecker-plugin-loader/src/main/java/org/meridor/stecker/impl/FileSystemHelper.java
// public class FileSystemHelper {
// 
//     public static Path createTempDirectory() throws IOException {
//         return Files.createTempDirectory("test");
//     }
// 
//     public static void removeDirectory(Path directory) throws IOException {
//         Files.walkFileTree(directory, new SimpleFileVisitor<Path>() {
//             @Override
//             public FileVisitResult visitFile(Path file, BasicFileAttributes attributes) throws IOException {
//                 Files.delete(file);
//                 return FileVisitResult.CONTINUE;
//             }
// 
//             @Override
//             public FileVisitResult postVisitDirectory(Path dir, IOException e) throws IOException {
//                 Files.delete(dir);
//                 return FileVisitResult.CONTINUE;
//             }
//         });
//     }
// 
// }


// Path: stecker-plugin-generator/src/test/java/org/meridor/stecker/generator/CreateMojoTest.java
import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.DefaultArtifact;
import org.apache.maven.artifact.handler.DefaultArtifactHandler;
import org.apache.maven.plugin.testing.MojoRule;
import org.apache.maven.project.MavenProject;
import org.junit.After;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.meridor.stecker.impl.FileSystemHelper;
import java.net.URISyntaxException;
import java.net.URL;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Optional;
import static com.marvinformatics.kiss.matchers.path.PathMatchers.exists;
import static com.marvinformatics.kiss.matchers.path.PathMatchers.isDirectory;
import static com.marvinformatics.kiss.matchers.path.PathMatchers.isRegularFile;
import static org.hamcrest.CoreMatchers.notNullValue;
import static org.junit.Assert.assertThat;

        Path generatedDataDir = targetDir.resolve("plugin-generator");
        assertThat(generatedDataDir, exists());
        assertThat(generatedDataDir, isDirectory());

        Path pluginFile = generatedDataDir.resolve("plugin-test-1.0.jar");
        assertThat(pluginFile, exists());
        assertThat(pluginFile, isRegularFile());

        Path pluginDataDir = generatedDataDir.resolve("data");
        assertThat(pluginDataDir, exists());
        assertThat(pluginDataDir, isDirectory());

        Path libDir = pluginDataDir.resolve("lib");
        assertThat(libDir, exists());
        assertThat(libDir, isDirectory());

        Path dependencyFile = libDir.resolve(ARTIFACT_FILE);
        assertThat(dependencyFile, exists());
        assertThat(dependencyFile, isRegularFile());

    }

    private Optional<Path> getResource(String resourceName) throws URISyntaxException {
        URL resource = getClass().getClassLoader().getResource(resourceName);
        return (resource != null) ? Optional.of(Paths.get(resource.toURI())) : Optional.empty();
    }

    @After
    public void removeData() throws Exception {
        if (targetDir != null && Files.exists(targetDir)) {
            FileSystemHelper.removeDirectory(targetDir);