use of org.gradle.plugins.ide.idea.model.IdeaModuleIml in project gradle by gradle.
the class IdeaPlugin method configureIdeaModule.
private void configureIdeaModule(final Project 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);
ConventionMapping conventionMapping = ((IConventionAware) module).getConventionMapping();
conventionMapping.map("sourceDirs", new Callable<Set<File>>() {
@Override
public Set<File> call() throws Exception {
return Sets.newHashSet();
}
});
conventionMapping.map("name", new Callable<String>() {
@Override
public String call() throws Exception {
return project.getName();
}
});
conventionMapping.map("contentRoot", new Callable<File>() {
@Override
public File call() throws Exception {
return project.getProjectDir();
}
});
conventionMapping.map("testSourceDirs", new Callable<Set<File>>() {
@Override
public Set<File> call() throws Exception {
return Sets.newHashSet();
}
});
conventionMapping.map("excludeDirs", new Callable<Set<File>>() {
@Override
public Set<File> call() throws Exception {
return Sets.newHashSet(project.getBuildDir(), project.file(".gradle"));
}
});
conventionMapping.map("pathFactory", new Callable<PathFactory>() {
@Override
public PathFactory call() throws Exception {
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;
}
});
addWorker(task);
}
use of org.gradle.plugins.ide.idea.model.IdeaModuleIml in project gradle by gradle.
the class IdeaPlugin method configureIdeaModule.
private void configureIdeaModule(final ProjectInternal project) {
IdeaModuleIml iml = new IdeaModuleIml(new XmlTransformer(), project.getProjectDir());
final IdeaModule module = instantiator.newInstance(IdeaModule.class, project, iml);
final TaskProvider<GenerateIdeaModule> task = project.getTasks().register(IDEA_MODULE_TASK_NAME, GenerateIdeaModule.class, module);
task.configure(new Action<GenerateIdeaModule>() {
@Override
public void execute(GenerateIdeaModule task) {
task.setDescription("Generates IDEA module files (IML)");
}
});
ideaModel.setModule(module);
final String defaultModuleName = uniqueProjectNameProvider.getUniqueName(project);
module.setName(defaultModuleName);
ConventionMapping conventionMapping = ((IConventionAware) module).getConventionMapping();
Set<File> sourceDirs = Sets.newLinkedHashSet();
conventionMapping.map("sourceDirs", new Callable<Set<File>>() {
@Override
public Set<File> call() {
return sourceDirs;
}
});
conventionMapping.map("contentRoot", new Callable<File>() {
@Override
public File call() {
return project.getProjectDir();
}
});
Set<File> testSourceDirs = Sets.newLinkedHashSet();
conventionMapping.map("testSourceDirs", new Callable<Set<File>>() {
@Override
public Set<File> call() {
return testSourceDirs;
}
});
Set<File> resourceDirs = Sets.newLinkedHashSet();
conventionMapping.map("resourceDirs", new Callable<Set<File>>() {
@Override
public Set<File> call() throws Exception {
return resourceDirs;
}
});
Set<File> testResourceDirs = Sets.newLinkedHashSet();
conventionMapping.map("testResourceDirs", new Callable<Set<File>>() {
@Override
public Set<File> call() throws Exception {
return testResourceDirs;
}
});
Set<File> excludeDirs = Sets.newLinkedHashSet();
conventionMapping.map("excludeDirs", new Callable<Set<File>>() {
@Override
public Set<File> call() {
excludeDirs.add(project.file(".gradle"));
excludeDirs.add(project.getBuildDir());
return excludeDirs;
}
});
conventionMapping.map("pathFactory", new Callable<PathFactory>() {
@Override
public PathFactory call() {
final PathFactory factory = new PathFactory();
factory.addPathVariable("MODULE_DIR", task.get().getOutputFile().getParentFile());
for (Map.Entry<String, File> entry : module.getPathVariables().entrySet()) {
factory.addPathVariable(entry.getKey(), entry.getValue());
}
return factory;
}
});
artifactRegistry.registerIdeProject(new IdeaModuleMetadata(module, task));
addWorker(task, IDEA_MODULE_TASK_NAME);
}
Aggregations