Return-Path: X-Original-To: apmail-maven-dev-archive@www.apache.org Delivered-To: apmail-maven-dev-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 10AC710725 for ; Tue, 30 Apr 2013 08:46:19 +0000 (UTC) Received: (qmail 89226 invoked by uid 500); 30 Apr 2013 08:46:18 -0000 Delivered-To: apmail-maven-dev-archive@maven.apache.org Received: (qmail 88726 invoked by uid 500); 30 Apr 2013 08:46:14 -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 88651 invoked by uid 99); 30 Apr 2013 08:46:11 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 30 Apr 2013 08:46:11 +0000 X-ASF-Spam-Status: No, hits=-0.7 required=5.0 tests=RCVD_IN_DNSWL_LOW,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of mcculls@gmail.com designates 209.85.212.172 as permitted sender) Received: from [209.85.212.172] (HELO mail-wi0-f172.google.com) (209.85.212.172) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 30 Apr 2013 08:46:05 +0000 Received: by mail-wi0-f172.google.com with SMTP id hm14so3640321wib.5 for ; Tue, 30 Apr 2013 01:45:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:content-type:mime-version:subject:from:in-reply-to:date :content-transfer-encoding:message-id:references:to:x-mailer; bh=KZkStiS2L39ATFH0308xV1GM/HES95/Ff7mM4xUss7s=; b=07xc9Ztnw6Tv5Z2LUmXSHDgT1qtgWaQ+hMPr7LuSXLDe1fZwoRBg1gCGYTiCiEU09A E6OmsGHSOVP79ovNEaNu0+2zFmhbeWw4cwStxJ2V60v7U0PlZ086Osq/jqs0Dq40GguN rJfhlh5wTOzfawV8HZ8H/6Ycl+Avb+DvBNejSa5lzzfdmMKp0W07moLOMDUNjXn44i0D I62EYmkX2E5ri6Xv4jEV5u7AIYfulT3vCAxd5Tjk79VKWrzse7XOb+l3sxZxSmpWzkj8 7LniIQ/7hhoescbbRu8VdMgEd/55A/bj9QnCBqyqvgff4OvUm8/b9EDBB7P7GTiNh1J3 5Oqg== X-Received: by 10.180.21.193 with SMTP id x1mr22644610wie.31.1367311545245; Tue, 30 Apr 2013 01:45:45 -0700 (PDT) Received: from [192.168.1.64] (host86-160-239-58.range86-160.btcentralplus.com. [86.160.239.58]) by mx.google.com with ESMTPSA id ge7sm24924557wic.0.2013.04.30.01.45.43 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 30 Apr 2013 01:45:43 -0700 (PDT) Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Apple Message framework v1085) Subject: Re: running maven programmatically, the DefaultRemoteRepositoryManager.connectorFactories is empty From: Stuart McCulloch In-Reply-To: Date: Tue, 30 Apr 2013 09:45:42 +0100 Content-Transfer-Encoding: quoted-printable Message-Id: <05BDF64D-5DAE-4A00-8F1C-7FFA542C64CC@gmail.com> References: To: "Maven Developers List" X-Mailer: Apple Mail (2.1085) X-Virus-Checked: Checked by ClamAV on apache.org On 30 Apr 2013, at 07:54, David Portabella wrote: > it works after adding these two dependencies, thanks! :) >=20 > but it seems to me that there is something wrong with this dependency > injection mechanism. > it would be fantastic to have something that fails at compile time (as = the > implicit in the scala language), but if that's not the case, > at least to throw an injection exception during runtime... >=20 > why there is not even an injection exception? Because the component just declares a dependency on a list of = RepositoryConnectorFactory: = https://github.com/sonatype/sonatype-aether/blob/master/aether-impl/src/ma= in/java/org/sonatype/aether/impl/internal/DefaultRemoteRepositoryManager.j= ava#L52 ie. how is the injector to know that it wants at least one = RepositoryConnectorFactory? The component could have been written with a = default fallback implementation, in which case it is OK to have a list = with no items. If you enforce by default that there must be at least one = item in an injected list then you break other components who expect (or = can handle) zero or more; such as components that let you supply = additional optional extensions. The injector could enforce this size check if it was given enough = information (which would involve coming up with an extra annotation / = extending the old one to declare that it expects at least one item) but = it's easier for the component to enforce the check itself, especially as = it could tailor the error message to point people to the relevant = dependency, instead of a generic "no found" message. > regards, > David >=20 >=20 > On Mon, Apr 29, 2013 at 11:19 PM, Stuart McCulloch = wrote: >=20 >> IIRC you need to also add dependencies to aether-connector-wagon and >> wagon-http... >>=20 >>=20 >> = http://stackoverflow.com/questions/4206679/can-anyone-give-a-good-example-= of-using-org-apache-maven-cli-mavencli-programatt/6255514#6255514 >>=20 >> -- >> Cheers, Stuart >>=20 >> On 29 April 2013 21:22, David Portabella >> wrote: >>=20 >>> I have a very simple project that starts maven programmatically, as >>> follows: >>>=20 >>> import org.apache.maven.cli.MavenCli; >>> public class Example { >>> public static void main(String[] args) throws Exception { >>> new MavenCli().doMain(new String[]{"clean", "install"}, >>> "/test/a_maven_project", null, null); >>> } >>> } >>>=20 >>> which uses only these two dependencies: >>> >>> org.apache.maven >>> maven-embedder >>> 3.0.5 >>> >>>=20 >>> >>> org.codehaus.plexus >>> plexus-utils >>> 3.0.10 >>> >>>=20 >>>=20 >>> The program initializes maven with plexus, and every seems to work, >>> *but the execution fails if some dependencies of the >>> "/test/a_maven_project" maven project are not in the local = repository.* >>> (all using default configurations (no custom settings.xml file)) >>>=20 >>> What can be the problem? >>>=20 >>> I debugged building the "/test/a_maven_project" project in two ways: >>> 1- Running my Example project (it fails) >>> 2- Running "mvnDebug clean install" from the command line and = debugging >>> remotely (it works) >>>=20 >>> The difference is that in the second case, >>> DefaultRemoteRepositoryManager.connectorFactories has an instance of = a >>> WagonRepositoryConnectorFactory, >>> while in the first >>> case DefaultRemoteRepositoryManager.connectorFactories is empty. >>>=20 >>>=20 >>>=20 >> = aether-impl-1.13.1-sources.jar!/org/sonatype/aether/impl/internal/DefaultR= emoteRepositoryManager.java >>>=20 >>>=20 >> = aether-connector-wagon/1.13.1/aether-connector-wagon-1.13.1.jar!/org/sonat= ype/aether/connector/wagon/WagonRepositoryConnectorFactory.class >>>=20 >>> Any idea of why in the first case the >>> DefaultRemoteRepositoryManager.connectorFactories is empty? >>>=20 >>> how to modify the Example to make it work? >>>=20 >>>=20 >>> Regards, >>> David Portabella >>>=20 >>=20 --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org For additional commands, e-mail: dev-help@maven.apache.org