Changing the maven plugin deployment path

I want my integration test to hit the tomcat load at http: // localhost: 8080 / messaging , but the load (load-maven2-plugin: 1.0.5) prefers to deploy my messaging project as / messaging -0.0.7- SNAPSHOT, as shown in the tomcat admin console and in the target \ tomcat6x \ webapps directory.

So, I tried to add these lines to the load configuration, assuming that it will take the artifact by default:

<deployer> <deployables> <deployable> <properties> <context>/messaging</context> </properties> </deployable> </deployables> </deployer> 

but this is not so. It doesnโ€™t even try, since I do not see the messaging or messages-0.0.7-SNAPSHOT in the target \ tomcat6x \ webapps directory.

The same thing happens when I configure it like this:

 <configuration> <type>standalone</type> <wait>false</wait> <properties> <cargo.servlet.port>8080</cargo.servlet.port> <cargo.logging>high</cargo.logging> </properties> <deployer> <deployables> <deployable> <groupId>com.company.platform</groupId> <artifactId>messaging</artifactId> <type>war</type> <properties> <context>/messaging</context> </properties> </deployable> </deployables> </deployer> </configuration> 

Here is the complete plugin configuration:

  <plugin> <groupId>org.codehaus.cargo</groupId> <artifactId>cargo-maven2-plugin</artifactId> <executions> <execution> <id>start</id> <phase>pre-integration-test</phase> <goals> <goal>start</goal> </goals> </execution> <execution> <id>stop</id> <phase>post-integration-test</phase> <goals> <goal>stop</goal> </goals> </execution> </executions> <configuration> <type>standalone</type> <wait>false</wait> <properties> <cargo.servlet.port>8080</cargo.servlet.port> <cargo.logging>high</cargo.logging> </properties> <deployer> <deployables> <deployable> <properties> <context>/messaging</context> </properties> </deployable> </deployables> </deployer> </configuration> 

My integration test is as follows:

 import junit.framework.TestCase; import java.io.InputStream; import java.net.URL; import java.net.HttpURLConnection; import java.sql.Time; public class WebappTest extends TestCase { public void testCallIndexPage() throws Exception { URL url = new URL("http://localhost:8080/messaging/"); HttpURLConnection connection = (HttpURLConnection) url.openConnection(); connection.connect(); assertEquals(200, connection.getResponseCode()); InputStream is = connection.getInputStream(); System.out.println(connection.getContent().getClass()); } } 

What is the best way to continue? Knowing that it will be successfully implemented as hxxp: // localhost: 8080 / messaging-0.0.7-SNAPSHOT, I could change the test, but what would be a quick way to pull out the artifact version?

Ideally, I would like the load to unfold it correctly, but it is not clear how.

+4
source share
3 answers

From the link to the plugin to download ,

 About WAR contexts Many containers have their specific files for redefining context roots (Tomcat has context.xml, JBoss has jboss-web.xml, etc.). If your WAR has such a file, the server will most probably use the context root defined in that file instead of the one you specify using the CARGO deployer. 

Could you face this problem?

Also, I think the context name should not have a leading / .

+2
source

How to set the finalName property?

If you installed <finalName>messaging</finalName> in your POM, this should do the trick.

+1
source
Tag

Deployables must not be inside the Deployer tag:

  <deployables> <deployable> <properties> <context>/messaging</context> </properties> </deployable> </deployables> 
+1
source

Source: https://habr.com/ru/post/1336064/


All Articles