NutzCN Logo
精华 Nutzboot 无法使用Gradle构建
发布于 2492天前 作者 qq_d321faea 2176 次浏览 复制 上一个帖子 下一个帖子
标签: gradle

我按照官网的例子,导出了Nutzboot的demo,但是默认是maven构建的,我使用gradle init --type pom自动转换,提示错误,信息如下,哪位高手帮忙解决一下。本地gradle版本 V 4.1

C:\Users\Administrator\Desktop\nutzboot>gradle init --type pom
:wrapper UP-TO-DATE
:init
Maven to Gradle conversion is an incubating feature.
:init FAILED

FAILURE: Build failed with an exception.

  • What went wrong:
    Execution failed for task ':init'.

    Could not convert Maven POM C:\Users\Administrator\Desktop\nutzboot\pom.xml to
    a Gradle build.
    > Unable to create Maven project model using POM C:\Users\Administrator\Deskt
    op\nutzboot\pom.xml.
    > java.lang.NullPointerException (no error message)

  • Try:
    Run with --stacktrace option to get the stack trace. Run with --info or --debug
    option to get more log output.

BUILD FAILED

Total time: 1.955 secs

12 回复
 java.lang.NullPointerException (no error message)

没有详细信息? 要不先报个issue吧

会不会是因为shade插件的缘故?

我刚刚用gradle 4.5 测试了一下, 是可以正常的输出build.gradle等文件的

C:\Users\Administrator\workspace\git\github\nutzboot\nutzboot-demo\nutzboot-demo
-simple\nutzboot-demo-simple-dao>C:\Users\Administrator\tools\gradle-4.5\bin\gra
dle.bat init --type pom

> Task :init
Maven to Gradle conversion is an incubating feature.


BUILD SUCCESSFUL in 0s
2 actionable tasks: 2 executed

输出的build.gradle是这样的

apply plugin: 'java'
apply plugin: 'maven'

group = 'org.nutz'
version = '2.2-SNAPSHOT'

description = """"""

sourceCompatibility = 1.8
targetCompatibility = 1.8
tasks.withType(JavaCompile) {
	options.encoding = 'UTF-8'
}



repositories {
        
     maven { url "https://jfrog.nutz.cn/artifactory/libs-release" }
     maven { url "https://jfrog.nutz.cn/artifactory/snapshots" }
     maven { url "http://repo.maven.apache.org/maven2" }
}
dependencies {
    compile group: 'org.nutz', name: 'nutzboot-starter-nutz-mvc', version:'2.2-SNAPSHOT'
    compile group: 'org.nutz', name: 'nutzboot-starter-nutz-dao', version:'2.2-SNAPSHOT'
    compile group: 'org.nutz', name: 'nutzboot-starter-jdbc', version:'2.2-SNAPSHOT'
    compile group: 'org.nutz', name: 'nutzboot-starter-jetty', version:'2.2-SNAPSHOT'
    compile group: 'org.nutz', name: 'nutzboot-starter-swagger', version:'2.2-SNAPSHOT'
    compile group: 'org.slf4j', name: 'slf4j-log4j12', version:'1.7.25'
    compile group: 'com.h2database', name: 'h2', version:'1.4.196'
    compile group: 'org.nutz', name: 'nutzboot-core', version:'2.2-SNAPSHOT'
}

我安装到4.5也还是不行,打印了下详细信息,有点看不明白,兽总帮看看。

  • Exception is:
    org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':init'.
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.ex
    ecuteActions(ExecuteActionsTaskExecuter.java:103)
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.ex
    ecute(ExecuteActionsTaskExecuter.java:73)
    at org.gradle.api.internal.tasks.execution.OutputDirectoryCreatingTaskEx
    ecuter.execute(OutputDirectoryCreatingTaskExecuter.java:51)
    at org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter.exec
    ute(SkipUpToDateTaskExecuter.java:59)
    at org.gradle.api.internal.tasks.execution.ResolveTaskOutputCachingState
    Executer.execute(ResolveTaskOutputCachingStateExecuter.java:54)
    at org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execut
    e(ValidatingTaskExecuter.java:59)
    at org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecu
    ter.execute(SkipEmptySourceFilesTaskExecuter.java:101)
    at org.gradle.api.internal.tasks.execution.FinalizeInputFilePropertiesTa
    skExecuter.execute(FinalizeInputFilePropertiesTaskExecuter.java:44)
    at org.gradle.api.internal.tasks.execution.CleanupStaleOutputsExecuter.e
    xecute(CleanupStaleOutputsExecuter.java:88)
    at org.gradle.api.internal.tasks.execution.ResolveTaskArtifactStateTaskE
    xecuter.execute(ResolveTaskArtifactStateTaskExecuter.java:62)
    at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter
    .execute(SkipTaskWithNoActionsExecuter.java:52)
    at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execut
    e(SkipOnlyIfTaskExecuter.java:54)
    at org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter
    .execute(ExecuteAtMostOnceTaskExecuter.java:43)
    at org.gradle.api.internal.tasks.execution.CatchExceptionTaskExecuter.ex
    ecute(CatchExceptionTaskExecuter.java:34)
    at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTa
    skWorker$1.run(DefaultTaskGraphExecuter.java:248)
    at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBu
    ildOperationWorker.execute(DefaultBuildOperationExecutor.java:336)
    at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBu
    ildOperationWorker.execute(DefaultBuildOperationExecutor.java:328)
    at org.gradle.internal.progress.DefaultBuildOperationExecutor.execute(De
    faultBuildOperationExecutor.java:199)
    at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(Defaul
    tBuildOperationExecutor.java:110)
    at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTa
    skWorker.execute(DefaultTaskGraphExecuter.java:241)
    at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTa
    skWorker.execute(DefaultTaskGraphExecuter.java:230)
    at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWo
    rker.processTask(DefaultTaskPlanExecutor.java:123)
    at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWo
    rker.access$200(DefaultTaskPlanExecutor.java:79)
    at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWo
    rker$1.execute(DefaultTaskPlanExecutor.java:104)
    at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWo
    rker$1.execute(DefaultTaskPlanExecutor.java:98)
    at org.gradle.execution.taskgraph.DefaultTaskExecutionPlan.execute(Defau
    ltTaskExecutionPlan.java:623)
    at org.gradle.execution.taskgraph.DefaultTaskExecutionPlan.executeWithTa
    sk(DefaultTaskExecutionPlan.java:578)
    at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWo
    rker.run(DefaultTaskPlanExecutor.java:98)
    at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.
    onExecute(ExecutorPolicy.java:63)
    at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecu
    torImpl.java:46)
    at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnabl
    e.run(ThreadFactoryImpl.java:55)
    Caused by: org.gradle.buildinit.plugins.internal.maven.MavenConversionException:
    Could not convert Maven POM C:\Users\Administrator\Desktop\nutzboot\pom.xml to
    a Gradle build.
    at org.gradle.buildinit.plugins.internal.PomProjectInitDescriptor.genera
    te(PomProjectInitDescriptor.java:50)
    at org.gradle.buildinit.tasks.InitBuild.setupProjectLayout(InitBuild.jav
    a:117)
    at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:73)
    at org.gradle.api.internal.project.taskfactory.StandardTaskAction.doExec
    ute(StandardTaskAction.java:46)
    at org.gradle.api.internal.project.taskfactory.StandardTaskAction.execut
    e(StandardTaskAction.java:39)
    at org.gradle.api.internal.project.taskfactory.StandardTaskAction.execut
    e(StandardTaskAction.java:26)
    at org.gradle.api.internal.AbstractTask$TaskActionWrapper.execute(Abstra
    ctTask.java:788)
    at org.gradle.api.internal.AbstractTask$TaskActionWrapper.execute(Abstra
    ctTask.java:755)
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter$1.
    run(ExecuteActionsTaskExecuter.java:124)
    at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBu
    ildOperationWorker.execute(DefaultBuildOperationExecutor.java:336)
    at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBu
    ildOperationWorker.execute(DefaultBuildOperationExecutor.java:328)
    at org.gradle.internal.progress.DefaultBuildOperationExecutor.execute(De
    faultBuildOperationExecutor.java:199)
    at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(Defaul
    tBuildOperationExecutor.java:110)
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.ex
    ecuteAction(ExecuteActionsTaskExecuter.java:113)
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.ex
    ecuteActions(ExecuteActionsTaskExecuter.java:95)
    ... 30 more
    Caused by: org.gradle.buildinit.plugins.internal.maven.MavenConversionException:
    Unable to create Maven project model using POM C:\Users\Administrator\Desktop\n
    utzboot\pom.xml.
    at org.gradle.buildinit.plugins.internal.maven.MavenProjectsCreator.crea
    te(MavenProjectsCreator.java:51)
    at org.gradle.buildinit.plugins.internal.PomProjectInitDescriptor.genera
    te(PomProjectInitDescriptor.java:47)
    ... 44 more
    Caused by: java.lang.NullPointerException
    at org.sonatype.aether.impl.internal.DefaultMetadataResolver.resolve(Def
    aultMetadataResolver.java:279)
    at org.sonatype.aether.impl.internal.DefaultMetadataResolver.resolveMeta
    data(DefaultMetadataResolver.java:173)
    at org.apache.maven.repository.internal.DefaultVersionResolver.resolveVe
    rsion(DefaultVersionResolver.java:225)
    at org.sonatype.aether.impl.internal.DefaultArtifactResolver.resolve(Def
    aultArtifactResolver.java:272)
    at org.sonatype.aether.impl.internal.DefaultArtifactResolver.resolveArti
    facts(DefaultArtifactResolver.java:216)
    at org.sonatype.aether.impl.internal.DefaultArtifactResolver.resolveArti
    fact(DefaultArtifactResolver.java:193)
    at org.sonatype.aether.impl.internal.DefaultRepositorySystem.resolveArti
    fact(DefaultRepositorySystem.java:286)
    at org.apache.maven.project.ProjectModelResolver.resolveModel(ProjectMod
    elResolver.java:155)
    at org.apache.maven.model.building.DefaultModelBuilder.importDependencyM
    anagement(DefaultModelBuilder.java:953)
    at org.apache.maven.model.building.DefaultModelBuilder.build(DefaultMode
    lBuilder.java:400)
    at org.apache.maven.model.building.DefaultModelBuilder.build(DefaultMode
    lBuilder.java:371)
    at org.apache.maven.model.building.DefaultModelBuilder.build(DefaultMode
    lBuilder.java:362)
    at org.apache.maven.model.building.DefaultModelBuilder.build(DefaultMode
    lBuilder.java:232)
    at org.apache.maven.project.DefaultProjectBuilder.build(DefaultProjectBu
    ilder.java:142)
    at org.apache.maven.project.DefaultProjectBuilder.build(DefaultProjectBu
    ilder.java:102)
    at org.gradle.buildinit.plugins.internal.maven.MavenProjectsCreator.crea
    teNow(MavenProjectsCreator.java:71)
    at org.gradle.buildinit.plugins.internal.maven.MavenProjectsCreator.crea
    te(MavenProjectsCreator.java:49)
    ... 45 more

贴一下你的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>
	<groupId>io.nutz</groupId>
	<artifactId>demo</artifactId>
	<version>1.0-SNAPSHOT</version>
	<packaging>jar</packaging>
	<properties>
		<nutzboot.version>2.2-SNAPSHOT</nutzboot.version>
		<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
	</properties>
	<dependencyManagement>
		<dependencies>
			<dependency>
				<groupId>org.nutz</groupId>
				<artifactId>nutzboot-parent</artifactId>
				<version>${nutzboot.version}</version>
				<type>pom</type>
            	<scope>import</scope>
			</dependency>
		</dependencies>
	</dependencyManagement>
	<dependencies>
		<dependency>
			<groupId>org.nutz</groupId>
			<artifactId>nutzboot-starter-swagger</artifactId>
		</dependency>
		<dependency>
			<groupId>org.nutz</groupId>
			<artifactId>nutzboot-starter-jetty</artifactId>
		</dependency>
		<dependency>
			<groupId>org.nutz</groupId>
			<artifactId>nutzboot-starter-nutz-mvc</artifactId>
		</dependency>
		<dependency>
			<groupId>org.nutz</groupId>
			<artifactId>nutzboot-starter-nutz-dao</artifactId>
		</dependency>
		<dependency>
			<groupId>org.nutz</groupId>
			<artifactId>nutzboot-starter-jdbc</artifactId>
		</dependency>
		<dependency>
			<groupId>com.alibaba</groupId>
			<artifactId>druid</artifactId>
		</dependency>
		<dependency>
			<groupId>org.nutz</groupId>
			<artifactId>nutzboot-starter-redis</artifactId>
		</dependency>
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		<dependency>
			<groupId>org.slf4j</groupId>
			<artifactId>slf4j-log4j12</artifactId>
		</dependency>
		<dependency>
			<groupId>com.h2database</groupId>
			<artifactId>h2</artifactId>
			<version>1.4.196</version>
		</dependency>
		<dependency>
			<groupId>junit</groupId>
			<artifactId>junit</artifactId>
			<scope>test</scope>
		</dependency>
	</dependencies>
	<repositories>
		<repository>
			<id>nutz</id>
			<url>http://jfrog.nutz.cn/artifactory/libs-release</url>
		</repository>
		<repository>
			<id>nutz-snapshots</id>
			<url>http://jfrog.nutz.cn/artifactory/snapshots</url>
			<snapshots>
				<enabled>true</enabled>
				<updatePolicy>always</updatePolicy>
			</snapshots>
			<releases>
				<enabled>false</enabled>
			</releases>
		</repository>
	</repositories>
	<build>
		<plugins>
			<plugin>
				<artifactId>maven-compiler-plugin</artifactId>
				<version>3.7.0</version>
				<configuration>
					<source>1.8</source>
					<target>1.8</target>
					<compilerArgs>
						<arg>-parameters</arg>
					</compilerArgs>
					<useIncrementalCompilation>false</useIncrementalCompilation>
				</configuration>
			</plugin>
			<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-javadoc-plugin</artifactId>
				<version>2.10.3</version>
				<configuration>
					<additionalparam>-Xdoclint:none</additionalparam>
				</configuration>
			</plugin>
			<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-jar-plugin</artifactId>
				<version>3.0.2</version>
				<configuration>
					<archive>
						<manifest>
							<addDefaultImplementationEntries>true</addDefaultImplementationEntries>
							<mainClass>io.nutz.demo.MainLauncher</mainClass>
						</manifest>
					</archive>
				</configuration>
			</plugin>
			<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-shade-plugin</artifactId>
				<version>3.0.0</version>
				<executions>
					<execution>
						<phase>package</phase>
						<goals>
							<goal>shade</goal>
						</goals>
						<configuration>
							<transformers>
								<transformer implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer" />
								<transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
									<resource>META-INF/nutz/org.nutz.boot.starter.NbStarter</resource>
								</transformer>
								<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
									<mainClass>io.nutz.demo.MainLauncher</mainClass>
								</transformer>
							</transformers>
						</configuration>
					</execution>
				</executions>
			</plugin>
		</plugins>
	</build>
</project>

这代码我是自动导出来的啊,pom.xml不应该有什么问题。

似乎是dependencyManagement的原因,继续排除中

我试了几种组合, 发现完全删除repositories能pass, 去掉dependencyManagement,补全版本号,能pass

果然,我手动加了版本号,过去了。感觉有点累,还是十分感谢兽总。

添加回复
请先登陆
回到顶部