From dev-return-127984-archive-asf-public=cust-asf.ponee.io@maven.apache.org Sun Apr 21 08:16:17 2019 Return-Path: X-Original-To: archive-asf-public@cust-asf.ponee.io Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [207.244.88.153]) by mx-eu-01.ponee.io (Postfix) with SMTP id 8F32C180658 for ; Sun, 21 Apr 2019 10:16:17 +0200 (CEST) Received: (qmail 45399 invoked by uid 500); 21 Apr 2019 08:16:16 -0000 Mailing-List: contact dev-help@maven.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Help: List-Post: List-Id: "Maven Developers List" Reply-To: "Maven Developers List" Delivered-To: mailing list dev@maven.apache.org Received: (qmail 21784 invoked by uid 99); 20 Apr 2019 20:44:06 -0000 X-Virus-Scanned: Debian amavisd-new at spamd1-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 0.302 X-Spam-Level: X-Spam-Status: No, score=0.302 tagged_above=-999 required=6.31 tests=[KAM_LAZY_DOMAIN_SECURITY=1, KAM_SHORT=0.001, RCVD_IN_DNSWL_LOW=-0.7, URIBL_BLOCKED=0.001] autolearn=disabled To: dev@maven.apache.org References: Subject: Re: Accessing a maven repository programatically (in 2019) From: Michael Lipp Openpgp: preference=signencrypt Message-ID: <3c99d19c-018f-8778-8a20-2aebd3cca9b6@mnl.de> Date: Sat, 20 Apr 2019 22:43:55 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.6.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Content-Language: en-US X-Con-Id: 228147 X-Con-U: 0-mnl X-Originating-IP: 95.222.215.22 On 2019/04/08 11:21:19, Paul Hammant wrote: > There's shades of https://en.wikipedia.org/wiki/XY_problem to what you> > posting. I, for one, an interested in what your trying to make after you've> > solved this problem :)> It's not trivial. There is a tool called "bnd" that supports the development and deployment of OSGi bundles. The tool works "natively" with OSGi Repositories (https://osgi.org/javadoc/osgi.cmpn/7.0.0/org/osgi/service/repository/Repository.html). There are various bnd plugins that provide "OSGi repository views" on a selection of artifacts from one or more maven repositories. In order to do this, bnd provides its own library for accessing maven repositories, including classes for parsing and evaluating POMs. When I started to write my own bnd plugin (https://github.com/mnlipp/de.mnl.osgi/tree/master/de.mnl.osgi.bnd.repository) I found that bnd's POM evaluation lacks some features. My first idea was to replace all of bnd's maven library with the "standard" maven library. This led to my initial question in this list. Sorry to say, but none of the answers really helped. I dug further through the maven API and the sources. Much too late I found https://lairdnelson.wordpress.com/2017/03/06/maven-and-the-project-formerly-known-as-aether/, I wish I had found it earlier, would have saved me a lot of "digging". It is obviously impossible to use the "standard" maven library (or better "components") without a ridiculous number of (partially redundant) CDI libraries. (That gave me quite a different perspective on bnd's sleek implementation.) Having understood this, I thought about fixing the problems I had identified with bnd's POM handling. But somehow, it seemed ridiculous to maintain this non-trivial functionality twice. So what I have ended up with is this: https://github.com/mnlipp/de.mnl.osgi/blob/2e9246a3a1fe416c50ec3667676a95b92babe232/de.mnl.osgi.bnd.repository/src/de/mnl/osgi/bnd/maven/CompositeMavenRepository.java#L134 . I use the "components" from the maven library and assemble them myself to avoid pulling in all those CDI libraries. Assembling the components, I found that eventually the only "repository functionality" required to evaluate a POM into a "Model" (using the standard maven components) is an implementation of "ModelResolver". I therefore provide such an implementation based on bnd's repository (access) classes (https://github.com/mnlipp/de.mnl.osgi/blob/bnd.repository-2.0.0/de.mnl.osgi.bnd.repository/src/de/mnl/osgi/bnd/maven/BndModelResolver.java). Maybe I'll some day try to assemble a "standard" repository access from the (former) aether components. But actually, this part of bnd's maven library seems to work flawlessly, so my motivation is quite low. (And I still don't understand the aether API. It seems to duplicate a lot of the functionality provided by the org.apache.maven.* classes.) Is this an X/Y problem? Maybe. The question was "How can I use the maven libraries for (easily) accessing a maven repository?". Maybe I should have asked first "Is the collection of maven APIs in the various libraries intended to support easy access to the content of a maven repository?"  - Michael --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org For additional commands, e-mail: dev-help@maven.apache.org