- Java 双重比较
- java - 比较器与 Apache BeanComparator
- Objective-C 完成 block 导致额外的方法调用?
- database - RESTful URI 是否应该公开数据库主键?
我尝试运行这个 gradle 任务:
task resources_cleaner_bl(type: JavaExec) {
classpath sourceSets.main.runtimeClasspath
systemProperties['cleanTarget'] = 'bl'
mainClassName = "com.w.routing.automation.runners.cleaner.ResourcesCleanerRunner"
}
使用这段 Java 代码:
package com.w.routing.automation.runners.cleaner;
public class ResourcesCleanerRunner {
private static IResourcesCleaner resourcesCleaner;
private static Injector injector;
public static void main(String args[]) {
init();
String cleanTarget = System.getProperty("cleanTarget");
switch (cleanTarget) {
但是我得到这个错误:
15:48:06.532 [ERROR] [org.gradle.BuildExceptionReporter] FAILURE: Build failed with an exception.
15:48:06.533 [ERROR] [org.gradle.BuildExceptionReporter]
15:48:06.549 [ERROR] [org.gradle.BuildExceptionReporter] * What went wrong:
15:48:06.549 [ERROR] [org.gradle.BuildExceptionReporter] Execution failed for task ':resources_cleaner_bl'.
15:48:06.549 [ERROR] [org.gradle.BuildExceptionReporter] > No main class specified
15:48:06.550 [ERROR] [org.gradle.BuildExceptionReporter]
15:48:06.550 [ERROR] [org.gradle.BuildExceptionReporter] * Exception is:
15:48:06.550 [ERROR] [org.gradle.BuildExceptionReporter] org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':resources_cleaner_bl'.
15:48:06.550 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:69)
15:48:06.550 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:46)
15:48:06.551 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.api.internal.tasks.execution.PostExecutionAnalysisTaskExecuter.execute(PostExecutionAnalysisTaskExecuter.java:35)
15:48:06.551 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter.execute(SkipUpToDateTaskExecuter.java:64)
15:48:06.551 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(ValidatingTaskExecuter.java:58)
15:48:06.552 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecuter.execute(SkipEmptySourceFilesTaskExecuter.java:52)
15:48:06.552 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:52)
15:48:06.553 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:53)
15:48:06.553 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter.execute(ExecuteAtMostOnceTaskExecuter.java:43)
15:48:06.553 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:203)
15:48:06.577 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:185)
15:48:06.577 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.execution.taskgraph.AbstractTaskPlanExecutor$TaskExecutorWorker.processTask(AbstractTaskPlanExecutor.java:66)
15:48:06.578 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.execution.taskgraph.AbstractTaskPlanExecutor$TaskExecutorWorker.run(AbstractTaskPlanExecutor.java:50)
15:48:06.578 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor.process(DefaultTaskPlanExecutor.java:25)
15:48:06.578 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter.execute(DefaultTaskGraphExecuter.java:110)
15:48:06.578 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.execution.SelectedTaskExecutionAction.execute(SelectedTaskExecutionAction.java:37)
15:48:06.578 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:37)
15:48:06.578 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.execution.DefaultBuildExecuter.access$000(DefaultBuildExecuter.java:23)
15:48:06.578 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.execution.DefaultBuildExecuter$1.proceed(DefaultBuildExecuter.java:43)
15:48:06.578 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.execution.DryRunBuildExecutionAction.execute(DryRunBuildExecutionAction.java:32)
15:48:06.579 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:37)
15:48:06.579 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:30)
15:48:06.579 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.initialization.DefaultGradleLauncher$4.run(DefaultGradleLauncher.java:154)
15:48:06.579 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.internal.Factories$1.create(Factories.java:22)
15:48:06.579 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:90)
15:48:06.579 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:52)
15:48:06.579 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.initialization.DefaultGradleLauncher.doBuildStages(DefaultGradleLauncher.java:151)
15:48:06.580 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.initialization.DefaultGradleLauncher.access$200(DefaultGradleLauncher.java:32)
15:48:06.580 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.initialization.DefaultGradleLauncher$1.create(DefaultGradleLauncher.java:99)
15:48:06.580 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.initialization.DefaultGradleLauncher$1.create(DefaultGradleLauncher.java:93)
15:48:06.580 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:90)
15:48:06.580 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:62)
15:48:06.580 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.initialization.DefaultGradleLauncher.doBuild(DefaultGradleLauncher.java:93)
15:48:06.580 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.initialization.DefaultGradleLauncher.run(DefaultGradleLauncher.java:82)
15:48:06.580 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.launcher.exec.InProcessBuildActionExecuter$DefaultBuildController.run(InProcessBuildActionExecuter.java:94)
15:48:06.581 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.tooling.internal.provider.ExecuteBuildActionRunner.run(ExecuteBuildActionRunner.java:28)
15:48:06.581 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.launcher.exec.ChainingBuildActionRunner.run(ChainingBuildActionRunner.java:35)
15:48:06.581 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:43)
15:48:06.581 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:28)
15:48:06.581 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.launcher.exec.ContinuousBuildActionExecuter.execute(ContinuousBuildActionExecuter.java:75)
15:48:06.581 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.launcher.exec.ContinuousBuildActionExecuter.execute(ContinuousBuildActionExecuter.java:45)
15:48:06.581 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.launcher.exec.DaemonUsageSuggestingBuildActionExecuter.execute(DaemonUsageSuggestingBuildActionExecuter.java:51)
15:48:06.582 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.launcher.exec.DaemonUsageSuggestingBuildActionExecuter.execute(DaemonUsageSuggestingBuildActionExecuter.java:28)
15:48:06.582 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.launcher.cli.RunBuildAction.run(RunBuildAction.java:43)
15:48:06.582 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.internal.Actions$RunnableActionAdapter.execute(Actions.java:170)
15:48:06.584 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.wrapper.WrapperExecutor.execute(WrapperExecutor.java:127)
15:48:06.584 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.wrapper.GradleWrapperMain.main(GradleWrapperMain.java:56)
15:48:06.584 [ERROR] [org.gradle.BuildExceptionReporter] Caused by: java.lang.IllegalStateException: No main class specified
15:48:06.584 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.process.internal.JavaExecHandleBuilder.build(JavaExecHandleBuilder.java:212)
15:48:06.585 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.process.internal.DefaultJavaExecAction.execute(DefaultJavaExecAction.java:28)
15:48:06.585 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.api.tasks.JavaExec.exec(JavaExec.java:74)
15:48:06.585 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:75)
我的主类有正确的命名空间,我错过了什么?
最佳答案
有几种方法可以做到,请看下面的代码。
//To run the class name from command line using gradle run
mainClassName = 'com.sam.home.HelloWorld'
//To create a runnable jar in GradleJavaProject\build\libs then java -jar GradleJavaProject.jar
jar {
manifest {
attributes 'Main-Class': 'com.sam.home.HelloWorld'
}
}
//Alternatively you can run it as a task too gradle -q runWithJavaExec
task runWithJavaExec(type: JavaExec) {
group = "Execution"
description = "Run the main class with JavaExecTask"
classpath = sourceSets.main.runtimeClasspath
main = 'com.sam.home.HelloWorld'
}
关于java - gradle "No main class specified"即使主类存在,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43611525/
在 spring-security项目,在 build.gradle文件,以下插件可用: apply plugin: 'io.spring.nohttp' apply plugin: 'locks'
我正在尝试使用gradle任务作为“与操作系统无关的shell脚本”。我在编写构建文件的逻辑时没有问题,但是我希望能够从任何文件夹中运行它。 我的第一次尝试是在路径上放置一个带有build.gradl
我在同一目录下有三个具有不同名称的build.gradle dev.build.gradle uat.build.gradle prd.build.gradle 我有4期 “gradle build”
乡亲们 有谁知道如何使用gradle与自定义的build.gradle和settings.gradle一起运行-即两者在一起? 我认为我可以有一个自定义的build.gradle文件(-b标志)-但这
Gradle 配置有两个属性,称为 dependencies和 incoming .根据我的理解,我们可以通过 Gradle 依赖 block 向配置添加依赖,如下所示: dependencies {
我正在测试将我的工件推送到 Nexus Maven 存储库。我正在使用 gradle这样做。 gradle upload有什么区别和 gradle publish ? 最佳答案 目前gradle提供了
这里有一个类似的问题:Gradle properties not being read from ~/.gradle/gradle.properties,但它不能解决我的问题。 在我看来,gradle
如何检索 Gradle 本身的版本 以编程方式从 Gradle 插件中? 最佳答案 刚刚发现可以使用任何一种方法来解决它 getProject().getGradle().getGradleVersi
2 个 gradle 项目,A 和 B,其中 A 定义了对 B 的编译依赖。为 maven 和 gradle 项目启用了 JAR 的重新映射。我试过启用和禁用自定义工具模型。我在 init.d 目录下
如何从 gradle 运行另一个 gradle 脚本。我有多个 gradle 脚本可以在 /test 下运行测试目录。 /build.gradle使用要运行的测试 gradle 文件的名称调用。例如
我已经看到了多模块项目的不同布局,其中有些项目只有一个 build.gradle。而其他项目将有 build.gradle在根和 build.gradle在每个子项目中。我想知道有什么区别以及首选哪种
我对 Gradle 生命周期有一个基本的询问。我的项目是一个多模块项目。 我注意到以下命令: ./gradlew clean bignibou-server:run 不等于运行以下两个命令按顺序运行:
我有一个项目,其中包含一个子项目,如下所示: Root Project |----gradle.build |----SubProject |----|----gradle.build 这里的子项目包
我有 gradle 项目,我想向不使用 gradle 或 maven 等构建工具的项目添加依赖项。 目录结构如下: commonfolder\ gradleProject\ b
我想创建一个类来帮助我加载不同类型的属性(local.properties,gradle.properties,$GRADLE_HOME/gradle.properties,环境变量,系统属性和自定义
我有一个多模块项目,其目录结构如下: proj |-modA |-modB |-modMain \-modSysTest 依赖项是: modB -> modA modMain -> modB modM
我正在尝试创建一个可以在 --offline 模式下工作的 gradle 项目的副本。除了一个步骤,我已经自动化了所有步骤。我无法自动将插件 jar 下载到 gradle 缓存中。 我的离线分发通过指
基本上我想这样做: Use Gradle function from other gradle file 也就是说,从另一个 gradle 脚本中调用一个函数。问题是我的 build.gradle 在
我有一个简单的 gradle 插件,我想试用一下,但我不确定如何“请求”gradle 运行我的测试 这是我要修改的 block (在我的 gradle 构建文件的顶部) buildscript {
在 Android Studio 中创建项目时,我收到以下错误消息。 Failed to import new Gradle project: Could not install Gradle dis
我是一名优秀的程序员,十分优秀!