You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by hb...@apache.org on 2022/02/03 07:09:47 UTC

[maven-site] 04/07: WIP

This is an automated email from the ASF dual-hosted git repository.

hboutemy pushed a commit to branch maven-repository-layout
in repository https://gitbox.apache.org/repos/asf/maven-site.git

commit cc5d3acf0b5e01cd4d5792ba2eb389b0c57b2c57
Author: Tamas Cservenak <ta...@cservenak.net>
AuthorDate: Wed Jan 19 16:56:15 2022 +0100

    WIP
---
 content/markdown/repositories/index.md  | 45 ++++++++++++++++++++++++++++-----
 content/markdown/repositories/layout.md | 36 +++++++++++++++++++++-----
 2 files changed, 69 insertions(+), 12 deletions(-)

diff --git a/content/markdown/repositories/index.md b/content/markdown/repositories/index.md
index 3352c46..66c3b9e 100644
--- a/content/markdown/repositories/index.md
+++ b/content/markdown/repositories/index.md
@@ -32,7 +32,7 @@ Maven to figure out (or you to tell Maven how to figure it out).
 
 While Maven internally uses notion of "artifact" thoroughly (just look at sources!), end user may never hit this name.
 That's due the fact, that while for Maven, "everything is artifact" (internally), the end users actually speak about
-"projects", "parent projects", "dependencies", "plugins", "extensions" and so on.
+"projects", "parent projects", "dependencies", "build plugins", "build extensions" and so on.
 
 ## Artifact properties
 
@@ -46,10 +46,43 @@ The artifacts that Maven (internally) uses has following (among many others, but
 | classifier | The artifact distinguishing classifier |
 | extension  | The artifact extension |
 
-And some more, a bit of special ones:
+And some more, a bit of special one: `baseVersion` that is actually derived from version (or other way around, 
+depends on context): for release artifacts holds same value as `version`, for snapshot artifacts holds "non-timestamped 
+snapshot version". For example, for `version` "1.0-20220119.164608-1" value the `baseVersion` would have value 
+"1.0-SNAPSHOT".
 
-| Name | Description                                                                                                                                                                                                          |
-|------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
-| type | The "type" of the artifact, implies extension.                                                                                                                                                                       |
-| baseVersion | Is actually derived from version (or other way around, depends on context): for release artifacts same as version, for snapshot artifacts this is always "non stamped snapshot version", for example "1.0-SNAPSHOT". |
+## But where do I set artifact extension?
 
+In short, nowhere. Or maybe "you rarely have to". Maven POM (where you declare your project, parent project,
+dependencies, plugins and other), maps those elements onto artifact coordinates with some simple mapping. In case
+of "project" and "parent project" (aka POMs):
+
+| Project    | Artifact      |
+|------------|---------------|
+| groupId    | -> groupId    |
+| artifactId | -> artifactId |
+| version    | -> version    |
+| classifier | empty         |
+| extension  | "pom"         |
+
+In case of "build plugins" and "build extensions", as they are JARs, this is how corresponding elements are mapped:
+
+| Plugin     | Artifact      |
+|------------|---------------|
+| groupId    | -> groupId    |
+| artifactId | -> artifactId |
+| version    | -> version    |
+| classifier | empty         |
+| extension  | "jar"         |
+
+And finally, in case of "dependencies", this is the mapping:
+
+| Dependency | Artifact                                 |
+|------------|------------------------------------------|
+| groupId    | -> groupId                               |
+| artifactId | -> artifactId                            |
+| version    | -> version                               |
+| classifier | -> classifier                            |
+| type       | -> type handler provided or same as type |
+
+Here, we need to make a short turn to explain "type" (of a dependency) and how it becomes artifact extension.
diff --git a/content/markdown/repositories/layout.md b/content/markdown/repositories/layout.md
index aace610..98ba670 100644
--- a/content/markdown/repositories/layout.md
+++ b/content/markdown/repositories/layout.md
@@ -34,12 +34,36 @@ the files on file paths for consumption (mainly for HTTP GET requests). Actually
 Maven1 and Maven2 (the today's "default") was exactly that: Maven1 layout was stressing the underlying file system 
 way too much, it was not scaling in this setup.
 
-The transformation rule is quite simple for that matter:
+The transformation rule is quite simple for that matter: consider artifact properties below:
 
-| Source coordinate | Transformation                                          | Result example |
-|-------------------|---------------------------------------------------------|----------------|
-| Group ID          | Replace "." (dot) characters with "/" (slash) character | `org.apache.maven` -> `org/apache/maven` |
-| Artifact ID       | none                                                    | `apache-maven` -> `apache-maven` |
-| Version           | none                                                    | `3.8.4` -> `3.8.4` |
+| Name       | Transformation                                          | Result example                           |
+|------------|---------------------------------------------------------|------------------------------------------|
+| groupId    | Replace "." (dot) characters with "/" (slash) character | `org.apache.maven` -> `org/apache/maven` |
+| artifactId | none | `apache-maven` -> `apache-maven`         |
+| version    | none | `3.8.4` -> `3.8.4`                       |
+| classifier | none | `bin` -> `bin`                           |
+| extension  | none | `tar.gz` -> `tar.gz`                     |
 
+And using these properties transformed as above we can construct following layout (if classifier not present):
 
+```
+${groupId}/${artifactId}/${version}/${artifactId}-${version}.${extension}
+```
+
+or if classifier present:
+
+```
+${groupId}/${artifactId}/${version}/${artifactId}-${version}-${classifier}.${extension}
+```
+
+So the example artifact above:
+
+```
+org.apache.maven:apache-maven:3.8.4:bin:tar.gz
+```
+
+is translated to path:
+
+```
+org/apache/maven/apache-maven/3.8.4/apache-maven-3.8.4-bin.tar.gz
+```