Nexus integration

nexus deploy 시 400 Error

[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2.114s
[INFO] Finished at: Wed May 15 15:12:19 KST 2013
[INFO] Final Memory: 7M/238M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.7:deploy (default-deploy) on project deploy-test: Failed to deploy artifacts: Could not transfer artifact org.example.app:deploy-test:jar:1.1 from/to tech.release (https://nexus.ktnet.com/content/repositories/com.company/): Failed to transfer file: https://nexus.company.com/content/repositories/com.ktnet/org/example/app/deploy-test/1.1/deploy-test-1.1.jar. Return code is: 400, ReasonPhrase:Bad Request. -> [Help 1]

원인: Release repository 일 경우 같은 version 이 이미 deploy 되어 있음

해결방안: version up

401 Aurhotized Error

원인

repository 에 권한 없음.

해결

${HOME}/.m2/settings.xml 에 암호 설정

 

nexus repository 에 해당 버전이 있는데 library 가 없다고 에러 발생

원인

  • maven 의 release updatePolicy 는 default가 daily 임 (http://maven.apache.org/ref/3.1.0/maven-settings/settings.html)
  • 해당 artifact를 nexus 에 deploy 하기전에 maven 을 실행했다면 local cache 에는 해당 artifact가 없고 caching을 위한 .lastUpdated 파일만 존재함
  • 따라서 다음 update 시간인 내일이 되기전가지는 artifact 가 없어서 빌드가 실패함
Error Message

"[ERROR] Failed to execute goal on project etsCoreServer: Could not resolve dependencies for project com.company.ets:etsCoreServer:war:10: Failure to find com.company.ets:ets-common:jar:0.91.08 inhttps://nexus.company.com/content/groups/public was cached in the local repository, resolution will not be reattempted until the update interval of Company-central has elapsed or updates are forced -> [Help 1]"

해결

1 .m2 의 cache 를 삭제

maven의 cache 폴더인 $HOME/.m2/repository 의 $artifact-$version 폴더를 삭제하고 maven 재구동 (Ex: rm -rf ~/.m2/repository/com/company/ets/ets-common/0.91.08)

2 .maven 실행시 --update-snapshots 를 주어서 실행

Forces a check for updated releases and snapshots on remote repositories

3 .updatePolicy 수정

아래의 snapshot repository의 updatepolicy 를 참고하여 always 나 interval:xxx 로 수정

Snapshots 으로 deploy중인데 Nexus Repository 에서 최근 snapshot을 못 가져옴

원인

snapshot repository의 기본 updatePolicy 가 daily 임

해결

${HOME}/.m2/settings.xml 에 다음 내용 추가 - http://maven.apache.org/settings.html#Repositories

  • updatePolicy: This element specifies how often updates should attempt to occur. Maven will compare the local POM's timestamp (stored in a repository's maven-metadata file) to the remote. The choices are: always, daily (default), interval:X (where X is an integer in minutes) or never.
<profiles>
    <profile>
      ...
      <repositories>       
          <snapshots>
            <enabled>true</enabled>
            <updatePolicy>always</updatePolicy>
            <checksumPolicy>fail</checksumPolicy>
          </snapshots>
          <url>http://snapshots.maven.codehaus.org/maven2</url>
          <layout>default</layout>
        </repository>
      </repositories>
      ...
    </profile>
  </profiles>

 

기타 

Configure Source file Encoding

증상

When I run maven install on my multi module maven project I always get the following output:

[WARNING] File encoding has not been set, using platform encoding UTF-8, i.e. build is platform dependent!code
처리

pom.xml 에 다음 내용 추가

<properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
</properties>

See also http://maven.apache.org/general.html#encoding-warning

“Updating Maven Project”. Unsupported IClasspathEntry kind=4?

증상

maven project import 시 위 메시지가 나오며 정상적으로 import가 안 됨.

처리

m2e bug 이며 다음 순서로 처리

  1. m2e 업데이트 (http://eclipse.org/m2e/download/ 참고)
  2. maven nature Diable(프로젝트 메뉴에서 우클릭)
     

  3. run mvn eclipse:clean (while your project is open in STS/eclipse)
  4. 'Configure'-> 'Convert to Maven Project')
     

See Also: http://stackoverflow.com/questions/10564684/how-to-fix-error-updating-maven-project-unsupported-iclasspathentry-kind-4

 

“webxml attribute is required” error in Maven Error

증상

Failed to execute goal org.apache.maven.plugins:maven-war-plugin:2.1.1:war (default-war) on project my-project: Error assembling WAR: webxml attribute is required (or pre-existing WEB-INF/web.xml if executing in update mode) -> [Help 1]

처리

maven-war-plugin 에 web.xml 의 경로를 지정

<plugin>            
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-war-plugin</artifactId>
  <configuration>
    <webXml>src\main\webapp\WEB-INF\web.xml</webXml>        
  </configuration>
</plugin>

 

 archetype:generate 실행 에러 - The goal you specified requires a project to execute but there is no POM in this directory.

증상

The goal you specified requires a project to execute but there is no POM in this directory.please verify you invoked Maven from the correct directory.

처리

Windows 의 cmd 에서 바로 실행시 파라미터를 제대로 처리하지 못 해서 발생하며 다음과 같이 처리

1.Batch 파일에서 실행
2.파라미터를 " 로 둘러 싸서 실행

Before

mvn archetype:generate -B -DarchetypeGroupId=org.apache.maven.archetypes -DarchetypeArtifactId=maven-archetype-webapp  -DgroupId=com.example -DartifactId=dogstore -Dversion=1.0-SNAPSHOT

After

mvn archetype:generate -B "-DarchetypeGroupId=org.apache.maven.archetypes" "-DarchetypeArtifactId=maven-archetype-webapp" "-DgroupId=com.example" "-DartifactId=dogstore" "-Dversion=1.0-SNAPSHOT"

 

 

Ref