Skip to content

Commit 82534d9

Browse files
authored
this fixes split packages across the repo in 4.x (#2933)
1 parent 32ef64b commit 82534d9

290 files changed

Lines changed: 428 additions & 335 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
#!/usr/bin/env python3
2+
# Licensed to the Apache Software Foundation (ASF) under one or more
3+
# contributor license agreements. See the NOTICE file distributed with
4+
# this work for additional information regarding copyright ownership.
5+
# The ASF licenses this file to You under the Apache License, Version 2.0
6+
# (the "License"); you may not use this file except in compliance with
7+
# the License. You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
"""
17+
Fail if any Java package is declared in more than one Maven module ("split
18+
package"). JPMS forbids split packages on the module path, and Tika keeps
19+
one-package-per-module as an invariant (see TIKA-4xxx). This is a structural,
20+
reactor-wide check that per-module tools (checkstyle, forbidden-apis, spotless,
21+
banDuplicateClasses) cannot express.
22+
23+
Scope: main sources only (src/main/java) -- that is what JPMS cares about;
24+
test sources live in the unnamed module and are intentionally excluded.
25+
26+
Usage: python3 .github/scripts/check_split_packages.py [repo_root]
27+
Exit: 0 = no split packages, 1 = split package(s) found.
28+
"""
29+
import os
30+
import sys
31+
import collections
32+
33+
PRUNE = {"target", ".git", ".local_m2_repo", "node_modules", ".mvn"}
34+
35+
36+
def main() -> int:
37+
root = os.path.abspath(sys.argv[1] if len(sys.argv) > 1 else ".")
38+
pkg_to_modules = collections.defaultdict(set)
39+
for dirpath, dirnames, _ in os.walk(root):
40+
dirnames[:] = [d for d in dirnames if d not in PRUNE]
41+
norm = dirpath.replace(os.sep, "/")
42+
if not norm.endswith("/src/main/java"):
43+
continue
44+
src_root = dirpath
45+
module = os.path.relpath(dirpath[: -len(os.sep + "src/main/java")], root).replace(os.sep, "/")
46+
for sub, _, files in os.walk(src_root):
47+
if any(f.endswith(".java") and f != "package-info.java" for f in files):
48+
pkg = os.path.relpath(sub, src_root).replace(os.sep, ".")
49+
if pkg and pkg != ".":
50+
pkg_to_modules[pkg].add(module)
51+
52+
splits = {p: sorted(m) for p, m in pkg_to_modules.items() if len(m) > 1}
53+
if not splits:
54+
print(f"OK: no split packages ({len(pkg_to_modules)} packages across the reactor).")
55+
return 0
56+
57+
print("ERROR: split package(s) found -- each package must live in exactly one module.\n")
58+
for pkg, mods in sorted(splits.items()):
59+
print(f" {pkg}")
60+
for m in mods:
61+
print(f" {m}")
62+
print("\nJPMS forbids a package spanning modules. Move the minority side into a")
63+
print("module-specific package (e.g. org.apache.tika.detect.icu4j) so the package")
64+
print("lives in one module only. See the maintainer docs on split packages.")
65+
return 1
66+
67+
68+
if __name__ == "__main__":
69+
sys.exit(main())
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#
2+
# Licensed to the Apache Software Foundation (ASF) under one or more
3+
# contributor license agreements. See the NOTICE file distributed with
4+
# this work for additional information regarding copyright ownership.
5+
# The ASF licenses this file to You under the Apache License, Version 2.0
6+
# (the "License"); you may not use this file except in compliance with
7+
# the License. You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
#
17+
18+
name: no split packages
19+
20+
on:
21+
pull_request:
22+
branches: [ main ]
23+
push:
24+
branches: [ main ]
25+
26+
jobs:
27+
check-split-packages:
28+
runs-on: ubuntu-latest
29+
timeout-minutes: 5
30+
steps:
31+
- uses: actions/checkout@v6
32+
- name: Check for split packages (one package = one module, JPMS invariant)
33+
run: python3 .github/scripts/check_split_packages.py

docs/modules/ROOT/pages/advanced/language-detection.adoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ For the default classpath resources (general model ~3.2 MB, short-text model
226226
== WordTokenizer (tika-eval integration)
227227

228228
The same preprocessing pipeline is exposed as a general-purpose word tokenizer
229-
via `org.apache.tika.langdetect.charsoup.WordTokenizer`. This replaces the former
229+
via `org.apache.tika.langdetect.charsoup.core.WordTokenizer`. This replaces the former
230230
Lucene-based tokenizer in `tika-eval`:
231231

232232
* `tokenize(String)` — alphabetic and ideographic tokens only (CJK bigrams)

docs/modules/ROOT/pages/developers/serialization.adoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,7 @@ Complete example of a custom metadata filter:
315315
----
316316
package com.example.tika;
317317
318-
import org.apache.tika.config.TikaComponent;
318+
import org.apache.tika.annotation.TikaComponent;
319319
import org.apache.tika.exception.TikaException;
320320
import org.apache.tika.metadata.Metadata;
321321
import org.apache.tika.metadata.filter.MetadataFilter;

tika-annotation-processor/src/main/java/org/apache/tika/config/TikaComponent.java renamed to tika-annotation-processor/src/main/java/org/apache/tika/annotation/TikaComponent.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
* See the License for the specific language governing permissions and
1515
* limitations under the License.
1616
*/
17-
package org.apache.tika.config;
17+
package org.apache.tika.annotation;
1818

1919
import java.lang.annotation.ElementType;
2020
import java.lang.annotation.Retention;

tika-annotation-processor/src/main/java/org/apache/tika/annotation/TikaComponentProcessor.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@
4545
import javax.tools.FileObject;
4646
import javax.tools.StandardLocation;
4747

48-
import org.apache.tika.config.TikaComponent;
4948

5049
/**
5150
* Annotation processor for {@link TikaComponent} that generates:
@@ -57,7 +56,7 @@
5756
* <p>The processor maintains an inclusion list of known Tika service interfaces
5857
* to avoid generating SPI files for utility interfaces like Serializable, etc.
5958
*/
60-
@SupportedAnnotationTypes("org.apache.tika.config.TikaComponent")
59+
@SupportedAnnotationTypes("org.apache.tika.annotation.TikaComponent")
6160
@SupportedSourceVersion(SourceVersion.RELEASE_17)
6261
public class TikaComponentProcessor extends AbstractProcessor {
6362

tika-app/src/test/java/org/apache/tika/cli/TikaCLIAsyncTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
import org.slf4j.Logger;
4040
import org.slf4j.LoggerFactory;
4141

42-
import org.apache.tika.config.JsonConfigHelper;
42+
import org.apache.tika.serialization.config.JsonConfigHelper;
4343

4444
public class TikaCLIAsyncTest {
4545

tika-core/src/main/java/org/apache/tika/config/EmbeddedLimits.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@
1515
* limitations under the License.
1616
*/
1717
package org.apache.tika.config;
18-
1918
import java.io.Serializable;
2019

20+
import org.apache.tika.annotation.TikaComponent;
2121
import org.apache.tika.parser.ParseContext;
2222

2323
/**

tika-core/src/main/java/org/apache/tika/config/OutputLimits.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@
1515
* limitations under the License.
1616
*/
1717
package org.apache.tika.config;
18-
1918
import java.io.Serializable;
2019

20+
import org.apache.tika.annotation.TikaComponent;
2121
import org.apache.tika.parser.ParseContext;
2222

2323
/**

tika-core/src/main/java/org/apache/tika/config/TimeoutLimits.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@
1515
* limitations under the License.
1616
*/
1717
package org.apache.tika.config;
18-
1918
import java.io.Serializable;
2019
import java.util.Objects;
2120

21+
import org.apache.tika.annotation.TikaComponent;
2222
import org.apache.tika.parser.ParseContext;
2323

2424
/**

0 commit comments

Comments
 (0)