private void doExpand(Jar jar) throws IOException {
if (getClasspath().size() == 0
&& (getProperty(EXPORT_PACKAGE) != null || getProperty(PRIVATE_PACKAGE) != null))
warning("Classpath is empty. Private-Package and Export-Package can only expand from the classpath when there is one");
Map<Instruction, Map<String, String>> privateMap = replaceWitInstruction(
getHeader(PRIVATE_PACKAGE), PRIVATE_PACKAGE);
Map<Instruction, Map<String, String>> exportMap = replaceWitInstruction(
getHeader(EXPORT_PACKAGE), EXPORT_PACKAGE);
if (isTrue(getProperty(Constants.UNDERTEST))) {
privateMap.putAll(replaceWitInstruction(parseHeader(getProperty(
Constants.TESTPACKAGES, "test;presence:=optional")),
TESTPACKAGES));
}
if (!privateMap.isEmpty())
doExpand(jar, "Private-Package, or -testpackages", privateMap, true);
if (!exportMap.isEmpty()) {
Jar exports = new Jar("exports");
doExpand(exports, "Export-Package", exportMap, true);
jar.addAll(exports);
exports.close();
}
if (privateMap.isEmpty() && exportMap.isEmpty() && !isResourceOnly()) {
warning("Neither Export-Package, Private-Package, -testpackages is set, therefore no packages will be included");
}
}