Skip to content

Commit

Permalink
[MNG-7897] Support ${project.rootDirectory} in file profile activation
Browse files Browse the repository at this point in the history
  • Loading branch information
gnodet committed Aug 29, 2024
1 parent 9bc5cc8 commit 82c61ab
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public Object getValue(String expression) {
interpolator.addValueSource(new AbstractValueSource(false) {
@Override
public Object getValue(String expression) {
if ("rootDirectory".equals(expression)) {
if ("project.rootDirectory".equals(expression)) {
Path root = rootLocator.findMandatoryRoot(basedir);
return root.toFile().getAbsolutePath();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public Object getValue(String expression) {
interpolator.addValueSource(new AbstractValueSource(false) {
@Override
public Object getValue(String expression) {
if ("rootDirectory".equals(expression)) {
if ("project.rootDirectory".equals(expression)) {
Path base = basedir != null ? basedir.toPath() : null;
Path root = rootLocator.findMandatoryRoot(base);
return root.toFile().getAbsolutePath();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,40 +67,40 @@ void testRootDirectoryWithNull() {

IllegalStateException e = assertThrows(
IllegalStateException.class,
() -> assertActivation(false, newExistsProfile("${rootDirectory}"), context));
() -> assertActivation(false, newExistsProfile("${project.rootDirectory}"), context));
assertEquals(RootLocator.UNABLE_TO_FIND_ROOT_PROJECT_MESSAGE, e.getMessage());
}

@Test
void testRootDirectory() {
assertActivation(false, newExistsProfile("${rootDirectory}/someFile.txt"), context);
assertActivation(true, newMissingProfile("${rootDirectory}/someFile.txt"), context);
assertActivation(true, newExistsProfile("${rootDirectory}"), context);
assertActivation(true, newExistsProfile("${rootDirectory}/" + "file.txt"), context);
assertActivation(false, newMissingProfile("${rootDirectory}"), context);
assertActivation(false, newMissingProfile("${rootDirectory}/" + "file.txt"), context);
assertActivation(false, newExistsProfile("${project.rootDirectory}/someFile.txt"), context);
assertActivation(true, newMissingProfile("${project.rootDirectory}/someFile.txt"), context);
assertActivation(true, newExistsProfile("${project.rootDirectory}"), context);
assertActivation(true, newExistsProfile("${project.rootDirectory}/" + "file.txt"), context);
assertActivation(false, newMissingProfile("${project.rootDirectory}"), context);
assertActivation(false, newMissingProfile("${project.rootDirectory}/" + "file.txt"), context);
}

@Test
void testIsActiveNoFile() {
assertActivation(false, newExistsProfile(null), context);
assertActivation(false, newExistsProfile("someFile.txt"), context);
assertActivation(false, newExistsProfile("${basedir}/someFile.txt"), context);
assertActivation(false, newExistsProfile("${project.basedir}/someFile.txt"), context);

assertActivation(false, newMissingProfile(null), context);
assertActivation(true, newMissingProfile("someFile.txt"), context);
assertActivation(true, newMissingProfile("${basedir}/someFile.txt"), context);
assertActivation(true, newMissingProfile("${project.basedir}/someFile.txt"), context);
}

@Test
void testIsActiveExistsFileExists() {
assertActivation(true, newExistsProfile("file.txt"), context);
assertActivation(true, newExistsProfile("${basedir}"), context);
assertActivation(true, newExistsProfile("${basedir}/" + "file.txt"), context);
assertActivation(true, newExistsProfile("${project.basedir}"), context);
assertActivation(true, newExistsProfile("${project.basedir}/" + "file.txt"), context);

assertActivation(false, newMissingProfile("file.txt"), context);
assertActivation(false, newMissingProfile("${basedir}"), context);
assertActivation(false, newMissingProfile("${basedir}/" + "file.txt"), context);
assertActivation(false, newMissingProfile("${project.basedir}"), context);
assertActivation(false, newMissingProfile("${project.basedir}/" + "file.txt"), context);
}

@Test
Expand Down

0 comments on commit 82c61ab

Please sign in to comment.