Skip to content
This repository has been archived by the owner on Jun 9, 2024. It is now read-only.

Commit

Permalink
#2 Implement the force-source-convert task properly
Browse files Browse the repository at this point in the history
Try and simplify the build system as well.
  • Loading branch information
mcartoixa committed Jan 31, 2020
1 parent f665c83 commit 98acf1a
Show file tree
Hide file tree
Showing 13 changed files with 196 additions and 98 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,5 @@ tmp/

.DS_Store
.env
/nbproject/private/
/nbproject/private/
/bin/
22 changes: 4 additions & 18 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,26 +11,12 @@ cache:

env:
global:
- _ANT_VERSION=1.9.14
- _CLOC_VERSION=1.82
- _PMD_VERSION=6.17.0
- _IVY_VERSION=2.5.0-rc1
- PACKAGE_VERSION=0.5.$TRAVIS_BUILD_NUMBER
- _IVY_VERSION=2.5.0
- PACKAGE_VERSION=0.6.$TRAVIS_BUILD_NUMBER

install:
- if [ ! -d .tmp ]; then mkdir .tmp; fi
# SFDX CLI
- cd .tmp && npm install sfdx-cli --loglevel info --cache npm-cache && cd ..
- export SFDX_HOME=$TRAVIS_BUILD_DIR/.tmp/node_modules/.bin
- export PATH=$SFDX_HOME:$PATH
# Apache Ant
- if [ ! -f .tmp/apache-ant-$_ANT_VERSION/bin/ant ]; then wget -nv -O .tmp/apache-ant-$_ANT_VERSION-bin.tar.gz http://mirrors.ircam.fr/pub/apache//ant/binaries/apache-ant-$_ANT_VERSION-bin.tar.gz && tar -xzvf .tmp/apache-ant-$_ANT_VERSION-bin.tar.gz -C .tmp; fi
- export ANT_HOME=$TRAVIS_BUILD_DIR/.tmp/apache-ant-$_ANT_VERSION
# PMD
- if [ ! -f .tmp/pmd-bin-$_PMD_VERSION/bin/run.sh ]; then wget -nv -O .tmp/pmd-bin-$_PMD_VERSION.zip https://github.com/pmd/pmd/releases/download/pmd_releases%2F$_PMD_VERSION/pmd-bin-$_PMD_VERSION.zip && unzip .tmp/pmd-bin-$_PMD_VERSION.zip -d .tmp; fi
- export PMD_HOME=$TRAVIS_BUILD_DIR/.tmp/pmd-bin-$_PMD_VERSION
# CLOC
- if [ ! -f .tmp/cloc.pl ]; then wget -nv -O .tmp/cloc.pl https://github.com/AlDanial/cloc/releases/download/$_CLOC_VERSION/cloc-$_CLOC_VERSION.pl; fi
- . build/.bashrc

# Apache Ivy
- if [ ! -d ivy ]; then mkdir ivy; fi
- if [ ! -f ivy/ivy.jar ]; then wget -nv -O ivy/ivy.jar https://repo1.maven.org/maven2/org/apache/ivy/ivy/$_IVY_VERSION/ivy-$_IVY_VERSION.jar; fi
Expand Down
4 changes: 2 additions & 2 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,12 @@
"**/tmp/*/**": true
},
"terminal.integrated.shell.linux": "bash",
"terminal.integrated.shell.osx": "bash",
"terminal.integrated.shell.windows": "cmd.exe",
"terminal.integrated.shellArgs.linux": [
"--rcfile",
"build/.bashrc",
"-i"
],
"terminal.integrated.shell.osx": "bash",
"terminal.integrated.shellArgs.osx": [
"--rcfile",
"build/.bashrc",
Expand All @@ -31,6 +30,7 @@
"/bin/zsh",
"-l"
],
"terminal.integrated.shell.windows": "cmd.exe",
"terminal.integrated.shellArgs.windows": [
"/V:ON",
"/K",
Expand Down
59 changes: 12 additions & 47 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
@@ -1,51 +1,17 @@
pool:
# cf. https://github.com/Microsoft/azure-pipelines-image-generation/blob/master/images/win/Vs2017-Server2016-Readme.md
vmImage: 'vs2017-win2016'
# cf. https://github.com/actions/virtual-environments/blob/master/images/win/Windows2019-Readme.md
vmImage: 'windows-2019'

variables:
_ANT_VERSION: 1.9.14
_CLOC_VERSION: 1.82
_PMD_VERSION: 6.17.0
IVY_VERSION: 2.5.0-rc1
ANT_HOME:
IVY_VERSION: 2.5.0

steps:
- script: |
ECHO ##vso[task.setvariable variable=SFDX_HOME]%AGENT_BUILDDIRECTORY%\.tmp\node_modules\.bin
ECHO ##vso[task.prependpath]%AGENT_BUILDDIRECTORY%\.tmp\node_modules\.bin
IF NOT EXIST .tmp MKDIR .tmp
PUSHD .tmp
npm install sfdx-cli --loglevel info --cache npm-cache
POPD
displayName: Install SFDX CLI
- script: |
ECHO ##vso[task.setvariable variable=ANT_HOME]%AGENT_BUILDDIRECTORY%\.tmp\apache-ant-%_ANT_VERSION%
ECHO ##vso[task.prependpath]%AGENT_BUILDDIRECTORY%\.tmp\apache-ant-%_ANT_VERSION%\bin
IF NOT EXIST "%CD%\.tmp\apache-ant-%_ANT_VERSION%\bin\ant.bat" (
IF NOT EXIST .tmp MKDIR .tmp
powershell.exe -NoLogo -NonInteractive -ExecutionPolicy ByPass -Command "& { [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; Invoke-WebRequest http://mirrors.ircam.fr/pub/apache//ant/binaries/apache-ant-$Env:_ANT_VERSION-bin.zip -OutFile .tmp\apache-ant-$Env:_ANT_VERSION-bin.zip; }"
IF ERRORLEVEL 1 GOTO ERROR_ANT
powershell.exe -NoLogo -NonInteractive -ExecutionPolicy ByPass -Command "Expand-Archive -Path .tmp\apache-ant-$Env:_ANT_VERSION-bin.zip -DestinationPath .tmp -Force"
IF ERRORLEVEL 1 GOTO ERROR_ANT
)
displayName: Install Ant $(_ANT_VERSION)
- script: |
ECHO ##vso[task.setvariable variable=PMD_HOME]%AGENT_BUILDDIRECTORY%\.tmp\pmd-bin-%_PMD_VERSION%
IF NOT EXIST "%CD%\.tmp\pmd-bin-%_PMD_VERSION%\bin\pmd.bat" (
IF NOT EXIST .tmp MKDIR .tmp
powershell.exe -NoLogo -NonInteractive -ExecutionPolicy ByPass -Command "& { [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; Invoke-WebRequest https://github.com/pmd/pmd/releases/download/pmd_releases%%2F$Env:_PMD_VERSION/pmd-bin-$Env:_PMD_VERSION.zip -OutFile .tmp\pmd-bin-$Env:_PMD_VERSION.zip; }"
IF ERRORLEVEL 1 GOTO ERROR_PMD
powershell.exe -NoLogo -NonInteractive -ExecutionPolicy ByPass -Command "Expand-Archive -Path .tmp\pmd-bin-$Env:_PMD_VERSION.zip -DestinationPath .tmp -Force"
IF ERRORLEVEL 1 GOTO ERROR_PMD
)
displayName: Install PMD $(_PMD_VERSION)
- script: |
IF NOT EXIST "%CD%\.tmp\cloc.exe" (
IF NOT EXIST .tmp MKDIR .tmp
powershell.exe -NoLogo -NonInteractive -ExecutionPolicy ByPass -Command "& { [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; Invoke-WebRequest https://github.com/AlDanial/cloc/releases/download/$Env:_CLOC_VERSION/cloc-$Env:_CLOC_VERSION.exe -OutFile .tmp\cloc.exe; }"
IF ERRORLEVEL 1 GOTO ERROR_CLOC
)
displayName: Install CLOC $(_CLOC_VERSION)
- task: BatchScript@1
inputs:
filename: build\SetEnv.bat
arguments: /useCurrentJavaHome
modifyEnvironment: True
workingFolder: $(Build.Repository.LocalPath)
- script: |
IF NOT EXIST ivy MKDIR ivy
PUSHD ivy
Expand All @@ -60,10 +26,9 @@ steps:
- task: Ant@1
inputs:
buildFile: 'build.xml'
options: -noclasspath -nouserlib -noinput -lib 'ivy/lib/test' -Dverbosity=verbose
options: -noclasspath -nouserlib -noinput -lib ivy/lib/test -Dverbosity=verbose
targets: release
publishJUnitResults: true
testResultsFiles: '$(Agent.BuildDirectory)\tmp\obj\test\results\**\TEST-*.xml'
antHomeDirectory: '$(Agent.BuildDirectory)\.tmp\apache-ant-$(_ANT_VERSION)'
testResultsFiles: '$(Build.Repository.LocalPath)\tmp\obj\test\results\**\TEST-*.xml'
antHomeDirectory: '$(ANT_HOME)'
jdkVersionOption: 1.8
- script: ECHO ##vso[build.uploadlog]$(Agent.BuildDirectory)\build.log
2 changes: 1 addition & 1 deletion build.bat
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ VERIFY OTHER 2>nul
SETLOCAL ENABLEEXTENSIONS ENABLEDELAYEDEXPANSION
IF ERRORLEVEL 1 GOTO ERROR_EXT

SET IVY_VERSION=2.5.0-rc1
SET IVY_VERSION=2.5.0

SET NO_PAUSE=0
SET PROJECT=build.xml
Expand Down
2 changes: 1 addition & 1 deletion build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

source build/.bashrc

_IVY_VERSION=2.5.0-rc1
_IVY_VERSION=2.5.0

_PROJECT=build.xml
_TARGET=build
Expand Down
43 changes: 31 additions & 12 deletions build/.bashrc
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,36 +1,55 @@
#!/bin/bash

_ANT_VERSION=1.9.14
_CLOC_VERSION=1.82
_PMD_VERSION=6.6.0

if [ -f ~/.bashrc ]; then
. ~/.bashrc;
fi

if [ -f ./build/versions.env ]; then
# xargs does not support the -d option on BSD (MacOS X)
export $(grep -a -v -e '^#' -e '^[[:space:]]*$' build/versions.env | tr '\n' '\0' | xargs -0 )
grep -a -v -e '^#' -e '^[[:space:]]*$' build/versions.env | tr '\n' '\0' | xargs -0 printf "\$%s\n"
echo
fi

echo \$JAVA_HOME=$JAVA_HOME

if [ -f ./.env ]; then
# xargs does not support the -d option on BSD (MacOS X)
export $(grep -a -v -e '^#' -e '^[[:space:]]*$' .env | tr '\n' '\0' | xargs -0)
grep -a -v -e '^#' -e '^[[:space:]]*$' .env | tr '\n' '\0' | xargs -0 printf "\$%s\n"
echo
fi

echo \$JAVA_HOME=$JAVA_HOME

if [ ! -d .tmp ]; then mkdir .tmp; fi

case "$-" in
*i*) _wget_interactive_options="--show-progress" ;;
*) _wget_interactive_options= ;;
esac



#Node.js
export NODEJS_HOME=$(pwd)/.tmp/node-v$_NODEJS_VERSION-linux-x64
if [ ! -f $NODEJS_HOME/npm ]; then
wget -nv $_wget_interactive_options -O .tmp/node-v$_NODEJS_VERSION-linux-x64.tar.gz https://nodejs.org/dist/v$_NODEJS_VERSION/node-v$_NODEJS_VERSION-linux-x64.tar.gz
tar -xzvf .tmp/node-v$_NODEJS_VERSION-linux-x64.tar.gz -C .tmp
fi
echo \$NODEJS_HOME=$NODEJS_HOME

#SFDX CLI
export SFDX_HOME=$TRAVIS_BUILD_DIR/.tmp/node_modules/.bin
if [ ! -f .tmp/node_modules/.bin/sfdx ]; then
export SFDX_HOME=$(pwd)/.tmp/node_modules/.bin
if [ ! -f $SFDX_HOME/sfdx ]; then
cd .tmp
npm install sfdx-cli --loglevel info --cache npm-cache
$NODEJS_HOME/npm install sfdx-cli --cache npm-cache
cd ..
fi
echo \$SFDX_HOME=$SFDX_HOME

#Ant
export ANT_HOME=$(pwd)/.tmp/apache-ant-$_ANT_VERSION
if [ ! -f $_ANT_HOME/bin/ant ]; then
wget -nv --show-progress -O .tmp/apache-ant-$_ANT_VERSION-bin.tar.gz http://mirrors.ircam.fr/pub/apache//ant/binaries/apache-ant-$_ANT_VERSION-bin.tar.gz
wget -nv $_wget_interactive_options -O .tmp/apache-ant-$_ANT_VERSION-bin.tar.gz http://mirrors.ircam.fr/pub/apache//ant/binaries/apache-ant-$_ANT_VERSION-bin.tar.gz
tar -xzvf .tmp/apache-ant-$_ANT_VERSION-bin.tar.gz -C .tmp
fi
echo \$ANT_HOME=$ANT_HOME
Expand All @@ -39,14 +58,14 @@ echo \$ANT_HOME=$ANT_HOME
# Best would to be able to manage PMD with Apache Ivy but this looks like an impossible task...
export PMD_HOME=$(pwd)/.tmp/pmd-bin-$_PMD_VERSION
if [ ! -f $PMD_HOME/bin/run.sh ]; then
wget -nv --show-progress -O .tmp/pmd-bin-$_PMD_VERSION.zip https://github.com/pmd/pmd/releases/download/pmd_releases%2F$_PMD_VERSION/pmd-bin-$_PMD_VERSION.zip
wget -nv $_wget_interactive_options -O .tmp/pmd-bin-$_PMD_VERSION.zip https://github.com/pmd/pmd/releases/download/pmd_releases%2F$_PMD_VERSION/pmd-bin-$_PMD_VERSION.zip
unzip .tmp/pmd-bin-$_PMD_VERSION.zip -d .tmp
fi
echo \$PMD_HOME=$PMD_HOME
echo

if [ ! -f $(pwd)/.tmp/cloc.pl ]; then
wget -nv --show-progress -O .tmp/cloc.pl https://github.com/AlDanial/cloc/releases/download/$_CLOC_VERSION/cloc-$_CLOC_VERSION.pl
wget -nv $_wget_interactive_options -O .tmp/cloc.pl https://github.com/AlDanial/cloc/releases/download/$_CLOC_VERSION/cloc-$_CLOC_VERSION.pl
fi

export PATH=$SFDX_HOME:$ANT_HOME/bin:$PATH
37 changes: 31 additions & 6 deletions build/SetEnv.bat
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
VERIFY OTHER 2>nul


SET _ANT_VERSION=1.9.14
SET _CLOC_VERSION=1.82
SET _PMD_VERSION=6.17.0

CALL :SetVersionsEnvHelper 2>nul



:: -------------------------------------------------------------------
Expand All @@ -15,16 +15,29 @@ SET _PMD_VERSION=6.17.0
CALL :SetLocalEnvHelper 2>nul

:: Java
CALL :SetJavaHomeHelper > nul 2>&1
IF ERRORLEVEL 1 GOTO ERROR_JDK
IF NOT "%1" == "/useCurrentJavaHome" (
CALL :SetJavaHomeHelper > nul 2>&1
IF ERRORLEVEL 1 GOTO ERROR_JDK
)
ECHO SET JAVA_HOME=%JAVA_HOME%

:: Node.js
SET NODEJS_HOME=%CD%\.tmp\node-v%_NODEJS_VERSION%-win-x64
IF NOT EXIST "%NODEJS_HOME%\npm.cmd" (
IF NOT EXIST .tmp MKDIR .tmp
powershell.exe -NoLogo -NonInteractive -ExecutionPolicy ByPass -Command "& { [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; Invoke-WebRequest https://nodejs.org/dist/v$Env:_NODEJS_VERSION/node-v$Env:_NODEJS_VERSION-win-x64.zip -OutFile .tmp\node-v$Env:_NODEJS_VERSION-win-x64.zip; }"
IF ERRORLEVEL 1 GOTO ERROR_NODEJS
powershell.exe -NoLogo -NonInteractive -ExecutionPolicy ByPass -Command "Expand-Archive -Path .tmp\node-v$Env:_NODEJS_VERSION-win-x64.zip -DestinationPath .tmp -Force"
IF ERRORLEVEL 1 GOTO ERROR_NODEJS
)
ECHO SET NODEJS_HOME=%NODEJS_HOME%

:: SFDX CLI
SET SFDX_HOME=%CD%\.tmp\node_modules\.bin
IF NOT EXIST "%SFDX_HOME%\sfdx.cmd" (
IF NOT EXIST .tmp MKDIR .tmp
PUSHD .tmp
npm install sfdx-cli --loglevel info --cache npm-cache
CALL "%NODEJS_HOME%\npm.cmd" install sfdx-cli --cache npm-cache
POPD
)
ECHO SET SFDX_HOME=%SFDX_HOME%
Expand Down Expand Up @@ -79,6 +92,18 @@ EXIT /B 0



:SetVersionsEnvHelper
IF EXIST build\versions.env (
FOR /F "eol=# tokens=1* delims==" %%i IN (build\versions.env) DO (
SET "%%i=%%j"
ECHO SET %%i=%%j
)
ECHO.
)
EXIT /B 0



:SetJavaHomeHelper
SET JAVA_HOME=
FOR /F "tokens=1,2*" %%i IN ('REG QUERY "HKLM\SOFTWARE\JavaSoft\Java Development Kit\1.8" /V JavaHome') DO (
Expand Down
4 changes: 4 additions & 0 deletions build/versions.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
_ANT_VERSION=1.9.14
_CLOC_VERSION=1.82
_NODEJS_VERSION=12.14.1
_PMD_VERSION=6.17.0
41 changes: 36 additions & 5 deletions docs/force-source-convert.html
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,15 @@ <h3>Parameters</h3>
</thead>
<tbody>
<tr>
<td>rootdir</td>
<td>-r</td>
<td>A directory other than the default package directory that contains the source-formatted files to convert.</td>
<td>No</td>
<td>manifest</td>
<td>-x</td>
<td>The path for the manifest (package.xml) file that specifies the metadata types to convert.</td>
<td>No.</td>
</tr>
<tr>
<td>outputdir</td>
<td>-d</td>
<td>The output directory to store the Metadata APIformatted metadata files in.</td>
<td>The output directory to store the Metadata API-formatted metadata files in.</td>
<td>No</td>
</tr>
<tr>
Expand All @@ -58,7 +58,38 @@ <h3>Parameters</h3>
<td>The name of the package to associate with the metadata-formatted files.</td>
<td>No</td>
</tr>
<tr>
<td>rootdir</td>
<td>-r</td>
<td>A directory other than the default package directory that contains the source-formatted files to convert.</td>
<td>No</td>
</tr>
<tr>
<td>sourcepath</td>
<td>-p</td>
<td>The path to the local source file (or directory) to convert.</td>
<td>No</td>
</tr>
</tbody>
</table>

<h3>Parameters specified as nested elements</h3>

<h4>metadata</h4>
<p>Specifies the name of a metadata component to convert.</p>

<h4>sourcepath</h4>
<p>The <var>sourcepath</var> attribute is a <a href="https://ant.apache.org/manual/using.html#path">path-like structure</a> and can also be set via a nested <code>&lt;sourcepath&gt;</code> element.</p>

<h3>Examples</h3>
<pre>
&lt;sfdx:force-source-convert sourcepath=&quot;force-app/main/default/objects/Case&quot;&gt;
&lt;sourcepath&gt;
&lt;pathelement location=&quot;force-app/main/default/objects/Contact&quot; /&gt;
&lt;dirset dir=&quot;force-app/main/default/objects&quot;&gt;
&lt;include name=&quot;Ac*&quot; /&gt;
&lt;/dirset&gt;
&lt;/sourcepath&gt;
&lt;/sfdx:sfdx:force-source-convert&gt;</pre>
</body>
</html>
3 changes: 2 additions & 1 deletion docs/force-source-deploy.html
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ <h3>Examples</h3>
&lt;dirset dir=&quot;force-app/main/default/objects&quot;&gt;
&lt;include name=&quot;Ac*&quot; /&gt;
&lt;/dirset&gt;
&lt;/sourcepath&gt;</pre>
&lt;/sourcepath&gt;
&lt;/sfdx:sfdx:force-source-deploy&gt;</pre>
</body>
</html>
1 change: 1 addition & 0 deletions src/main/com/mcartoixa/ant/sfdx/antlib.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
<taskdef name="force-org-list" classname="com.mcartoixa.ant.sfdx.force.org.ListTask" />
<taskdef name="force-package-install" classname="com.mcartoixa.ant.sfdx.force.pkg.InstallTask" />
<taskdef name="force-package-installed-list" classname="com.mcartoixa.ant.sfdx.force.pkg.installed.ListTask" />
<taskdef name="force-source-convert" classname="com.mcartoixa.ant.sfdx.force.source.ConvertTask" />
<taskdef name="force-source-deploy" classname="com.mcartoixa.ant.sfdx.force.source.DeployTask" />
<taskdef name="force-source-push" classname="com.mcartoixa.ant.sfdx.force.source.PushTask" />
<taskdef name="force-user-permset-assign" classname="com.mcartoixa.ant.sfdx.force.user.permset.AssignTask" />
Expand Down
Loading

0 comments on commit 98acf1a

Please sign in to comment.