Git Product home page Git Product logo

maven-adapter's Introduction

Join our Telegram group

EO principles respected here DevOps By Rultor.com We recommend IntelliJ IDEA

Javadoc License codecov Hits-of-Code Maven Central PDD status

This Java library is turns binary storage (files, S3 objects, anything) into Maven repository. It implements and can work with Maven repository structure and provides fully-functionable mvn support in Artipie binary repository manager service.

If you have any question or suggestions, do not hesitate to create an issue or contact us in Telegram.
Artipie roadmap.

Maven repository concepts

Files

A dependency is identified by its coordinates - groupId, artifactId and version. JAR files may contain a classifier suffix - sources or javadoc. By coordinates you can determine the artifact path in local or remote repository and vice versa.

Repositories must handle following types of files:

  • A primary artifact - a main JAR file.
  • Secondary artifacts - a POM file, files with a classifier.
  • Attribute files - checksums, signatures, lastUpdate files for primary and secondary artifacts.
  • Metadata files - maven-metadata.xml, containing information about artifact versions including snapshot versions.

File naming convention is: artifactId-version[-classifier]-extension

Layout

(Default) naming convention is - in groupId replace all dots with directory separator ('/') then put artifactId, version and then go files.

Example layout (not fully exhaustive):

$ROOT
|-- org/
    `-- example/
        `-- artifact/
            `-- maven-metadata.xml
            `-- maven-metadata.xml.sha1
            `-- 1.0/
                |-- artifact-1.0.jar
                |-- artifact-1.0.jar.sha1
                |-- artifact-1.0.pom
                |-- artifact-1.0.pom.sha1
                |-- artifact-1.0-sources.jar
                |-- artifact-1.0-sources.jar.sha1
            `-- 2.0-SNAPSHOT/
                |-- artifact-2.0-20210409.123503.jar
                |-- artifact-2.0-20210409.123503.jar.sha1
                |-- artifact-2.0-20210409.123503.pom
                |-- artifact-2.0-20210409.123503.pom.sha1
                |-- artifact-2.0-20210412.163503.jar
                |-- artifact-2.0-20210412.163503.jar.sha1
                |-- artifact-2.0-20210412.163503.pom
                |-- artifact-2.0-20210412.163503.pom.sha1
                |-- maven-metadata.xml
                |-- maven-metadata.xml.sha1

For example, for an artifact org.example:artifact:1.0 (Gradle-style notation is used for clarity) the path would be org/example/artifact/1.0/artifact-1.0.jar (and other files).

Snapshot support

Maven supports the use of snapshot repositories. These repositories are used only when resolving SNAPSHOT dependencies. SNAPSHOT dependencies are just like regular dependencies, with -SNAPSHOT appended to it:

<dependency>
    <groupId>com.artipie</groupId>
    <artifactId>maven-adapter</artifactId>
    <version>2.0-SNAPSHOT</version>
</dependency>

This feature allows anyone which depends on the SNAPSHOT version get the latest changes on every build.

In the repository layout snapshots subdirectories usually contain several versions of the package, files creation timestamps are appended to the filenames. Also, snapshots have their own maven metadata.

Upload process

On deploy maven client sends to the server package artifacts with the help of the PUT HTTP requests, at the end of the deploy process maven client sends package metadata. Here an example of maven request set:

PUT /com/artipie/helloworld/1.0/helloworld-1.0.jar
PUT /com/artipie/helloworld/1.0/helloworld-1.0.jar.sha1
PUT /com/artipie/helloworld/1.0/helloworld-1.0.pom
PUT /com/artipie/helloworld/1.0/helloworld-1.0.pom.sha1
GET /com/artipie/helloworld/maven-metadata.xml
PUT /com/artipie/helloworld/maven-metadata.xml
PUT /com/artipie/helloworld/maven-metadata.xml.sha1

Uploaded data are saved to the temporary upload location with the following layout:

|-- .upload
  `-- com
     `--example
        `-- logger
          `-- 0.1-SNAPSHOT
              |-- logger-0.1.jar
              |-- logger-0.1.jar.sha1
              |-- logger-0.1.jar.md5
              |-- logger-0.1.pom
              |-- logger-0.1.pom.sha1
              |-- logger-0.1.pom.md5
              |-- maven-metadata.xml             # snapshot metadata
              |-- maven-metadata.xml.sha1
              |-- maven-metadata.xml.md5
                `-- meta
                    |-- maven-metadata.xml       # package metadata
                    |-- maven-metadata.xml.sha1
                    |-- maven-metadata.xml.md5

Repository update is started when an artifact (any, nondeterministic) and package maven-metadata.xml have the same set of checksums. On the repository update checksums are verified, package metadata are processed and all the received artifacts are saved to the repository.

How to contribute

Fork repository, make changes, send us a pull request. We will review your changes and apply them to the master branch shortly, provided they don't violate our quality standards. To avoid frustration, before sending us your pull request please run full Maven build:

$ mvn clean install -Pqulice

To avoid build errors use Maven 3.2+ and please read contributing rules.

maven-adapter's People

Contributors

carlosmiranda avatar dependabot-preview[bot] avatar dependabot[bot] avatar g4s8 avatar genryxy avatar ilyamoskva avatar olegmoz avatar olenagerasimova avatar paulodamaso avatar swizbiz avatar victornoel avatar yegor256 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

maven-adapter's Issues

LocalArtifactResolver unit test

LocalArtifactResolver resolves an artifact in a local repository by its relative path.
The class was not covered by test to split the original pull request.

AstoTransporterTest.java:73-76: Delete temp directory....

The puzzle 37-329dc9a9 from #37 has to be resolved:

* @todo #37:30min Delete temp directory.
* Because of a bug in Asto,
* the temp directory maybe not deleted and the test would fail.
* Quietly deleting it as a workaround.

The puzzle was created by @Nimmaster on 18-Feb-20.

Estimate: 30 minutes, role: DEV.

If you have any technical questions, don't ask me, submit new tickets instead. The task will be "done" when the problem is fixed and the text of the puzzle is removed from the source code. Here is more about PDD and about me.

File.java:38-40: Implement file storage using...

The puzzle 58-abf1aafd from #58 has to be resolved:

* @todo #58:30min Implement file storage using artipie/asto Storage.
* Finish File.Asto implementation and then remove the disabled
* annotation from the tests in AstoFileTest.

The puzzle was created by paulodamaso on 26-Mar-20.

Estimate: 30 minutes, role: DEV.

If you have any technical questions, don't ask me, submit new tickets instead. The task will be "done" when the problem is fixed and the text of the puzzle is removed from the source code. Here is more about PDD and about me.

Validating ServiceLocator

org.eclipse.aether.spi.locator.ServiceLocator is a ServiceLocator pattern interface. It creates/retrieves services by matching service class. If the service was not yet registered it simply returns null forcing you to make a null check on each invocation.
We should hide null checks in another class implementing the interface.

Update readme

"A developer's entrypoint" and further information in readme file seem to be outdated, for example Repository interface is deprecated and does not have method upload.

May be it will be better to update readme after all deprecated classes will be refactored and removed.

Metadata.java:39-44: Implement Metadata generation....

The puzzle 54-83abca7b from #54 has to be resolved:

* @todo #54:30min Implement Metadata generation.
* Artifact metadata is generated according to Artifact versions and files.
* The implementation of metadata must read all files from all versions of
* some artifact and then generate a xml representing it. Please refer to
* http://maven.apache.org/ref/3.3.9/maven-repository-metadata/repository-metadata.html
* to metadata xml structure.

The puzzle was created by paulodamaso on 13-Mar-20.

Estimate: 30 minutes, role: DEV.

If you have any technical questions, don't ask me, submit new tickets instead. The task will be "done" when the problem is fixed and the text of the puzzle is removed from the source code. Here is more about PDD and about me.

Maven.java:43-50: Generate valid checksums on metadata...

The puzzle 85-bba77ac2 from #85 has to be resolved:

* @todo #85:30min Generate valid checksums on metadata update.
* When updating the maven-metadata.xml, then we should find all checksum files in the root of
* repository by prefix maven-metadata.xml (it can be done using storage.list), there will be
* few checksum files like `maven-metadata.xml.md5`, `maven-metadata.xml.sha1`,
* `maven-metadata.xml.sha256`, `maven-metadata.xml.sha512`. We need to update all these files
* with checksums of `maven-metadata.xml` data using checksum file extension as digest algorithm.
* If we found some unsupported algorithm, then delete checksum file. I'd start with
* `MD5`, `SHA-256`, `SHA-1` and `SHA-512`.

The puzzle was created by @g4s8 on 21-May-20.

Estimate: 30 minutes, role: DEV.

If you have any technical questions, don't ask me, submit new tickets instead. The task will be "done" when the problem is fixed and the text of the puzzle is removed from the source code. Here is more about PDD and about me.

Snapshot repository support

Let's support snapshot repositories. Start with investigating how snapshot repository works (add it to the readme), then implement integration tests, then actual implementation.

Basic uploading

Use Maven libraries.
Scope: no snapshots, plugins, parents

OptionalAssertions.java:35-38: We added class...

The puzzle 1-539b0424 from #1 has to be resolved:

* @todo #1:30min We added class com.artipie.maven.test.OptionalAssertions,
* which contains some utility methods for asserting Optional stuff within our
* unit tests. Please, provide some unit tests for this class. It's a tool used in
* our tests, which should be tested itself to ensure it works as expected.

The puzzle was created by Nimmaster on 30-Jan-20.

Estimate: 30 minutes, role: DEV.

If you have any technical questions, don't ask me, submit new tickets instead. The task will be "done" when the problem is fixed and the text of the puzzle is removed from the source code. Here is more about PDD and about me.

File.java:34-36: Implement file storage using...

The puzzle 54-affb36a2 from #54 has to be resolved:

* @todo #54:30min Implement file storage using artipie/asto Storage.
* Files must be stored somewhere. Use artipie/asto to provide an storage for
* the repository files.

The puzzle was created by paulodamaso on 10-Mar-20.

Estimate: 30 minutes, role: DEV.

If you have any technical questions, don't ask me, submit new tickets instead. The task will be "done" when the problem is fixed and the text of the puzzle is removed from the source code. Here is more about PDD and about me.

AetherRepository.java:43-46: Inject Deployer (and...

The puzzle 37-15918c08 from #37 has to be resolved:

* @todo #37:30min Inject Deployer (and Resolver) as constructor args.
* Inject other services directly to Deployer.
* Create locator and session in Deployer method call.
* Same for Resolver.

The puzzle was created by @g4s8 on 26-Feb-20.

Estimate: 30 minutes, role: DEV.

If you have any technical questions, don't ask me, submit new tickets instead. The task will be "done" when the problem is fixed and the text of the puzzle is removed from the source code. Here is more about PDD and about me.

pom.xml:102: Remove commons usage in favor of cactoos

The puzzle 54-9c5a8d8c from #54 has to be resolved:

<!-- @todo #54:30min Remove commons usage in favor of cactoos

The puzzle was created by paulodamaso on 10-Mar-20.

Estimate: 30 minutes, role: DEV.

If you have any technical questions, don't ask me, submit new tickets instead. The task will be "done" when the problem is fixed and the text of the puzzle is removed from the source code. Here is more about PDD and about me.

MavenSlice.java:45-47: Continue working on the Maven HTTP...

The puzzle 72-b493e50d from #72 has to be resolved:

* @todo #72:30min Continue working on the Maven HTTP API for uploading artifacts:
* we need to protect the upload of files using some kind of authentication similar
* to what is used for downloads.

The puzzle was created by Victor Noël on 08-May-20.

Estimate: 30 minutes, role: DEV.

If you have any technical questions, don't ask me, submit new tickets instead. The task will be "done" when the problem is fixed and the text of the puzzle is removed from the source code. Here is more about PDD and about me.

Implement two FileCoordinates methods

FileCoordinates contains two methods: coords() and path() that throw UnsupportedOperationException. We should implement it (and unit test too).
The class was not implemented to split the original pull request.

MavenHttpITCase.java:158-164: For now the generation of...

The puzzle 72-9e640b6a from #72 has to be resolved:

// @todo #72:30min For now the generation of artifact and repository metadata
// (e.g. md5 sums, metadata.xml, etc) happens on the client side (in the
// maven-deploy-plugin, simulated by MavenArtifacts here).
// We should decide to either: 1) validate the uploaded artifacts to ensure the
// repository is consistent or 2) to delegate the generation of the metadata to
// the server side. This is not clear if it is feasible with maven-deploy-plugin
// on the client side, see #72 for some details on that.

The puzzle was created by Victor Noël on 08-May-20.

Estimate: 30 minutes, role: DEV.

If you have any technical questions, don't ask me, submit new tickets instead. The task will be "done" when the problem is fixed and the text of the puzzle is removed from the source code. Here is more about PDD and about me.

Return text list for repo or artifact request

Let's reutrn simple text list (or primitive HTML list) of items in repo or artifact paths. E.g. if the request is pointing to repository like host/maven/ then we should return list of artifacts in this repo, same for artifact host/mave/com/artipie/asto reutrns list of metadata and versions.
Similar to Maven central:

README.md:46-50: Continue working in the Maven HTTP API...

The puzzle 64-cc923fd8 from #64 has to be resolved:

maven-adapter/README.md

Lines 46 to 50 in 2a0fdc0

@todo #64:30min Continue working in the Maven HTTP API for uploading artifacts: we need to 1) investigate
exactly what are the HTTP endpoints needed when using the maven-deploy-plugin with the HTTP Wagon extension,
2) add IT tests that uses a traditional Maven client (investigate for libraries used in the Maven
ecosystem to simulate proper Maven client requests), and then 3) implement those HTTP API
so that the IT tests pass.

The puzzle was created by Victor Noël on 11-Apr-20.

Estimate: 30 minutes, role: DEV.

If you have any technical questions, don't ask me, submit new tickets instead. The task will be "done" when the problem is fixed and the text of the puzzle is removed from the source code. Here is more about PDD and about me.

Adapter refactoring

Refactor maven adapter base interfaces and entry points:

  • it should be reactive - no support for InputStream and OutputStream, only Publisher<ByteBuffer> from reactivestreams.org
  • Entry point class should encapsulate Storage interface from artipie/asto dependency and use it to generate metadata by key, e.g. new Maven(storage).update(new Key.From("org/artipie/maven-adapter"))

Ask me if something is not clear.

Introduce context object

org.eclipse.aether.spi.locator.ServiceLocator and org.eclipse.aether.RepositorySystemSession are principal interfaces in Maven library. They should be created as instance-per-request which makes them quiet unwieldy.
I propose to create a new class (say com.artipie.maven.aether.Context) which:

  • implements these two interfaces and passes method calls to delegate fields
  • absorbs com.artipie.maven.aether.ValidatingServiceLocator
  • stores contextual values like correlationId in org.eclipse.aether.RepositorySystemSession#getData()
    Its instances should be created by a factory class com.artipie.maven.aether.ContextFactory
    which accepts com.artipie.asto.Storage and org.eclipse.aether.repository.LocalRepository as a constructor args. It absorbs com.artipie.maven.aether.ServiceLocatorFactory and com.artipie.maven.aether.SessionFactory.

Absorbs #41

More:

ServiceLocator and RepositorySystemSession are not thread-safe. RxJava may reschedule operator execution in another thread exposing these objects to race condition. You should investigate how to solve it.

README.md:35-38: Continue working in the Maven HTTP API...

The puzzle 64-a4ea9323 from #64 has to be resolved:

maven-adapter/README.md

Lines 35 to 38 in 2a0fdc0

@todo #64:30min Continue working in the Maven HTTP API for downloading artifacts: we need to 1) add
IT tests that uses a traditional Maven client (investigate for libraries used in the Maven
ecosystem to simulate proper Maven client requests), and then 2) implement those HTTP API
so that we serve the artifacts according to the layout described below.

The puzzle was created by Victor Noël on 11-Apr-20.

Estimate: 30 minutes, role: DEV.

If you have any technical questions, don't ask me, submit new tickets instead. The task will be "done" when the problem is fixed and the text of the puzzle is removed from the source code. Here is more about PDD and about me.

OptionalAssertionsTest

Testing facility class com.artipie.maven.test.OptionalAssertions requires its own unit tests

Setup logging more

  • the project uses org.slf4j.Marker in logging statements, logback config pattern should support it.
  • set WARN level for io.netty

MavenHttpITCase.java:70-72: For some unknown reason the...

The puzzle 72-e21c7763 from #72 has to be resolved:

* @todo #72:30min For some unknown reason the two tests involving
* the deployment of files are extremely slow, each upload of empty
* files takes several seconds. Fix this situation.

The puzzle was created by Victor Noël on 08-May-20.

Estimate: 30 minutes, role: DEV.

If you have any technical questions, don't ask me, submit new tickets instead. The task will be "done" when the problem is fixed and the text of the puzzle is removed from the source code. Here is more about PDD and about me.

Readme documentation is missed

It's not clear how to use this module, which classes to use as entry points and how to construct it. @Nimmaster please add these details to usage section of README.md.

MavenHttpITCase.java:54-60: Continue working on the Maven...

The puzzle 71-c580cc48 from #71 has to be resolved:

* @todo #71:30min Continue working on the Maven HTTP API for downloading artifacts: we need to 1)
* add to the test serveArtifact a) the instantiation of the artipie Maven server with a test
* artifact being served via the Maven HTTP API (see README for details) and b) configure the
* remote repository in the test serveArtifact to point to the Artipie Maven server and c) verify
* the test serveArtifact is able to download the artifact correctly via aether (already setup
* in test serveArtifact). Once this is done, then 2) implement those HTTP API so that the test
* serveArtifact passes.

The puzzle was created by @g4s8 on 23-Apr-20.

Estimate: 30 minutes, role: DEV.

If you have any technical questions, don't ask me, submit new tickets instead. The task will be "done" when the problem is fixed and the text of the puzzle is removed from the source code. Here is more about PDD and about me.

Purge local repository directory

To delete files in local repository just like in AutoCloseablePath.
Consider and putting artifacts directly to local repository, dropping AutoCloseablePath.
Introduce an interface for different deletion strategies in local repositories - possibly LRU time-based policy.

Maven repository HTTP API

Let's investigate what API methods Maven repo supports and add these methods.
Start this task in following order:

  1. Documentation update: let's add specification and references about maven repo API in README
  2. Create integration tests for API
  3. Implement API methods.

Try to decompose this task as much as possible using todos (e.g. one todo per API)

AstoTransporter should set checksums for artifact resolution

Set checksums in Task object in com.artipie.maven.aether.AstoTransporter#implGet like:

task.setChecksum("MD5", /* get checksum from Asto */);
task.setChecksum("SHA1", /* get checksum from Asto */);

Now, if checksums are not set, Maven library logs warnings like:

WARN  o.e.a.i.impl.WarnChecksumPolicy -  Could not validate integrity of download from asto://artipie.com/maven/org/example/artifact/maven-metadata.xml
org.eclipse.aether.transfer.ChecksumFailureException: Checksum validation failed, no checksums available

It is a place for possible optimization - to fetch a binary and its checksums in one call.

Staging file java facilities

Maven relies heavily on file system. Before processing an artifact, we should put it in some temporary storage.

Metadata.java:39-44: Continue to implement metadata...

The puzzle 57-0a27a98f from #57 has to be resolved:

* @todo #57:30min Continue to implement metadata generation.
* Artifact metadata is generated according to Artifact versions and files.
* The implementation of metadata must read all files from all versions of
* some artifact and then generate a xml representing it. Please refer to
* http://maven.apache.org/ref/3.3.9/maven-repository-metadata/repository-metadata.html
* to metadata xml structure. Once finished, enable test at Metadata test.

The puzzle was created by paulodamaso on 23-Mar-20.

Estimate: 30 minutes, role: DEV.

If you have any technical questions, don't ask me, submit new tickets instead. The task will be "done" when the problem is fixed and the text of the puzzle is removed from the source code. Here is more about PDD and about me.

Parse coordinates by path

Now com.artipie.maven.FileCoordinates expects artfiact name to be as colon-delimited string. It should be URI path segment

ServiceLocatorFactory.java:60-62: Inject a...

The puzzle 10-5f36658f from #10 has to be resolved:

* @todo #10:30min Inject a LocalRepository into a ServiceLocator.
* Current design made ServiceLocatorFactory and LocalRepository coupled together.
* We can retrieve a LocalRepository directly from the ServiceLocator

The puzzle was created by @Nimmaster on 10-Feb-20.

Estimate: 30 minutes, role: DEV.

If you have any technical questions, don't ask me, submit new tickets instead. The task will be "done" when the problem is fixed and the text of the puzzle is removed from the source code. Here is more about PDD and about me.

Maven proxy

Implement Maven proxy repository (or Maven mirror) with authentication and cache support. Maven mirrors are described here: https://maven.apache.org/guides/mini/guide-mirror-settings.html

Multi-remote

Maven proxy can be used to merge multiple remote repositories into single one. In this case, proxy repository is trying to access remotes one by one in specified order until find applicable artifact.

Example: user uses Artipie Maven mirror to get artifacts from custom private repository and from Maven central, user configures Artipie Maven mirror to first search artifacts in private repository, and then from central, if artifact was not found in private repo.

Authentication

Proxy should be able to use authentication to access remote repository. The use case is when the user is giving access to different repositories through proxy or hiding actual credentials on proxy side.

Caching

Proxy should be able to cache artifacts and metadata, the user can configure the TTL and size of the cache. Proxy needs to check HTTP cache control directives when pulling remote artifacts.
Artipie Maven proxy should use cache directives as well to avoid redundant downloads.

Configuration

The suggested configuration for proxy repository for Artipie is:

repository:
  type: maven-proxy
  remotes:
    - url: https://private.repo.com/maven # required
      username: admin # optional
      password: qwerty # optional
      cache: # optional
        ttl: 5d # optional
        maxSize: 10G # optional
    - url: https://repo.maven.apache.org/maven2

This job may be discussed and changed, also it can be boosted if needed.

README.md cleanup

README.md has leftovers from previous implementations which does not apply to current project structure. We need to do a cleanup, removing or correcting the following items:

  • "maven-adapter": correct project description, it does not depends on 'org.apache.maven' and 'org.eclipse.aether' anymore
  • "how it works": we have some documentation on how maven works in "files" and "layout" topics, maybe we could leave them here for documentation purposes
  • "a developer's entrypoint": "storaqge lifecycle" topic is outdated and could be removed
  • "maven library abstract": is outdated and can be removed also

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.