Skip to content

Commit

Permalink
feat: support relative path
Browse files Browse the repository at this point in the history
  • Loading branch information
heowc committed Jun 10, 2024
1 parent 361242d commit ba314a9
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 1 deletion.
1 change: 1 addition & 0 deletions heo-core/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ dependencies {

tasks.named('test') {
useJUnitPlatform()
systemProperty 'rootDir', "${rootDir}"
}

publishing {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public class ModuleLoader {
private final String rootPackage;

public ModuleLoader(String projectDirectory, String rootPackage) {
this.projectPath = Path.of(projectDirectory);
this.projectPath = Path.of(projectDirectory).toAbsolutePath();
this.rootPackage = rootPackage;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package dev.heowc.heo.core.loader.domain;

import static org.assertj.core.api.Assertions.assertThat;

import java.io.IOException;
import java.nio.file.Path;
import java.util.List;

import org.junit.jupiter.api.Test;

import dev.heowc.heo.core.Module;

class ModuleLoaderVariousPathTest {

private final String rootDir = System.getProperty("rootDir");

@Test
void absolutePath() throws IOException {
final Path cycleIntergationTestProjectPath = Path.of(rootDir, "heo-core").toAbsolutePath();

final List<Module> modules = new ModuleLoader(cycleIntergationTestProjectPath.toString(),
"dev.heowc.heo.core").loadModules();

assertThat(modules).hasSize(4);
}

@Test
void relativePath() throws IOException {
final Path cycleIntergationTestProjectPath = Path.of("");

final List<Module> modules = new ModuleLoader(cycleIntergationTestProjectPath.toString(),
"dev.heowc.heo.core").loadModules();

assertThat(modules).hasSize(4);
}
}

0 comments on commit ba314a9

Please sign in to comment.