Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MNG-7897] Support ${project.rootDirectory} in file profile activation #1687

Merged
merged 2 commits into from
Aug 29, 2024
Merged
Show file tree
Hide file tree
Changes from all 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 @@ -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,22 +67,22 @@ 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() {
void testIsActiveNoFileWithShortBasedir() {
assertActivation(false, newExistsProfile(null), context);
assertActivation(false, newExistsProfile("someFile.txt"), context);
assertActivation(false, newExistsProfile("${basedir}/someFile.txt"), context);
Expand All @@ -92,15 +92,26 @@ void testIsActiveNoFile() {
assertActivation(true, newMissingProfile("${basedir}/someFile.txt"), context);
}

@Test
void testIsActiveNoFile() {
assertActivation(false, newExistsProfile(null), context);
assertActivation(false, newExistsProfile("someFile.txt"), context);
assertActivation(false, newExistsProfile("${project.basedir}/someFile.txt"), context);
slawekjaranowski marked this conversation as resolved.
Show resolved Hide resolved

assertActivation(false, newMissingProfile(null), context);
assertActivation(true, newMissingProfile("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