Skip to content

Commit

Permalink
Fixed: Replace SvnCheckout in Gradle (OFBIZ-12868)
Browse files Browse the repository at this point in the history
Removes definitely SvnCheckout, pullPluginSource and pullAllPluginsSource tasks
from Gradle (in build.gradle)

Fixes both pullPluginSource scripts, notably uses a shallow clone rather than a
blobless clone as suggested by Eugen, less space, faster
  • Loading branch information
JacquesLeRoux committed Jan 4, 2024
1 parent 9bd538b commit bdbc08a
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 80 deletions.
56 changes: 0 additions & 56 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
* specific language governing permissions and limitations
* under the License.
*/
import at.bxm.gradleplugins.svntools.tasks.SvnCheckout
import org.apache.tools.ant.filters.ReplaceTokens
import org.asciidoctor.gradle.jvm.AsciidoctorTask

Expand All @@ -30,7 +29,6 @@ plugins {
id 'checkstyle'
id 'codenarc'
id 'maven-publish'
id 'at.bxm.svntools' version '3.1'
id 'org.asciidoctor.jvm.convert' version '3.3.2'
id 'org.asciidoctor.jvm.pdf' version '3.3.2'
id 'org.owasp.dependencycheck' version '7.4.4' apply false
Expand Down Expand Up @@ -980,60 +978,6 @@ task pullPlugin(group: ofbizPlugin, description: 'Download and install a plugin
}
}
}
/* The pullPluginSource and pullPluginSource task are now replaced by the OS scripts pullPluginSource and pullAllPluginsSource
task pullPluginSource(group: ofbizPlugin, description: 'Download and install a plugin from source control') {
if (project.hasProperty('pluginId')) {
// GitHub SVN feature https://docs.github.com/en/github/importing-your-projects-to-github/working-with-subversion-on-github/support-for-subversion-clients
task pullPluginFromSvn(type: SvnCheckout) {
def currentBranch = getCurrentGitBranch()
// Only used for release branches
if (currentBranch == "trunk") {
svnUrl = "https://github.com/apache/ofbiz-plugins/trunk/${pluginId}"
} else {
svnUrl = "https://github.com/apache/ofbiz-plugins/branches/" + currentBranch + "/${pluginId}"
}
workspaceDir = "${pluginsDir}/${pluginId}"
}
dependsOn pullPluginFromSvn
}
doLast {
gradlewSubprocess(['installPlugin', "-PpluginId=${pluginId}"])
}
}
task pullAllPluginsSource(group: ofbizPlugin,
description: 'Download and install all plugins from source control. Warning! deletes existing plugins') {
task deleteBeforePulling {
doLast { delete "${pluginsDir}" }
}
task pullPluginsFromSvn(type: SvnCheckout, dependsOn: deleteBeforePulling) {
// GitHub SVN feature https://docs.github.com/en/github/importing-your-projects-to-github/working-with-subversion-on-github/support-for-subversion-clients
def currentBranch = getCurrentGitBranch()
// Only used for release branches
if (currentBranch == "trunk") {
svnUrl = "https://github.com/apache/ofbiz-plugins/trunk"
} else {
svnUrl = "https://github.com/apache/ofbiz-plugins/branches/" + currentBranch
}
workspaceDir = "${pluginsDir}"
}
dependsOn pullPluginsFromSvn
task installAllPlugins {
subdirs(file("${pluginsDir}"))
.filter(this.isComponentEnabled)
.filter { taskExistsInproject(":plugins:${it.name}", 'install') }
.forEach({ plugin ->
dependsOn ":plugins:${plugin.name}:install"
doLast { println "installed plugin ${plugin.name}" }
})
}
doLast {
gradlewSubprocess(['installAllPlugins'])
}
}*/

// ========== Clean up tasks ==========
task cleanCatalina(group: cleanupGroup, description: 'Clean Catalina data in runtime/catalina/work') {
Expand Down
26 changes: 13 additions & 13 deletions pullPluginSource.bat
Original file line number Diff line number Diff line change
Expand Up @@ -18,31 +18,31 @@ rem specific language governing permissions and limitations
rem under the License.
rem #####################################################################

rem Remove plugins dir in case of all plugins present
rem Remove plugins dir in case of all plugins present (no .git)
if EXIST plugins\ (
if NOT EXIST plugins\.git\ (
cmd /c rd/s/q plugins
)
)
rem Clone if new else simply init sparse-checkout
rem Clone and set if new else simply add
if NOT EXIST plugins\.git\ (
git clone --filter=blob:none --sparse https://github.com/apache/ofbiz-plugins.git plugins
cd plugins
git clone --depth=1 --sparse https://github.com/apache/ofbiz-plugins.git plugins
cd plugins
git sparse-checkout set %1
) else (
cd plugins
rem the documentation says init is deprecated but set does work here: https://git-scm.com/docs/git-sparse-checkout
git sparse-checkout init --cone --sparse-index
git sparse-checkout add %1
)

rem Add the plugin
git sparse-checkout add %1


rem Get the branch used in framework
cd ..
git branch --show-current > temp.txt
set /p branch=<temp.txt
del temp.txt
rem By default the clone branch is trunk

rem By default the cloned branch is trunk, switch if necessary
if NOT trunk == %branch% (
call git switch -c %1 --track origin/%1
cd plugins
git switch -C %branch%
cd ..
)
cd ..
21 changes: 10 additions & 11 deletions pullPluginSource.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,38 +17,37 @@
# under the License.


# Remove plugins dir in case of all plugins present
# Remove plugins dir in case of all plugins present (no .git)
if [ -d "plugins" ]
then
if [ ! -d "plugins\.git" ]
if [ ! -d "plugins/.git" ]
then
rm -rf plugins
fi
fi

# Clone if new else simply init sparse-checkout
if [ ! -d "plugins\.git" ]
# Clone and set if new else simply add
if [ ! -d "plugins/.git" ]
then
git clone --filter=blob:none --sparse https://github.com/apache/ofbiz-plugins.git plugins
git clone --depth=1 --sparse https://github.com/apache/ofbiz-plugins.git plugins
cd plugins
git sparse-checkout set "$1"
else
cd plugins
# the documentation says init is deprecated but set does work here: https://git-scm.com/docs/git-sparse-checkout
git sparse-checkout init --cone --sparse-index
git sparse-checkout add "$1"
fi

# Add the plugin
git sparse-checkout add "$1"

# Get the branch used in framework
cd ..
git branch --show-current > temp.txt
branch=$(cat temp.txt)
rm temp.txt

# By default the clone branch is trunk
# By default the cloned branch is trunk, switch if necessary
if [ ! "$branch" = trunk ]
then
cd plugins
git switch -C "$branch"
cd ..
fi
cd ..

0 comments on commit bdbc08a

Please sign in to comment.