Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/305.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在Intellij/idea的Cucumber/Java项目中创建可执行JAR_Java_Intellij Idea_Cucumber_Pom.xml_Executable Jar - Fatal编程技术网

在Intellij/idea的Cucumber/Java项目中创建可执行JAR

在Intellij/idea的Cucumber/Java项目中创建可执行JAR,java,intellij-idea,cucumber,pom.xml,executable-jar,Java,Intellij Idea,Cucumber,Pom.xml,Executable Jar,我需要为基于Java的Cucumber项目创建一个可执行JAR 这是我的文件夹结构: (main/java/skeleton中的Bellyclass也未使用)。所有功能步骤都在resources/skeleton文件夹中,所有步骤定义都在test/java/skeleton下 未显示的文件包括: -gitignore、build.xml、cucumber-java-skeleton.iml、pom.xml和README.md 我试着做了一些研究,但很难找到我应该在pom.xml文件中包含什么。

我需要为基于Java的Cucumber项目创建一个可执行JAR

这是我的文件夹结构:

(main/java/skeleton中的Bellyclass也未使用)。所有功能步骤都在resources/skeleton文件夹中,所有步骤定义都在test/java/skeleton下

未显示的文件包括: -gitignore、build.xml、cucumber-java-skeleton.iml、pom.xml和README.md

我试着做了一些研究,但很难找到我应该在pom.xml文件中包含什么。我目前已经使用Intellij运行了我的项目,但我需要将它交给能够在iOS/Mac上轻松运行项目的人


向您致意,V.

我看不到您的结构,但根据我的经验,您可以按照下面的结构生成jar

假设我们使用的是maven,我们可以拥有类似于src/main/java的结构

1:-创建主类并在其中使用以下代码

  • 字符串[]参数={--glue”,“path/to/glue/code”,“--glue”, “第二个/Path/to/glue code”、“--tags”、“@test”, 路径“--plugin”、“pretty”、“--plugin”、“json:/path/to/report”}; cumber.api.cli.Main.Main(参数)
在pom.xml中添加以下插件以创建具有依赖关系的可运行jar:-

<plugin>
                           <groupId>org.apache.maven.plugins</groupId>
                           <artifactId>maven-assembly-plugin</artifactId>
                           <executions>
                               <execution>
                                   <phase>package</phase>
                                   <goals>
                                       <goal>single</goal>
                                   </goals>
                                   <configuration>
                                       <archive>
                                           <manifest>
                                               <mainClass>
                                                   com.cucumber.CucumberMain
                                               </mainClass>
                                           </manifest>
                                       </archive>
                                       <descriptorRefs>
                                           <descriptorRef>jar-with-dependencies</descriptorRef>
                                       </descriptorRefs>
                                   </configuration>
                               </execution>
                           </executions>
                       </plugin>

org.apache.maven.plugins
maven汇编插件
包裹
单一的
黄瓜
带有依赖项的jar
在此之后,只需使用mvn clean构建代码,然后使用java-jar“jar的路径和名称”安装并运行jar。这会奏效的

注意:-
在CucumberMain内部,在执行任务后,它会调用system.exit(..),因此在使用shutdownhook之前,在调用它之后您不能在代码中执行任何操作。

Hi,您可以粘贴CucumberMain类的示例代码吗?我不知道该把它放在哪里。