Home Maven打包配置
Post
Cancel

Maven打包配置

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
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.4.0</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>
    <groupId>com.nhsoft.neptune</groupId>
    <artifactId>wms-adapter-jiayituan</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <name>wms-adapter-jiayituan</name>
    <description>wms-adapter</description>

    <packaging>jar</packaging>

    <properties>
        <java.version>1.8</java.version>
        <package.todir>${project.build.directory}\classes</package.todir>
        <deploy.name>wms-adapter-jiayituan</deploy.name>
    </properties>


    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-jpa</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-redis</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>

        <dependency>
            <groupId>io.github.openfeign</groupId>
            <artifactId>feign-core</artifactId>
            <version>11.0</version>
        </dependency>

        <dependency>
            <groupId>io.github.openfeign</groupId>
            <artifactId>feign-gson</artifactId>
            <version>11.0</version>
        </dependency>

        <dependency>
            <groupId>io.github.openfeign</groupId>
            <artifactId>feign-httpclient</artifactId>
            <version>11.0</version>
        </dependency>

        <dependency>
            <groupId>org.projectlombok</groupId>
            <artifactId>lombok</artifactId>
            <optional>true</optional>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <scope>runtime</scope>
        </dependency>

        <dependency>
            <groupId>com.alibaba</groupId>
            <artifactId>druid</artifactId>
            <version>1.1.10</version>
        </dependency>

        <dependency>
            <groupId>org.apache.commons</groupId>
            <artifactId>commons-lang3</artifactId>
            <version>3.8.1</version>
        </dependency>

    </dependencies>

    <profiles>
        <profile>
            <id>dev</id>
            <properties>
                <package.environment>测试环境</package.environment>
                <package.properties.basedir>src/main/resources</package.properties.basedir>
                <profiles.active>dev</profiles.active>
                <server.port>8081</server.port>
            </properties>

            <activation>
                <activeByDefault>true</activeByDefault>
            </activation>

        </profile>
        <profile>
            <id>prod</id>
            <properties>
                <package.environment>生产环境</package.environment>
                <package.properties.basedir>src/main/resources/deploy</package.properties.basedir>
                <profiles.active>prod</profiles.active>
                //可以跟spring boot 下的 application.yml配置对应起来 @server.port@
                <server.port>80</server.port>
            </properties>

        </profile>
        <profile>
            <id>jyt-cs</id>
            <properties>
                <package.environment>加壹团-测试环境</package.environment>
                <package.properties.basedir>src/main/resources/deploy</package.properties.basedir>
                <profiles.active>jyt-cs</profiles.active>
                <server.port>8081</server.port>
            </properties>
        </profile>
    </profiles>

    <build>
        <plugins>

            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <version>1.5.4.RELEASE</version>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.8.1</version>
                <configuration>
                    <source>${java.version}</source>
                    <target>${java.version}</target>
                    <encoding>${project.build.sourceEncoding}</encoding>
                </configuration>
            </plugin>

            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>build-helper-maven-plugin</artifactId>
                <version>1.10</version>
                <executions>
                    <execution>
                        <id>timestamp-property</id>
                        <goals>
                            <goal>timestamp-property</goal>
                        </goals>
                        <phase>validate</phase>
                        <configuration>
                            <name>current.year</name>
                            <pattern>yyyy</pattern>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-antrun-plugin</artifactId>
                <version>1.8</version>
                <executions>
                    <execution>
                        <id>compile</id>
                        <phase>compile</phase>
                        <goals>
                            <goal>run</goal>
                        </goals>
                        <configuration>
                            <target>
                                <echo message="******Start Copy ${package.environment} Files******"/>

                                <echo message="******application-${profiles.active}.properties From ${package.properties.basedir} To ${package.todir}******"/>

                                <copy todir="${package.todir}" overwrite="true" >
                                    <fileset dir="${package.properties.basedir}" erroronmissingdir="false" includes="application-${profiles.active}.yml">
                                        <exclude name="deploy" />
                                    </fileset>
                                </copy>
                            </target>
                        </configuration>
                    </execution>


                    <execution>
                        <phase>package</phase>
                        <goals>
                            <goal>run</goal>
                        </goals>
                    </execution>
                </executions>

                <configuration>
                    <tasks>
                        <echo>Removing deploy dir</echo>
                        <!--一下分别是排除源文件目录,资源文件, 资源文件目录 -->
                        <delete dir="target/classes/deploy"/>
                    </tasks>
                </configuration>
            </plugin>

            <!-- deploy时只上传jar包到远程仓库的配置 -->
            <plugin>
                <artifactId>maven-deploy-plugin</artifactId>
                <executions>
                    <execution>
                        <id>default-deploy</id>
                        <phase>deploy</phase>
                        <goals>
                            <goal>deploy</goal>
                        </goals>
                        <!-- skip默认deploy插件的执行 -->
                        <configuration>
                            <skip>true</skip>
                        </configuration>
                    </execution>
                    <execution>
                        <id>deploy-file</id>
                        <phase>deploy</phase>
                        <goals>
                            <goal>deploy-file</goal>
                        </goals>
                        <configuration>
                            <!-- 开发阶段上传到snapshot仓库,上线阶段上传到release仓库 -->
                            <repositoryId>${project.distributionManagement.snapshotRepository.id}</repositoryId>
                            <url>${project.distributionManagement.snapshotRepository.url}</url>
                            <file>${project.build.directory}/${project.artifactId}.jar</file>
                            <groupId>${project.groupId}</groupId>
                            <artifactId>${project.artifactId}</artifactId>
                            <version>${project.version}</version>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
        <finalName>${deploy.name}</finalName>
    </build>
</project>

weixin.png

公众号名称:怪味Coding
微信扫码关注或搜索公众号名称
This post is licensed under CC BY 4.0 by the author.