I need to create a .jar file using maven and testng.
My jar needs to read a testng.xml file and execute all the tests that are in there.
I tried maven-shade-plugin
and created a jar, but when i try to execute it i have the error:Could not find or load main class org.testng.TestNG
.
I tried to solve this problem finding a lot of solutions suggesting to create classpath but i fear this is not what i need. My jar file will be uploaded in a server and it will have to be executed from there, i can't create a classpath on that server, i need an independent file.
i can use some workarounds if thery are able to do this task (war file, exe file, etc...)
My tests are under the src/test/java
path.
My POM:
<repositories>
<repository>
<id>jcenter</id>
<name>bintray</name>
<url>https://jcenter.bintray.com</url>
</repository>
</repositories>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.2.1</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<transformers>
<transformer
implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<mainClass>org.testng.TestNG</mainClass>
</transformer>
</transformers>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…