java - maven pom 到 gradle - 程序集插件失败

标签 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>

构建.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 文件中生成程序集插件部分。如果我遗漏了什么,请告诉我。

最佳答案

没有类似的方式来使用 Maven 和 gradle。仅仅运行 gradle init 并不能帮助解决大部分 pom 结构。

Gradle 有类似的分发插件。

下面的链接有更多详细信息,介绍如何在 build.gradle 文件中编写代码块来实现汇编和分发。

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

关于java - maven pom 到 gradle - 程序集插件失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39078420/

相关文章:

java - 作为参数的静态函数 (::) 抛出错误

android - Android Studio 4.01版本更新

java - 检查服务是否正在从广播接收器内运行

java - 所有请求重定向特定的 url

java - DLFileEntry在内存中的大小

java - 最好的 jar 组织策略是什么?

java - 如何从sql数据库获取唯一值

java.lang.NoClassDefFoundError Spark-submit 使用其他项目中的类

maven - 执行失败 : 'control build' & Failed to execute goal: maven-compiler

android - Gradle build for Android 中的 JUnit 测试结果在哪里?