-
-
Notifications
You must be signed in to change notification settings - Fork 0
ProjectSetup
To setup a project for using Neuron DI, it's generally required to add a single dependency to the project. If your project is using Scala, it's also required to add the Macro Paradise plugin to the Scala compiler. If your project is using SBT, both can be easily done by applying the Neuron DI SBT Plugin to your project.
Assuming Neuron DI 6.0.1 is still the latest release, add the following line to project/plugins.sbt
:
addSbtPlugin("global.namespace.neuron-di" % "neuron-di-sbt-plugin" % "6.0.1")
Next, in build.sbt
, you need to add one of the following plugins to your project, depending on the application
environment and programming language:
Java | Scala | |
---|---|---|
Standalone | NeuronDIForJavaPlugin | NeuronDIForScalaPlugin |
Guice | NeuronDIAtGuiceForJavaPlugin | NeuronDIAtGuiceForScalaPlugin |
Play | TODO | NeuronDIAtGuiceForScalaPlugin* |
* There is no specific plugin for Play.
For example, to use Neuron DI in an application using Play For Scala with Guice, your build.sbt
file should contain
the following line:
lazy val root = (project in file(".")).enablePlugins(PlayScala, NeuronDIAtGuiceForScalaPlugin)
Note that this project definition enables two plugins, PlayForScala
and NeuronDIAtGuiceForScalaPlugin
.
The latter plugin modifies the project definition as follows:
- It adds a dependency on Neuron DI @ Guice For Scala 6.0.1 and its transitive dependency Guice 4.1.0.
- It adds the Macro Paradise plugin to the Scala compiler.
If your project is not built using SBT, you need to set it up manually. The following assumes that your project is built using Maven.
Depending on your application environment and programming language, you need to add one of the following dependencies to your build, identified as Maven coordinates:
For example, to use Neuron DI in a Java application using Guice, your pom.xml
file should contain the following XML
element in the element with the path /project/dependencies
:
<dependency>
<groupId>global.namespace.neuron-di</groupId>
<artifactId>neuron-di-guice</artifactId>
<version>6.0.1</version>
</dependency>
This adds a dependency on Neuron DI @ Guice For Scala 6.0.1 and its transitive dependency Guice 4.1.0.
If your project is using Scala, you also need to add the Macro Paradise plugin to the Scala compiler or
otherwise it would not understand the @Neuron
and @Caching
annotations in the Scala API of Neuron DI.
Note that the plugin is solely required for compiling your Scala source code:
It's not a runtime dependency of the compiled byte code!
Follow the instructions on this page to add the plugin to the Scala compiler.