gpt4 book ai didi

maven - Gradle 创建 pom 失败

转载 作者:行者123 更新时间:2023-12-03 04:17:33 25 4
gpt4 key购买 nike

我想用 Gradle 创建一个 pom.xml。
但它失败了。

这是我的 build.gradle (项目)

   // Top-level build file where you can add configuration options common      to all sub-projects/modules.
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.2.1'
classpath 'com.github.dcendents:android-maven-gradle-plugin:1.5'

// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}

allprojects {
repositories {
google()
jcenter()
}
}

task clean(type: Delete) {
delete rootProject.buildDir
}

task writeNewPom {
doLast {
pom {
project {
inceptionYear '2008'
licenses {
license {
name 'The Apache Software License, Version 2.0'
url 'http://www.apache.org/licenses/LICENSE-2.0.txt'
distribution 'repo'
}
}
}
}.writeTo("$buildDir/pom.xml")
}
}

和我的 build.gradle (模块)
apply plugin: 'com.android.application'

apply plugin: 'com.github.dcendents.android-maven'
group = 'com.github.ludev-studio'

apply plugin: 'maven'

android {
compileSdkVersion 28
defaultConfig {
applicationId "com.ludevstudio.colorpicker"
minSdkVersion 15
targetSdkVersion 28
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard- android.txt'), 'proguard-rules.pro'
}
}
buildToolsVersion '28.0.3'
}

dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support:appcompat-v7:28.0.0'
testImplementation 'junit:junit:4.12'
implementation project(':colorpicker')
}

这是输出,然后我使用 gradlew.bat 执行 writeNewPom 任务:
FAILURE: Build failed with an exception.

* Where:
Build file 'C:\Users\lucad\Documents\programmierung\Projekte\Java\Androidlibraries\Colo rpicker\build.gradle' line: 32

* What went wrong:
Execution failed for task ':writeNewPom'.
> Could not find method pom() for arguments [build_1nb7g16o7col6erw9g4aech65 $_run_closure3$_closure5 $_closure6@30d7b2ef] on task ':writeNewPom' of type org.gradle.api.DefaultTask.

* Try:
Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Exception is:
org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':writeNewPom'.
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions (ExecuteActionsTaskExecuter.java:103)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute (ExecuteActionsTaskExecuter.java:73)
at org.gradle.api.internal.tasks.execution.OutputDirectoryCreatingTaskExecuter.execu te(OutputDirectoryCreatingTaskExecuter.java:51)
at org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter.execute(SkipUpToDateTaskExecuter.java:59)
at org.gradle.api.internal.tasks.execution.ResolveTaskOutputCachingStateExecuter.exe cute(ResolveTaskOutputCachingStateExecuter.java:54)
at org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute (ValidatingTaskExecuter.java:59)
at org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecuter.execute (SkipEmptySourceFilesTaskExecuter.java:101)
at org.gradle.api.internal.tasks.execution.FinalizeInputFilePropertiesTaskExecuter.execute(FinalizeInputFilePropertiesTaskExecuter.java:44)
at org.gradle.api.internal.tasks.execution.CleanupStaleOutputsExecuter.execute (CleanupStaleOutputsExecuter.java:91)
at org.gradle.api.internal.tasks.execution.ResolveTaskArtifactStateTaskExecuter.execute(ResolveTaskArtifactStateTaskExecuter.java:62)
at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:59)
at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:54)
at org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter.execute(ExecuteAtMostOnceTaskExecuter.java:43)
at org.gradle.api.internal.tasks.execution.CatchExceptionTaskExecuter.execute(CatchExceptionTaskExecuter.java:34)
at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker$1.run(DefaultTaskGraphExecuter.java:256)
at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:336)
at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:328)
at org.gradle.internal.progress.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:199)
at org.gradle.internal.progress.DefaultBuildOperationExecutor.run (DefaultBuildOperationExecutor.java:110)
at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:249)
at o rg.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:238)
at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker.processTask(DefaultTaskPlanExecutor.java:123)
at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker.access$200(DefaultTaskPlanExecutor.java:79)
at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker$1.execute(DefaultTaskPlanExecutor.java:104)
at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker$1.execute(DefaultTaskPlanExecutor.java:98)
at org.gradle.execution.taskgraph.DefaultTaskExecutionPlan.execute(DefaultTaskExecutionPlan.java:663)
at org.gradle.execution.taskgraph.DefaultTaskExecutionPlan.executeWithTask(DefaultTaskExecutionPlan.java:597)
at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker.run(DefaultTaskPlanExecutor.java:98)
at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:63)
at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run (ManagedExecutorImpl.java:46)
at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:55)
Caused by: org.gradle.internal.metaobject.AbstractDynamicObject$CustomMessageMissingMethodException: Could not find method pom() for arguments [build_1nb7g16o7col6erw9g4aech65$_run_closure3$_closure5$_closure6@30d7b2ef] on task ':writeNewPom' of type org.gradle.api.DefaultTask.
atorg.gradle.internal.metaobject.AbstractDynamicObject.methodMissingException(AbstractDynamicObject.java:179)
at org.gradle.internal.metaobject.AbstractDynamicObject.invokeMethod(AbstractDynamicObject.java:164)
at org.gradle.api.DefaultTask_Decorated.invokeMethod(Unknown Source)
at build_1nb7g16o7col6erw9g4aech65$_run_closure3$_closure5.doCall(C:\Users\lucad\Documents\programmierung\Projekte\Java\Androidlibraries\Colorpicker\build.gradle:32)
at org.gradle.api.internal.AbstractTask$ClosureTaskAction.execute(AbstractTask.java:726)
at org.gradle.api.internal.AbstractTask$ClosureTaskAction.execute(AbstractTask.java:699)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter$1.run (ExecuteActionsTaskExecuter.java:124) at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperation Worker.execute(DefaultBuildOperationExecutor.java:336)
at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperation Worker.execute(DefaultBuildOperationExecutor.java:328)
at org.gradle.internal.progress.DefaultBuildOperationExecutor.execute (DefaultBuildOperationExecutor.java:199)
at org.gradle.internal.progress.DefaultBuildOperationExecutor.run (DefaultBuildOperationExecutor.java:110)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeAction (ExecuteActionsTaskExecuter.java:113)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions (ExecuteActionsTaskExecuter.java:95)
... 30 more


* Get more help at https://help.gradle.org

BUILD FAILED in 8s
1 actionable task: 1 executed

我对缺少 maven 插件进行了修改,但就像您在我的 gradle.build 中看到的那样,我添加了插件。
那么该怎么办?

最佳答案

从你的踪迹

Caused by:     org.gradle.internal.metaobject.AbstractDynamicObject$CustomMessageMissingMethodException: Could not find method pom() for arguments [build_1nb7g16o7col6erw9g4aech65$_run_closure3$_closure5$_closure6@30d7b2ef] on task ':writeNewPom' of type org.gradle.api.DefaultTask.

Gradle 找不到任何合适的类型来委托(delegate) pom() 方法,那是因为你忘记了
apply plugin: 'maven'
在您的 项目 build.gradle .只需将以上行放入您的 项目 build.gradle一切都会好的。

关于maven - Gradle 创建 pom 失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53436539/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com