0

I have two profiles like this in my pom.xml file- Updated POM file

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>com.SC</groupId>
  <artifactId>SmartConnectAPITesting</artifactId>
  <version>0.0.1-SNAPSHOT</version>

    <profiles>
   <profile>
      <id>selenium-tests</id>
      <build>
         <plugins>
            <plugin>
               <groupId>org.apache.maven.plugins</groupId>
               <artifactId>maven-surefire-plugin</artifactId>
               <version>2.22.0</version>
               <configuration>
                  <suiteXmlFiles>
                     <suiteXmlFile>src\test\resources\runner\testng.xml</suiteXmlFile>
                  </suiteXmlFiles>
               </configuration>
            </plugin>     
         </plugins>
      </build>
   </profile>

   <profile>  
  <id>excel-generator</id>  
  <build>
        <plugins>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>exec-maven-plugin</artifactId>
                <version>1.6.0</version> 
                  <configuration>
                    <mainClass>com.SC.APITesting.utilities.CreateExcelReport</mainClass>
                    <classpathScope>test</classpathScope>
                </configuration> 
            </plugin>
        </plugins>
    </build>
 </profile>  

</profiles>     
    <dependencies>
        <dependency>
            <groupId>org.testng</groupId>
            <artifactId>testng</artifactId>
            <version>6.14.3</version>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>io.rest-assured</groupId>
            <artifactId>rest-assured</artifactId>
            <version>4.1.2</version>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>org.json</groupId>
            <artifactId>json</artifactId>
            <version>20190722</version>
        </dependency>

<dependency>
    <groupId>org.apache.poi</groupId>
    <artifactId>poi</artifactId>
    <version>3.11</version>
</dependency>   
<dependency>
    <groupId>org.apache.poi</groupId>
    <artifactId>poi-ooxml</artifactId>
    <version>3.11</version>
</dependency>
<dependency>
    <groupId>org.apache.poi</groupId>
    <artifactId>poi-examples</artifactId>
    <version>3.10-FINAL</version>
</dependency>
<dependency>
    <groupId>org.apache.poi</groupId>
    <artifactId>poi-excelant</artifactId>
    <version>3.10-FINAL</version>
</dependency>
<dependency>
    <groupId>org.apache.poi</groupId>
    <artifactId>poi-ooxml-schemas</artifactId>
    <version>3.11</version>
</dependency>
<dependency>
    <groupId>org.apache.poi</groupId>
    <artifactId>poi-scratchpad</artifactId>
    <version>3.10-FINAL</version>
</dependency>
<dependency>
    <groupId>org.apache.xmlbeans</groupId>
    <artifactId>xmlbeans</artifactId>
    <version>2.6.0</version>
</dependency>
<dependency>
    <groupId>dom4j</groupId>
    <artifactId>dom4j</artifactId>
    <version>1.6.1</version>
</dependency>
        <dependency>
            <groupId>com.googlecode.json-simple</groupId>
            <artifactId>json-simple</artifactId>
            <version>1.1.1</version>
        </dependency>
        <dependency>
            <groupId>com.aventstack</groupId>
            <artifactId>extentreports</artifactId>
            <version>4.0.9</version>
        </dependency>
<dependency>
    <groupId>com.google.code.gson</groupId>
    <artifactId>gson</artifactId>
    <version>2.8.5</version>
</dependency>
<dependency>
    <groupId>commons-io</groupId>
    <artifactId>commons-io</artifactId>
    <version>2.4</version>
</dependency>     
<dependency>
    <groupId>com.google.guava</groupId>
    <artifactId>guava</artifactId>
    <version>23.0</version>
</dependency>   
    </dependencies>
</project> 

and i'm running these two commands-
1) install -Pselenium-tests
2) exec:java -Pexcel-generator
But now i want to run these two command from one maven command, i have tried this

install -Pselenium-tests exec:java -Pexcel-generator

First Profile executed successfully but second does not. Please help.

What i want that when selenium test profile will build successfully then for maven it will create a result file in surefire-reports folder so on basis of that result file i'm creating a excel report file which will execute after selenium test.

Upkar Singh
  • 147
  • 1
  • 9
  • did you try separating profile names with a comma as mentioned in below link https://stackoverflow.com/questions/16792499/how-do-i-invoke-two-different-profiles-in-one-maven-command/42766252 – Sachin Feb 07 '20 at 12:50
  • @Sachin i tried, only first one execute no status for second one. – Upkar Singh Feb 07 '20 at 13:15
  • Does this answer your question? [How do I invoke two different profiles in one maven command?](https://stackoverflow.com/questions/16792499/how-do-i-invoke-two-different-profiles-in-one-maven-command) – J Fabian Meier Feb 07 '20 at 18:04
  • @JFMeier I have already said this in above comments. It's not working for me i have different commands with different scope. – Upkar Singh Feb 11 '20 at 05:33
  • Could you please describe what exactly happens when you try it? Please also note that if you put them into one maven command, first _both_ profiles are activated and then the commands are run (no matter which order you write them). – J Fabian Meier Feb 11 '20 at 06:04
  • Furthermore, it is not clear to me why you have these profiles in the first place. Do you use the surefire plugin at another place in the same pom _again_? – J Fabian Meier Feb 11 '20 at 06:29
  • @JFMeier When i'm running the command then my test build only completed but my class file does not executed. Also, when i'm running this command `help:active-profiles -P selenium-tests,excel-generator` then i'm getting that both profile are active. – Upkar Singh Feb 11 '20 at 08:31
  • I have update my POM file, you can see i'm using `surefire plugin` only for selenium test. – Upkar Singh Feb 11 '20 at 08:32

0 Answers0