final boolean export = requireTransitive ? true : dependency.isExport();
final List<FilterSpecification> importFilters = dependency.getImportFilters();
final List<FilterSpecification> exportFilters = dependency.getExportFilters();
final PathFilter importFilter;
final PathFilter exportFilter;
final MultiplePathFilterBuilder importBuilder = PathFilters.multiplePathFilterBuilder(true);
for (final FilterSpecification filter : importFilters) {
importBuilder.addFilter(filter.getPathFilter(), filter.isInclude());
}
if (dependency.isImportServices()) {
importBuilder.addFilter(PathFilters.getMetaInfServicesFilter(), true);
}
importBuilder.addFilter(PathFilters.getMetaInfSubdirectoriesFilter(), false);
importBuilder.addFilter(PathFilters.getMetaInfFilter(), false);
importFilter = importBuilder.create();
if (exportFilters.isEmpty()) {
if (export) {
exportFilter = PathFilters.acceptAll();
} else {
exportFilter = PathFilters.rejectAll();
}
} else {
final MultiplePathFilterBuilder exportBuilder = PathFilters
.multiplePathFilterBuilder(export);
for (final FilterSpecification filter : exportFilters) {
exportBuilder.addFilter(filter.getPathFilter(), filter.isInclude());
}
exportFilter = exportBuilder.create();
}
final DependencySpec depSpec = DependencySpec.createModuleDependencySpec(importFilter, exportFilter, dependency
.getModuleLoader(), dependency.getIdentifier(), dependency.isOptional());
specBuilder.addDependency(depSpec);
logger.debug("Adding dependency " + dependency + " to module " + specBuilder.getIdentifier());