You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by us...@apache.org on 2022/09/27 09:13:08 UTC

[lucene] branch branch_9x updated: GH-11819: Fix the Eclipse part to support deveopment of the MR-JAR: (#11823)

This is an automated email from the ASF dual-hosted git repository.

uschindler pushed a commit to branch branch_9x
in repository https://gitbox.apache.org/repos/asf/lucene.git


The following commit(s) were added to refs/heads/branch_9x by this push:
     new 265e25f4fbf GH-11819: Fix the Eclipse part to support deveopment of the MR-JAR: (#11823)
265e25f4fbf is described below

commit 265e25f4fbf5468828f1081b3c3d1f0914402442
Author: Uwe Schindler <us...@apache.org>
AuthorDate: Tue Sep 27 11:11:49 2022 +0200

    GH-11819: Fix the Eclipse part to support deveopment of the MR-JAR: (#11823)
    
    - by default, Lucene will only generate a config for Java 17 (or 11 in 9.x), without the MR-JAR sourceSets
    - if passed -Peclipse.javaVersion=19, it will include matching sourcesets and set compiler version to given version in classpath
---
 gradle/ide/eclipse.gradle            | 24 +++++++---
 gradle/ide/eclipse/dot.classpath.xsl | 87 ------------------------------------
 2 files changed, 17 insertions(+), 94 deletions(-)

diff --git a/gradle/ide/eclipse.gradle b/gradle/ide/eclipse.gradle
index ffe88eafe3f..f18ceb75872 100644
--- a/gradle/ide/eclipse.gradle
+++ b/gradle/ide/eclipse.gradle
@@ -24,6 +24,7 @@ def resources = scriptResources(buildscript)
 configure(rootProject) {
   apply plugin: "eclipse"
 
+  def eclipseJavaVersion = propertyOrDefault("eclipse.javaVersion", rootProject.minJavaVersion)
   def relativize = { other -> rootProject.rootDir.relativePath(other).toString() }
 
   eclipse {
@@ -41,13 +42,16 @@ configure(rootProject) {
           def projects = allprojects.findAll { prj ->
             return prj.plugins.hasPlugin(JavaPlugin)
           }
-
+          
+          Set<String> sourceSetNames = ["main", "test", "main${eclipseJavaVersion}", "test${eclipseJavaVersion}", "tools"] as Set
           Set<String> sources = []
           Set<File> jars = []
           projects.each { prj ->
             prj.sourceSets.each { sourceSet ->
-              sources += sourceSet.java.srcDirs.findAll { dir -> dir.exists() }.collect { dir -> relativize(dir) }
-              sources += sourceSet.resources.srcDirs.findAll { dir -> dir.exists() }.collect { dir -> relativize(dir) }
+              if (sourceSetNames.contains(sourceSet.name)) {
+                sources += sourceSet.java.srcDirs.findAll { dir -> dir.exists() }.collect { dir -> relativize(dir) }
+                sources += sourceSet.resources.srcDirs.findAll { dir -> dir.exists() }.collect { dir -> relativize(dir) }
+              } 
             }
 
             // This is hacky - we take the resolved compile classpath and just
@@ -71,9 +75,9 @@ configure(rootProject) {
     }
 
     jdt {
-      sourceCompatibility = rootProject.minJavaVersion
-      targetCompatibility = rootProject.minJavaVersion
-      javaRuntimeName = "JavaSE-${rootProject.minJavaVersion}"
+      sourceCompatibility = eclipseJavaVersion
+      targetCompatibility = eclipseJavaVersion
+      javaRuntimeName = "JavaSE-$eclipseJavaVersion"
     }
   }
 
@@ -85,6 +89,7 @@ configure(rootProject) {
     
     inputs.file(ecjLintFile)
     inputs.property('errorMode', errorMode)
+    inputs.property('eclipseJavaVersion', eclipseJavaVersion as String)
   
     from rootProject.file("${resources}/dot.settings")
     into rootProject.file(".settings")
@@ -94,7 +99,8 @@ configure(rootProject) {
     filteringCharset = 'UTF-8'
     
     doLast {
-      logger.lifecycle('Eclipse config written with ECJ errors configured as {}. Change by passing -Peclipse.errors=ignore/warning/error.', errorMode)
+      logger.lifecycle('Eclipse config for Java {} written with ECJ errors configured as {}. Change by passing -Peclipse.errors=ignore/warning/error.', eclipseJavaVersion, errorMode)
+      logger.lifecycle('To edit classes of MR-JARs for a specific Java version, use e.g., -Peclipse.javaVersion=19')
     }
   }
   
@@ -102,6 +108,10 @@ configure(rootProject) {
     enabled = false    
     dependsOn 'luceneEclipseJdt'
   }
+  
+  eclipseClasspath {
+    inputs.property('eclipseJavaVersion', eclipseJavaVersion as String)
+  }
 }
 
 public class LibEntry implements ClasspathEntry {
diff --git a/gradle/ide/eclipse/dot.classpath.xsl b/gradle/ide/eclipse/dot.classpath.xsl
deleted file mode 100644
index 8d48c5d9acd..00000000000
--- a/gradle/ide/eclipse/dot.classpath.xsl
+++ /dev/null
@@ -1,87 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-  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.
--->
-<xsl:stylesheet version="1.0" 
-  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
-  xmlns:str="http://exslt.org/strings"
-  extension-element-prefixes="str"
->
-  <xsl:param name="eclipse.fileset.sourcefolders"/>
-  <xsl:param name="eclipse.fileset.libs"/>
-  <xsl:param name="eclipse.fileset.webfolders"/>
-  
-  <!--
-    NOTE: This template matches the root element of any given input XML document!
-    The XSL input file is ignored completely.
-  --> 
-  <xsl:template match="/">
-    <classpath>
-      <xsl:for-each select="str:split($eclipse.fileset.sourcefolders,'|')">
-        <!-- hack to sort the list, starts-with() returns "true" which sorts before "false" if descending: -->
-        <xsl:sort select="string(starts-with(text(), 'lucene/core/'))" order="descending" lang="en"/>
-        <xsl:sort select="string(starts-with(text(), 'lucene/test-framework/'))" order="descending" lang="en"/>
-        <xsl:sort select="string(starts-with(text(), 'lucene/'))" order="descending" lang="en"/>
-        <xsl:sort select="string(starts-with(text(), 'solr/core/'))" order="descending" lang="en"/>
-        <xsl:sort select="string(starts-with(text(), 'solr/solrj/'))" order="descending" lang="en"/>
-        <xsl:sort select="string(starts-with(text(), 'solr/test-framework/'))" order="descending" lang="en"/>
-        <xsl:sort select="string(starts-with(text(), 'solr/'))" order="descending" lang="en"/>
-        <!-- all others in one group above are sorted by path name: -->
-        <xsl:sort select="text()" order="ascending" lang="en"/>
-        
-        <classpathentry kind="src" path="{.}">
-          <!-- make Lucene's resource folders unique (for SPI), but leave the main SPI in default target folder: -->
-          <xsl:if test="starts-with(.,'lucene/') and not(starts-with(.,'lucene/core')) and contains(.,'/src/resources')">
-            <xsl:attribute name="output">
-              <xsl:text>eclipse-build/</xsl:text><xsl:value-of select="position()"/>
-            </xsl:attribute>
-          </xsl:if>
-        </classpathentry>
-        <!-- special case for benchmark, we add extra entry after the tests: -->
-        <xsl:if test="text()='lucene/benchmark/src/test'">
-          <classpathentry excluding="src" including="conf/**" kind="src" path="lucene/benchmark"/>
-        </xsl:if>
-      </xsl:for-each>
-
-      <xsl:for-each select="str:split($eclipse.fileset.webfolders,'|')">
-        <xsl:sort select="text()" order="ascending" lang="en"/>
-        <classpathentry kind="src" path="{.}">
-          <xsl:attribute name="output">
-            <xsl:choose>
-              <xsl:when test="contains(.,'solr/webapp/web')">
-                <xsl:text>eclipse-build/solr-server/solr-webapp/webapp</xsl:text>
-              </xsl:when>
-              <xsl:otherwise>
-                <xsl:text>eclipse-build/solr-server/</xsl:text><xsl:value-of select="substring(text(), 13)"/>
-              </xsl:otherwise>
-            </xsl:choose>
-          </xsl:attribute>
-        </classpathentry>
-      </xsl:for-each>
-
-      <!-- the main resources folder is here (see above), so it's listed after the test-framework resources, making preflex-override work: -->
-      <classpathentry kind="output" path="eclipse-build/main"/>
-      <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-11"/>
-
-      <xsl:for-each select="str:split($eclipse.fileset.libs,'|')">
-        <!-- sort the jars by path name: -->
-        <xsl:sort select="text()" order="ascending" lang="en"/>
-        <classpathentry kind="lib" path="{.}"/>
-      </xsl:for-each>
-    </classpath>
-  </xsl:template>
-
-</xsl:stylesheet>