mirror of
https://github.com/ethauvin/bld.git
synced 2025-04-24 15:57:11 -07:00
Fixed #57 : Add an option to check if project required settins have been set
This commit is contained in:
parent
4b762796e0
commit
f9f20e62ef
2 changed files with 52 additions and 0 deletions
|
@ -1376,6 +1376,17 @@ public class BaseProject extends BuildExecutor {
|
|||
return pkg;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether this project's package was set.
|
||||
*
|
||||
* @return {@code true} if the package was set; or
|
||||
* {@code false} otherwise
|
||||
* @since 2.2.1
|
||||
*/
|
||||
public boolean hasPkg() {
|
||||
return pkg != null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the project's name.
|
||||
*
|
||||
|
@ -1388,6 +1399,17 @@ public class BaseProject extends BuildExecutor {
|
|||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether this project's name was set.
|
||||
*
|
||||
* @return {@code true} if the name was set; or
|
||||
* {@code false} otherwise
|
||||
* @since 2.2.1
|
||||
*/
|
||||
public boolean hasName() {
|
||||
return name != null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the project's version.
|
||||
*
|
||||
|
@ -1400,6 +1422,17 @@ public class BaseProject extends BuildExecutor {
|
|||
return version;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether this project's version was set.
|
||||
*
|
||||
* @return {@code true} if the version was set; or
|
||||
* {@code false} otherwise
|
||||
* @since 2.2.1
|
||||
*/
|
||||
public boolean hasVersion() {
|
||||
return version != null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the project's main class to execute.
|
||||
*
|
||||
|
|
|
@ -29,10 +29,13 @@ public class TestProject {
|
|||
assertTrue(project.workDirectory().exists());
|
||||
assertTrue(project.workDirectory().isDirectory());
|
||||
assertNull(project.pkg);
|
||||
assertFalse(project.hasPkg());
|
||||
assertThrows(IllegalStateException.class, project::pkg);
|
||||
assertNull(project.name);
|
||||
assertFalse(project.hasName());
|
||||
assertThrows(IllegalStateException.class, project::name);
|
||||
assertNull(project.version);
|
||||
assertFalse(project.hasVersion());
|
||||
assertThrows(IllegalStateException.class, project::version);
|
||||
assertNull(project.mainClass);
|
||||
assertNull(project.module);
|
||||
|
@ -140,6 +143,22 @@ public class TestProject {
|
|||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
void testCustomProject()
|
||||
throws Exception {
|
||||
var tmp = Files.createTempDirectory("test").toFile();
|
||||
try {
|
||||
var result = new StringBuilder();
|
||||
var project = new CustomProject(tmp, result);
|
||||
|
||||
assertTrue(project.hasPkg());
|
||||
assertTrue(project.hasName());
|
||||
assertTrue(project.hasVersion());
|
||||
} finally {
|
||||
FileUtils.deleteDirectory(tmp);
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
void testCustomCommand()
|
||||
throws Exception {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue