You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@geode.apache.org by GitBox <gi...@apache.org> on 2022/02/16 20:10:00 UTC

[GitHub] [geode] rhoughton-pivot commented on a change in pull request #7348: GEODE-8705: Introduce classloader isolation for deployments using JBoss Modules.

rhoughton-pivot commented on a change in pull request #7348:
URL: https://github.com/apache/geode/pull/7348#discussion_r808396009



##########
File path: buildSrc/src/main/groovy/org/apache/geode/gradle/plugins/DependencyConstraints.groovy
##########
@@ -243,6 +243,7 @@ class DependencyConstraints implements Plugin<Project> {
     dependencySet(group: 'io.netty', version: '4.1.74.Final') {
       entry('netty-codec-redis')
       entry('netty-handler')
+      entry('netty-all')

Review comment:
       This is a little sloppy. Can we call out what pieces of `netty` that are being added by this PR, and add them explicitly?

##########
File path: geode-lucene/build.gradle
##########
@@ -19,11 +19,12 @@ apply from: "${rootDir}/${scriptDir}/standard-subproject-configuration.gradle"
 
 apply from: "${project.projectDir}/../gradle/publish-java.gradle"
 
+apply plugin: 'geode.jboss-modules-plugin'
 
 dependencies {
   api(platform(project(':boms:geode-all-bom')))
 
-  api(project(':geode-core'))
+  implementation(project(':geode-core'))

Review comment:
       `geode-lucene` creates `LuceneIndexDestroyedException`, which extends `GemFireException`.  This requires `geode-core` to remain an `api` dependency.

##########
File path: buildSrc/src/main/java/org/apache/geode/gradle/jboss/modules/plugins/services/GeodeJBossModuleDescriptorService.java
##########
@@ -0,0 +1,550 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.geode.gradle.jboss.modules.plugins.services;
+
+import static org.apache.geode.gradle.jboss.modules.plugins.utils.ProjectUtils.getProjectDependenciesForConfiguration;
+import static org.apache.geode.gradle.jboss.modules.plugins.utils.ProjectUtils.getTargetConfigurations;
+
+import java.io.File;
+import java.io.IOException;
+import java.nio.file.Path;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+import java.util.Optional;
+import java.util.Set;
+import java.util.TreeMap;
+import java.util.TreeSet;
+import java.util.stream.Collectors;
+
+import javax.xml.XMLConstants;
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+
+import org.gradle.api.Project;
+import org.gradle.api.artifacts.Configuration;
+import org.gradle.api.artifacts.Dependency;
+import org.gradle.api.artifacts.DependencyConstraint;
+import org.gradle.api.artifacts.ModuleIdentifier;
+import org.gradle.api.artifacts.ModuleVersionIdentifier;
+import org.gradle.api.artifacts.ResolvedArtifact;
+import org.gradle.api.artifacts.SelfResolvingDependency;
+import org.gradle.api.attributes.AttributeContainer;
+import org.gradle.api.attributes.Category;
+import org.gradle.api.internal.artifacts.dependencies.DefaultExternalModuleDependency;
+import org.gradle.api.internal.artifacts.dependencies.DefaultProjectDependency;
+import org.gradle.api.plugins.ExtraPropertiesExtension;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.NodeList;
+import org.xml.sax.SAXException;
+
+import org.apache.geode.gradle.jboss.modules.plugins.config.ModulesGeneratorConfig;
+import org.apache.geode.gradle.jboss.modules.plugins.domain.DependencyWrapper;
+import org.apache.geode.gradle.jboss.modules.plugins.generator.ModuleDescriptorGenerator;
+import org.apache.geode.gradle.jboss.modules.plugins.generator.domain.ModuleDependency;
+import org.apache.geode.gradle.jboss.modules.plugins.generator.xml.JBossModuleDescriptorGenerator;
+import org.apache.geode.gradle.jboss.modules.plugins.utils.ProjectUtils;
+
+public class GeodeJBossModuleDescriptorService implements GeodeModuleDescriptorService {
+
+  private static final String API = "api";
+  private static final String IMPLEMENTATION = "implementation";
+  private static final String RUNTIME_ONLY = "runtimeOnly";
+  private static final String RUNTIME_CLASSPATH = "runtimeClasspath";
+  private static final String JBOSS_MODULAR = "jbossModular";
+  private static final String EXTERNAL_LIBRARY_DEPENDENCIES_MODULE_NAME =
+      "external-library-dependencies";
+
+  private static final String LIB_PATH_PREFIX = "../../../../../lib/";
+  private static final String PLUGIN_ID = "geode.jboss-modules-plugin";
+  private final ModuleDescriptorGenerator moduleDescriptorGenerator =
+      new JBossModuleDescriptorGenerator();
+
+  private List<Project> allProjects;
+  private static final String IS_GEODE_EXTENSION_STRING = "isGeodeExtension";
+
+  @Override
+  public void createModuleDescriptor(Project project, ModulesGeneratorConfig config,
+      File projectJarFile) {
+
+    List<ModuleDependency> moduleDependencies = generateModuleDependencies(project, config);
+
+    Set<String> resourceRoots = generateResourceRoots(project, projectJarFile, config);
+
+    String moduleVersion = project.getVersion().toString();
+
+    generateNewModuleDescriptor(project, config, moduleDependencies, resourceRoots, moduleVersion);
+  }
+
+
+  private void generateNewModuleDescriptor(Project project, ModulesGeneratorConfig config,
+      List<ModuleDependency> moduleDependencies, Set<String> resourceRoots, String moduleVersion) {
+
+    moduleDescriptorGenerator.generate(config.outputRoot.resolve(config.name), project.getName(),
+        moduleVersion, resourceRoots, moduleDependencies, config.mainClass, Collections.EMPTY_LIST,
+        config.packagesToExport, config.packagesToExclude);
+
+    moduleDescriptorGenerator
+        .generateAlias(config.outputRoot.resolve(config.name), project.getName(), moduleVersion);
+  }
+
+  private List<ModuleDependency> generateModuleDependencies(Project project,
+      ModulesGeneratorConfig config) {
+    List<String> projectNames =
+        getAllProjects(project).stream().filter(proj -> proj.getPluginManager().hasPlugin(
+            PLUGIN_ID)).map(Project::getName).collect(Collectors.toList());
+
+    List<ModuleDependency> moduleDependencies = getModuleDependencies(projectNames,
+        getApiProjectDependencies(project, config),
+        getRuntimeProjectDependencies(project, config),
+        getJBossProjectDependencies(project, config));
+
+    if (config.parentModule != null) {
+      if (isGeodeExtensionProject(config.parentModule)) {
+        moduleDependencies
+            .add(new ModuleDependency(config.parentModule.getName() + "-external-library",
+                true, false));
+      }
+    }
+
+    moduleDependencies.add(new ModuleDependency(EXTERNAL_LIBRARY_DEPENDENCIES_MODULE_NAME,
+        false, false));
+
+    if (isGeodeExtensionProject(project)) {
+      moduleDependencies.add(new ModuleDependency(project.getName() + "-external-library",
+          true, false));
+    }
+
+    moduleDependencies.addAll(getJBossJDKModuleDependencies(config));
+    return moduleDependencies;
+  }
+
+  private static boolean isGeodeExtensionProject(Project project) {
+    ExtraPropertiesExtension extraProperties = project.getExtensions().getExtraProperties();
+    return extraProperties.has(IS_GEODE_EXTENSION_STRING) &&
+            (boolean) extraProperties.get(IS_GEODE_EXTENSION_STRING );
+  }
+
+  private List<DependencyWrapper> getRuntimeProjectDependencies(Project project,
+      ModulesGeneratorConfig config) {
+    return getOrPopulateCachedDependencies(project, config,
+        IMPLEMENTATION, RUNTIME_ONLY);

Review comment:
       Should this include `API` as well, since api dependencies appear at runtime as well?




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@geode.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org