Ant plugin library for Force.com Development #Salesforce
Java Apex Other
Permalink
Failed to load latest commit information.
bin
src
templates/src
.classpath
.gitignore
.project
README.md
build.properties
build.sh
build.xml
d.sh
pom.xml

README.md

Leap: An Ant Library Plugin for Salesforce Apex Development

Project Goals

  • Accelerate the Apex learning and development process
  • Catalog Apex patterns and best practices in a template library
  • Enable continuous integration / Built around the Apex development lifecycle
  • Extensible and open

Overview

Leap is a Java Ant library that integrates with the Salesforce migration toolkit to help Developers with common tasks, such as generating trigger handlers and wrapper classes. The leap template library is an open source catalog of Apex best practices and examples, compiled from the Salesforce Development community, that encourages coding styles that work well on the Salesforce platform.

Usage

From the command line of any Salesforce development environment:

    ~/ant leapTargetName

List of Leap Tasks

  • leapsfields: Generates a class of static fields for all SObjects
  • leaptriggers: Generates triggers and Apex trigger handler class(es) for SObjects
  • leapwrappers: Generates wrapper class(es) (in development)
  • leapmetadiff: Compares org files in 2 directories. Copies diff files into a 3rd directory.
  • leaplint: Static analysis of human editable files (*.cls, *.page, *.component, *.trigger, *.resource)
  • executeAnonymous: executes Apex code on the target Salesforce environment.

Getting started

  • Download and copy bin/ant-leap.jar into the local Ant library folder (on a Mac this is located at /usr/share/ant/lib).
  • Create build.properties and build.xml files within the root of any Salesforce development project (see example templates below).
  • Enter Salesforce development credentials into build.properties.
  • To test, type "ant leapsfields" to run the leap task that builds a class of field names.

Example build.properties

    # build.properties
    #
    # For server URL properties...
    # Use 'https://login.salesforce.com' for production or developer edition.
    # Use 'https://test.salesforce.com for sandbox.

    # Specify the login credentials for the Salesforce development organization
    sf.dev.username = developername@domain.com
    sf.dev.password = password
    sf.dev.url = https://login.salesforce.com

    # Specify the login credentials for the Salesforce staging/test organization
    sf.test.username = 
    sf.test.password = 
    sf.test.url = https://login.salesforce.com

    # Specify the login credentials for the Salesforce production/packaging organization
    sf.prod.username = 
    sf.prod.password = 
    sf.prod.url = https://login.salesforce.com

Example build.xml

<project name="Project Name" default="test" basedir="." xmlns:sf="antlib:com.salesforce" xmlns:leap="antlib:org.leap">
    <target name="leapTaskName">
        <leap:leapTaskName username="${sf.dev.username}" password="${sf.dev.password}" serverurl="${sf.dev.url}" />
    </target>

    <target name="leapsfields">
        <leap:leapsfields username="${sf.dev.username}" password="${sf.dev.password}" token="${sf.dev.token}" serverurl="${sf.dev.url}" objects="Lead,Contact,Account,Opportunity,Order__c" />
    </target>

    <target name="leaptriggers">
        <leap:leaptriggers username="${sf.dev.username}" password="${sf.dev.password}" token="${sf.dev.token}" serverurl="${sf.dev.url}" objects="Lead,Contact,Account,Opportunity,Order__c" />
    </target>

    <target name="leapwrappers">
        <leap:leapwrappers username="${sf.dev.username}" password="${sf.dev.password}" token="${sf.dev.token}" serverurl="${sf.dev.url}" objects="Lead,Contact,Account,Opportunity,Order__c" />
    </target>
    
    <target name="leapmetadiff">
        <leap:leapmetadiff srcFolder="${sf.dev.srcFolder}" destFolder="${sf.prod.srcFolder}" outFolder="${sf.outFolder}"  username="${sf.dev.username}" password="${sf.dev.password}" token="${sf.dev.token}" serverurl="${sf.dev.url}"/>
    </target>

    <target name="lint">
        <leap:lint maxFileLines="500" ignoreFiles="(comma separated list of files to be ignored)" failonerror="true|false" />
    </target> 

    <target name="delete">
        <leap:deleteObjects query="SELECT Id FROM ApexClass WHERE Name Like 'SomePattern%Test'" failonerror="true|false" username="${sf.dev.username}" password="${sf.dev.password}" token="${sf.dev.token}" se    rverurl="${sf.dev.url}" />
    </target> 

    <target name="execAnon">
        <leap:executeAnonymous code="MyApexClass.staticMethod();" failonerror="true|false" username="${sf.dev.username}" password="${sf.dev.password}" token="${sf.dev.token}" se    rverurl="${sf.dev.url}" />
    </target> 

    <target name="runtests">
        <leap:runtests classes="MyApexClass,MyApexClass_Tests" regex="regex matching pattern" username="${sf.dev.username}" password="${sf.dev.password}" token="${sf.dev.token}" serverurl="${sf.dev.url}" failonerror="true|false" />
    </target>
</project>

Attributes

Notes on attributes. failonerror: When set to "true" will stop the build process.

Proxy Confguration

To connect to Salesforce using a proxy, define an environment variable named HTTPS_PROXY in the format host:port. Example: proxy.internal.domain.com:8080

Open Source

Leap is open sourced under the BSD license.

Copyright (c) 2014, Michael Leach All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

  1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.

  2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.