It was almost perfect, Tim. Then you screwed up the last example. ;-)

>    <dependency>
>      <groupId>com.myco.app</groupId>
>      <artifactId>foo</artifactId>
>      <version>1.0-SNAPSHOT</version>
>      <classifier>tests</classifier>
>    </dependency>

This corresponds to the file:
com/myco/app/foo/1.0-SNAPSHOT/foo-1.0-SNAPSHOT-tests.jar

The default naming convention is:
groupId/artifactId-version-classifier.packaging

Wayne

On 9/24/07, Tim Kettler <[EMAIL PROTECTED]> wrote:
> Hi,
>
> I will try my best to explain how I understand the underlying concepts
> but as I'm not a maven developer and the code and design documentation
> is rather sparse there might be some misconceptions on my side.
>
> What I'm a little bit confused about is the distinction between type and
> packaging. The termes are used somewhat interchangable in the pom and
> documentation: You give a 'packaging' for the artifact you build but
> declare the 'type' of dependencies. In the below text I will use them as
> if they would mean the same.
>
> For example when you build a j2ee app you would have a war project with
> the packaging set to 'war'. In the ear project you then declare the
> dependency to the war project with a type of 'war'.
>
> Perhaps someone with more insight than me can explain why this
> distinction between packaging and type is made.
>
> A maven artifact is identified by the coordinates
> groupId:artifactid:classifier:version:packaging (where a default
> packaging of kind 'jar' is assumed if no packaging is explicitly given).
>
> What is going on behind the scences is this:
>
> For each artifact-(type/packaging) there is an associated
> ArtifactHandler [1] either explicitly declared or implicitly created
> on the fly. An ArtifactHandler provides the file extension and default
> classifier for an artifact-type. The ArtifactHandler for a dependency is
> looked up in the ArtifactHandlerManager [2].
>
> The ArtifactHandlers for the standard artifact-types are declared in
> this components.xml file [3].
>
> When you declare this dependency:
>
>    <dependency>
>      <groupId>com.myco.app</groupId>
>      <artifactId>foo</artifactId>
>      <version>1.0-SNAPSHOT</version>
>      <type>tests</type>
>    </dependency>
>
> Maven looks up the ArtifactHandler for artifacts of type 'tests' in its
> ArtifactHandlerManager, since there is no such handler explicitly
> declared in [3] the DefaultArtifactHandlerManager [4] creates one on the
> fly based on the given type. This on-the-fly handler returns the value
> of the type for the extension and packaging ('tests' in this case). So
> the dependency given above resolves to this path in the repository:
>
>    com/myco/app/foo/1.0-SNAPSHOT/foo-1.0-SNAPSHOT.tests
>
> wich obviously doesn't exist. However, this dependency declaration
> should work:
>
>    <dependency>
>      <groupId>com.myco.app</groupId>
>      <artifactId>foo</artifactId>
>      <version>1.0-SNAPSHOT</version>
>      <type>test-jar</type>
>    </dependency>
>
> As there is a artifact handler defined for the type 'test-jar' that maps
> to a standard classifier of 'tests' and an extension of 'jar'. This
> should result in a repository path of:
>
>    com/myco/app/foo/1.0-SNAPSHOT/foo-tests-1.0-SNAPSHOT.jar
>
> Similar for this declaration:
>
>    <dependency>
>      <groupId>com.myco.app</groupId>
>      <artifactId>foo</artifactId>
>      <version>1.0-SNAPSHOT</version>
>      <classifier>tests</classifier>
>    </dependency>
>
> Here a default type of 'jar' is assumed which maps to an extension of
> 'jar' via the associated artifact handler. Together with the explicitly
> declared classifier one should end up with a path of:
>
>    com/myco/app/foo/1.0-SNAPSHOT/foo-tests-1.0-SNAPSHOT.jar
>
> PERIOD.
>
> Sorry for this lengthy explanation, I hope it is somewhat understandable.
>
> -Tim
>
> [1]
> https://svn.apache.org/repos/asf/maven/components/branches/maven-2.0.x/maven-artifact/src/main/java/org/apache/maven/artifact/handler/ArtifactHandler.java
> [2]
> https://svn.apache.org/repos/asf/maven/components/branches/maven-2.0.x/maven-artifact/src/main/java/org/apache/maven/artifact/handler/manager/ArtifactHandlerManager.java
> [3]
> https://svn.apache.org/repos/asf/maven/components/branches/maven-2.0.x/maven-artifact/src/main/resources/META-INF/plexus/components.xml
> [4]
> https://svn.apache.org/repos/asf/maven/components/branches/maven-2.0.x/maven-artifact/src/main/java/org/apache/maven/artifact/handler/manager/DefaultArtifactHandlerManager.java
>
> zalym schrieb:
> > Hi Tim,
> >
> > totally out of scope, but i am curious.  what is this type identifier for in
> > dependency?  and why is it resolved as period in the artifact?
> >
> > Saleem
> >
> >
> > Tim Kettler wrote:
> >> zalym schrieb:
> >>> I followed the attached tests guide to create a dependency to my core
> >>> tests.
> >>> The first part of the tutorial worked, and I could install a version of
> >>> the
> >>> test jar in the local repository as models-3.0-tests.jar.  When I tried
> >>> to
> >>> add this as a dependency in another project, it came up with a dependency
> >>> missing error and when I noticed this in the message:
> >>> models-3.0.tests
> >>>
> >>> What could be wrong?  Why would the dependency be resolbed with a period
> >>> and
> >>> not a hyphen.
> >> This is most probably a bug in the documentation. Looking at the mojo's
> >> source code [1] shows that the artifact is created with a type of
> >> 'test-jar' and the classifier 'tests'.
> >>
> >> You should try to use 'test-jar' as the type in your dependency
> >> declaration or respectivly skip the type declaration and use a
> >> <classifier>tests</classifier> element in the declaration.
> >>
> >> Please report this as a bug in jira [2] and provide the correct
> >> dependency declaration to use.
> >>
> >>> Appreciate your help.
> >> -Tim
> >>
> >> [1]
> >> https://svn.apache.org/repos/asf/maven/plugins/trunk/maven-jar-plugin/src/main/java/org/apache/maven/plugin/jar/TestJarMojo.java
> >> [2] http://jira.codehaus.org/browse/MNGSITE
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: [EMAIL PROTECTED]
> >> For additional commands, e-mail: [EMAIL PROTECTED]
> >>
> >>
> >>
> >
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to