use of org.gradle.plugins.ide.idea.internal.IdeaModuleMetadata in project gradle by gradle.
the class IdeaPlugin method configureIdeaModule.
private void configureIdeaModule(final ProjectInternal project) {
final GenerateIdeaModule task = project.getTasks().create("ideaModule", GenerateIdeaModule.class);
task.setDescription("Generates IDEA module files (IML)");
IdeaModuleIml iml = new IdeaModuleIml(task.getXmlTransformer(), project.getProjectDir());
final IdeaModule module = instantiator.newInstance(IdeaModule.class, project, iml);
task.setModule(module);
ideaModel.setModule(module);
final String defaultModuleName = uniqueProjectNameProvider.getUniqueName(project);
module.setName(defaultModuleName);
ConventionMapping conventionMapping = ((IConventionAware) module).getConventionMapping();
conventionMapping.map("sourceDirs", new Callable<Set<File>>() {
@Override
public Set<File> call() {
return Sets.newLinkedHashSet();
}
});
conventionMapping.map("contentRoot", new Callable<File>() {
@Override
public File call() {
return project.getProjectDir();
}
});
conventionMapping.map("testSourceDirs", new Callable<Set<File>>() {
@Override
public Set<File> call() {
return Sets.newLinkedHashSet();
}
});
conventionMapping.map("excludeDirs", new Callable<Set<File>>() {
@Override
public Set<File> call() {
Set<File> defaultExcludes = Sets.newLinkedHashSet();
defaultExcludes.add(project.file(".gradle"));
defaultExcludes.add(project.getBuildDir());
return defaultExcludes;
}
});
conventionMapping.map("pathFactory", new Callable<PathFactory>() {
@Override
public PathFactory call() {
final PathFactory factory = new PathFactory();
factory.addPathVariable("MODULE_DIR", task.getOutputFile().getParentFile());
for (Map.Entry<String, File> entry : module.getPathVariables().entrySet()) {
factory.addPathVariable(entry.getKey(), entry.getValue());
}
return factory;
}
});
artifactRegistry.registerIdeArtifact(new IdeaModuleMetadata(module, task));
addWorker(task);
}
use of org.gradle.plugins.ide.idea.internal.IdeaModuleMetadata in project gradle by gradle.
the class IdeaPlugin method allImlArtifactsInComposite.
private List<TaskDependency> allImlArtifactsInComposite(ProjectInternal project, IdeaProject ideaProject) {
List<TaskDependency> dependencies = Lists.newArrayList();
ProjectComponentIdentifier thisProjectId = projectPathRegistry.getProjectComponentIdentifier(project.getIdentityPath());
for (IdeArtifactRegistry.Reference<IdeaModuleMetadata> reference : artifactRegistry.getIdeArtifactMetadata(IdeaModuleMetadata.class)) {
BuildIdentifier otherBuildId = reference.getOwningProject().getBuild();
if (thisProjectId.getBuild().equals(otherBuildId)) {
// IDEA Module for project in current build: don't include any module that has been excluded from project
boolean found = false;
for (IdeaModule ideaModule : ideaProject.getModules()) {
if (reference.get().getFile().equals(ideaModule.getOutputFile())) {
found = true;
break;
}
}
if (!found) {
continue;
}
}
dependencies.add(reference.getBuildDependencies());
}
return dependencies;
}
use of org.gradle.plugins.ide.idea.internal.IdeaModuleMetadata in project gradle by gradle.
the class IdeaProject method configureModulePaths.
private void configureModulePaths(Project xmlProject) {
ProjectComponentIdentifier thisProjectId = projectPathRegistry.getProjectComponentIdentifier(((ProjectInternal) project).getIdentityPath());
for (IdeArtifactRegistry.Reference<IdeaModuleMetadata> reference : artifactRegistry.getIdeArtifactMetadata(IdeaModuleMetadata.class)) {
BuildIdentifier otherBuildId = reference.getOwningProject().getBuild();
if (thisProjectId.getBuild().equals(otherBuildId)) {
// IDEA Module for project in current build: handled via `modules` model elements.
continue;
}
xmlProject.addModulePath(reference.get().getFile());
}
}
Aggregations