Forum Discussion

kmaster's avatar
kmaster
New Contributor
8 years ago

How do I set a project property through the maven command line?

I'm using the maven-soapui-extension-plugin and I'm trying to figure out a way to run all the tests in a project with a specific tag. I couldn't find a way to do this with the built in tagging feature (at least not through maven) so I've created a project property that I want to be able to set through the maven command line so I can have all the other tests cross check against this property to determine whether they should execute or not. 

 

I've setup the project property in the pom.xml like this: 

 

<projectProperties>
<projectProperty>testExecution="Smoke_Test"</projectProperty>
</projectProperties>

 

I also created a custom project property through the UI using the custom project properties and left the value blank so it could be replaced with this. However, even without adding a flag in the command line the pom.xml is not changing the property to Smoke_Test for me. I figure I've done something wrong but I can't seem to get it to work. I'm also not sure how to change the property through maven, from what I've read here on other posts the command has to use -Dsoapui.projectProperties. How do I actually use this? Is it just -Dsoapui.projectProperties.testExecution="tag_i_want"?

 

Thanks.

K M

  • I've made some progress. I've finally got the pom.xml file to pass in the parameter I wanted for the project property. I deleted the custom project property from the SoapUI and changed the xml to have this instead: 

     

    <projectProperties>
    <value>testExecution=${projectProperty}</value>
    </projectProperties>

     

    I then defined the projectProperty later in the pom right before </project> : 

     

    <properties>
    <projectProperty>Smoke_Test</projectProperty>
    </properties>
    </project>

     

    Trying now to change the value of project property. I've tried -Dproperties.projectProperty=new_val but no luck. 

  • Alright figured it out. I changed the project property value (the one right before </project>) to $(projectProperty) and now I can use -DprojectProperty="any_val" to pass in whatever I want. Hope this helps someone later 

     

    Edit: I should note that in order to actually use the property in the test cases, I had used a groovy script and the get data to define it in a script. However, since I deleted it after it won't show up anymore but you can still define the property like such: 

     

    def testExecution = context.expand( '${#Project#testExecution}' )    // the property name is 'testExecution' in my case

     

    I'm not sure whether or not it would work if I hadn't deleted the custom property. It may not have made a difference. 

  • kmaster's avatar
    kmaster
    New Contributor

    I've made some progress. I've finally got the pom.xml file to pass in the parameter I wanted for the project property. I deleted the custom project property from the SoapUI and changed the xml to have this instead: 

     

    <projectProperties>
    <value>testExecution=${projectProperty}</value>
    </projectProperties>

     

    I then defined the projectProperty later in the pom right before </project> : 

     

    <properties>
    <projectProperty>Smoke_Test</projectProperty>
    </properties>
    </project>

     

    Trying now to change the value of project property. I've tried -Dproperties.projectProperty=new_val but no luck. 

    • kmaster's avatar
      kmaster
      New Contributor

      Alright figured it out. I changed the project property value (the one right before </project>) to $(projectProperty) and now I can use -DprojectProperty="any_val" to pass in whatever I want. Hope this helps someone later 

       

      Edit: I should note that in order to actually use the property in the test cases, I had used a groovy script and the get data to define it in a script. However, since I deleted it after it won't show up anymore but you can still define the property like such: 

       

      def testExecution = context.expand( '${#Project#testExecution}' )    // the property name is 'testExecution' in my case

       

      I'm not sure whether or not it would work if I hadn't deleted the custom property. It may not have made a difference. 

      • TanyaYatskovska's avatar
        TanyaYatskovska
        SmartBear Alumni (Retired)

        Hi,

         

        Thanks for sharing your solution with us. It will help other community members for sure!