How to Access a Maven Repository » History » Version 5
Henning Blohm, 21.03.2014 17:01
1 | 1 | Henning Blohm | h1. Maven Repos Support |
---|---|---|---|
2 | |||
3 | The main idea behind this concept is to hook existing Maven repositories in as component repositories. At first this is most useful for libraries, later this may be extended to other archetypes. |
||
4 | |||
5 | Maven repository suppport can be implemented in z2-base and does not require core changes. |
||
6 | |||
7 | 5 | Henning Blohm | h2. Principles |
8 | 1 | Henning Blohm | |
9 | 5 | Henning Blohm | The main idea is that based on some root artifacts and some maven remote repository configuration, jar artifacts and dependencies will be made available as Java component in Z2 that can be referenced or included as suits best. |
10 | |||
11 | h2. Name mapping and version resolution |
||
12 | |||
13 | 1 | Henning Blohm | Artefacts in Maven repos have a fully qualified name of the form |
14 | |||
15 | <pre> |
||
16 | <groupId>:<artifactId>:<version> |
||
17 | </pre> |
||
18 | |||
19 | 5 | Henning Blohm | or |
20 | 1 | Henning Blohm | |
21 | 5 | Henning Blohm | <pre> |
22 | <groupId>:<artifactId>:<packaging>:<version> |
||
23 | </pre> |
||
24 | 1 | Henning Blohm | |
25 | 5 | Henning Blohm | By default, a jar artifact @<groupId>:<artifactId>:<version>@ will result into a Java component of name |
26 | 1 | Henning Blohm | |
27 | <pre> |
||
28 | 5 | Henning Blohm | <groupId>:<artifactId>/java |
29 | 1 | Henning Blohm | </pre> |
30 | |||
31 | 5 | Henning Blohm | Given that the resolution of the root artifacts and dependencies lead to artifacts of the same packaging, group id, and artifact id but with different versions the higher version number will be used (but see #1695). |
32 | 1 | Henning Blohm | |
33 | 5 | Henning Blohm | h2. Example configuration |
34 | |||
35 | A maven repository component may look like this: |
||
36 | |||
37 | <pre> |
||
38 | com.zfabrik.systemStates.participation=com.zfabrik.boot.main/sysrepo_up |
||
39 | com.zfabrik.component.type=com.zfabrik.mvncr |
||
40 | mvn.priority=200 |
||
41 | mvn.roots=\ |
||
42 | org.springframework:spring-context:4.0.2.RELEASE,\ |
||
43 | org.springframework:spring-aspects:4.0.2.RELEASE,\ |
||
44 | org.springframework:spring-tx:4.0.2.RELEASE,\ |
||
45 | org.springframework:spring-orm:4.0.2.RELEASE,\ |
||
46 | org.springframework:spring-web:4.0.2.RELEASE,\ |
||
47 | org.springframework.security:spring-security-core:3.2.2.RELEASE,\ |
||
48 | org.springframework.security:spring-security-web:3.2.2.RELEASE,\ |
||
49 | org.springframework.security:spring-security-config:3.2.2.RELEASE,\ |
||
50 | org.springframework.security:spring-security-aspects:3.2.2.RELEASE,\ |
||
51 | hibernate:hibernate:2.1.4,\ |
||
52 | aopalliance:aopalliance:1.0,\ |
||
53 | org.aspectj:aspectjweaver:1.7.4,\ |
||
54 | org.aspectj:aspectjtools:1.6.9,\ |
||
55 | </pre> |
||
56 | |||
57 | By default, all non-optional compile scope dependencies will be resolved. The resulting Java component will have the target artifact as API library and all non-optional compile scope dependencies as public references in their mapped form. |
||
58 | |||
59 | The z2 core will use lazy component class loaders to make sure that use of include libraries has virtually no runtime penalty. |
||
60 | |||
61 | |||
62 | h2. Modifications |
||
63 | |||
64 | In order to deviate from the default resolution and mapping, maven repository roots may be specified with a query string like this: |
||
65 | |||
66 | <pre> |
||
67 | org.springframework.security:spring-security-aspects:3.2.2.RELEASE?versioned=true&scope=RUNTIME |
||
68 | </pre> |
||
69 | |||
70 | *versioned:* If set to @true@, the version part will not be removed from the java component name mapping and instead a versioned name is used. That is, in the case above, a java component @org.springframework.security:spring-security-aspects:3.2.2.RELEASE/java@ would be mapped. This is useful if "non-default" versions are required. |
||
71 | |||
72 | *scope:* Any of RUNTIME, COMPILE, PROVIDED, SYSTEM, TEST. Conforms to the corresponding Maven dependency scopes. If set, non-optional dependencies of the respective scope will be traversed to resolve dependencies. |