반응형


젠킨스로 소스파일을 war로 배포를 하기 위해서,


사용하는 시스템의 build 속성을 변경해야 했다.



기존 시스템은

기존의 build는 ant를 사용하여 main project, frame project 빌드를 두번 했고


설정파일은 총 4개로 구성되어 있었다.


그리고 실제 서버에 배포해야할 경우 war가 아닌 파일단위로 copy를 해야했다.



main project와 frame project, 그리고 lib로 구성되어 있다.

main prjoect는 frame project와 lib를 포함하고

frame project는 lib를 포함한다.




변경 내용은 이렇다.


1. 빌드 속성 파일 삭제


2. 빌드 설정 파일은 한개로 취합


 war-build [war배포시 사용]

 1)  특정 폴더 초기화

 2)  frame project를 ant로 compile 

 3)  frame project build정보를 webapps폴더로 copy

 4)  main project를  ant로 compile 후 webapps폴더로 copy

 5)  main project build정보를 webapps폴더로 copy

 6)  war export


 all-build [default]

 1)  frame project를 ant로 compile 

 2)  frame project build정보를 webapps폴더로 copy

 3)  main project를  ant로 compile 후 webapps폴더로 copy

 4)  main project build정보를 webapps폴더로 copy

 



<?xml version="1.0"?>

<project name="ROOT" basedir="." default="all-build">

<property environment="env" />


<!-- 

         폴더 구조

  - D:\Project\deploy

 

최상위 폴더에서 git project import 

  - D:\Project\deploy\system

  - D:\Project\deploy\lib

  - D:\Project\deploy\main

 

웹서비스 tomcat webapps

  - D:\Project\deploy\webapps

war폴더

  - D:\Project\deploy\main\dist

-->

<!-- 빌드 환경변수 -->

<property name="webapp.name"   value="webapps" />

<property name="main.name"       value="../main" />

<property name="system.name"    value="../system" />

<property name="lib.dir"              value="../lib" />

<property name="src.dir"              value="src" />

<property name="web.dir"            value="web" />

<property name="test.src"            value="test" />

<property name="bin.dir"             value="bin" />

<property name="build.dir"           value="build" />

<property name="resources.dir"     value="resources" />

<property name="test.dir"             value="${build.dir}/test" />  

<property name="core.dir"            value="${system.name}/bin" />

<property name="dist.dir"             value="dist" /> 

<property name="deploy.dir"         value="../${webapp.name}" /> 

<!-- 빌드 경로 -->

<path id="main_classpath">

<fileset dir="${lib.dir}" includes="*.jar" />

<pathelement path="${main.name}/${build.dir}" />

<pathelement path="${core.dir}" />

</path>

<path id="system_classpath">

<fileset dir="${lib.dir}" includes="*.jar" />

<pathelement path="${system.name}/${build.dir}" />

</path>

<patternset id="war.files">

<include name="**/*.*" />

<exclude name="**/cargo*.jar" />

<exclude name="**/junit.jar" />

<exclude name="**/jwebunit*.jar" />

<exclude name="**/httpunit*.jar" />

<exclude name="**/*mock*.jar" />

<exclude name="**/servlet-api*.jar" />

<exclude name="**/strutstestcase*.jar" />

<exclude name="**/Tidy.jar" />

</patternset>


<target name="clean">

<delete dir="${main.name}/build" />

<delete dir="${main.name}/${dist.dir}" />

<delete dir="${deploy.dir}" />

<delete dir="${dist.dir}" />

<mkdir dir="${system.name}/build" />

<mkdir dir="${system.name}/${dist.dir}" />

<mkdir dir="${dist.dir}" />

</target>


<target name="all-build" depends="system_deploy, main_deploy"/>

<target name="war-build" depends="clean, system_deploy, main_deploy, war"/>

<!-- system compile -->

<target name="system_compile">

<mkdir dir="${system.name}/${build.dir}/classes" />

<javac destdir="${system.name}/${build.dir}/classes" 

     debug="true" 

   optimize="false" 

     deprecation="false" 

     failonerror="true" 

     encoding="UTF-8"

     classpathref="main_classpath"

     includeantruntime="true"

     verbose="true">

<src path="${system.name}/${src.dir}" />

</javac>

<copy todir="${system.name}/${build.dir}/classes">

<fileset dir="${system.name}/${src.dir}" includes="**/*.xml" />

<fileset dir="${system.name}/${src.dir}" includes="**/*.properties" />

<fileset dir="${system.name}/${resources.dir}" includes="**/*.xml" />

</copy>

<native2ascii encoding="utf-8" src="${system.name}/${resources.dir}" dest="${system.name}/${build.dir}/classes"         

                  includes="**/*.properties" />

</target>

<!-- system deploy -->

<target name="system_deploy" depends="system_compile">

<mkdir dir="${deploy.dir}/upload" />

<mkdir dir="${deploy.dir}/WEB-INF/temp" />

<copy todir="${deploy.dir}" preservelastmodified="true">

<fileset dir="${system.name}/${web.dir}">

<patternset refid="war.files" />

</fileset>

</copy>

<copy todir="${deploy.dir}/WEB-INF/classes" preservelastmodified="true">

<fileset dir="${system.name}/${build.dir}/classes">

<exclude name="/test" />

</fileset>

</copy>

<copy todir="${deploy.dir}/WEB-INF/lib" preservelastmodified="true">

<fileset dir="${lib.dir}">

<exclude name="**/junit.jar" />

<exclude name="**/servlet-api.jar" />

<exclude name="**/jsp-api.jar" />

<exclude name="**/mysql-connector-java-3.1.10-bin.jar" />

</fileset>

</copy>

</target>


<!-- main compile -->

<target name="main_compile">

<mkdir dir="${main.name}/${build.dir}/classes" />

<javac destdir="${main.name}/${build.dir}/classes" 

     debug="true" 

   optimize="false" 

     deprecation="false" 

     failonerror="true" 

     encoding="UTF-8"

     classpathref="main_classpath"

     includeantruntime="true"

     verbose="true">

<src path="${main.name}/${src.dir}" />

</javac>


<copy todir="${main.name}/${build.dir}/classes">

<fileset dir="${main.name}/${src.dir}" includes="**/*.xml" />

<fileset dir="${main.name}/${src.dir}" includes="**/*.properties" />

<fileset dir="${main.name}/${resources.dir}" includes="**/*.xml" />

<fileset dir="${main.name}/${resources.dir}" includes="**/*.key" />

</copy>

<native2ascii encoding="utf-8" src="${main.name}/${resources.dir}" dest="${main.name}/${build.dir}/classes" 

                  includes="**/*.properties" />

</target>


<!-- main deploy -->

<target name="main_deploy" depends="main_compile">

<copy todir="${deploy.dir}" preservelastmodified="true">

<fileset dir="${main.name}/${web.dir}">

<patternset refid="war.files" />

</fileset>

</copy>

<copy todir="${deploy.dir}/WEB-INF/classes" preservelastmodified="true">

<fileset dir="${main.name}/${build.dir}/classes">

<exclude name="/test" />

</fileset>

</copy>

<copy todir="${deploy.dir}/WEB-INF/lib" preservelastmodified="true">

<fileset dir="${lib.dir}">

<exclude name="**/jsp-api.jar" />

<exclude name="**/junit.jar" />

<exclude name="**/servlet-api.jar" />

<exclude name="**/mysql-connector-java-3.1.10-bin.jar" />

</fileset>

</copy>

</target>


<!-- war -->

        <target name="war">

           <jar   jarfile="${dist.dir}/${webapp.name}.war"

                   basedir="${deploy.dir}" includes="**"/>

        </target>

</project>



반응형

'개발환경' 카테고리의 다른 글

OpenJDK 설정 방법  (0) 2019.08.13
Spring + Active Directory 연동기  (0) 2019.08.13
3일차 - Git 저장소와 STS연동하기  (0) 2018.10.24
2일차 - Git 원격서버 설정하기  (0) 2018.10.24
1일차 - 윈도우에 Git 설치하기  (0) 2018.10.24
블로그 이미지

ingus

,