2009-07-27 2 views
3

내가하고 싶은 일은 모든 의존성이있는 응용 프로그램의 소스 코드 배포판을 만들어 DVD에 구울 수 있습니다. 내가 100 년 만에 만들 수 있도록 (글쎄, 오케이, 내 말은 ...). 라이브러리 또는 메이븐 플러그인에 대한 온라인 의존성이 없습니다!자급 자족 가능한 메이븐 빌드로 소스 배포판을 만드는 방법은 무엇입니까?

나는이 개미가 더 좋을 것이라는 것을 알고 있지만, 내 프로젝트에서 maven을 사용하고있다. 나는 그것을 위해 Ant로 전환하지 않을 것이고, 나는 이것을 Maven으로하는 방법을 묻는다. 또는 자기 유지 형 Ant 빌드를 생성하는 방법이 있다면 DVD를 넣을 수도 있습니다. (ant:ant 플러그인이 있지만 단지 로컬 빌드에 의존성을 가리키는 Ant build.xml을 생성합니다)

내가 취한 접근법은 DVD에 넣고 빌드 할 수있는 특별한 로컬 리포지토리를 만들고 싶었습니다 프로젝트는 mvn -o -Dmaven.repo.local=repo/on/dvd입니다. dependency:copy-dependenciesuseRepositoryLayout 매개 변수를 true으로 설정하여 이러한 저장소를 만들려고했습니다. 하지만 그것은 내 빌드가 의존하는 이상한 Maven 플러그인을 복사하지 않습니다. ...

답변

3

플러그인을 포함하는 유일한 방법은 명령 행에서 빌드를위한 다른 로컬 저장소를 지정하는 것입니다. 의존성 소스 등을 다운로드 한 다음 프로젝트 내용과 사용자 정의 저장소를 포함하는 아카이브를 만듭니다.

소스 및 javadocs를 다운로드하는 pom은 프로젝트의 대상 디렉토리에 다운로드합니다.이 디렉토리는 로컬 저장소에도 있으므로 아카이브에서 제외됩니다. 어셈블리 디스크립터는 프로젝트의 내용과 로컬 저장소를 단일 (꽤 큰) 아카이브로 묶습니다.

처리가 모든 빌드에서 실제로 실행되기를 원하지 않기 때문에 모든 처리가 프로파일에 있음에 유의하십시오. 임시 로컬 저장소가 대상 디렉토리에 있으면 mvn clean으로 나중에 쉽게 정리할 수 있습니다.

mvn package -Parchive -Dmaven.repo.local=.\target\repo 

가 여기에 치어입니다 : 여기

<?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 http://maven.apache.org/maven-v4_0_0.xsd"> 
    <modelVersion>4.0.0</modelVersion> 
    <groupId>name.seller.rich</groupId> 
    <artifactId>test-archive</artifactId> 
    <version>0.0.1</version> 
    <dependencies> 
    <dependency> 
     <groupId>junit</groupId> 
     <artifactId>junit</artifactId> 
     <version>4.5</version> 
     <scope>test</scope> 
    </dependency> 
    </dependencies> 
    <profiles> 
    <profile> 
     <id>archive</id> 
     <build> 
     <plugins> 
      <plugin> 
      <groupId>org.apache.maven.plugins</groupId> 
      <artifactId>maven-dependency-plugin</artifactId> 
      <executions> 
       <execution> 
       <id>sources</id> 
       <phase>pre-package</phase> 
       <goals> 
        <goal>copy-dependencies</goal> 
       </goals> 
       <configuration> 
        <classifier>sources</classifier> 
        <failOnMissingClassifierArtifact>false</failOnMissingClassifierArtifact> 
        <!--the target directory won't be included, but the sources will be in the repository--> 
        <outputDirectory>${project.build.directory}/sources</outputDirectory> 
       </configuration> 
       </execution> 
       <execution> 
       <id>javadocs</id> 
       <phase>pre-package</phase> 
       <goals> 
        <goal>copy-dependencies</goal> 
       </goals> 
       <configuration> 
        <classifier>javadoc</classifier>      <failOnMissingClassifierArtifact>false</failOnMissingClassifierArtifact> 
        <outputDirectory>${project.build.directory}/javadocs</outputDirectory> 
       </configuration> 
       </execution> 
      </executions> 
      </plugin> 
      <plugin> 
      <artifactId>maven-assembly-plugin</artifactId> 
      <version>2.2-beta-4</version> 
      <executions> 
       <execution> 
       <phase>package</phase> 
       <goals> 
        <goal>single</goal> 
       </goals> 
       <configuration> 
        <descriptors> 
        <descriptor>src/main/assembly/archive.xml</descriptor> 
        </descriptors> 
       </configuration> 
       </execution> 
      </executions> 
      </plugin>  
     </plugins> 
     </build> 
    </profile> 
    </profiles> 
</project> 

그리고

어셈블리의 :

<assembly> 
    <id>archive</id> 
    <formats> 
    <format>zip</format> 
    </formats> 
    <fileSets> 
    <fileSet> 
    <directory>${project.basedir}</directory> 
    <outputDirectory>/</outputDirectory> 
     <excludes> 
     <exclude>target/**</exclude> 
     </excludes> 
    </fileSet> 
    <fileSet> 
    <directory>${maven.repo.local}</directory> 
    <outputDirectory>repo</outputDirectory> 
    </fileSet> 
    </fileSets> 
</assembly> 
+0

+1 재미있는 답변입니다. 나는 그것을 필요로 할지도 모른다. .. – KLE

0

내가 완전한 답이없는 프로필을 활성화하려면 다음과 같은 일을. 마지막으로이 것을 보았을 때 빌드 시작시 (또는 별도의 라이브러리 사용) 및 실행중인 mvn dependency:go-offline에서 localRepository를 제거한다고 생각했습니다.

정말 열정적이라면, Maven 자체와 JDK를 배포판에 번들로 묶어 놓을 수도 있습니다. 이것은 아마도 순수한 Maven 빌드의 범위를 벗어난다.

1

시계이 :

, 당신은 가 지원하는 스크립트, 구성 파일을 포함하는 Maven 프로젝트에서 바이너리 분포를 만드시겠습니까 모든 런타임 : 홈페이지에서 이 Maven Assembly Plugin

견적 의존성? 프로젝트의 배포판을 만들려면 어셈블리 플러그인을 사용해야합니다.

잘 구성 할 수 있습니다. 특히 임베디드 jetty 서버 및 사용자 문서를 사용하여 웹 응용 프로그램의 자체 실행 데모 버전을 만드는 데 사용했습니다.

관련 문제