Search in sources :

Example 1 with WebConfiguration

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);
}
Also used : DependencyData(com.intellij.openapi.externalSystem.model.project.DependencyData) NotNullLazyValue(com.intellij.openapi.util.NotNullLazyValue) EarConfiguration(org.jetbrains.plugins.gradle.model.ear.EarConfiguration) DataNode(com.intellij.openapi.externalSystem.model.DataNode) ModuleData(com.intellij.openapi.externalSystem.model.project.ModuleData) WebConfiguration(org.jetbrains.plugins.gradle.model.web.WebConfiguration)

Example 2 with WebConfiguration

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();
        }
    }));
}
Also used : Function(com.intellij.util.Function) IdeaModule(org.gradle.tooling.model.idea.IdeaModule) WebResource(org.jetbrains.plugins.gradle.model.web.WebConfiguration.WebResource) WarModel(org.jetbrains.plugins.gradle.model.web.WebConfiguration.WarModel) WebConfiguration(org.jetbrains.plugins.gradle.model.web.WebConfiguration) Test(org.junit.Test)

Aggregations

WebConfiguration (org.jetbrains.plugins.gradle.model.web.WebConfiguration)2 DataNode (com.intellij.openapi.externalSystem.model.DataNode)1 DependencyData (com.intellij.openapi.externalSystem.model.project.DependencyData)1 ModuleData (com.intellij.openapi.externalSystem.model.project.ModuleData)1 NotNullLazyValue (com.intellij.openapi.util.NotNullLazyValue)1 Function (com.intellij.util.Function)1 IdeaModule (org.gradle.tooling.model.idea.IdeaModule)1 EarConfiguration (org.jetbrains.plugins.gradle.model.ear.EarConfiguration)1 WarModel (org.jetbrains.plugins.gradle.model.web.WebConfiguration.WarModel)1 WebResource (org.jetbrains.plugins.gradle.model.web.WebConfiguration.WebResource)1 Test (org.junit.Test)1