From users-return-144736-archive-asf-public=cust-asf.ponee.io@maven.apache.org Fri Apr 17 03:04:08 2020 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 7736C180638 for ; Fri, 17 Apr 2020 05:04:08 +0200 (CEST) Received: (qmail 7843 invoked by uid 500); 17 Apr 2020 03:04:06 -0000 Mailing-List: contact users-help@maven.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Help: List-Post: List-Id: "Maven Users List" Reply-To: "Maven Users List" Delivered-To: mailing list users@maven.apache.org Received: (qmail 7830 invoked by uid 99); 17 Apr 2020 03:04:05 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd2-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 17 Apr 2020 03:04:05 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd2-us-west.apache.org (ASF Mail Server at spamd2-us-west.apache.org) with ESMTP id BC1531A417D for ; Fri, 17 Apr 2020 03:04:04 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd2-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -15.501 X-Spam-Level: X-Spam-Status: No, score=-15.501 tagged_above=-999 required=6.31 tests=[DKIMWL_WL_MED=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, ENV_AND_HDR_SPF_MATCH=-0.5, HTML_MESSAGE=0.2, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, USER_IN_DEF_DKIM_WL=-7.5, USER_IN_DEF_SPF_WL=-7.5] autolearn=disabled Authentication-Results: spamd2-us-west.apache.org (amavisd-new); dkim=pass (2048-bit key) header.d=google.com Received: from mx1-ec2-va.apache.org ([10.40.0.8]) by localhost (spamd2-us-west.apache.org [10.40.0.9]) (amavisd-new, port 10024) with ESMTP id HfOD3mNdlwXE for ; Fri, 17 Apr 2020 03:04:03 +0000 (UTC) Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=209.85.166.170; helo=mail-il1-f170.google.com; envelope-from=suztomo@google.com; receiver= Received: from mail-il1-f170.google.com (mail-il1-f170.google.com [209.85.166.170]) by mx1-ec2-va.apache.org (ASF Mail Server at mx1-ec2-va.apache.org) with ESMTPS id 54133BB9A1 for ; Fri, 17 Apr 2020 03:04:03 +0000 (UTC) Received: by mail-il1-f170.google.com with SMTP id i75so717804ild.13 for ; Thu, 16 Apr 2020 20:04:03 -0700 (PDT) X-ASF-DKIM-Sig: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to; bh=kKt1WLy1OlvJR25c8UOoV3cyBAcBYk2H5HHhPu8agCo=; b=W6tSF0kab8YrNlli9rEYaFv05b48jq4xdk6gqKAOqWJELVTONwVU71MajENxA17CbB vZxtoOaZCNuyAC8th5A1tbHROKyeOccPqmNp6ZIOh6vdwEDzcFlsM1BM3aauKQAu3mFa IXYyCo7/3i+CY5FqN7Flp+xO86DL72ATTUsg/mZvey1JQl7RotVDzvZ4o73hVimyX7on +hiq1KOfC5weeic2m3mtmHpqnXErA4ECR0UFkoiGlOMKVcWqyvMYBTAtN1NXAnjvf/1y PvyD3eYuTpylTFUCf3hS+hD5/iARmJCVZs4iEJbInHB+oMwk9T9X3+sMLMm9IJKKFImc GzEw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to; bh=kKt1WLy1OlvJR25c8UOoV3cyBAcBYk2H5HHhPu8agCo=; b=e3ow2Wq1IjGtwkhN/uRBy9V2FUOIt/mhhVPADASDly0yoY+J28SpkhmeEggrQQvIav Ul2qRscyvvCF3esU3XiMG3b6AoqtwNSXa7OcmwCd7v76YdqijSXGY8SRmkN/HFAx4hnY Q5V/te7ryGF/40s5XhHWPETZszZOLpw9XaBs5idWSKNcfMb/xV1RAbhFGuTEQJnjm/0T VRRMikyzAEjUll6EuLa1EkANXG1ds40CtSdspoDzLHfymr519wmCPcHJvXyZ/EnzZ/Qe f72mCmOiL/t5mPZRRuwVkSFFbEiPXit+CpUb8bRPOQX58kUeHdbt2BO3WOic4T4fMqYt xzAA== X-Gm-Message-State: AGi0PuZ0j+ngPbf0mxWJTy0yLMhrsb0tKzpQg52szMRYIzSDIILR0hIq YsQ2aPfVsQyrG8srFa7s18kR0ymYOj2bubSdPDmBgMZpGzGqmw== X-Google-Smtp-Source: APiQypIzxSlGsrZRx7sZxSFBBoGZEegPMZnnt8MNWUmiuYckhLS1KruzYeGN63NUxWYJLrc79B4ehDbc6KSjnt1q/AA= X-Received: by 2002:a92:7e86:: with SMTP id q6mr1008477ill.9.1587092642341; Thu, 16 Apr 2020 20:04:02 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Tomo Suzuki Date: Thu, 16 Apr 2020 23:03:51 -0400 Message-ID: Subject: Re: Launching full Maven programmatically To: Maven Users List Content-Type: multipart/alternative; boundary="0000000000002cd27205a373cd59" --0000000000002cd27205a373cd59 Content-Type: text/plain; charset="UTF-8" I'm interested in that problem too. In the project below, we use PlexusContainer to instantiate MavenProject class from pom file: https://github.com/GoogleCloudPlatform/cloud-opensource-java/blob/master/dependencies/src/main/java/com/google/cloud/tools/opensource/dependencies/RepositoryUtility.java#L209 I hope there's a better way to achieve this. On Thu, Apr 16, 2020 at 6:55 AM Andres Almiray wrote: > Hi, > > I'm looking for a way to launch Maven programmatically in such a way that I > can get access to fully resolved Model and MavenProject instances, and not > just for a single project but also for all projects that belong to a > Reactor. > > At first I used this code > > try { > FileReader reader = new FileReader(pom); > MavenXpp3Reader mavenReader = new MavenXpp3Reader(); > return new MavenProject(mavenReader.read(reader)); > } catch (Exception e) { > throw new IllegalArgumentException(e); > } > > But of course that's not enough. Next I tried using the maven-model-builder > APIs directly but not all references get resolved (such as parent POMs) as > a custom ModelResolver is required and the default one is not intended to > be used in standalone fashion. > > Ideally I would call some sort of embeddable Maven API that can give me the > answers I seek, something like this > > MavenProject project = EmbeddableMaven.launch(propsOrFlags).file(pomFile); > > or alternatively something like > > MavenReactor reactor = EmbeddableMaven.launch(propsOrFlags).file(pomFile); > for(MavenProject project : reactor.getProjects()) { /* do stuff */ } > > Of course I'm making up these types and method names as I do not know if > something like this exist or not, hence why I'm asking here. > > Thanks in advance. > > Cheers > Andres > -- Regards, Tomo --0000000000002cd27205a373cd59--