File tree 1 file changed +66
-0
lines changed
1 file changed +66
-0
lines changed Original file line number Diff line number Diff line change
1
+ # Maven plugin
2
+ ### Maven-shade-plugin vs Maven-assembly plugin
3
+ dependencies 가 있고 실행 가능한 ` jar ` 파일을 만들고자 할때, ` maven-assembly-plugin ` 이나 ` maven-shade-plugin ` 을 사용할 수 있다.
4
+ 둘 다 의존성을 포함한 하나의 ` jar ` 실행 파일을 생성하지만, 약간의 차이가 있다.
5
+
6
+ ### maven-assembly-plugin
7
+ ` maven-assembly-plugin ` 은 필요한 모든 의존성을 ` jar ` 파일에 자동으로 복사한다. ` jar ` 파일 내부에 의존성 파일이 존재 하므로 하나의 ` jar `
8
+ 실행파일만으로 프로세스를 실행할 수 있다. 그렇지만 클래스 ** relocation** 을 지원하지는 않는다. 다시말해, 동일한 파일명의 리소스 파일이 존재할 때,
9
+ 파일이 덮여쓰여지는 문제가 있을 수 있다.
10
+ ``` xml
11
+ <plugin >
12
+ <groupId >org.apache.maven.plugins</groupId >
13
+ <artifactId >maven-assembly-plugin</artifactId >
14
+ <executions >
15
+ <execution >
16
+ <phase >package</phase >
17
+ <goals >
18
+ <goal >single</goal >
19
+ </goals >
20
+ <configuration >
21
+ <archive >
22
+ <manifest >
23
+ <!-- information of main class -->
24
+ <mainClass >
25
+ com.grace.Main
26
+ </mainClass >
27
+ </manifest >
28
+ </archive >
29
+ <descriptorRefs >
30
+ <!-- example output name is `core-java-jar-with-dependencies.jar`. -->
31
+ <descriptorRef >jar-with-dependencies</descriptorRef >
32
+ </descriptorRefs >
33
+ </configuration >
34
+ </execution >
35
+ </executions >
36
+ </plugin >
37
+ ```
38
+
39
+ ### maven-shade-plugin
40
+ ` maven-shade-plugin ` 도 마찬가지로 모든 dependencies 파일을 하나의 ` jar ` 로 패키징할 수 있다. 또한 특정 파일의 내용을 덮어쓰지 않고 merge 하므로
41
+ ` jar ` 에서 동일한 이름을 가진 리소스 파일이 있고, 모든 리소스 파일을 패키징하려고 할 때 유용하게 쓸 수 있다.
42
+ 대신 configuration 이 약간 복잡해질 수 있는 단점이 있다.
43
+ ``` xml
44
+ <plugin >
45
+ <groupId >org.apache.maven.plugins</groupId >
46
+ <artifactId >maven-shade-plugin</artifactId >
47
+ <executions >
48
+ <execution >
49
+ <goals >
50
+ <goal >shade</goal >
51
+ </goals >
52
+ <configuration >
53
+ <!-- all dependencies to be packaged into the jar -->
54
+ <shadedArtifactAttached >true</shadedArtifactAttached >
55
+ <transformers >
56
+ <transformer implementation =
57
+ " org.apache.maven.plugins.shade.resource.ManifestResourceTransformer" >
58
+ <!-- specify the main class of our application -->
59
+ <mainClass >com.grace.Main</mainClass >
60
+ </transformer >
61
+ </transformers >
62
+ </configuration >
63
+ </execution >
64
+ </executions >
65
+ </plugin >
66
+ ```
You can’t perform that action at this time.
0 commit comments