Skip to content

Commit

Permalink
Fix transitive dependencies
Browse files Browse the repository at this point in the history
was: 39b8c4c
  • Loading branch information
stuartwdouglas committed Jun 20, 2011
1 parent 0617269 commit b893ac2
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public void deploy(final DeploymentPhaseContext phaseContext) throws DeploymentU
new ValueService<Object>(new ImmediateValue<Object>(moduleSpec)))
.install();

for (ModuleDependency dependency : moduleSpec.getSystemDependencies()) {
for (ModuleDependency dependency : moduleSpec.getAllDependencies()) {
if (dependency.getIdentifier().getName().startsWith(ServiceModuleLoader.MODULE_PREFIX)) {
phaseContext.addDependency(ServiceModuleLoader.moduleInformationServiceName(dependency.getIdentifier()), Attachments.MODULE_DEPENDENCY_INFORMATION);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,18 +139,13 @@ public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitPro
*/
private void processTransitiveDependencies(final ModuleSpecification moduleSpecification, final DeploymentPhaseContext phaseContext) {
final Set<ModuleIdentifier> deps = new HashSet<ModuleIdentifier>();
for (ModuleDependency dependency : moduleSpecification.getSystemDependencies()) {
deps.add(dependency.getIdentifier());
}
for (ModuleDependency dependency : moduleSpecification.getUserDependencies()) {
deps.add(dependency.getIdentifier());
}
for (ModuleDependency dependency : moduleSpecification.getLocalDependencies()) {
for (ModuleDependency dependency : moduleSpecification.getAllDependencies()) {
deps.add(dependency.getIdentifier());
}
for (final ModuleSpecification depInfo : phaseContext.getAttachmentList(Attachments.MODULE_DEPENDENCY_INFORMATION)) {
for (ModuleDependency dependency : depInfo.getSystemDependencies()) {
if (deps.contains(dependency)) {

for (ModuleDependency dependency : depInfo.getAllDependencies()) {
if (deps.contains(dependency.getIdentifier())) {
continue;
}
deps.add(dependency.getIdentifier());
Expand Down Expand Up @@ -184,7 +179,8 @@ private void processManualTransitiveDependencies(final ModuleSpecification modul
}
try {
ModuleSpecification specification = controller.getValue();
for (ModuleDependency dependency : specification.getSystemDependencies()) {
final List<ModuleDependency> allDeps = specification.getAllDependencies();
for (ModuleDependency dependency : allDeps) {
if (deps.contains(dependency)) {
continue;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ public class ModuleSpecification extends SimpleAttachable {

private final List<ResourceLoaderSpec> resourceLoaders = new ArrayList<ResourceLoaderSpec>();

private volatile List<ModuleDependency> allDependencies = null;

/**
* Modules that cannot be added as dependencies to the deployment, as the user has excluded them
*/
Expand Down Expand Up @@ -89,26 +91,31 @@ public void addSystemDependency(ModuleDependency dependency) {
}

public void addSystemDependencies(Collection<ModuleDependency> dependencies) {
allDependencies = null;
for (ModuleDependency dependency : dependencies) {
addSystemDependency(dependency);
}
}

public void addUserDependency(ModuleDependency dependency) {
allDependencies = null;
this.userDependencies.add(dependency);
}

public void addUserDependencies(Collection<ModuleDependency> dependencies) {
allDependencies = null;
userDependencies.addAll(dependencies);
}

public void addLocalDependency(ModuleDependency dependency) {
allDependencies = null;
if (!exclusions.contains(dependency.getIdentifier())) {
this.localDependencies.add(dependency);
}
}

public void addLocalDependencies(Collection<ModuleDependency> dependencies) {
allDependencies = null;
for (ModuleDependency dependency : dependencies) {
addLocalDependency(dependency);
}
Expand All @@ -119,6 +126,7 @@ public List<ModuleDependency> getSystemDependencies() {
}

public void addExclusion(ModuleIdentifier exclusion) {
allDependencies = null;
exclusions.add(exclusion);
Iterator<ModuleDependency> it = systemDependencies.iterator();
while (it.hasNext()) {
Expand Down Expand Up @@ -183,4 +191,13 @@ public void setRequiresTransitiveDependencies(final boolean requiresTransitiveDe
this.requiresTransitiveDependencies = requiresTransitiveDependencies;
}

public List<ModuleDependency> getAllDependencies() {
if(allDependencies == null) {
allDependencies = new ArrayList<ModuleDependency>();
allDependencies.addAll(systemDependencies);
allDependencies.addAll(userDependencies);
allDependencies.addAll(localDependencies);
}
return allDependencies;
}
}

0 comments on commit b893ac2

Please sign in to comment.