Maven 在复制资源时跳过文件



我们有一个项目存储在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 文件与.sh文件一起存在于src/main/scripts下的目录中,并且在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的脚本目录中(没有转移到SVN,但.sh文件是?

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

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

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

相关内容

最新更新