Maven在复制资源时跳过文件

时间:2017-08-10 15:40:14

标签: git maven svn jenkins

我们有一个存储在BitBucket中的项目。我们使用Jenkins从BitBucket中取出它,运行/xenv/Maven/X/3.2.5/bin/mvn -f $WORKSPACE/feeds/project -s $WORKSPACE/feeds/project/settings.xml -e clean package -Dmaven.test.skip=true然后执行:

export SVNMESSAGE=Commit msg

chmod 755 $WORKSPACE/feeds/project/packageRelease.sh 

$WORKSPACE/feeds/project/packageRelease.sh NO

packageRelase.sh负责最终将JAR和其他必需的东西推送到SVN,以便以ZIP的形式进行部署。它看起来像这样:

###########################
# Variables Declarations� 
###########################

export TMPDIR=TmpDir

# SVN location where we will check the newly created zip
export SVNPKGDIR=...

# SVN location where we will create a release tag directory
export SVNRELEASEDIRBASE=...

# Name of the release tag directory to create
export SVNRELEASEDIRNAME=Project_$(date +%Y%m%d)


# Credentials for SVN checkins
echo "SVN user" $SVNUSER

#########################
#Parse Arguments passed
#########################

BuildOnly="NO"

if [ "$1" == "YES" ]
  then
    BuildOnly="YES"
fi

echo "Shell parameter value= $1"
echo "BuildOnly value is set to : $BuildOnly"

#############################
### Check BuildOnly State ###
#############################

if [ ${BuildOnly} == "YES" ]
  then
    echo
    echo "Build Only variable is set to ${BuildOnly} ; exiting program."
    exit 0
 fi

set -x

##############################
# Create the package directory
##############################

rm -fR ${TMPDIR}
if [[ $? -ne 0 ]]
then
echo error removing existing ${TMPDIR} dir
exit 2
fi

mkdir ${TMPDIR}

if [[ $? -ne 0 ]]
then
echo error creating ${TMPDIR} dir
exit 3
fi

################################
# Checkout svn package directory
################################
svn checkout ${SVNPKGDIR}/send ${TMPDIR}/send --username ${SVNUSER} --password ${SVNPASSWORD}

if [[ $? -ne 0 ]]
then
echo cannot checkout from svn RLM package directory ${SVNPKGDIR}/send
exit 9
fi

###################################
# Copy new zip to package directory
###################################

echo "copy $WORKSPACE/feeds/apamafeeds/ApamaFeeds.zip ${TMPDIR}/send"
cp $WORKSPACE/feeds/apamafeeds/ApamaFeeds.zip ${TMPDIR}/send

ls ${TMPDIR}/send

if [[ $? -ne 0 ]]
then
echo cannot copy zip into RLM package directory ${TMPDIR}/send
exit 10
fi

###############################################
# Check into SVN package directory
###############################################
svn add ${TMPDIR}/send/* --force --username ${SVNUSER} --password ${SVNPASSWORD}
svn ci --username ${SVNUSER} --password ${SVNPASSWORD} -m "${SVNMESSAGE}" ${TMPDIR}/send

if [[ $? -ne 0 ]]
then
echo cannot checkin new zip to package directory. Working dir ${TMPDIR}/send
exit 11
fi

############################################################
# Create a new tag Release directory in svn for this release
############################################################
svn delete --username ${SVNUSER} --password ${SVNPASSWORD} -m "${SVNMESSAGE}" ${SVNRELEASEDIRBASE}/${SVNRELEASEDIRNAME}
svn cp --username ${SVNUSER} --password ${SVNPASSWORD} -m "${SVNMESSAGE}" ${SVNPKGDIR} ${SVNRELEASEDIRBASE}/${SVNRELEASEDIRNAME}


if [[ $? -ne 0 ]]
then
  echo cannot create tag release directory. From ${SVNPKGDIR} to ${SVNRELEASEDIRBASE}/${SVNRELEASEDIRNAME}
  exit 15
else
  echo Tag release directory created. From ${SVNPKGDIR} to ${SVNRELEASEDIRBASE}/${SVNRELEASEDIRNAME}
  exit 0
fi

ZIP应包含多个.sh文件,SQL文件,JAR,配置文件夹和数据文件夹。问题是它省略了所有的SQL文件。 SQL文件与src/main/scripts下的目录中的.sh文件一起存在,pom.xml中明确提到该目录:

<plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-resources-plugin</artifactId>
                <version>2.7</version>
                <executions>
                    <execution>
                        <id>copy-resources</id>
                        <!-- here the phase you need -->
                        <phase>package</phase>
                        <goals>
                            <goal>copy-resources</goal>
                        </goals>
                        <configuration>
                            <outputDirectory>${basedir}/target/config</outputDirectory>
                            <resources>
                                <resource>
                                    <directory>src/main/resources</directory>
                                    <filtering>true</filtering>
                                </resource>
                            </resources>
                        </configuration>
                    </execution>
                    <execution>
                        <id>copy-scripts</id>
                        <phase>package</phase>
                        <goals>
                            <goal>copy-resources</goal>
                        </goals>
                        <configuration>
                            <outputDirectory>${basedir}/target/scripts</outputDirectory>
                            <resources>
                                <resource>
                                    <directory>src/main/scripts</directory>
                                    <filtering>true</filtering>
                                </resource>
                            </resources>
                        </configuration>
                    </execution>
                    <execution>
                        <id>copy-data</id>
                        <phase>package</phase>
                        <goals>
                            <goal>copy-resources</goal>
                        </goals>
                        <configuration>
                            <outputDirectory>${basedir}/target/data</outputDirectory>
                            <resources>
                                <resource>
                                    <directory>src/main/data</directory>
                                    <filtering>true</filtering>
                                </resource>
                            </resources>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

为什么这些SQL文件(肯定在git的scripts目录中)没有通过SVN,但.sh文件是?

1 个答案:

答案 0 :(得分:0)

问题实际上并不在我上面列出的任何文件中。问题在于build.xml脚本。它有

    <copy todir="${package.dir}/">
        <fileset dir="target/scripts">
            <include name="*.sh" />
        </fileset>
    </copy>

就我的目的而言,<include>行应该看起来像<include name="*.*" />