maven pom to gradle - assembly plugin failure

时间:2016-08-22 11:31:30

标签: java maven gradle gradle-plugin

我目前正在使用我的JAVA Maven项目并尝试将其迁移到Gradle。我发出了以下命令来转换它,

gradle init

请找到pom.xml,我项目的描述符xml文件以及下面生成的build.gradle文件,

的pom.xml

<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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<artifactId>ProjectA</artifactId>
<packaging>jar</packaging>

<name>ProjectA</name>


<dependencies>
    <dependency>
        <groupId>org.jpos</groupId>
        <artifactId>jpos</artifactId>
        <version>113</version>
        <scope>system</scope>
        <systemPath>${project.basedir}/src/main/non-distributable-lib/jpos113.jar</systemPath>
    </dependency>
</dependencies>

<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-assembly-plugin</artifactId>
            <version>2.5.3</version>
            <configuration>
                <archive>
                    <manifest>
                        <mainClass>com.test.jpos.Main</mainClass>
                    </manifest>
                </archive>
                <descriptor>src/main/assembly/assemble_POSMClient_JPOS_Bridge.xml</descriptor>
            </configuration>
            <executions>
                <execution>
                    <id>make-assembly</id>
                    <phase>package</phase>
                    <goals>
                        <goal>single</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
        <plugin>
            <artifactId>maven-compiler-plugin</artifactId>
            <configuration>
                <source>1.6</source>
                <target>1.6</target>
            </configuration>
        </plugin>
    </plugins>
</build>
<parent>
    <groupId>com.test</groupId>
    <artifactId>ProjectRoot</artifactId>
    <version>5.0.0</version>
    <relativePath>../pom.xml</relativePath>
</parent>

build.gradle:

description = 'ProjectA'
sourceCompatibility = 1.8
targetCompatibility = 1.8

dependencies {
    compile files('src/main/non-distributable-lib/jpos113.jar')
}

assemble_POSMClient_JPOS_Bridge.xml:

<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2 http://maven.apache.org/xsd/assembly-1.1.2.xsd">
<id>assemble_pos</id>
<formats>
    <format>jar</format>
</formats>
<includeBaseDirectory>false</includeBaseDirectory>
<dependencySets>
    <dependencySet>
        <outputDirectory>/</outputDirectory>
        <useProjectArtifact>true</useProjectArtifact>
        <unpack>true</unpack>
        <scope>runtime</scope>
    </dependencySet>
</dependencySets>
<fileSets>
    <fileSet>
        <directory>${project.basedir}/../POSMClient-Common/src/main/lib/Packaged-Web-Components</directory>
        <outputDirectory>Packaged-Web-Components</outputDirectory>
        <includes>
            <include>**/*.*</include>
        </includes>
        <excludes>
            <exclude>www.zip</exclude>
            <exclude>*.uncompressed.js</exclude>
            <exclude>js/lib/cometd/*</exclude>
            <exclude>.gitmodules</exclude>
            <exclude>README.md</exclude>
            <exclude>package.sh</exclude>
            <exclude>updateDojo.sh</exclude>
        </excludes>
    </fileSet>
    <fileSet>
        <directory>${project.basedir}/../POSMClient-Common/src/main/native</directory>
        <outputDirectory>Packaged-Web-Components/</outputDirectory>
        <includes>
            <include>*</include>
        </includes>
    </fileSet>
</fileSets>

注意: 当我做一个干净的时候没有异常出现并且是成功的,但是它无法生成汇编jar文件。

gradle clean

无法在build.gradle文件中生成程序集插件部分。如果我有什么遗失,请告诉我。

1 个答案:

答案 0 :(得分:0)

没有类似于使用maven和gradle的方式。只运行gradle init将无法解决大部分pom结构问题。

Gradle有类似的插件供分发。

下面链接有更多细节,关于如何在build.gradle文件中编写代码块以实现汇编和分发。

https://docs.gradle.org/current/userguide/distribution_plugin.html