mirror of
https://github.com/ethauvin/bld.git
synced 2025-04-25 08:17: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;
|
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.
|
* Returns the project's name.
|
||||||
*
|
*
|
||||||
|
@ -1388,6 +1399,17 @@ public class BaseProject extends BuildExecutor {
|
||||||
return name;
|
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.
|
* Returns the project's version.
|
||||||
*
|
*
|
||||||
|
@ -1400,6 +1422,17 @@ public class BaseProject extends BuildExecutor {
|
||||||
return version;
|
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.
|
* Returns the project's main class to execute.
|
||||||
*
|
*
|
||||||
|
|
|
@ -29,10 +29,13 @@ public class TestProject {
|
||||||
assertTrue(project.workDirectory().exists());
|
assertTrue(project.workDirectory().exists());
|
||||||
assertTrue(project.workDirectory().isDirectory());
|
assertTrue(project.workDirectory().isDirectory());
|
||||||
assertNull(project.pkg);
|
assertNull(project.pkg);
|
||||||
|
assertFalse(project.hasPkg());
|
||||||
assertThrows(IllegalStateException.class, project::pkg);
|
assertThrows(IllegalStateException.class, project::pkg);
|
||||||
assertNull(project.name);
|
assertNull(project.name);
|
||||||
|
assertFalse(project.hasName());
|
||||||
assertThrows(IllegalStateException.class, project::name);
|
assertThrows(IllegalStateException.class, project::name);
|
||||||
assertNull(project.version);
|
assertNull(project.version);
|
||||||
|
assertFalse(project.hasVersion());
|
||||||
assertThrows(IllegalStateException.class, project::version);
|
assertThrows(IllegalStateException.class, project::version);
|
||||||
assertNull(project.mainClass);
|
assertNull(project.mainClass);
|
||||||
assertNull(project.module);
|
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
|
@Test
|
||||||
void testCustomCommand()
|
void testCustomCommand()
|
||||||
throws Exception {
|
throws Exception {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue