2021-03-19-maven-settings
๋ค์ด๊ฐ๋ฉฐ
- Maven์์ ์์ฃผ ๋ง์ฃผ์น๋ ์ค์ ํ์ผ์ธ
settings.xml
์ด ์์ต๋๋ค. - ๋ฌด์จ ์ญํ ์ ๊ฐ์ง๊ณ ์๋์ง ์ด๋ป๊ฒ ์ฌ์ฉํ๋์ง ์ ๋ฆฌํฉ๋๋ค.
settings.xml์ ๋ฌด์จ ์ค์ ์ ์ํ ํ์ผ์ผ๊น?
- Maven ์คํ์ ํ์ํ ์ค์ ๋ค์ ์ ์ํ๋ ํ์ผ์ ๋๋ค.
- ๊ทธ๋ผ ์
pom.xml
์ ์ ๋ฃ๊ณ settings.xml์ ๋ฐ๋ก ๋ง๋ค์์๊น?- ํน์ ํ๋ก์ ํธ์ ์ข ์๋๋ ์ ๋ณด๊ฐ ์๋๋ค.
settings.xml์ ์ด๋๊ณณ์ ์์๊น?
${user.home}/.m2/settings.xml
- default path
${maven.home}/conf/settings.xml
- ๋ช
๋ น์ด๋ฅผ ํตํด custom settings.xml์ ์ ์ฉํ ์ ์์ต๋๋ค.
mvn package -s ./setting/settings.xml
settings.xml์ ๋ฌด์จ ์ ๋ณด๋ฅผ ๊ฐ์ง๊ณ ์์๊น?
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 https://maven.apache.org/xsd/settings-1.0.0.xsd">
<localRepository/>
<interactiveMode/>
<offline/>
<pluginGroups/>
<servers/>
<mirrors/>
<proxies/>
<profiles/>
<activeProfiles/>
</settings>
Simple Values
- localRepository
- maven ๋ก์ปฌ ์ ์ฅ์ ์์น
- interactiveMode
- ์ฌ์ฉ์์ input์ ์์ง์๋ ๋ชจ๋๋ก ๋ณ๊ฒฝ
- default true
- offline
- remote ์ ์ฅ์์ ์ฐ๊ฒฐํ์ง ์๊ณ ๋น๋๋ฅผ ํ๊ธฐ ์ํ ์ต์
- default false
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 https://maven.apache.org/xsd/settings-1.0.0.xsd">
<localRepository>${user.home}/.m2/repository</localRepository>
<interactiveMode>true</interactiveMode>
<offline>false</offline>
...
</settings>
Plugin Groups
pom.xml
์ groupId๊ฐ ์ค์ ๋์ด ์์ง ์์ ๋ ์ ์ธ๋ GroupId๋ก ํ๋ฌ๊ทธ์ธ์ ํ์- plugin์ groupId๋ฅผ ํ์ํ๋ค๋ฉด ์๋ฌด ๊ธฐ๋ฅ๋ ํ์ง ์์.
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 https://maven.apache.org/xsd/settings-1.0.0.xsd">
...
<pluginGroups>
<pluginGroup>org.eclipse.jetty</pluginGroup>
</pluginGroups>
...
</settings>
Servers
- ์ ์ฅ์ ์๋ฒ์ ๊ด๋ จ๋ ์ค์
- ์ ์ฅ์(nexus)์ ์ธ์ฆํ๋ ๋ฐฉ๋ฒ์ ์ ๊ณตํฉ๋๋ค.
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 https://maven.apache.org/xsd/settings-1.0.0.xsd">
...
<servers>
<server>
<id>server001</id>
<username>my_login</username>
<password>my_password</password>
<privateKey>${user.home}/.ssh/id_dsa</privateKey>
<passphrase>some_passphrase</passphrase>
<filePermissions>664</filePermissions>
<directoryPermissions>775</directoryPermissions>
<configuration></configuration>
</server>
</servers>
...
</settings>
Mirros
-
์ ์ฅ์์ ๋ํ ๋ค์ด๋ก๋ mirror๋ฅผ ์ค์ ํ๋ ์์ฑ
-
์ Mirror๊ฐ ํ์ํ ๊น?
- ์ง๋ฆฌ์ ์ผ๋ก ๊ฐ๊น์ ์๋๊ฐ ๋น ๋ฅด๊ฒ ๋๊ธฐํํ ์ ์๊ธฐ ๋๋ฌธ์ ๋๋ค.
- https://maven.apache.org/guides/mini/guide-mirror-settings.html
-
์๋์ ์๋
https://repo.maven.apache.org/maven2/
๋ก ๋ฑ๋ก๋ plugin๋ค์planetmirror.com
์ผ๋ก mirrorํฉ๋๋ค.
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 https://maven.apache.org/xsd/settings-1.0.0.xsd">
...
<mirrors>
<mirror>
<id>planetmirror.com</id>
<name>PlanetMirror Australia</name>
<url>http://downloads.planetmirror.com/pub/maven2</url>
<mirrorOf>central</mirrorOf>
</mirror>
</mirrors>
...
</settings>
Proxies
- ๋ฐฉํ๋ฒฝ์ด๋ SSL ์ด์๋ฅผ ํด๊ฒฐํ๊ธฐ ์ํด Proxy ์ค์ ์ ํฉ๋๋ค.
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 https://maven.apache.org/xsd/settings-1.0.0.xsd">
...
<proxies>
<proxy>
<id>myproxy</id>
<active>true</active>
<protocol>http</protocol>
<host>proxy.somewhere.com</host>
<port>8080</port>
<username>proxyuser</username>
<password>somepassword</password>
<nonProxyHosts>*.google.com|ibiblio.org</nonProxyHosts> // ํด๋น ๋๋ฉ์ธ์ Proxy ์ ์ฉ์ด ๋์ง ์์ต๋๋ค.
</proxy>
</proxies>
...
</settings>
Profiles
- JDK ๋ฒ์ ผ, OS์ ๋ง๊ฒ ๋น๋ ๊ตฌ์ฑ์ ๋ค๋ฅด๊ฒ ์ค์ ํ ์ ์์ต๋๋ค.
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 https://maven.apache.org/xsd/settings-1.0.0.xsd">
...
<profiles>
<profile>
<id>test</id>
<activation>
<activeByDefault>false</activeByDefault>
<jdk>1.5</jdk>
<os>
<name>Windows XP</name>
<family>Windows</family>
<arch>x86</arch>
<version>5.1.2600</version>
</os>
<property>
<name>mavenVersion</name>
<value>2.0.3</value>
</property>
<file>
<exists>${basedir}/file2.properties</exists>
<missing>${basedir}/file1.properties</missing>
</file>
</activation>
...
</profile>
</profiles>
...
</settings>
Active Profiles
- ์์ ์ ์ธํ Profile์ ์ ์ํ๋ฉด ํด๋น Profile๋ก ๋น๋๊ฐ ๋ฉ๋๋ค.
- ์ฌ๋ฌ Profile์ ์ ์ธํ๋ฉด ์์๋๋ก ๋น๋๊ฐ ๋ฉ๋๋ค.
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 https://maven.apache.org/xsd/settings-1.0.0.xsd">
...
<activeProfiles>
<activeProfile>env-test</activeProfile>
</activeProfiles>
</settings>