repo.maven.com,oss.sonatype.org 에 없는 3rd party java lib을 팀 전용 private repository에 올리고 난 이후의 개발환경 정보를 공유한다.



private repository 의 user, password 정보는 maven_home/settings.xml에 저장한다. 

mac이라면, ~/.m2 밑에 settings.xml 파일이 존재한다. 그 파일에 maven pom.xml 에서 사용할 내부 maven repository 정보를 입력한다.

유의할 점은 id 이다. id는 pom.xml의 repositories/repository의 id 값과 동일해야 한다. 


<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

                      http://maven.apache.org/xsd/settings-1.0.0.xsd">

  <localRepository/>

  <interactiveMode/>

  <usePluginRegistry/>

  <offline/>

  <pluginGroups/>

  <mirrors/>

  <proxies/>

<profiles>

<profile>

    <id>downloadSources</id>

    <properties>

        <downloadSources>true</downloadSources>

        <downloadJavadocs>true</downloadJavadocs>           

    </properties>

</profile>

</profiles>


<activeProfiles>

  <activeProfile>downloadSources</activeProfile>

</activeProfiles>



<servers>

    <server>

      <id>userinfra-release</id>

      <username>google</username>

      <password>googleuserinfra</password>

    </server>

</servers>

</settings>



pom.xml 에서는


<repositories>

<repository>

<id>sonatype-oss-snapshot</id>

<url>https://oss.sonatype.org/content/repositories/snapshots/</url>

<snapshots>

<enabled>true</enabled>

<updatePolicy>daily</updatePolicy>

</snapshots>

</repository>


<repository>

<id>sonatype-oss-releases</id>

<url>https://oss.sonatype.org/content/repositories/releases/</url>    

</repository>    

<repository>

    <id>userinfra-release</id>

    <name>Google Nexus Repository - Release</name>

    <url>http://mvn.google.com/content/repositories/userinfra-releases/</url>

    </repository>

</repositories>


만약 계정 접근에서 실패가 발생하면,  401 unauthroized exception 이 발생한다. 

동작되면, maven pom.xml 컴파일은 성공이 된다. 


특이하게 Eclipse (STS 3.5.0) 에서 다음과 같은 에러가 발생할 수 있다. 



ArtifactDescriptorException: Failed to read artifact descriptor for app:app:jar:1.1.1.1.0: Error code 401, Unauthorized pom.xml /idp line 1 Maven Dependency Problem




mvn 명령이나 eclipse(sts 3.5.0)의 maven build는 성공하는데. Problem 창에서 계속 저 에러가 나오는 경우가 있다.  그럴 때는 pom.xml 파일을 작은 수정만 주면 이슈는 해결한다.작은 수정 후 저장하니. 바로 에러가 사라졌다. 

(이클립스가 변화에 따라서 triggering 되는 구조라, 터미널에서는 되는데. 이상하게 이클립스에서 안되면 조금씩 수정하면 문제는 해결되는 경우가 있다. )

Posted by '김용환'
,