Skip to content

Configure POM File

Ta Van Dung edited this page Jun 18, 2016 · 1 revision

To deploy an application to smartfox we can use ant syntax, and we need configure somethings

Step 1. Configure maven assembly plugin

Firstly, we need add configuration of the plugin in pom file like this:

<plugin>
	<groupId>org.apache.maven.plugins</groupId>
	<artifactId>maven-assembly-plugin</artifactId>
	<version>2.2.1</version>
	<configuration>
		<descriptors>
			<descriptor>assembly.xml</descriptor>
		</descriptors>
	</configuration>
	<executions>
		<execution>
			<id>make-assembly</id>
			<phase>package</phase>
			<goals>
				<goal>single</goal>
			</goals>
		</execution>
	</executions>
</plugin>

secondly, you need add assembly.xml file to project directory, content of assembly.xml file may like this:

<?xml version="1.0" encoding="UTF-8"?>
<assembly>
	<id>bin</id>
	<includeBaseDirectory>false</includeBaseDirectory>
	<formats>
		<format>zip</format>
	</formats>

	<dependencySets>
		<dependencySet>
			<useProjectArtifact>true</useProjectArtifact>
			<outputDirectory>lib</outputDirectory>
			<excludes>
				<exclude>com.smartfoxserver:ezyfox-sfs2x</exclude>
				<exclude>com.smartfoxserver:ezyfox-v2</exclude>
				<exclude>log4j:log4j</exclude>
				<exclude>org.slf4j:slf4j-log4j12</exclude>
				<exclude>org.slf4j:slf4j-api</exclude>
			</excludes>
		</dependencySet>
	</dependencySets>

	<fileSets>
		<fileSet>
			<directory>src/main/resources</directory>
			<outputDirectory>/</outputDirectory>
			<includes>
				<include>your_file.zone.xml</include>
			</includes>
		</fileSet>
	</fileSets>
</assembly>

lets replace your_file with your zone.xml file

** Step 2. Configure maven antrun plugin** In pom file, you need add maven-antrun-plugin into tags:

<plugin>
	<artifactId>maven-antrun-plugin</artifactId>
	<executions>
		<execution>
		<phase>install</phase>
		<configuration>
			<tasks>
				<!-- Place any Ant task here. You can add anything you can add between 
				<target> and </target> in a build.xml. -->
				<delete dir="${deploy.path}/${project.name}" />
				<mkdir dir="${deploy.path}/${project.name}" />
				<mkdir dir="${deploy.path}/${project.name}/config" />
				<copy file="target/${project.name}-${project.version}-bin/your_file.zone.xml"
					todir="${deploy.path}/../zones" />
				<copy todir="${deploy.path}/${project.name}">
					<fileset dir="target/${project.name}-${project.version}-bin/lib">
						<exclude name="**/.svn" />
						<exclude name="**/.git" />
						<exclude name="**/*.class" />
					</fileset>
				</copy>
				<move file="${deploy.path}/${project.name}/${project.name}-${project.version}.jar"
					tofile="${deploy.path}/${project.name}/${project.name}-${project.version}-Extension.jar" />
				<copy todir="${deploy.path}/${project.name}/config">
					<fileset dir="target/${project.name}-${project.version}-bin/config">
						<exclude name="**/.svn" />
						<exclude name="**/.git" />
						<exclude name="**/*.class" />
					</fileset>
				</copy>
					<delete dir="${deploy.path}/${project.name}/classes" />
			</tasks>
		</configuration>
		<goals>
			<goal>run</goal>
		</goals>
		</execution>
	</executions>
</plugin>

${deploy.path} is the path to extensions folder of smartfox, example:

<deploy.path>/Applications/SmartFoxServer_2X/SFS2X/extensions</deploy.path>

Step 3. Deploy Application

After configuration done, to deploy an application you need run maven with goals:

clean assembly:directory install

Hello World

Clone this wiki locally