Skip to content

Instantly share code, notes, and snippets.

@fbricon
Created September 17, 2012 08:26
Show Gist options
  • Save fbricon/3736168 to your computer and use it in GitHub Desktop.
Save fbricon/3736168 to your computer and use it in GitHub Desktop.
Add access rules to Maven Classpath
public void configureClasspath(IMavenProjectFacade facade,
IClasspathDescriptor classpath, IProgressMonitor monitor)
throws CoreException {
IProject project = facade.getProject();
Set<IRuntime> runtimes = getTargetedJBossRuntimes(project);
if (runtimes == null || runtimes.isEmpty()) {
return;
}
List<IClasspathEntryDescriptor> entries = classpath.getEntryDescriptors();
for (IRuntime runtime : runtimes) {
Map<String, List<IAccessRule>> runtimeAccessRules = getAccessRules(runtime);
if (runtimeAccessRules == null || runtimeAccessRules.isEmpty()) {
continue;
}
for (IClasspathEntryDescriptor e : entries) {
//Don't use e.getGroupId()+":"+e.getGroupId(); //values are null
ArtifactKey aKey = e.getArtifactKey();
if (aKey == null) {
continue;
}
String key = aKey.getGroupId()+":"+aKey.getArtifactId();
List<IAccessRule> artifactAccessRules = runtimeAccessRules.get(key);
if (artifactAccessRules != null && !artifactAccessRules.isEmpty()) {
mergeAccessRules(e, artifactAccessRules);
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment