package com.dev9.mvn.watcher;

import com.dev9.mvn.watcher.event.DirectoryEventWatcherImpl;
import com.dev9.mvn.watcher.event.FileChangeSubscriber;
import com.google.common.eventbus.EventBus;

import java.io.File;
import java.io.IOException;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Objects;
import java.util.concurrent.CountDownLatch;

public class Mvnrunner {

    private final Path sourcePath;
    private final Path projectPath;

    public Mvnrunner(Path sourcePath, Path projectPath) {
        this.sourcePath = Objects.requireNonNull(sourcePath);
        this.projectPath = Objects.requireNonNull(projectPath);
    }

    private EventBus eventBus;
    private DirectoryEventWatcherImpl dirWatcher;
    private CountDownLatch doneSignal;
    private FileChangeSubscriber subscriber;

    public void startUpWatcher() throws IOException {
        eventBus = new EventBus();
        dirWatcher = new DirectoryEventWatcherImpl(eventBus, sourcePath);
        dirWatcher.start();
        subscriber = new FileChangeSubscriber(dirWatcher, projectPath);
        eventBus.register(subscriber);
    }

    public void waitForCancel() {
        boolean running = true;

        while (running) {
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    }

    public static void main(String[] args) {

        Path projectPath = Paths.get("src/mvnrunnner/src/test/resources/sample-project/");
        Path sourcePath = Paths.get("src/mvnrunnner/src/test/resources/sample-project/src/main/java");

        Mvnrunner runner = null;

        try {
            runner = new Mvnrunner(sourcePath, projectPath);
            runner.startUpWatcher();
        } catch (IOException e) {
            e.printStackTrace();
        }

        if (runner != null)
            runner.waitForCancel();

    }

}

@@ -1429,24 +1429,89 @@
 %5B%5D args) %7B%0A%0A
+        String cwd = Paths.get(%22%22).toAbsolutePath().toString();%0A%0A
         Path
@@ -1535,32 +1535,22 @@
 ths.get(
-%22src/mvnrunnner/
+cwd, %22
 src/test
@@ -1619,24 +1619,13 @@
 get(
-%22src/mvnrunnner/
+cwd,%22
 src/

Fix identifying the correct working directory for Path