Configure DeltaSpike in Your Projects

DeltaSpike is available for use in projects of many build tools. Instructions are given here for obtaining released final versions of DeltaSpike for both approaches.

You can also opt to use the lastest DeltaSpike snapshots; for more information, see Use DeltaSpike Snapshots.

Maven Projects

DeltaSpike released versions are available from the Maven Central repository for use in Maven-based projects. This means that you do not need to modify your Maven configuration settings.xml file; when building projects, Maven automatically searches the online Maven Central repository for project dependencies and downloads sources to your local Maven repository.

To begin use the DeltaSpike releases from Maven Central, you simply need to configure the project pom.xml file for each project with information about the release version and modules you want to use. At a minimum, you must add the DeltaSpike Core module, which provides the DeltaSpike API and utility classes.

  1. Open the project pom.xml file for editing

  2. Add the DeltaSpike version to the list of properties

    <properties>
        <deltaspike.version>1.9.4</deltaspike.version>
    </properties>
  3. Add the DeltaSpike Core module to the list of dependencies

    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>org.apache.deltaspike.distribution</groupId>
                <artifactId>distributions-bom</artifactId>
                <version>${deltaspike.version}</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
        </dependencies>
    </dependencyManagement>
    
    <dependency>
        <groupId>org.apache.deltaspike.core</groupId>
        <artifactId>deltaspike-core-api</artifactId>
        <scope>compile</scope>
    </dependency>
    
    <dependency>
        <groupId>org.apache.deltaspike.core</groupId>
        <artifactId>deltaspike-core-impl</artifactId>
        <scope>runtime</scope>
    </dependency>
  4. Save the pom.xml file changes

The API is scoped for compile time and implementation only included for runtime, assisting to prevent you from inadvertently depending on an implementation class.

For instructions on adding the optional DeltaSpike modules, see the relevant module page:

Gradle Projects

Setting up DeltaSpike in a Gradle based project is just as easy as Maven.

// setup the Spring Dependency Management Plugin for Gradle, to import BOMs.
plugins {
    id "io.spring.dependency-management" version "0.5.6.RELEASE"
    id "java" // you'll likely also want the WAR plugin
}
repositories {
    mavenCentral()
}
dependencyManagement {
    imports {
        mavenBom 'org.apache.deltaspike.distribution:distributions-bom:1.9.4'
    }
}
dependencies {
     compile 'org.apache.deltaspike.core:deltaspike-core-api'
     runtime 'org.apache.deltaspike.core:deltaspike-core-impl'
}
sourceSets {
   main {
     //To use standard bean discovery mechanisms, CDI expects beans.xml to be in your classes directory
     output.resourcesDir = output.classesDir
   }
   test {
        output.resourcesDir = output.classesDir
   } // and any other sourceSet you might have.
 }

This will give you a Gradle build setup to run DeltaSpike.

Other Projects

DeltaSpike is provided as a set of downloadable .jar files for projects not utilizing the Maven build system. Alternatively, you can build the DeltaSpike .jar files from source; for instructions, see Build DeltaSpike from Source. In both cases, you must add the DeltaSpike .jar files directly to your projects.

To use DeltaSpike without Maven from the downloadable .jar files, complete the following steps:

  1. Download the latest distribution-full-<version>.zip from https://deltaspike.apache.org/download.html

  2. Extract the archive contents

    $ unzip distribution-full-<version>.zip
  3. Add the source to your project

    1. For .war projects, copy the .jar files to the WEB-INF/lib directory

    2. For .ear projects, copy the .jar files to the EAR/lib directory and add the following to META-INF/application.xml:

      <library-directory>lib</library-directory>

Next