# This is the config file for the ofbiz project.
#The names contains ofbiz to not be confused with other esternal builders when appended to the common c['schedulers'], This is only a convention not a syntax issue, but useful when debugging.

from buildbot import locks

simple_lock = locks.MasterLock("simpleLock")

### SCHEDULERS --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
## TRUNK ------------------------------------------------------------------
# Per commit builds from the ofbiz-framework branch. Once triggered, also triggers a ofbiz-plugins branch dependent build if and only if successful
ofbizTrunkFramework = AnyBranchScheduler(name="onTrunkFrameworkCommit",
                         branches=["ofbiz/ofbiz-framework/trunk"],
                         treeStableTimer=2*60,
                         builderNames=["ofbizTrunkFramework"])

# Per commit builds from the ofbiz-plugins branch. Does not trigger any other build.
ofbizTrunkFrameworkPlugins = AnyBranchScheduler(name="onTrunkPluginsCommit",
                         branches=["ofbiz/ofbiz-plugins/trunk"],
                         treeStableTimer=2*60,
                         builderNames=["ofbizTrunkFrameworkPlugins"])

c['schedulers'].append(ofbizTrunkFramework)
c['schedulers'].append(ofbizTrunkFrameworkPlugins)

# This dependent will build the plugins branch after a successful ofbiz-framework branch commit.
ofbizTrunkPluginsDependsOnFramework = Dependent(name="trunkPluginsDependsOnFramework",
                                   upstream=ofbizTrunkFramework,
                                   builderNames=["ofbizTrunkFrameworkPlugins"])

# This dependent will build the RAT report after a successful ofbiz-framework branch commit. Rat is only done for trunk.
ofbizTrunkFrameworkRat = Dependent(name="ofbizTrunkFrameworkRat",
                                   upstream=ofbizTrunkFramework,
                                   builderNames=["ofbizTrunkFrameworkRat"])

c['schedulers'].append(ofbizTrunkPluginsDependsOnFramework)
c['schedulers'].append(ofbizTrunkFrameworkRat)


## BRANCH18 ------------------------------------------------------------------
## Per commit builds from the ofbiz-framework branch 18. Once triggered, also triggers a ofbiz-plugins branch18 dependent build if and only if successful
ofbizBranch18Framework = AnyBranchScheduler(name="onBranch18FrameworkCommit",
                         branches=["ofbiz/ofbiz-framework/branches/release18.12"],
                         treeStableTimer=2*60,
                         builderNames=["ofbizBranch18Framework"])

# Per commit builds from the ofbiz-plugins branch.18 Does not trigger any other build.
ofbizBranch18FrameworkPlugins = AnyBranchScheduler(name="onBranch18PluginsCommit",
                         branches=["ofbiz/ofbiz-plugins/branches/release18.12"],
                         treeStableTimer=2*60,
                         builderNames=["ofbizBranch18FrameworkPlugins"])

c['schedulers'].append(ofbizBranch18Framework)
c['schedulers'].append(ofbizBranch18FrameworkPlugins)

# This dependent will build the plugins branch 18 after a successful ofbiz-framework branch 18 commit.
ofbizBranch18PluginsDependsOnFramework = Dependent(name="ofbizBranch18PluginsDependsOnFramework",
                                   upstream=ofbizBranch18Framework,
                                   builderNames=["ofbizBranch18FrameworkPlugins"])

c['schedulers'].append(ofbizBranch18PluginsDependsOnFramework)

## BRANCH17 ------------------------------------------------------------------
## Per commit builds from the ofbiz-framework branch 17. Once triggered, also triggers a ofbiz-plugins branch17 dependent build if and only if successful
ofbizBranch17Framework = AnyBranchScheduler(name="onBranch17FrameworkCommit",
                         branches=["ofbiz/ofbiz-framework/branches/release17.12"],
                         treeStableTimer=2*60,
                         builderNames=["ofbizBranch17Framework"])

# Per commit builds from the ofbiz-plugins branch.17 Does not trigger any other build.
ofbizBranch17FrameworkPlugins = AnyBranchScheduler(name="onBranch17PluginsCommit",
                         branches=["ofbiz/ofbiz-plugins/branches/release17.12"],
                         treeStableTimer=2*60,
                         builderNames=["ofbizBranch17FrameworkPlugins"])

c['schedulers'].append(ofbizBranch17Framework)
c['schedulers'].append(ofbizBranch17FrameworkPlugins)

# This dependent will build the plugins branch 17 after a successful ofbiz-framework branch 17 commit.
ofbizBranch17PluginsDependsOnFramework = Dependent(name="ofbizBranch17PluginsDependsOnFramework",
                                   upstream=ofbizBranch17Framework,
                                   builderNames=["ofbizBranch17FrameworkPlugins"])

c['schedulers'].append(ofbizBranch17PluginsDependsOnFramework)

## BRANCH16 ------------------------------------------------------------------
ofbizBranch16= AnyBranchScheduler(name="onOfbizR16Commit",
                         branches=["ofbiz/branches/release16.11"],
                         treeStableTimer=2*60,
                         builderNames=["ofbizBranch16"])

c['schedulers'].append(ofbizBranch16)

### BUILDERS ----------------------------------------------------------------------------------------
##  TRUNK  --------------------------------------------
## ------------------------------ofbizTrunkFramework. Only framework: build and tests
f_ofb_trunk_framework = factory.BuildFactory()
f_ofb_trunk_framework.addStep(SVN(mode='full', method='clobber', repourl="http://svn.apache.org/repos/asf/ofbiz/ofbiz-framework/trunk",
                    haltOnFailure=True
))
# If checkout of source didn't work, then no point continuing.

# I prefer to separate each step because it's easier to find issue in case
f_ofb_trunk_framework.addStep(ShellCommand(command=["./gradlew", "--no-daemon", "--stacktrace",  "build"],
                    haltOnFailure=True
))

f_ofb_trunk_framework.addStep(ShellCommand(command=["./gradlew", "--no-daemon", "--stacktrace", "loadAll"],
                    haltOnFailure=True
))
f_ofb_trunk_framework.addStep(ShellCommand(command=["./gradlew", "--no-daemon", "--stacktrace", "testIntegration"],
                    haltOnFailure=True,
                    locks=[simple_lock.access('exclusive')]
))

# Copy HTML logs to make it available externally
f_ofb_trunk_framework.addStep(DirectoryUpload(slavesrc="runtime/logs/test-results/html",
                            masterdest="/tmp/ofbiz/html",
                            alwaysRun=True,
                            ),
)
f_ofb_trunk_framework.addStep(MasterShellCommand(command="""
            rm -rf /x1/buildmaster/master1/public_html/projects/ofbiz/logs/trunk/framework/html;
            cp -r /tmp/ofbiz/html /x1/buildmaster/master1/public_html/projects/ofbiz/logs/trunk/framework""",
            alwaysRun=True
            ),
)
# Always run the tmp cleanup step, in case of failures part way through uploading etc..
f_ofb_trunk_framework.addStep(MasterShellCommand(command="""
            rm -rf /tmp/ofbiz""",
            alwaysRun=True
            ),
)

b_ofb_trunk_framework = {'name': "ofbizTrunkFramework",
      'slavenames': ["lares_ubuntu" , "orcus_ubuntu" , "silvanus_ubuntu"],
      'builddir': "ofbizTrunkFramework",
      'factory': f_ofb_trunk_framework,
      'category': "ofbizTrunkFramework",
      'env': {'JAVA_HOME': "/home/buildslave/slave/tools/java/latest1.8"}
      }

c['builders'].append(b_ofb_trunk_framework)

## -------------------------ofbizTrunkFrameworkPlugins. Framework + plugins
f_ofb_trunk_framework_plugins = factory.BuildFactory()
f_ofb_trunk_framework_plugins.addStep(SVN(mode='full', method='clobber', repourl="https://svn.apache.org/repos/asf/ofbiz/ofbiz-framework/trunk",
                    haltOnFailure=True
))
# If checkout of source didn't work, then no point continuing.

f_ofb_trunk_framework_plugins.addStep(ShellCommand(command=["./gradlew", "--no-daemon", "--stacktrace",  "pullAllPluginsSource"],
                    haltOnFailure=True
))
f_ofb_trunk_framework_plugins.addStep(ShellCommand(command=["./gradlew", "--no-daemon", "--stacktrace",  "build"],
                    haltOnFailure=True
))
f_ofb_trunk_framework_plugins.addStep(ShellCommand(command=["./gradlew", "--no-daemon", "--stacktrace", "javadoc"],
                        haltOnFailure=True
))
f_ofb_trunk_framework_plugins.addStep(DirectoryUpload(slavesrc="build/docs/javadoc",
                            masterdest="/x1/buildmaster/master1/public_html/projects/ofbiz/site/javadocs"))

f_ofb_trunk_framework_plugins.addStep(ShellCommand(command=["./gradlew", "--no-daemon", "--stacktrace", "loadAll"],
                    haltOnFailure=True
))
f_ofb_trunk_framework_plugins.addStep(ShellCommand(command=["./gradlew", "--no-daemon", "--stacktrace", "testIntegration"],
                    haltOnFailure=True,
                    locks=[simple_lock.access('exclusive')]
))

# Copy HTML logs to make it available externally
f_ofb_trunk_framework_plugins.addStep(DirectoryUpload(slavesrc="runtime/logs/test-results/html",
                            masterdest="/tmp/ofbiz/html",
                            alwaysRun=True,
                            ),
)
f_ofb_trunk_framework_plugins.addStep(MasterShellCommand(command="""
            rm -rf /x1/buildmaster/master1/public_html/projects/ofbiz/logs/trunk/plugins/html;
            cp -r /tmp/ofbiz/html /x1/buildmaster/master1/public_html/projects/ofbiz/logs/trunk/plugins""",
            alwaysRun=True
            ),
)
# Always run the tmp cleanup step, in case of failures part way through uploading etc..
f_ofb_trunk_framework_plugins.addStep(MasterShellCommand(command="""
            rm -rf /tmp/ofbiz""",
            alwaysRun=True
            ),
)

b_ofbiz_trunk_framework_plugins = {'name': "ofbizTrunkFrameworkPlugins",
      'slavenames': ["lares_ubuntu" , "orcus_ubuntu" , "silvanus_ubuntu"],
      'builddir': "ofbizTrunkFrameworkPlugins",
      'factory': f_ofb_trunk_framework_plugins,
      'category': "ofbizTrunkFrameworkPlugins",
      'env': {'JAVA_HOME': "/home/buildslave/slave/tools/java/latest1.8"}
      }

c['builders'].append(b_ofbiz_trunk_framework_plugins)


## ofbizBranch18  ---------------------------------------------
# --------------------------------------------framework
f_ofb_branch18_framework = factory.BuildFactory()
f_ofb_branch18_framework .addStep(SVN(mode='full', method='clobber', repourl="http://svn.apache.org/repos/asf/ofbiz/ofbiz-framework/branches/release18.12",
                    haltOnFailure=True
))
# If checkout of source didn't work, then no point continuing.

# I prefer to separate each step because it's easier to find issue in case
f_ofb_branch18_framework .addStep(ShellCommand(command=["./gradlew", "--no-daemon", "--stacktrace",  "build"],
                    haltOnFailure=True
))

f_ofb_branch18_framework .addStep(ShellCommand(command=["./gradlew", "--no-daemon", "--stacktrace", "loadAll"],
                    haltOnFailure=True
))
f_ofb_branch18_framework .addStep(ShellCommand(command=["./gradlew", "--no-daemon", "--stacktrace", "testIntegration"],
                    haltOnFailure=True,
                    locks=[simple_lock.access('exclusive')]
))

# Copy HTML logs to make it available externally
f_ofb_branch18_framework .addStep(DirectoryUpload(slavesrc="runtime/logs/test-results/html",
                            masterdest="/tmp/ofbiz/html",
                            alwaysRun=True,
                            ),
)
f_ofb_branch18_framework .addStep(MasterShellCommand(command="""
            rm -rf /x1/buildmaster/master1/public_html/projects/ofbiz/logs/18.12/framework/html;
            cp -r /tmp/ofbiz/html /x1/buildmaster/master1/public_html/projects/ofbiz/logs/18.12/framework""",
            alwaysRun=True
            ),
)
# Always run the tmp cleanup step, in case of failures part way through uploading etc..
f_ofb_branch18_framework .addStep(MasterShellCommand(command="""
            rm -rf /tmp/ofbiz""",
            alwaysRun=True
            ),
)

b_ofbiz_branch18_framework = {'name': "ofbizBranch18Framework",
      'slavenames': ["lares_ubuntu" , "orcus_ubuntu" , "silvanus_ubuntu"],
      'builddir': "ofbizBranch18Framework",
      'factory': f_ofb_branch18_framework,
      'category': "ofbizBranch18Framework",
      'env': {'JAVA_HOME': "/home/buildslave/slave/tools/java/latest1.8"}
      }

c['builders'].append(b_ofbiz_branch18_framework )

# --------------------------------------------plugins ,  Javadoc, and Documentation are generated with ofbizTrunkFrameworkPlugins (the whole)
f_ofb_branch18_framework_plugins = factory.BuildFactory()
f_ofb_branch18_framework_plugins.addStep(SVN(mode='full', method='clobber', repourl="http://svn.apache.org/repos/asf/ofbiz/ofbiz-framework/branches/release18.12",
                    haltOnFailure=True
))
# If checkout of source didn't work, then no point continuing.

f_ofb_branch18_framework_plugins.addStep(ShellCommand(command=["./gradlew", "--no-daemon", "--stacktrace",  "pullAllPluginsSource"],
                    haltOnFailure=True
))
f_ofb_branch18_framework_plugins.addStep(ShellCommand(command=["./gradlew", "--no-daemon", "--stacktrace",  "build"],
                    haltOnFailure=True
))

f_ofb_branch18_framework_plugins.addStep(ShellCommand(command=["./gradlew", "--no-daemon", "--stacktrace", "generateOfbizDocumentation"],
                        haltOnFailure=True
))
f_ofb_branch18_framework_plugins.addStep(DirectoryUpload(slavesrc="build/asciidoc/ofbiz",
                            masterdest="/x1/buildmaster/master1/public_html/projects/ofbiz/site/ofbizdoc"))

f_ofb_branch18_framework_plugins.addStep(ShellCommand(command=["./gradlew", "--no-daemon", "--stacktrace", "generateAllPluginsDocumentation"],
                        haltOnFailure=True
))
f_ofb_branch18_framework_plugins.addStep(DirectoryUpload(slavesrc="build/asciidoc/plugins",
                            masterdest="/x1/buildmaster/master1/public_html/projects/ofbiz/site/pluginsdoc"))

f_ofb_branch18_framework_plugins.addStep(ShellCommand(command=["./gradlew", "--no-daemon", "--stacktrace", "loadAll"],
                    haltOnFailure=True
))
f_ofb_branch18_framework_plugins.addStep(ShellCommand(command=["./gradlew", "--no-daemon", "--stacktrace", "testIntegration"],
                    haltOnFailure=True,
                    locks=[simple_lock.access('exclusive')]
))

# Copy HTML logs to make it available externally
f_ofb_branch18_framework_plugins.addStep(DirectoryUpload(slavesrc="runtime/logs/test-results/html",
                            masterdest="/tmp/ofbiz/html",
                            alwaysRun=True,
                            ),
)
f_ofb_branch18_framework_plugins.addStep(MasterShellCommand(command="""
            rm -rf /x1/buildmaster/master1/public_html/projects/ofbiz/logs/18.12/plugins/html;
            cp -r /tmp/ofbiz/html /x1/buildmaster/master1/public_html/projects/ofbiz/logs/18.12/plugins""",
            alwaysRun=True
            ),
)
# Always run the tmp cleanup step, in case of failures part way through uploading etc..
f_ofb_branch18_framework_plugins.addStep(MasterShellCommand(command="""
            rm -rf /tmp/ofbiz""",
            alwaysRun=True
            ),
)

b_ofbiz_branch18_framework_plugins = {'name': "ofbizBranch18FrameworkPlugins",
      'slavenames': ["lares_ubuntu" , "orcus_ubuntu" , "silvanus_ubuntu"],
      'builddir': "ofbizBranch18FrameworkPlugins",
      'factory': f_ofb_branch18_framework_plugins,
      'category': "ofbizBranch18FrameworkPlugins",
      'env': {'JAVA_HOME': "/home/buildslave/slave/tools/java/latest1.8"}
      }

c['builders'].append(b_ofbiz_branch18_framework_plugins)

## ofbizBranch17  ---------------------------------------------
# --------------------------------------------framework
f_ofb_branch17_framework = factory.BuildFactory()
f_ofb_branch17_framework .addStep(SVN(mode='full', method='clobber', repourl="http://svn.apache.org/repos/asf/ofbiz/ofbiz-framework/branches/release17.12",
                    haltOnFailure=True
))
# If checkout of source didn't work, then no point continuing.

# I prefer to separate each step because it's easier to find issue in case
f_ofb_branch17_framework .addStep(ShellCommand(command=["./gradlew", "--no-daemon", "--stacktrace",  "build"],
                    haltOnFailure=True
))

f_ofb_branch17_framework .addStep(ShellCommand(command=["./gradlew", "--no-daemon", "--stacktrace", "loadAll"],
                    haltOnFailure=True
))
f_ofb_branch17_framework .addStep(ShellCommand(command=["./gradlew", "--no-daemon", "--stacktrace", "testIntegration"],
                    haltOnFailure=True,
                    locks=[simple_lock.access('exclusive')]
))

# Copy HTML logs to make it available externally
f_ofb_branch17_framework .addStep(DirectoryUpload(slavesrc="runtime/logs/test-results/html",
                            masterdest="/tmp/ofbiz/html",
                            alwaysRun=True,
                            ),
)
f_ofb_branch17_framework .addStep(MasterShellCommand(command="""
            rm -rf /x1/buildmaster/master1/public_html/projects/ofbiz/logs/17.12/framework/html;
            cp -r /tmp/ofbiz/html /x1/buildmaster/master1/public_html/projects/ofbiz/logs/17.12/framework""",
            alwaysRun=True
            ),
)
# Always run the tmp cleanup step, in case of failures part way through uploading etc..
f_ofb_branch17_framework .addStep(MasterShellCommand(command="""
            rm -rf /tmp/ofbiz""",
            alwaysRun=True
            ),
)

b_ofbiz_branch17_framework = {'name': "ofbizBranch17Framework",
      'slavenames': ["lares_ubuntu" , "orcus_ubuntu" , "silvanus_ubuntu"],
      'builddir': "ofbizBranch17Framework",
      'factory': f_ofb_branch17_framework,
      'category': "ofbizBranch17Framework",
      'env': {'JAVA_HOME': "/home/buildslave/slave/tools/java/latest1.8"}
      }

c['builders'].append(b_ofbiz_branch17_framework )

# --------------------------------------------plugins ,  Javadoc, and Documentation are generated with ofbizTrunkFrameworkPlugins (the whole)
f_ofb_branch17_framework_plugins = factory.BuildFactory()
f_ofb_branch17_framework_plugins.addStep(SVN(mode='full', method='clobber', repourl="http://svn.apache.org/repos/asf/ofbiz/ofbiz-framework/branches/release17.12",
                    haltOnFailure=True
))
# If checkout of source didn't work, then no point continuing.

f_ofb_branch17_framework_plugins.addStep(ShellCommand(command=["./gradlew", "--no-daemon", "--stacktrace",  "pullAllPluginsSource"],
                    haltOnFailure=True
))
f_ofb_branch17_framework_plugins.addStep(ShellCommand(command=["./gradlew", "--no-daemon", "--stacktrace",  "build"],
                    haltOnFailure=True
))

f_ofb_branch17_framework_plugins.addStep(ShellCommand(command=["./gradlew", "--no-daemon", "--stacktrace", "generateOfbizDocumentation"],
                        haltOnFailure=True
))
f_ofb_branch17_framework_plugins.addStep(DirectoryUpload(slavesrc="build/asciidoc/ofbiz",
                            masterdest="/x1/buildmaster/master1/public_html/projects/ofbiz/site/ofbizdoc"))

f_ofb_branch17_framework_plugins.addStep(ShellCommand(command=["./gradlew", "--no-daemon", "--stacktrace", "generateAllPluginsDocumentation"],
                        haltOnFailure=True
))
f_ofb_branch17_framework_plugins.addStep(DirectoryUpload(slavesrc="build/asciidoc/plugins",
                            masterdest="/x1/buildmaster/master1/public_html/projects/ofbiz/site/pluginsdoc"))

f_ofb_branch17_framework_plugins.addStep(ShellCommand(command=["./gradlew", "--no-daemon", "--stacktrace", "loadAll"],
                    haltOnFailure=True
))
f_ofb_branch17_framework_plugins.addStep(ShellCommand(command=["./gradlew", "--no-daemon", "--stacktrace", "testIntegration"],
                    haltOnFailure=True,
                    locks=[simple_lock.access('exclusive')]
))

# Copy HTML logs to make it available externally
f_ofb_branch17_framework_plugins.addStep(DirectoryUpload(slavesrc="runtime/logs/test-results/html",
                            masterdest="/tmp/ofbiz/html",
                            alwaysRun=True,
                            ),
)
f_ofb_branch17_framework_plugins.addStep(MasterShellCommand(command="""
            rm -rf /x1/buildmaster/master1/public_html/projects/ofbiz/logs/17.12/plugins/html;
            cp -r /tmp/ofbiz/html /x1/buildmaster/master1/public_html/projects/ofbiz/logs/17.12/plugins""",
            alwaysRun=True
            ),
)
# Always run the tmp cleanup step, in case of failures part way through uploading etc..
f_ofb_branch17_framework_plugins.addStep(MasterShellCommand(command="""
            rm -rf /tmp/ofbiz""",
            alwaysRun=True
            ),
)

b_ofbiz_branch17_framework_plugins = {'name': "ofbizBranch17FrameworkPlugins",
      'slavenames': ["lares_ubuntu" , "orcus_ubuntu" , "silvanus_ubuntu"],
      'builddir': "ofbizBranch17FrameworkPlugins",
      'factory': f_ofb_branch17_framework_plugins,
      'category': "ofbizBranch17FrameworkPlugins",
      'env': {'JAVA_HOME': "/home/buildslave/slave/tools/java/latest1.8"}
      }

c['builders'].append(b_ofbiz_branch17_framework_plugins)


## ofbizBranch16

f_ofb_16 = factory.BuildFactory()
f_ofb_16.addStep(SVN(mode='full', method='clobber', repourl="https://svn.apache.org/repos/asf/ofbiz/branches/release16.11",
                    haltOnFailure=True
))
# If checkout of source didn't work, then no point continuing.

f_ofb_16.addStep(ShellCommand(command=["./gradlew", "--no-daemon", "--stacktrace",  "build"],
                    haltOnFailure=True
))

f_ofb_16.addStep(ShellCommand(command=["./gradlew", "--no-daemon", "--stacktrace", "loadDefault"],
                    haltOnFailure=True
))

f_ofb_16.addStep(ShellCommand(command=["./gradlew", "--no-daemon", "--stacktrace", "testIntegration"],
                    haltOnFailure=True,
                    locks=[simple_lock.access('exclusive')]
))



# Copy HTML logs to make it available externally
f_ofb_16.addStep(DirectoryUpload(slavesrc="runtime/logs/test-results/html",
                            masterdest="/tmp/ofbiz-16/html",
                            alwaysRun=True,
                            ),
)

f_ofb_16.addStep(MasterShellCommand(command="""
            rm -rf /x1/buildmaster/master1/public_html/projects/ofbiz/logs/16.11/html;
            cp -r /tmp/ofbiz-16/html /x1/buildmaster/master1/public_html/projects/ofbiz/logs/16.11""",
            alwaysRun=True
            ),
)

# Always run the tmp cleanup step, in case of failures part way through uploading etc..
f_ofb_16.addStep(MasterShellCommand(command="""
            rm -rf /tmp/ofbiz-16""",
            alwaysRun=True
            ),

)

b_ofb_16 = {'name': "ofbizBranch16",
      'slavenames': ["lares_ubuntu" , "orcus_ubuntu" , "silvanus_ubuntu"],
      'builddir': "ofbizBranch16",
      'factory': f_ofb_16,
      'category': "ofbizBranch16",
      'env': {'JAVA_HOME': "/home/buildslave/slave/tools/java/latest1.8"}
      }

c['builders'].append(b_ofb_16)


### RAT build runs on its own on lares buildslave only due to needed path. Triggered by commit at the same time as trunk build.
## RAT for framework
f_ofb_rat_trunk = factory.BuildFactory()
f_ofb_rat_trunk.addStep(SVN(mode='full', method='clobber', repourl="https://svn.apache.org/repos/asf/ofbiz/ofbiz-framework/trunk")),
f_ofb_rat_trunk.addStep(ShellCommand(name="Export", command=["svn", "export", "--", "https://svn.apache.org/repos/asf/ofbiz/tools/rat-excludes.txt", "rat-excludes.txt"],
                    timeout=60, haltOnFailure=True, description='Export')),

f_ofb_rat_trunk.addStep(ShellCommand(command=["./gradlew", "--no-daemon", "--stacktrace",  "pullAllPluginsSource"],
                    haltOnFailure=True
))


f_ofb_rat_trunk.addStep(ShellCommand(
            command=['bash', '-c', 'ant -f /home/buildslave/slave/rat-buildfiles/ofbiz.xml -lib /home/buildslave/'],
            description=["RAT Testing"],
            descriptionDone=["RAT Report Complete"],
            timeout=7200,
            haltOnFailure=True
))

# Above performs RAT tests on entire ofbiz build directories, output to txt file.
# Now we will publish that report to ci.apache.org/projects/ofbiz/rat-output.xml
# assuming that the report step itself was successful.

f_ofb_rat_trunk.addStep(FileUpload(slavesrc="../rat-output.html",
                       masterdest="/tmp/ofbiz-rat/rat-output.html",
               haltOnFailure=True
))

# If we get this far, then the RAT report went fine and it was uploaded to master tmp
# dir without error. So now we can delete any previous report and move from tmp to
# published.

f_ofb_rat_trunk.addStep(MasterShellCommand(command="""
            rm -f /x1/buildmaster/master1/public_html/projects/ofbiz/rat-output.html;
            cp /tmp/ofbiz-rat/rat-output.html /x1/buildmaster/master1/public_html/projects/ofbiz/rat-output.html"""))

b_ofb_rat_trunk = {'name': "ofbizTrunkFrameworkRat",
      'slavename': "lares_ubuntu",
      'builddir': "ofbizTrunkFrameworkRat",
      'factory': f_ofb_rat_trunk,
      'category': "ofbizTrunkFrameworkRat",
      }

c['builders'].append(b_ofb_rat_trunk)

################### Common part ##################
#mail status

c['status'].append(mail.MailNotifier(fromaddr="buildbot@apache.org",
                                     extraRecipients=["commits@ofbiz.apache.org"],
                                     sendToInterestedUsers=False,
                                     mode="change",
                                     categories=["ofbizTrunkFrameworkPlugins", "ofbizTrunkFramework", "ofbizBranch16" , "ofbizBranch17Framework", "ofbizBranch17FrameworkPlugins", "ofbizBranch18Framework", "ofbizBranch18FrameworkPlugins", "ofbizTrunkFrameworkRat"]))

c['status'].append(words.IRC(host="irc.freenode.net", nick="ofbiz-bot",
                              allowForce=True,
                              channels=["#ofbiz"],
                  notify_events={
                'successToFailure': 1,
                'failureToSuccess': 1,
                },
                categories=["ofbizTrunkFrameworkPlugins", "ofbizTrunkFramework", "ofbizBranch16" , "ofbizBranch17Framework", "ofbizBranch17FrameworkPlugins", "ofbizBranch18Framework", "ofbizBranch18FrameworkPlugins", "ofbizTrunkFrameworkRat"]))

