use of org.jetbrains.plugins.gradle.model.web.WebConfiguration in project intellij-community by JetBrains.
the class JavaEEGradleProjectResolverExtension method populateModuleExtraModels.
@Override
public void populateModuleExtraModels(@NotNull IdeaModule gradleModule, @NotNull final DataNode<ModuleData> ideModule) {
final WebConfiguration webConfiguration = resolverCtx.getExtraProject(gradleModule, WebConfiguration.class);
final NotNullLazyValue<DataNode<? extends ModuleData>> findTargetModuleNode = new NotNullLazyValue<DataNode<? extends ModuleData>>() {
@NotNull
@Override
protected DataNode<? extends ModuleData> compute() {
final String mainSourceSetModuleId = ideModule.getData().getId() + ":main";
DataNode<? extends ModuleData> targetModuleNode = ExternalSystemApiUtil.find(ideModule, GradleSourceSetData.KEY, node -> mainSourceSetModuleId.equals(node.getData().getId()));
if (targetModuleNode == null) {
targetModuleNode = ideModule;
}
return targetModuleNode;
}
};
if (webConfiguration != null) {
final List<War> warModels = ContainerUtil.map(webConfiguration.getWarModels(), new Function<WebConfiguration.WarModel, War>() {
@Override
public War fun(WebConfiguration.WarModel model) {
War war = new War(model.getWarName(), model.getWebAppDirName(), model.getWebAppDir());
war.setWebXml(model.getWebXml());
war.setWebResources(mapWebResources(model.getWebResources()));
war.setClasspath(model.getClasspath());
war.setManifestContent(model.getManifestContent());
war.setArchivePath(model.getArchivePath());
return war;
}
});
findTargetModuleNode.getValue().createChild(WebConfigurationModelData.KEY, new WebConfigurationModelData(GradleConstants.SYSTEM_ID, warModels));
}
final EarConfiguration earConfiguration = resolverCtx.getExtraProject(gradleModule, EarConfiguration.class);
if (earConfiguration != null) {
final List<Ear> warModels = ContainerUtil.map(earConfiguration.getEarModels(), new Function<EarConfiguration.EarModel, Ear>() {
@Override
public Ear fun(EarConfiguration.EarModel model) {
Ear ear = new Ear(model.getEarName(), model.getAppDirName(), model.getLibDirName());
ear.setManifestContent(model.getManifestContent());
ear.setDeploymentDescriptor(model.getDeploymentDescriptor());
ear.setResources(mapEarResources(model.getResources()));
ear.setArchivePath(model.getArchivePath());
return ear;
}
});
final Collection<DependencyData> deployDependencies = GradleProjectResolverUtil.getIdeDependencies(resolverCtx, findTargetModuleNode.getValue(), earConfiguration.getDeployDependencies());
final Collection<DependencyData> earlibDependencies = GradleProjectResolverUtil.getIdeDependencies(resolverCtx, findTargetModuleNode.getValue(), earConfiguration.getEarlibDependencies());
findTargetModuleNode.getValue().createChild(EarConfigurationModelData.KEY, new EarConfigurationModelData(GradleConstants.SYSTEM_ID, warModels, deployDependencies, earlibDependencies));
}
nextResolver.populateModuleExtraModels(gradleModule, ideModule);
}
use of org.jetbrains.plugins.gradle.model.web.WebConfiguration in project intellij-community by JetBrains.
the class WebConfigurationBuilderImplTest method testDefaultWarModel.
@Test
public void testDefaultWarModel() throws Exception {
DomainObjectSet<? extends IdeaModule> ideaModules = allModels.getIdeaProject().getModules();
List<WebConfiguration> ideaModule = ContainerUtil.mapNotNull(ideaModules, new Function<IdeaModule, WebConfiguration>() {
@Override
public WebConfiguration fun(IdeaModule module) {
return allModels.getExtraProject(module, WebConfiguration.class);
}
});
assertEquals(1, ideaModule.size());
WebConfiguration webConfiguration = ideaModule.get(0);
assertEquals(1, webConfiguration.getWarModels().size());
final WarModel warModel = webConfiguration.getWarModels().iterator().next();
assertEquals("src/main/webapp", warModel.getWebAppDirName());
assertArrayEquals(new String[] { "MANIFEST.MF", "additionalWebInf", "rootContent" }, ContainerUtil.map2Array(warModel.getWebResources(), new Function<WebResource, Object>() {
@Override
public String fun(WebResource resource) {
return resource.getFile().getName();
}
}));
}
Aggregations