I have some schemas in my project . When I am running mvn deploy command. It is copying my schema to a centralized server.
For unit testing of schema changes ,we have to upload it to the server first and then we can use it in our project. After setting up the schema locally as well we have to run mvn deploy command to upload it to the local server, because there was no configuration for install phase in existing pom.
For that purpose I have written the similar copy execution in install phase. Below is the snapshot of plugin configuration :
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<executions>
<execution>
<id>xsd-publish</id>
<phase>deploy</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>${xsd.publish.location}\event</outputDirectory>
<resources>
<resource>
<directory>src/main/resources</directory>
<includes>
<include>**/*.xsd</include>
</includes>
</resource>
</resources>
<overwrite>true</overwrite>
</configuration>
</execution>
<execution>
<id>copy-xsd-local</id>
<phase>install</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>\\localhost\xsd\event</outputDirectory>
<resources>
<resource>
<directory>src/main/resources</directory>
<includes>
<include>**/*.xsd</include>
</includes>
</resource>
</resources>
<overwrite>true</overwrite>
</configuration>
</execution>
</executions>
</plugin>
When I am running this configuration at my local machine , it is running fine and as expected. When I am trying to build the project using TeamCity , it got failed , as team city has it's own servr , which do not have a folder named xsd. And ideally I do not even want to call this plugin execution when I am running it from Team city.
Any suggestion?
You can use different profiles activated by environment entries.
Define an XSDTeamCity env entry in the build server. Then use two profiles, each with the corresponding execution. The activation of the profiles can look like this:
One more thing: you can easily validate your XML against an XSD which is in a jar file for example. Why do you need to copy this XSD to anywhere at all?