我正在尝试从zip格式的项目中导入一些模式。该文件的名称为mySchema-1.0.32-schema.zip
。我的依赖关系如下:
<dependency>
<groupId>some.group.id</groupId>
<artifactId>mySchema</artifactId>
<version>${schema.version}</version>
<classifier>schema</classifier>
<type>zip</type>
</dependency>
但依赖关系不会被导入。它在我的仓库中(我已经检查过),并且我对同一个项目有源依赖,它工作得很好。我的分类器和我的类型是对的吗?这是导入zip
文件的方式吗?
修改
我发现如果我将<classifier>
更改为source
,它会导入源,如果我将其更改为-schemas
,则会发出错误。因此,进口似乎正在发挥作用。虽然我在IntelliJ IDEA的依赖列表中看不到它,但如果我运行mvn dependency:tree
,它就存在于:
\- some.group.id:mySchema:zip:schema:1.0.32-SNAPSHOT:compile
可能是我的解压缩无效:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>unpack</id>
<phase>process-resources</phase>
<goals>
<goal>unpack</goal>
</goals>
<configuration>
<artifactItems>
<artifactItem>
<groupId>some.group.id</groupId>
<artifactId>mySchema</artifactId>
<version>${schema.version}</version>
<classifier>schema</classifier>
<type>zip</type>
<overWrite>false</overWrite>
<outputDirectory>${basedir}/src/main/resources/json</outputDirectory>
</artifactItem>
</artifactItems>
</configuration>
</execution>
</executions>
</plugin>
只是为了澄清,我的输出目录存在。
答案 0 :(得分:0)
找到解决方案。在<build>
部分添加了此插件:
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>unpack-config</id>
<phase>compile</phase>
<goals><goal>unpack-dependencies</goal></goals>
<configuration>
<includeGroupIds>some.group.id</includeGroupIds>
<includeArtifactIds>mySchema</includeArtifactIds>
<includeClassifiers>schema</includeClassifiers>
<outputDirectory>${project.build.directory}</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<additionalClasspathElements>
<additionalClasspathElement>${project.build.directory}</additionalClasspathElement>
</additionalClasspathElements>
</configuration>
</plugin>
</plugins>