티스토리 뷰

[DEV] 개발툴

Maven 용어 정리

목표를 위해 2017. 10. 16. 11:17

아래 이미지를 참고하자.

메이븐의 Lifecycle, Phase, Goal, Plugin에 대해 설명해 주고 있다.

[참고 이미지] https://i.stack.imgur.com/tp88Z.jpg



Lifecycle

Maven에는 3가지 라이프사이클을 제공하고 있다.

Clean lifecycle : 빌드된 결과물 제거

Default/build lifecycle : 빌드 결과물 생성

Site lifecycle : Java document 결과물 생성

CI 툴을 이용하여 메이븐 빌드를 할 때 mvn clean deploy 와 같이 실행하면 빌드된 결과물을 제거하고 빌드 결과물이 생성된다.



Phase

라이프사이클의 단계를 의미한다.

Phase는 의존관계를 가지고 있다. 

예를들어 mvn package 를 실행하게 되면 package phase위에 있는 모든 phase가 우선적으로 실행되고 package가 실행된다. (위의 이미지 참고)

validate -> ... -> compile -> ... -> test -> ... -> package 순으로 실행



Goal

goal은 ant의 target과 같은 개념

Maven에서 제공하는 모든 기능은 플러그인 기반으로 동작

Phase를 실행하면 해당 Phase와 연결된 플러그인 Goal이 실행된다.

mvn compiler:compile (compiler 플러그인에서 compile Goal을 실행한다는 의미)

mvn [plugin-name]:[goal-name]



Plugin Goal 기능

compile : src/main/java 디렉토리에 위치한 코드 컴파일

test-compile : compile goal에 의존관계 있음. compile goal 먼저 실행 후 test 코드 컴파일

test : target/test-classes에 위치한 junit 단위 테스트 실행, 결과는 target/surefire-reports 디렉토리에 생성

package : jar, war 압축 

install : 압축한 jar, war 파일을 local repoitory에 등록

deploy : jar, war 파일을 remote repository에 등록

clean : target 디렉토리의 결과물을 모두 제거



[참고]

모든 메이븐 프로젝트는 Super POM을 상속한다.

Super POM에는 Phase와 연결된 플러그인 Goal이 등록되어 있다.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
<plugin>
  <groupId>org.jooq</groupId>
  <artifactId>jooq-codegen-maven</artifactId>
  <version>3.9.1</version>
</plugin>
<plugin>
  <groupId>org.springframework.boot</groupId>
  <artifactId>spring-boot-maven-plugin</artifactId>
  <version>1.5.2.RELEASE</version>
  <executions>
    <execution>
      <goals>
        <goal>repackage</goal>
      </goals>
      <configuration>
        <mainClass>${start-class}</mainClass>
      </configuration>
    </execution>
  </executions>
  <configuration>
    <mainClass>${start-class}</mainClass>
  </configuration>
</plugin>
<plugin>
  <artifactId>maven-antrun-plugin</artifactId>
  <version>1.8</version>
</plugin>
<plugin>
  <artifactId>maven-assembly-plugin</artifactId>
  <version>2.6</version>
  <configuration>
    <recompressZippedFiles>false</recompressZippedFiles>
  </configuration>
</plugin>
<plugin>
  <artifactId>maven-clean-plugin</artifactId>
  <version>2.6.1</version>
</plugin>
<plugin>
  <artifactId>maven-compiler-plugin</artifactId>
  <version>3.1</version>
</plugin>
<plugin>
  <artifactId>maven-deploy-plugin</artifactId>
  <version>2.8.2</version>
</plugin>
<plugin>
  <artifactId>maven-dependency-plugin</artifactId>
  <version>2.10</version>
</plugin>
<plugin>
  <artifactId>maven-release-plugin</artifactId>
  <version>2.3.2</version>
</plugin>
<plugin>
  <artifactId>maven-eclipse-plugin</artifactId>
  <version>2.10</version>
</plugin>
<plugin>
  <artifactId>maven-enforcer-plugin</artifactId>
  <version>1.4</version>
</plugin>
<plugin>
  <artifactId>maven-failsafe-plugin</artifactId>
  <version>2.18.1</version>
  <executions>
    <execution>
      <goals>
        <goal>integration-test</goal>
        <goal>verify</goal>
      </goals>
    </execution>
  </executions>
</plugin>
<plugin>
  <artifactId>maven-install-plugin</artifactId>
  <version>2.5.2</version>
</plugin>
<plugin>
  <artifactId>maven-invoker-plugin</artifactId>
  <version>1.10</version>
</plugin>
<plugin>
  <artifactId>maven-help-plugin</artifactId>
  <version>2.2</version>
</plugin>
<plugin>
  <artifactId>maven-jar-plugin</artifactId>
  <version>2.6</version>
  <configuration>
    <archive>
      <manifest>
        <mainClass>${start-class}</mainClass>
        <addDefaultImplementationEntries>true</addDefaultImplementationEntries>
      </manifest>
    </archive>
  </configuration>
</plugin>
<plugin>
  <artifactId>maven-javadoc-plugin</artifactId>
  <version>2.10.4</version>
</plugin>
<plugin>
  <artifactId>maven-resources-plugin</artifactId>
  <version>2.6</version>
  <configuration>
    <delimiters>
      <delimiter>@</delimiter>
    </delimiters>
    <useDefaultDelimiters>false</useDefaultDelimiters>
  </configuration>
</plugin>
<plugin>
  <artifactId>maven-shade-plugin</artifactId>
  <version>2.4.3</version>
  <executions>
    <execution>
      <phase>package</phase>
      <goals>
        <goal>shade</goal>
      </goals>
      <configuration>
        <transformers>
          <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
            <resource>META-INF/spring.handlers</resource>
          </transformer>
          <transformer implementation="org.springframework.boot.maven.PropertiesMergingResourceTransformer">
            <resource>META-INF/spring.factories</resource>
          </transformer>
          <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
            <resource>META-INF/spring.schemas</resource>
          </transformer>
          <transformer implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer" />
          <transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
            <mainClass>${start-class}</mainClass>
          </transformer>
        </transformers>
        <keepDependenciesWithProvidedScope>true</keepDependenciesWithProvidedScope>
        <createDependencyReducedPom>true</createDependencyReducedPom>
        <filters>
          <filter>
            <artifact>*:*</artifact>
            <excludes>
              <exclude>META-INF/*.SF</exclude>
              <exclude>META-INF/*.DSA</exclude>
              <exclude>META-INF/*.RSA</exclude>
            </excludes>
          </filter>
        </filters>
      </configuration>
    </execution>
  </executions>
  <dependencies>
    <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-maven-plugin</artifactId>
      <version>1.5.2.RELEASE</version>
    </dependency>
  </dependencies>
  <configuration>
    <keepDependenciesWithProvidedScope>true</keepDependenciesWithProvidedScope>
    <createDependencyReducedPom>true</createDependencyReducedPom>
    <filters>
      <filter>
        <artifact>*:*</artifact>
        <excludes>
          <exclude>META-INF/*.SF</exclude>
          <exclude>META-INF/*.DSA</exclude>
          <exclude>META-INF/*.RSA</exclude>
        </excludes>
      </filter>
    </filters>
  </configuration>
</plugin>
<plugin>
  <artifactId>maven-site-plugin</artifactId>
  <version>3.5.1</version>
</plugin>
<plugin>
  <artifactId>maven-source-plugin</artifactId>
  <version>2.4</version>
</plugin>
<plugin>
  <artifactId>maven-surefire-plugin</artifactId>
  <version>2.18.1</version>
  <configuration>
    <includes>
      <include>**/*Tests.java</include>
      <include>**/*Test.java</include>
    </includes>
    <excludes>
      <exclude>**/Abstract*.java</exclude>
    </excludes>
  </configuration>
</plugin>
<plugin>
  <artifactId>maven-war-plugin</artifactId>
  <version>2.6</version>
  <configuration>
    <failOnMissingWebXml>false</failOnMissingWebXml>
    <archive>
      <manifest>
        <mainClass>${start-class}</mainClass>
        <addDefaultImplementationEntries>true</addDefaultImplementationEntries>
      </manifest>
    </archive>
  </configuration>
</plugin>
<plugin>
  <groupId>org.codehaus.mojo</groupId>
  <artifactId>build-helper-maven-plugin</artifactId>
  <version>1.10</version>
</plugin>
<plugin>
  <groupId>org.codehaus.mojo</groupId>
  <artifactId>exec-maven-plugin</artifactId>
  <version>1.5.0</version>
  <configuration>
    <mainClass>${start-class}</mainClass>
  </configuration>
</plugin>
<plugin>
  <groupId>org.codehaus.mojo</groupId>
  <artifactId>versions-maven-plugin</artifactId>
  <version>2.2</version>
</plugin>
<plugin>
  <groupId>pl.project13.maven</groupId>
  <artifactId>git-commit-id-plugin</artifactId>
  <version>2.2.2</version>
  <executions>
    <execution>
      <goals>
        <goal>revision</goal>
      </goals>
      <configuration>
        <verbose>true</verbose>
        <dateFormat>yyyy-MM-dd'T'HH:mm:ssZ</dateFormat>
        <generateGitPropertiesFile>true</generateGitPropertiesFile>
        <generateGitPropertiesFilename>D:\workspace_IntelliJ\project_test\my_application\target\classes/git.properties</generateGitPropertiesFilename>
      </configuration>
    </execution>
  </executions>
  <configuration>
    <verbose>true</verbose>
    <dateFormat>yyyy-MM-dd'T'HH:mm:ssZ</dateFormat>
    <generateGitPropertiesFile>true</generateGitPropertiesFile>
    <generateGitPropertiesFilename>D:\workspace_IntelliJ\project_test\my_application\target\classes/git.properties</generateGitPropertiesFilename>
  </configuration>
</plugin>
cs


TAG
댓글
댓글쓰기 폼