Maven 어셈블리 플러그인 용 사용자 정의 형식을 만들려고합니다. Creating a Custom Build Extension for Maven 3.0Maven 3 사용자 정의 형식
확장자에 대한 나의 pom.xml 파일 :
<?xml version="1.0"?>
<project
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<groupId>my.maven.extention</groupId>
<artifactId>pkg</artifactId>
<version>0.0.1</version>
<name>maven pkg archiver</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-archiver</artifactId>
<version>1.1</version>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-compat</artifactId>
<version>3.0.1</version>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-core</artifactId>
<version>3.0.1</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-component-metadata</artifactId>
<version>1.5.5</version>
<executions>
<execution>
<goals>
<goal>generate-metadata</goal>
<goal>generate-test-metadata</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
그리고 빈 클래스 : 나는 받는다는 3 확장명을 만드는 방법 지시에 따라 사용하십시오
import java.io.IOException;
import org.codehaus.plexus.archiver.AbstractArchiver;
import org.codehaus.plexus.archiver.Archiver;
import org.codehaus.plexus.archiver.ArchiverException;
import org.codehaus.plexus.component.annotations.Component;
@Component(role = Archiver.class, hint = "pkg")
public class PkgArchiver extends AbstractArchiver {
@Override
protected void close() throws IOException {
// TODO Auto-generated method stub
}
@Override
protected void execute() throws ArchiverException, IOException {
// TODO Auto-generated method stub
}
@Override
protected String getArchiveType() {
return "pkg";
}
}
을 그리고 내 받는다는 프로젝트에 사용
를<extensions>
<extension>
<groupId>my.maven.extention</groupId>
<artifactId>pkg</artifactId>
<version>0.0.1</version>
</extension>
</extensions>
mvn failed :
[오류] 목표 org.apache.maven.plugins를 실행하지 못했습니다. maven-assembly-plugin : 2.2 : 프로젝트의 어셈블리 (기본 cli) cl3 : org.apache.maven.plugins를 실행하는 동안 형식이 호환되지 않습니다. : maven-assembly-plugin : 2.2 : 어셈블리 : my.maven.extention.pkg.PkgArchiver는 org.codehaus.plexus.archiver.Archiver로 캐스트 할 수 없습니다.
나는 과소 평가하지 않습니다. AbstractArchiver는 org.codehaus.plexus.archiver.Archiver를 구현하고 내 클래스는이 추상 클래스를 확장하기 때문입니다. 내 제안 : 다른 플러그인에 대해 다른 클래스 로더를 사용합니다. 그것은 메이븐에 대한 첫 번째 플러그인이고 나는 그것을 고칠 수있는 방법을 이해하지 않습니다.
미리 감사드립니다.