This is an automated email from the ASF dual-hosted git repository.
ndipiazza pushed a commit to branch pf4j-development-mode
in repository https://gitbox.apache.org/repos/asf/tika.git
The following commit(s) were added to refs/heads/pf4j-development-mode by this
push:
new 47b098312 TIKA-4587: Fix ignite plugin compilation and improve dev mode
47b098312 is described below
commit 47b098312eaea313092435bbdaeff6032022afee
Author: Nicholas DiPiazza <[email protected]>
AuthorDate: Mon Dec 22 08:17:05 2025 -0600
TIKA-4587: Fix ignite plugin compilation and improve dev mode
- Fixed ignite plugin compilation by ensuring tika-pipes-core is built first
- Set pf4j.mode system property in TikaPluginManager.load() to properly
enable pf4j's DEVELOPMENT mode
- Override createPluginDescriptorFinder() to use
PropertiesPluginDescriptorFinder
in development mode (looks for plugin.properties instead of MANIFEST.MF)
- Add Maven dev profile in tika-grpc for easy development server startup
- Add dev-config.json with all 13 plugin directories
Maven dev profile usage:
cd tika-pipes/tika-pipes-plugins && mvn compile
cd ../../tika-grpc && mvn compile exec:java -Pdev
Successfully loads plugins from target/classes in development mode!
---
tika-grpc/README.md | 31 ++++++++++++++++
tika-grpc/dev-config.json | 35 ++++++++++++++++++
tika-grpc/pom.xml | 31 ++++++++++++++++
.../org/apache/tika/plugins/TikaPluginManager.java | 41 +++++++++++++++++-----
4 files changed, 129 insertions(+), 9 deletions(-)
diff --git a/tika-grpc/README.md b/tika-grpc/README.md
index 9359b0c60..fba703341 100644
--- a/tika-grpc/README.md
+++ b/tika-grpc/README.md
@@ -346,6 +346,37 @@ When developing plugins, you can use pf4j's development
mode to load plugins dir
**Configuration Location:** The `plugin-roots` setting is specified in your
**Tika configuration JSON file** (commonly named `tika-config.json`,
`dev-config.json`, or similar).
+### Quick Start with Maven Dev Profile
+
+The easiest way to run tika-grpc in development mode:
+
+```bash
+# 1. Build all plugins once
+cd tika-pipes/tika-pipes-plugins
+mvn clean compile
+cd ../../tika-grpc
+
+# 2. Run tika-grpc with dev profile (auto-enables development mode)
+mvn compile exec:java -Pdev
+```
+
+This will:
+- Automatically enable `tika.plugin.dev.mode=true`
+- Load plugins from `tika-pipes-plugins/*/target/classes` directories
+- Start gRPC server on port 50052
+- Use the `dev-config.json` configuration
+
+**Customizing the dev profile:**
+
+Edit `tika-grpc/dev-config.json` to modify:
+- Which plugins to load
+- Fetcher/emitter configurations
+- Port number (default: 50052)
+
+### Manual Development Mode Setup
+
+If you prefer to run without the dev profile:
+
### Enabling Development Mode
Set one of the following:
diff --git a/tika-grpc/dev-config.json b/tika-grpc/dev-config.json
new file mode 100644
index 000000000..b1934a63e
--- /dev/null
+++ b/tika-grpc/dev-config.json
@@ -0,0 +1,35 @@
+{
+ "plugin-roots": [
+ "../tika-pipes/tika-pipes-plugins/tika-pipes-az-blob/target/classes",
+ "../tika-pipes/tika-pipes-plugins/tika-pipes-csv/target/classes",
+ "../tika-pipes/tika-pipes-plugins/tika-pipes-file-system/target/classes",
+ "../tika-pipes/tika-pipes-plugins/tika-pipes-gcs/target/classes",
+ "../tika-pipes/tika-pipes-plugins/tika-pipes-http/target/classes",
+ "../tika-pipes/tika-pipes-plugins/tika-pipes-ignite/target/classes",
+ "../tika-pipes/tika-pipes-plugins/tika-pipes-jdbc/target/classes",
+ "../tika-pipes/tika-pipes-plugins/tika-pipes-json/target/classes",
+ "../tika-pipes/tika-pipes-plugins/tika-pipes-kafka/target/classes",
+
"../tika-pipes/tika-pipes-plugins/tika-pipes-microsoft-graph/target/classes",
+ "../tika-pipes/tika-pipes-plugins/tika-pipes-opensearch/target/classes",
+ "../tika-pipes/tika-pipes-plugins/tika-pipes-s3/target/classes",
+ "../tika-pipes/tika-pipes-plugins/tika-pipes-solr/target/classes"
+ ],
+ "fetchers": [
+ {
+ "fs": {
+ "defaultFetcher": {
+ "basePath": "/tmp/input"
+ }
+ }
+ }
+ ],
+ "emitters": [
+ {
+ "fs": {
+ "defaultEmitter": {
+ "basePath": "/tmp/output"
+ }
+ }
+ }
+ ]
+}
diff --git a/tika-grpc/pom.xml b/tika-grpc/pom.xml
index 5a5094a9f..3324ffc72 100644
--- a/tika-grpc/pom.xml
+++ b/tika-grpc/pom.xml
@@ -483,4 +483,35 @@
</plugin>
</plugins>
</build>
+
+ <profiles>
+ <!-- Development profile for running tika-grpc with plugin development
mode -->
+ <profile>
+ <id>dev</id>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>exec-maven-plugin</artifactId>
+ <version>${maven.exec.version}</version>
+ <configuration>
+ <mainClass>org.apache.tika.pipes.grpc.TikaGrpcServer</mainClass>
+ <systemProperties>
+ <systemProperty>
+ <key>tika.plugin.dev.mode</key>
+ <value>true</value>
+ </systemProperty>
+ </systemProperties>
+ <arguments>
+ <argument>-c</argument>
+ <argument>${project.basedir}/dev-config.json</argument>
+ <argument>-p</argument>
+ <argument>50052</argument>
+ </arguments>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+ </profiles>
</project>
diff --git
a/tika-plugins-core/src/main/java/org/apache/tika/plugins/TikaPluginManager.java
b/tika-plugins-core/src/main/java/org/apache/tika/plugins/TikaPluginManager.java
index eb500ef50..3be548b00 100644
---
a/tika-plugins-core/src/main/java/org/apache/tika/plugins/TikaPluginManager.java
+++
b/tika-plugins-core/src/main/java/org/apache/tika/plugins/TikaPluginManager.java
@@ -118,6 +118,9 @@ public class TikaPluginManager extends DefaultPluginManager
{
public static TikaPluginManager load(TikaJsonConfig tikaJsonConfig)
throws TikaConfigException, IOException {
+ // Configure pf4j runtime mode before creating the manager
+ configurePf4jRuntimeMode();
+
JsonNode root = tikaJsonConfig.getRootNode();
JsonNode pluginRoots = root.get("plugin-roots");
if (pluginRoots == null) {
@@ -146,18 +149,23 @@ public class TikaPluginManager extends
DefaultPluginManager {
public TikaPluginManager(List<Path> pluginRoots) throws IOException {
super(pluginRoots);
- // Must configure runtime mode immediately after super() but before
loading plugins
- configureRuntimeMode();
- // Note: init() should NOT call loadPlugins() - let the caller do that
explicitly
- // This is because in DEPLOYMENT mode we need to unzip first
+
+ // Log the runtime mode
+ if (getRuntimeMode() == RuntimeMode.DEVELOPMENT) {
+ LOG.info("TikaPluginManager running in DEVELOPMENT mode");
+ }
+
+ // Initialize (unzip plugins if in deployment mode)
init();
}
- private void configureRuntimeMode() {
- RuntimeMode mode = isDevelopmentMode() ? RuntimeMode.DEVELOPMENT :
RuntimeMode.DEPLOYMENT;
- this.runtimeMode = mode;
- if (mode == RuntimeMode.DEVELOPMENT) {
- LOG.info("TikaPluginManager running in DEVELOPMENT mode");
+ /**
+ * Set pf4j's runtime mode system property based on Tika's dev mode
setting.
+ * This must be called before creating TikaPluginManager instance.
+ */
+ private static void configurePf4jRuntimeMode() {
+ if (isDevelopmentMode()) {
+ System.setProperty("pf4j.mode",
RuntimeMode.DEVELOPMENT.toString());
}
}
@@ -210,6 +218,21 @@ public class TikaPluginManager extends
DefaultPluginManager {
// In deployment mode, use the default behavior
return super.createPluginRepository();
}
+
+ /**
+ * Override to use PropertiesPluginDescriptorFinder in development mode.
+ * In development mode, plugins are in target/classes with
plugin.properties,
+ * not packaged JARs with META-INF/MANIFEST.MF.
+ */
+ @Override
+ protected org.pf4j.PluginDescriptorFinder createPluginDescriptorFinder() {
+ if (getRuntimeMode() == RuntimeMode.DEVELOPMENT) {
+ // In development mode, use properties-based finder
+ return new org.pf4j.PropertiesPluginDescriptorFinder();
+ }
+ // In deployment mode, use default manifest-based finder
+ return super.createPluginDescriptorFinder();
+ }
private void init() throws IOException {
if (getRuntimeMode() == RuntimeMode.DEPLOYMENT) {