簡體   English   中英

在Intellij / idea的Cucumber / Java項目中創建可執行JAR

[英]Create executable JAR in Cucumber/Java project in Intellij/idea

我需要為基於Java的Cucumber項目創建一個可執行JAR。

這是我的文件夾結構:

https://imagizer.imageshack.us/v2/229x373q90/674/EiXWux.png

(也不使用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:-使用以下代碼創建主類和內部

  • String [] arguments = {“ --glue”,“ path / to / glue / code”,“-glue”,“ Second / Path / to / glue代碼”,“ --tags”,“ @ test”, path,“-plugin”,“ pretty”,“-plugin”,“ json:/ path / to / report”}; cumul.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>

之后,只需使用mvn clean install構建代碼,然后使用java -jar“ jar的路徑和名稱”運行jar。 會的。

注意:-在黃瓜主管道內部,執行任務后,它將調用system.exit(..),因此在調用它之后,除非使用shutdownhook,否則您將無法在代碼中進行任何操作。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM