您的位置:首页 > 其它

第一次使用自己上传的maven库时遇到的错误总结

2016-11-21 14:00 363 查看
背景:好不容易将自己的jar包上传到maven中心,可以下载了,结果使用的时候,报各种错误。

错误1:

wudideMacBook-Pro:UCarNew xiepengchong$ ./gradlew tasks

Parallel execution with configuration on demand is an incubating feature.

Download https://repo1.maven.org/maven2/com/github/xiepengchong/lint-cleaner-plugin/1.0.1/lint-cleaner-plugin-1.0.1.pom
Download https://repo1.maven.org/maven2/com/github/xiepengchong/lint-cleaner-plugin/1.0.1/lint-cleaner-plugin-1.0.1.jar
FAILURE: Build failed with an exception.

* Where:

Build file '/Users/xiepengchong/ucar_git/ucarandroid/UCarNew/build.gradle' line: 27

* What went wrong:

A problem occurred evaluating root project 'UCarNew'.

原因:原来是我的版本不对,后来将build tool版本更改了一下。gradle版本改为2.10,
classpath 'com.android.tools.build:gradle:2.1.2'


错误2:

* Where:Build file '/Users/xiepengchong/ucar_git/ucarandroid/UCarNew/build.gradle' line: 32
* What went wrong:A problem occurred evaluating root project 'UCarNew'.> Could not find implementation class 'com.droidtitan.lintcleaner.LintCleanerPlugin' for plugin 'com.droidtitan.lintcleaner' specified in jar:file:/Users/xiepengchong/ucar_git/ucarandroid/UCarNew/external_lib/lint-cleaner-plugin-1.0.1.jar!/META-INF/gradle-plugins/com.droidtitan.lintcleaner.properties.原因:
我上传的jar包中,没有class文件,原来我的工程是使用groovy写的,所以有一些东西和java的不同,所以需要单独配置。

在pom.xml中指定路径

 87   <build> 88     <sourceDirectory>src/main/groovy</sourceDirectory> 89     <resources> 90       <resource> 91         <directory>src/main/resources</directory> 92           <includes> 93             <include>**/*.*</include> 94           </includes> 95       </resource> 96     </resources>


错误:指定之后,还需要使之可以编译进去,需要在pom.xml中配置下面的信息
mvn compile
 98       <plugin> 99         <groupId>org.codehaus.gmaven</groupId>100         <artifactId>gmaven-plugin</artifactId>101         <version>1.2</version>102         <configuration>103           <providerSelection>1.7</providerSelection>104           <sourceEncoding>UTF-8</sourceEncoding>105         </configuration>106         <executions>107           <execution>108             <goals>109               <goal>generateStubs</goal>110               <goal>compile</goal>111             </goals>112           </execution>113         </executions>114       </plugin>

错误:编译的时候,各种路径找不到

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project lint-cleaner-plugin: Compilation failure: Compilation failure:[ERROR] /Users/xiepengchong/opensource/2_my-cleaner-plugin/lint-cleaner-plugin/target/generated-sources/groovy-stubs/main/com/droidtitan/lintcleaner/LintCleanerPlugin.java:[6,1] 程序包org.gradle.api不存在[ERROR] /Users/xiepengchong/opensource/2_my-cleaner-plugin/lint-cleaner-plugin/target/generated-sources/groovy-stubs/main/com/droidtitan/lintcleaner/LintCleanerPlugin.java:[13,5] 找不到符号[ERROR] 符号: 类 Plugin[ERROR] /Users/xiepengchong/opensource/2_my-cleaner-plugin/lint-cleaner-plugin/target/generated-sources/groovy-stubs/main/com/droidtitan/lintcleaner/LintCleanerPlugin.java:[13,12] 找不到符号[ERROR] 符号: 类 Project[ERROR] /Users/xiepengchong/opensource/2_my-cleaner-plugin/lint-cleaner-plugin/target/generated-sources/groovy-stubs/main/com/droidtitan/lintcleaner/LintCleanerPlugin.java:[18,20] 找不到符号[ERROR] 符号:   类 Project[ERROR] 位置: 类 com.droidtitan.lintcleaner.LintCleanerPlugin[ERROR] /Users/xiepengchong/opensource/2_my-cleaner-plugin/lint-cleaner-plugin/target/generated-sources/groovy-stubs/main/com/droidtitan/lintcleaner/LintCleanerPluginExtension.java:[6,1] 程序包org.gradle.api不存在[ERROR] /Users/xiepengchong/opensource/2_my-cleaner-plugin/lint-cleaner-plugin/target/generated-sources/groovy-stubs/main/com/droidtitan/lintcleaner/LintCleanerPluginExtension.java:[14,35] 找不到符号[ERROR] 符号:   类 Project[ERROR] 位置: 类 com.droidtitan.lintcleaner.LintCleanerPluginExtension[ERROR] /Users/xiepengchong/opensource/2_my-cleaner-plugin/lint-cleaner-plugin/target/generated-sources/groovy-stubs/main/com/droidtitan/lintcleaner/LintCleanerTask.java:[7,1] 程序包org.gradle.api不存在[ERROR] /Users/xiepengchong/opensource/2_my-cleaner-plugin/lint-cleaner-plugin/target/generated-sources/groovy-stubs/main/com/droidtitan/lintcleaner/LintCleanerTask.java:[11,1] 程序包org.gradle.api.tasks不存在[ERROR] /Users/xiepengchong/opensource/2_my-cleaner-plugin/lint-cleaner-plugin/target/generated-sources/groovy-stubs/main/com/droidtitan/lintcleaner/LintCleanerTask.java:[15,11] 找不到符号[ERROR] 符号: 类 DefaultTask[ERROR] /Users/xiepengchong/opensource/2_my-cleaner-plugin/lint-cleaner-plugin/target/generated-sources/groovy-stubs/main/com/droidtitan/lintcleaner/LintCleanerTask.java:[44,28] 对NodeList的引用不明确[ERROR] groovy.util 中的类 groovy.util.NodeList 和 org.w3c.dom 中的接口 org.w3c.dom.NodeList 都匹配

原因:我们使用gradle编译,系统下好多jar都是配置好的,如果用maven编译,则需要指定,在pom.xml指定我们本地以来jar文件

 58     <dependency> 59       <groupId>gradle-core</groupId> 60       <artifactId>gradle-core</artifactId> 61       <version>2.10</version> 62       <scope>system</scope> 63       <systemPath>${project.basedir}/libs/gradle-core-2.10.jar</systemPath> 64     </dependency> 65     <dependency> 66       <groupId>gradle-base-services-groovy</groupId> 67       <artifactId>gradle-base-services-groovy</artifactId> 68       <version>2.10</version> 69       <scope>system</scope> 70       <systemPath>${project.basedir}/libs/gradle-base-services-groovy-2.10.jar</systemPath> 71     </dependency> 72     <dependency> 73       <groupId>gradle-base-services</groupId> 74       <artifactId>gradle-base-services</artifactId> 75       <version>2.10</version> 76       <scope>system</scope> 77       <systemPath>${project.basedir}/libs/gradle-base-services-2.10.jar</systemPath> 78     </dependency> 79     <dependency> 80       <groupId>gradle-model-core</groupId> 81       <artifactId>gradle-model-core</artifactId> 82       <version>2.10</version> 83       <scope>system</scope> 84       <systemPath>${project.basedir}/libs/gradle-model-core-2.10.jar</systemPath> 85     </dependency>

错误:一切都结束了,但是发现我们部署的时候,没有上传javadoc和source,所以部署的时候,会有问题。

原因:同样需要在build的时候,配置plugin

115       <plugin>116         <groupId>org.apache.maven.plugins</groupId>117         <artifactId>maven-source-plugin</artifactId>118         <version>2.4</version>119         <configuration>120           <attach>true</attach>121         </configuration>122           <executions>123             <execution>124               <id>attach-sources</id>125               <phase>package</phase>126               <goals>127                 <goal>jar-no-fork</goal>128               </goals>129             </execution>130           </executions>131        </plugin>132        <plugin>133          <groupId>org.apache.maven.plugins</groupId>134          <artifactId>maven-javadoc-plugin</artifactId>135          <version>2.10.2</version>136          <configuration>137            <aggregate>true</aggregate>138          </configuration>139          <executions>140            <execution>141               <id>attach-javadocs</id>142               <goals>143                 <goal>jar</goal>144               </goals>145             </execution>146           </executions>147       </plugin>


这回上传就等待审核吧。


                                            
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: