diff --git a/CONTRIBUTORS b/CONTRIBUTORS new file mode 100644 index 0000000..84d48a9 --- /dev/null +++ b/CONTRIBUTORS @@ -0,0 +1 @@ +Boris Baldassari diff --git a/docs/README.md b/docs/README.md index a0e771b..e6308dc 100644 --- a/docs/README.md +++ b/docs/README.md @@ -1,78 +1,78 @@ # Documentation ## Sequence The index files can be dowloaded from any maven repository that uses maven-indexer, like maven central: https://repo1.maven.org/maven2/.index/ Copy all files (i.e. the main index, the updates and properties file) into the volume directory (`$WORKDIR`). It will be mounted as `/work/` in the docker image. The export is then achieved in two steps: * Unpack the Lucene indexes from the Maven Indexer indexes using `maven-indexer-cli`. The command used is: ``` $ java --illegal-access=permit -jar $INDEXER_JAR \ --unpack $FILE_IN \ --destination $WORKDIR/indexes/ \ --type full ``` This generates a set of binary lucene files as shown below: ``` $ ls -lh $WORKDIR/indexes/ total 5,2G -rw-r--r-- 1 root root 500M juil. 7 22:06 _4m.fdt -rw-r--r-- 1 root root 339K juil. 7 22:06 _4m.fdx -rw-r--r-- 1 root root 2,2K juil. 7 22:07 _4m.fnm -rw-r--r-- 1 root root 166M juil. 7 22:07 _4m_Lucene50_0.doc -rw-r--r-- 1 root root 147M juil. 7 22:07 _4m_Lucene50_0.pos [SNIP] -rw-r--r-- 1 root root 363 juil. 7 22:06 _e0.si -rw-r--r-- 1 root root 1,7K juil. 7 22:07 segments_2 -rw-r--r-- 1 root root 8 juil. 7 21:54 timestamp ``` * Export the Lucene documents from the Lucene indexes using `clue`. This generates a set of text files as shown below: ``` $ java --illegal-access=permit -jar $JAR_CLUE $WORKDIR/indexes/ \ export $WORKDIR/export/ text ``` This generates a bunch of text files relating to the Lucene indexes, made available in `$WORKDIR/export/`. For our purpose we only keep the `*.fld` file that includes the indexed documents. ## Output The clue command is documented on [its github page](https://github.com/javasoze/clue). The indexed Lucene documents are located in the `*.fld` file. A description of the fields used by maven-indexer can be found in the project's API docs: https://maven.apache.org/maven-indexer-archives/maven-indexer-6.0.0/indexer-core/apidocs/org/apache/maven/index/ArtifactInfo.html ## How to build The build downloads binaries for both tools (maven-indexer-cli and clue), so make sure there is an internet connection. Go to the `docker/` dorectory and issue the folowing command: ``` -$ docker build . -t bbaldassari/maven-index-exporter --no-cache +$ docker build . -t softwareheritage/maven-index-exporter --no-cache ``` An up-to-date docker image is also available on docker hub at -[bbaldassari/maven-index-exporter](https://hub.docker.com/r/bbaldassari/maven-index-exporter). +[softwareheritage/maven-index-exporter](https://hub.docker.com/r/softwareheritage/maven-index-exporter). ``` -$ docker pull bbaldassari/maven-index-exporter +$ docker pull softwareheritage/maven-index-exporter ``` diff --git a/docs/build_and_test.md b/docs/build_and_test.md index df5de31..8a649bb 100644 --- a/docs/build_and_test.md +++ b/docs/build_and_test.md @@ -1,199 +1,199 @@ # Build and test Maven index exporter ## How to test (the quick way) There is a bash script called `test_docker_image.sh` in the `scripts/` directory, simply execute it. Tests cover the creation of the docker image, its execution, and the resulting output. ``` $ bash test_docker_image.sh Script started on 20210911_181912. * Writing log to test_docker_image.log. * Docker image [maven-index-exporter] doesn't exist. * Building docker image. PASS: docker build returned 0. PASS: Docker image is listed. PASS: file [$HOME/Projects/gh_maven-index-exporter/repository_test/export/_1.fld] has been created. PASS: file [$HOME/Projects/gh_maven-index-exporter/repository_test/export/_1.fld] has 7 docs. PASS: file [$HOME/Projects/gh_maven-index-exporter/repository_test/export/_1.fld] has 26 fields. PASS: file [$HOME/Projects/gh_maven-index-exporter/repository_test/export/_1.fld] has sprova4j-0.1.0-sources.jar. PASS: file [$HOME/Projects/gh_maven-index-exporter/repository_test/export/_1.fld] has sprova4j-0.1.0.pom. PASS: file [$HOME/Projects/gh_maven-index-exporter/repository_test/export/_1.fld] has sprova4j-0.1.1-sources.jar. PASS: file [$HOME/Projects/gh_maven-index-exporter/repository_test/export/_1.fld] has sprova4j-0.1.1.pom. $ ``` ## How to test (the long road) This repository has a simple, almost-empty maven-indexer index that can be used to test the docker build. To use it, make sure that the directory `repository_test/` is present and run this command: ``` -$ docker run -v $(pwd)/repository_test:/work bbaldassari/maven-index-exporter +$ docker run -v $(pwd)/repository_test:/work softwareheritage/maven-index-exporter ``` The exported files will be stored in `repository_test/export/`, and output should look like this: ``` -$ docker run -v $(pwd)/repository_test:/work bbaldassari/maven-index-exporter +$ docker run -v $(pwd)/repository_test:/work softwareheritage/maven-index-exporter Docker Script started on 2021-08-27 06:32:22. # Checks.. * Content of /opt: total 32156 -rw------- 1 root root 18000742 Jan 8 2018 clue-6.2.0-1.0.0.jar -rw-r--r-- 1 root root 2574 Aug 25 18:28 extract_indexes.sh -rw------- 1 root root 14914610 Nov 28 2017 indexer-cli-6.0.0.jar drwxr-xr-x 3 root root 4096 Jun 29 16:23 java * Content of /work: total 36 -rw-r--r-- 1 1000 1000 254 Aug 26 09:21 nexus-maven-repository-index.1.gz -rw-r--r-- 1 1000 1000 32 Aug 26 09:21 nexus-maven-repository-index.1.gz.md5 -rw-r--r-- 1 1000 1000 40 Aug 26 09:21 nexus-maven-repository-index.1.gz.sha1 -rw-r--r-- 1 1000 1000 344 Aug 26 09:21 nexus-maven-repository-index.gz -rw-r--r-- 1 1000 1000 32 Aug 26 09:21 nexus-maven-repository-index.gz.md5 -rw-r--r-- 1 1000 1000 40 Aug 26 09:21 nexus-maven-repository-index.gz.sha1 -rw-r--r-- 1 1000 1000 193 Aug 26 09:21 nexus-maven-repository-index.properties -rw-r--r-- 1 1000 1000 32 Aug 26 09:21 nexus-maven-repository-index.properties.md5 -rw-r--r-- 1 1000 1000 40 Aug 26 09:21 nexus-maven-repository-index.properties.sha1 * Will read files from [/work/nexus-maven-repository-index.gz]. * Found file [/work/nexus-maven-repository-index.gz]. * Found indexer [/opt/indexer-cli-6.0.0.jar]. * Found clue [/opt/clue-6.2.0-1.0.0.jar]. * Java version:. openjdk version "11.0.11" 2021-04-20 OpenJDK Runtime Environment AdoptOpenJDK-11.0.11+9 (build 11.0.11+9) OpenJDK 64-Bit Server VM AdoptOpenJDK-11.0.11+9 (build 11.0.11+9, mixed mode) ############################# Unpacking [/work/nexus-maven-repository-index.gz] to /work/indexes SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder". SLF4J: Defaulting to no-operation (NOP) logger implementation SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details. Index Folder: /work Output Folder: /work/indexes Total time: 0 sec Final memory: 41M/1004M Unpacking finished on 2021-08-27 06:32:23. ############################# Exporting indexes /work/indexes to /work/export no configuration found, using default configuration Analyzer: class org.apache.lucene.analysis.standard.StandardAnalyzer Query Builder: class com.senseidb.clue.api.DefaultQueryBuilder Directory Builder: class com.senseidb.clue.api.DefaultDirectoryBuilder IndexReader Factory: class com.senseidb.clue.api.DefaultIndexReaderFactory Term Bytesref Display: class com.senseidb.clue.api.StringBytesRefDisplay Payload Bytesref Display: class com.senseidb.clue.api.RawBytesRefDisplay exporting index to text Exporting finished on 2021-08-27 06:32:23. ############################# Cleaning useless files. Size before cleaning: 32.0K /work/export 28.0K /work/indexes 4.0K /work/nexus-maven-repository-index.1.gz 4.0K /work/nexus-maven-repository-index.1.gz.md5 4.0K /work/nexus-maven-repository-index.1.gz.sha1 4.0K /work/nexus-maven-repository-index.gz 4.0K /work/nexus-maven-repository-index.gz.md5 4.0K /work/nexus-maven-repository-index.gz.sha1 4.0K /work/nexus-maven-repository-index.properties 4.0K /work/nexus-maven-repository-index.properties.md5 4.0K /work/nexus-maven-repository-index.properties.sha1 * Removing useless exports. Keeping only fld text extract. Size after cleaning: 8.0K /work/export 28.0K /work/indexes 4.0K /work/nexus-maven-repository-index.1.gz 4.0K /work/nexus-maven-repository-index.1.gz.md5 4.0K /work/nexus-maven-repository-index.1.gz.sha1 4.0K /work/nexus-maven-repository-index.gz 4.0K /work/nexus-maven-repository-index.gz.md5 4.0K /work/nexus-maven-repository-index.gz.sha1 4.0K /work/nexus-maven-repository-index.properties 4.0K /work/nexus-maven-repository-index.properties.md5 4.0K /work/nexus-maven-repository-index.properties.sha1 * Make files modifiable by the end-user. Docker Script execution finished on 2021-08-27 06:32:23. ``` The `_1.fld` file contains the fields for each document: ``` $ head repository_test/export/_1.fld doc 0 field 0 name u type string value al.aldi|sprova4j|0.1.0|sources|jar field 1 name m type string value 1626111735737 field 2 ``` ### Building the test repository The test repository `repository_test` can be rebuilt from the `repository_src` structure using [indexer-cli](https://search.maven.org/remotecontent?filepath=org/apache/maven/indexer/indexer-cli/6.0.0/indexer-cli-6.0.0.jar) with the following commands: ``` $ cd repository_src $ java -jar ~/Downloads/indexer-cli-6.0.0.jar -i index/ -d repository_test/ -r repo1 -s -c SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder". SLF4J: Defaulting to no-operation (NOP) logger implementation SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details. Repository Folder: $HOME/Projects/maven-index-exporter/repository_src/repo1 Index Folder: $HOME/Projects/maven-index-exporter/repository_src/index Output Folder: $HOME/Projects/maven-index-exporter/repository_src/repository_test Repository name: index Indexers: [min, jarContent] Will create checksum files for all published files (sha1, md5). Will create incremental chunks for changes, along with baseline file. Scanning started Artifacts added: 2 Artifacts deleted: 0 Total time: 1 sec Final memory: 48M/1012M $ java -jar ~/Downloads/indexer-cli-6.0.0.jar -i index/ -d repository_test/ -r repo2 -s -c SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder". SLF4J: Defaulting to no-operation (NOP) logger implementation SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details. Repository Folder: $HOME/Projects/maven-index-exporter/repository_src/repo2 Index Folder: $HOME/Projects/maven-index-exporter/repository_src/index Output Folder: $HOME/Projects/maven-index-exporter/repository_src/repository_test Repository name: index Indexers: [min, jarContent] Will create checksum files for all published files (sha1, md5). Will create incremental chunks for changes, along with baseline file. Scanning started Artifacts added: 2 Artifacts deleted: 0 Total time: 0 sec Final memory: 7M/1012M $ java -jar ~/Downloads/indexer-cli-6.0.0.jar -i index/ -d repository_test/ -r repo3 -s -c SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder". SLF4J: Defaulting to no-operation (NOP) logger implementation SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details. Repository Folder: $HOME/Projects/maven-index-exporter/repository_src/repo3 Index Folder: $HOME/Projects/maven-index-exporter/repository_src/index Output Folder: $HOME/Projects/maven-index-exporter/repository_src/repository_test Repository name: index Indexers: [min, jarContent] Will create checksum files for all published files (sha1, md5). Will create incremental chunks for changes, along with baseline file. Scanning started Artifacts added: 1 Artifacts deleted: 2 Total time: 0 sec Final memory: 8M/1012M $ ``` diff --git a/docs/maven_repositories.md b/docs/maven_repositories.md index 012909b..9699919 100644 --- a/docs/maven_repositories.md +++ b/docs/maven_repositories.md @@ -1,163 +1,163 @@ A list of remote Maven repositories using [Maven Indexer](https://maven.apache.org/maven-indexer/) for their catalogue. # Introduction In the Maven ecosystem, dependencies and artefacts required to develop Java projects can be automatically downloaded from remote Maven repositories using a set of unique identifiers (aka coordinates): the groupId, artefactId and version. Maven repositories use a standard directory structure for their hosting, which enables to easily identify and download any artefact with its (groupId, artefactid, version) coordinates. Although it is technically not *required*, Maven repositories often provide an index of all the files they host, mostly for IDEs ( e.g. Eclipse, IntelliJ IDEA, or NetBeans). These index files are usually generated with [Maven Indexer](https://maven.apache.org/maven-indexer/) and consist of gzipped Lucene indexes stored in a `.index/` directory at the root of the repository. The largest and most used Maven repository is of course [Maven Central](https://search.maven.org/), but there are many, many [other repositories](https://mvnrepository.com/repos/central) available around. These are set up by individuals, companies and organisations to provide their own builds or domain-specific repositories. Since it is by no means necessary to register repositories, and as far as we know, there is no exhaustive list of Maven repositories. The resources in this directory are an attempt to identify a list of Maven repository servers, as complete as possible. We also publish a list of servers that provide public indexes that can be analysed and exported with the [Maven index -exporter](https://github.com/borisbaldassari/maven-index-exporter) Docker image. +exporter](https://forge.softwareheritage.org/source/maven-index-exporter/) Docker image. # Method ## Build a list of URLs from poms We started from a dump of all pom files hosted on Maven Central (6.9 million files XML files at the time of collection). For each pom we looked for XML nodes that can represent Maven repositories; starting from the root of the document and using XPath expressions we specifically looked for: * `.//m:repositories/m:repository/` * `.//m:pluginRepository` * `.//m:distributionManagement/m:snapshotRepository` * `.//m:distributionManagement/m:repository` The transformation can be reproduced with the scripts in the `scripts/` directory: ``` time bash extract_repositories_from_stock.sh list_poms.txt | tee extract.log ``` The full execution took 61 hours and produced a list of "only" 928808 lines. Each line provides the origin of the URL in the POM, the repository id, and the URL itself. ``` distrib_snapshot,ossrh,https://oss.sonatype.org/content/repositories/snapshots distrib_repo,ossrh,https://oss.sonatype.org/service/local/staging/deploy/maven2/ ``` ## Download properties In the resulting set, there are many duplicates, non-existent, private or invalid URLs. To make sure that we only list publicly available servers we tried to download the Maven index properties file from every server. This properties file is mandatory in Maven indexer; it can be found at `.index/nexus-maven-repository-index.properties` and contains the list of incremental updates to the index. The sequence of actions is as follows: * Remove printed comments, sort and remove duplicate lines: ``` grep -Ev "^# " extract.log | sort -u > extract_uniq.txt ``` * Extract the list of URLs (3rd column) and filter all but http(s) links: ``` cat result_uniq.txt | cut -d, -f 3 | grep -E '^http' > list_urls.txt ``` * The output list has 7145 lines URLs to test. For each item, we try to get the file in `/.index/nexus-maven-repository-index.properties`. If it yields a file, save it. ```shell SUFFIX="/.index/nexus-maven-repository-index.properties" for url in `cat list_urls.txt`; do echo "Testing URL [$url]." full_url="${url}${SUFFIX}" name=$(echo $url | cut -d/ -f 3- | tr '/' '_') full_name="${name}.properties" echo " Writing to [$full_name]." wget -O servers/"$full_name" --tries=2 $full_url & done ``` * This downloads in the `servers/` directory 3820 properties files. Most of them are empty or contain invalid information, leaving only files that contain an actual list of Maven indexer compressed files. * Rebuild the list of URLs by removing 404s (i.e. servers that did not create a file). Remove trailing slashes to prevent duplicates, sort and make unique: ```shell for f in `ls ../servers/`; do url=$(echo ${f%.properties} | tr '_' '/'); grep ${url%/} list_urls_full.txt; done | sed 's:/*$::' | sort -u > list_urls_final.txt ``` The result is a list of 339 unique URLs: to be downloaded here: [list_urls_final.txt](https://files.nuclino.com/files/e75205b3-354e-4794-a43a-d9f98ad08039/list_urls_final.txt) ## Checking compatibility To ensure that these repositories can be actually parsed with the Maven index exporter, there is no better way than parsing them and generating the index and text export. For this, we first need to download all indexes from all servers: ``` bash scripts/convert_url_to_repo.sh ``` This will rely on the list of directories downloaded previously, and generate a series of subdirectories for each server, with the index files. If the index files already exist they won't be downloaded again. The next step is to execute the docker image from -[bbaldassari/maven-index-exporter](https://github.com/borisbaldassari/maven-index-exporter) +[softwareheritage/maven-index-exporter](https://forge.softwareheritage.org/source/maven-index-exporter/) to export all text indexes in `/export/`. ```shell mkdir -p ../maven_repositories/ for i in `ls`; do time docker run -v /data/work/$i:/work maven-index-exporter | tee ../logs/$i.log; mv $i/ ../maven_repositories/; done ``` This again filters out some servers that use a Maven Indexer version different from the Docker image's compatibility. # Result The final list contains only Maven repositories that: * use Maven Indexer for their indexing, * are publicly available, * are still available as of 2021-11-20, and * can be extracted using the Maven index exporter Docker image. Please note that there will probably be a huge amount of artefact duplicates, as several server names can map to to the same repository, and some repositories might mirror existing content. List of downloads: * The curated list of maven repositories (333 servers): [list_maven_repositories_with_index.txt](maven_repositories/list_maven_repositories_with_index.txt) * A list of compressed text exports for the above maven repositories (as of 2021-11-28): https://icedrive.net/1/01BQpqC6rA We will add more downloads as they are generated, so stay tuned.