-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
👻 Fix maven index and update it weekly (#63)
Signed-off-by: Jason Montleon <[email protected]>
- Loading branch information
Showing
5 changed files
with
75 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
name: 'Generate Maven Index and Commit' | ||
on: | ||
workflow_dispatch: | ||
schedule: | ||
- cron: '0 3 * * 0' | ||
|
||
jobs: | ||
build_and_commit: | ||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: write | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
- name: Install podman | ||
shell: bash | ||
run: sudo apt-get install -y podman | ||
- name: | ||
run: | | ||
podman build -f hack/Dockerfile -t export hack/ | ||
podman cp $(podman create export):/unpack/maven.default.index ./hack | ||
- name: Commit Updated maven.default.index update | ||
uses: stefanzweifel/git-auto-commit-action@v4 | ||
with: | ||
commit_message: ":ghost: Update Maven Index" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
FROM registry.access.redhat.com/ubi9/ubi | ||
RUN dnf module enable -y maven:3.8 \ | ||
&& dnf clean all \ | ||
&& dnf -y update \ | ||
&& dnf -y install https://dl.fedoraproject.org/pub/epel/epel-release-latest-9.noarch.rpm \ | ||
&& dnf -y install maven-openjdk17 git parallel pigz \ | ||
&& dnf clean all | ||
RUN git clone https://github.com/apache/maven-indexer.git | ||
RUN cd maven-indexer/indexer-cli && mvn install -Denforcer.skip=true -Dmaven.test.skip=true | ||
RUN mkdir -p /unpack/index | ||
COPY export.java /unpack/export.java | ||
RUN cd /unpack/index \ | ||
&& curl -s -o nexus-maven-repository-index.gz https://repo.maven.apache.org/maven2/.index/nexus-maven-repository-index.gz \ | ||
&& java -jar $(find /root/.m2 -name indexer-cli-*-cli.jar) -u nexus-maven-repository-index.gz \ | ||
&& rm nexus-maven-repository-index.gz \ | ||
&& cd /unpack \ | ||
&& java -classpath $(find /root/.m2 -name lucene-core*.jar) export.java | pigz -k -p$(nproc) > export.gz \ | ||
&& rm -rf index \ | ||
&& unpigz -p$(nproc) export.gz \ | ||
&& cat export | \ | ||
parallel -j150% --pipe --block 100M --cat \ | ||
grep -oaP "'[a-z][a-zA-Z0-9_.-]+\|[a-zA-Z][a-zA-Z0-9_.-]+\|([a-zA-Z0-9_.-]+\|)?(sources|pom|jar|maven-plugin|ear|ejb|ejb-client|java-source|rar|war)\|(jar|war|ear|pom|war|rar)'" {} | \ | ||
cut -d'|' -f1 | \ | ||
sed 's/$/.*/' | \ | ||
sort | \ | ||
uniq > maven.default.index \ | ||
&& rm -rf export |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import java.nio.file.Path; | ||
import java.nio.file.Paths; | ||
import org.apache.lucene.document.Document; | ||
import org.apache.lucene.index.DirectoryReader; | ||
import org.apache.lucene.index.IndexReader; | ||
import org.apache.lucene.store.Directory; | ||
import org.apache.lucene.store.FSDirectory; | ||
|
||
public class Export { | ||
public static void main(String[] args) throws Exception { | ||
Path path = Paths.get("index"); | ||
Directory index = FSDirectory.open(path); | ||
IndexReader reader = DirectoryReader.open(index); | ||
|
||
int num = reader.numDocs(); | ||
for ( int i = 0; i < num; i++) | ||
{ | ||
Document d = reader.document( i); | ||
System.out.println( "d=" +d); | ||
} | ||
reader.close(); | ||
} | ||
} |