Apache Solr open-source search software
SOLR-15921 Look for jars in SOLR_TIP/lib/ (#525)
Jan Høydahl16657ccab092
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txtindex 9b5831e83da..d389961f58b 100644--- a/solr/CHANGES.txt+++ b/solr/CHANGES.txt@@ -33,6 +33,8 @@ New Features* SOLR-16111: Add hl.queryFieldPattern support, an advanced alternative to the hl.requireFieldMatch boolean flag.(Christine Poerschke, David Smiley)+* SOLR-15921: Load jars in <solr-install-dir>/lib/ by default (janhoy)+Improvements---------------------* SOLR-15986: CommitUpdateCommand and SplitIndexCommand can write user commit metadata. (Bruno Roustant)diff --git a/solr/build.gradle b/solr/build.gradleindex 60961744285..0493eae7a7f 100644--- a/solr/build.gradle+++ b/solr/build.gradle@@ -20,5 +20,3 @@ description = 'Parent project for Apache Solr'subprojects {group "org.apache.solr"}--diff --git a/solr/core/src/java/org/apache/solr/core/NodeConfig.java b/solr/core/src/java/org/apache/solr/core/NodeConfig.javaindex 757e8b3bf4a..114ac3b8fef 100644--- a/solr/core/src/java/org/apache/solr/core/NodeConfig.java+++ b/solr/core/src/java/org/apache/solr/core/NodeConfig.java@@ -427,6 +427,9 @@ public class NodeConfig {Set<String> libDirs = new LinkedHashSet<>();libDirs.add("lib");+ // Always add $SOLR_TIP/lib to the shared resource loader+ libDirs.add(getSolrInstallDir().resolve("lib").toAbsolutePath().normalize().toString());+if (!StringUtils.isBlank(getSharedLibDirectory())) {List<String> sharedLibs = Arrays.asList(getSharedLibDirectory().split("\\s*,\\s*"));libDirs.addAll(sharedLibs);diff --git a/solr/core/src/test/org/apache/solr/core/TestCoreContainer.java b/solr/core/src/test/org/apache/solr/core/TestCoreContainer.javaindex bbe302fb4fa..363da957814 100644--- a/solr/core/src/test/org/apache/solr/core/TestCoreContainer.java+++ b/solr/core/src/test/org/apache/solr/core/TestCoreContainer.java@@ -16,6 +16,7 @@*/package org.apache.solr.core;+import static org.apache.solr.servlet.SolrDispatchFilter.SOLR_INSTALL_DIR_ATTRIBUTE;import static org.hamcrest.CoreMatchers.not;import static org.hamcrest.CoreMatchers.nullValue;import static org.hamcrest.core.Is.is;@@ -477,6 +478,35 @@ public class TestCoreContainer extends SolrTestCaseJ4 {System.clearProperty(SolrDispatchFilter.SOLR_INSTALL_DIR_ATTRIBUTE);}+ @Test+ public void testSolrInstallDir() throws Exception {+ Path installDirPath = createTempDir("solrInstallDirTest").toAbsolutePath().normalize();+ Files.createDirectories(installDirPath.resolve("lib"));+ try (JarOutputStream jar1 =+ new JarOutputStream(+ new FileOutputStream(installDirPath.resolve("lib").resolve("jar1.jar").toFile()))) {+ jar1.putNextEntry(new JarEntry("solrInstallDirLibResource"));+ jar1.closeEntry();+ }++ System.setProperty(SOLR_INSTALL_DIR_ATTRIBUTE, installDirPath.toString());++ final CoreContainer cores = init(CONFIGSETS_SOLR_XML);+ try {+ Path solrInstallDir = cores.getConfig().getSolrInstallDir();+ assertTrue(+ "solrInstallDir was " + solrInstallDir,+ solrInstallDir != null+ && installDirPath+ .toString()+ .equals(cores.getConfig().getSolrInstallDir().toString()));+ // Proves that <solr-install-dir>/lib/jar1.jar is found, and the resource inside available+ assertNotNull(cores.getResourceLoader().openResource("solrInstallDirLibResource"));+ } finally {+ cores.shutdown();+ }+ }+private static final String CONFIGSETS_SOLR_XML ="<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n"+ "<solr>\n"diff --git a/solr/packaging/build.gradle b/solr/packaging/build.gradleindex 9a98ae436b9..91ce0b60c30 100644--- a/solr/packaging/build.gradle+++ b/solr/packaging/build.gradle@@ -85,6 +85,10 @@ distributions {include "README.md"})+ from ('static/lib', {+ into 'lib'+ })+from(configurations.modules, {into "modules"})diff --git a/solr/packaging/static/lib/README.md b/solr/packaging/static/lib/README.mdnew file mode 100644index 00000000000..38447c46342--- /dev/null+++ b/solr/packaging/static/lib/README.md@@ -0,0 +1,24 @@+<!--+ 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.+-->++Lib directories+===============++There are several special places you can place Solr plugin .jar files. This is one of them.+Jar files placed in this folder will be globally available.++See https://solr.apache.org/guide/libs.html for more information.\ No newline at end of filediff --git a/solr/solr-ref-guide/modules/configuration-guide/pages/libs.adoc b/solr/solr-ref-guide/modules/configuration-guide/pages/libs.adocindex db651e2403d..6843686cd24 100644--- a/solr/solr-ref-guide/modules/configuration-guide/pages/libs.adoc+++ b/solr/solr-ref-guide/modules/configuration-guide/pages/libs.adoc@@ -35,6 +35,10 @@ See xref:deployment-guide:taking-solr-to-production.adoc[].* `<core_instance>/lib/`: In a user-managed cluster or a single-node installation, you may want to add plugins just for a specific Solr core.Create this adjacent to the `conf/` directory; it's not present by default.+* `<solr_install>/lib/`: The `.jar` files placed here are available to all Solr cores running on the node, and to node level plugins referenced in `solr.xml` -- so basically everything.+Contrary to `<solr_home>/lib/`, this directory is always located in the install dir, so it can be used e.g. for custom+Dockerfile to place custom plugin jars.+* `<solr_install>/server/solr-webapp/webapp/WEB-INF/lib/`: The `.jar` files for Solr itself and it's dependencies live here.Certain plugins or add-ons to plugins require placement here.They will document themselves to say so.diff --git a/solr/solr-ref-guide/modules/deployment-guide/pages/installing-solr.adoc b/solr/solr-ref-guide/modules/deployment-guide/pages/installing-solr.adocindex 26e7a29c8f5..920e9a3d103 100644--- a/solr/solr-ref-guide/modules/deployment-guide/pages/installing-solr.adoc+++ b/solr/solr-ref-guide/modules/deployment-guide/pages/installing-solr.adoc@@ -104,6 +104,12 @@ This directory also contains the scripts needed when using Solr inside the DockeThe `README.md` in this directory describes how custom Solr Docker images can be built using this binary distribution.Refer to the section xref:deployment-guide:solr-in-docker.adoc[] page for information on using a Solr Docker image.+lib/::+Folder where Solr will look for additional plugin jar files.++dist/::+The `dist` directory contains the main Solr .jar files.+docs/::The `docs` directory includes a link to online Javadocs for Solr.diff --git a/solr/test-framework/src/java/org/apache/solr/SolrTestCase.java b/solr/test-framework/src/java/org/apache/solr/SolrTestCase.javaindex 14d05a97c29..ea72ebe2fae 100644--- a/solr/test-framework/src/java/org/apache/solr/SolrTestCase.java+++ b/solr/test-framework/src/java/org/apache/solr/SolrTestCase.java@@ -119,6 +119,11 @@ public class SolrTestCase extends LuceneTestCase {ExternalPaths.DEFAULT_CONFIGSET);}+ // set solr.install.dir needed by some test configs outside of the test sandbox (!)+ if (ExternalPaths.SOURCE_HOME != null) {+ System.setProperty("solr.install.dir", ExternalPaths.SOURCE_HOME);+ }+if (!TEST_NIGHTLY) {System.setProperty("zookeeper.nio.numSelectorThreads", "2");System.setProperty("zookeeper.nio.numWorkerThreads", "3");diff --git a/solr/test-framework/src/java/org/apache/solr/SolrTestCaseJ4.java b/solr/test-framework/src/java/org/apache/solr/SolrTestCaseJ4.javaindex bdd127356a7..09ced75588b 100644--- a/solr/test-framework/src/java/org/apache/solr/SolrTestCaseJ4.java+++ b/solr/test-framework/src/java/org/apache/solr/SolrTestCaseJ4.java@@ -149,7 +149,6 @@ import org.apache.solr.update.processor.DistributedZkUpdateProcessor;import org.apache.solr.update.processor.UpdateRequestProcessor;import org.apache.solr.util.BaseTestHarness;import org.apache.solr.util.ErrorLogMuter;-import org.apache.solr.util.ExternalPaths;import org.apache.solr.util.LogLevel;import org.apache.solr.util.RandomizeSSL;import org.apache.solr.util.RandomizeSSL.SSLRandomizer;@@ -284,10 +283,6 @@ public abstract class SolrTestCaseJ4 extends SolrTestCase {new SolrNamedThreadFactory("testExecutor"),true);- // set solr.install.dir needed by some test configs outside of the test sandbox (!)- if (ExternalPaths.SOURCE_HOME != null) {- System.setProperty("solr.install.dir", ExternalPaths.SOURCE_HOME);- }// not strictly needed by this class at this point in the control lifecycle, but for// backcompat create it now in case any third party tests expect initCoreDataDir to be// non-null after calling setupTestCases()