解决gradle自定义插件中的依赖项问题

时间:2015-10-28 09:15:10

标签: gradle-plugin

我在maven中开发了一个实用程序。我希望在graven自定义插件中使用maven自定义插件使用maven实用程序这个实用程序工作正常但是在gradle插件的情况下它会抛出以下问题。

例外是:

org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':hiveUnitTask'. at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:69)


Caused by: java.lang.NoSuchMethodError: org.apache.hive.service.cli.operation.LogDivertAppender.setWriter(Ljava/io/Writer;)V
    at org.apache.hive.service.cli.operation.LogDivertAppender.<init>(LogDivertAppender.java:166)
    at org.apache.hive.service.cli.operation.OperationManager.initOperationLogCapture(OperationManager.java:85)
    at org.apache.hive.service.cli.operation.OperationManager.init(OperationManager.java:63)

Gradle插件是用java开发的。

我的实用程序的Pom文件如下:

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

    <groupId>com.datametica.hiveunit</groupId>
    <artifactId>hive_unit</artifactId>
    <version>1.0</version>
    <packaging>jar</packaging>

    <name>HiveUnit</name>
    <url>http://maven.apache.org</url>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <hadoop.version>2.2.0</hadoop.version>
        <hive.version>1.2.1</hive.version>
    </properties>

    <dependencies>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.10</version>
            <scope>test</scope>
            <type>jar</type>
        </dependency>

        <dependency>
            <groupId>junit-addons</groupId>
            <artifactId>junit-addons</artifactId>
            <version>1.4</version>
        </dependency>

        <dependency>
            <groupId>org.apache.hadoop</groupId>
            <artifactId>hadoop-minicluster</artifactId>
            <version>${hadoop.version}</version>
        </dependency>
        <dependency>
            <groupId>xerces</groupId>
            <artifactId>xercesImpl</artifactId>
            <version>2.9.1</version>
        </dependency>
        <dependency>
            <groupId>org.apache.hive</groupId>
            <artifactId>hive-service</artifactId>
            <version>${hive.version}</version>
        </dependency>

        <dependency>
            <groupId>org.apache.hive</groupId>
            <artifactId>hive-jdbc</artifactId>
            <version>${hive.version}</version>
            <exclusions>
                <exclusion>
                    <artifactId>hive-service</artifactId>
                    <groupId>org.apache.hive</groupId>
                </exclusion>
            </exclusions>
        </dependency>
</dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>2.3.2</version>
                <configuration>
                    <source>1.6</source>
                    <target>1.6</target>
                </configuration>
            </plugin>
</plugins>
    </build>
</project>

2 个答案:

答案 0 :(得分:0)

从类路径中删除log4j-over-slf4j。

答案 1 :(得分:0)

我从hive服务jar包的源码中复制了这个错误来源的包,并将它放在我的插件项目中,通过制作与hive服务jar中相同的包结构,这解决了我的问题我知道它知道完美的解决方案,但解决了我的目的的解决方法