window bat 版本发布

1:用maven 构建项目jar和copy lib包
2:用bat copy部分其他资源文件

<build>
        <plugins>

            <plugin>
                <groupId>org.apache.maven.pluginsgroupId>
                <artifactId>maven-jar-pluginartifactId>
                <version>2.6version>
                <configuration>
                    <archive>
                        <manifest>
                            <addClasspath>trueaddClasspath>
                            <classpathPrefix>lib/classpathPrefix>
                            <mainClass>com.xxxxmainClass>
                        manifest>
                    archive>
                configuration>
            plugin>
            <plugin>
                <groupId>org.apache.maven.pluginsgroupId>
                <artifactId>maven-dependency-pluginartifactId>
                <version>2.10version>
                <executions>
                    <execution>
                        <id>copy-dependenciesid>
                        <phase>packagephase>
                        <goals>
                            <goal>copy-dependenciesgoal>
                        goals>
                        <configuration>
                            <outputDirectory>${project.build.directory}/liboutputDirectory>
                        configuration>
                    execution>
                executions>
            plugin>

        plugins>
    build>

直接在命令行mvn package 可得到lib下的jar 和 可执行jar

然后就是撸bat文件了

call mvn clean package
set curPath=%cd%
cd ..
cd ..
cd ..
set BASE_PATH=%cd%\Client\Branch
set QA_SVN_PATH=%BASE_PATH%\qaserver\
echo %QA_SVN_PATH%
echo "拷贝game-server.jar"
for /r %curPath%\target %%a in (*game-server*.jar) do (copy /Y %%a %QA_SVN_PATH%)
echo "拷贝lib下的所有jar"
copy %curPath%\target\lib %QA_SVN_PATH%\lib /Y
echo "拷贝策划数据data"
xcopy /r /h /k /e /i /c /Y %BASE_PATH%\data %QA_SVN_PATH%\data 
cd %QA_SVN_PATH%
svn update
svn commit -m xxxxx
@pause

这样可以很方便给策划 或者测试自己单独部署一套服务器版本了。
然后在运行jar的bat的命令里 可以调用Java 代码 修改部分配置参数

set JAR_NAME=game-server.jar
for /r ../ %%a in (game-server.jar) do (set JAR_NAME=%%a)
java ReplaceStr xx
echo %JAR_NAME%
java -jar %JAR_NAME%
@pause

你可能感兴趣的:(java)