@@ -5,61 +5,70 @@ import sbt.Keys.*
55
66/** A helper that can be used to configure the complex dependencies in the Akka Platform.
77 *
8- * IMPORTANT: Akka is licensed under the Business Source License (BSL) 1.1 as of 2024.
9- * Two separate credentials are required:
8+ * IMPORTANT: Akka is licensed under the Business Source License (BSL) 1.1 as of 2024. Two separate
9+ * credentials are required:
1010 *
11- * 1. AKKA_REPO_TOKEN - Repository access token for downloading artifacts.
12- * Set this environment variable with your token from https://account.akka.io
13- * Used in repository URL: https://repo.akka.io/{token}/secure
11+ * 1. AKKA_REPO_TOKEN - Repository access token for downloading artifacts. Set this environment
12+ * variable with your token from https://account.akka.io Used in repository URL:
13+ * https://repo.akka.io/{token}/secure
1414 *
15- * 2. akka.license-key - Runtime license key for your application.
16- * Configure this in your application.conf, NOT as an environment variable for sbt.
15+ * 2. akka.license-key - Runtime license key for your application. Configure this in your
16+ * application.conf, NOT as an environment variable for sbt.
1717 *
1818 * This helper automatically:
19- * - Adds the Akka repository resolver with tokenized URL (requires AKKA_REPO_TOKEN)
20- * - Configures CrossVersion.for3Use2_13 for Scala 3 projects (Akka is Scala 2.13 only)
19+ * - Adds the Akka repository resolver with tokenized URL (requires AKKA_REPO_TOKEN)
20+ * - Configures CrossVersion.for3Use2_13 for Scala 3 projects (Akka is Scala 2.13 only)
2121 */
2222object Akka extends AutoPluginHelper {
2323
24- /** Akka repository URL with embedded token.
25- * Akka uses tokenized URLs for authentication - the token is part of the URL path.
26- * See https://doc.akka.io/libraries/akka-dependencies/current/
24+ /** Akka repository URL with embedded token. Akka uses tokenized URLs for authentication - the
25+ * token is part of the URL path. See https://doc.akka.io/libraries/akka-dependencies/current/
2726 */
28- def akkaRepoUrl : String = {
27+ private def akkaRepoUrl : String = {
2928 sys.env.get(" AKKA_REPO_TOKEN" ) match {
3029 case Some (token) => s " https://repo.akka.io/ $token/secure "
3130 case None =>
3231 System .err.println(
3332 " WARNING: AKKA_REPO_TOKEN environment variable not set. " +
34- " Get your repository access token at https://account.akka.io"
33+ " Get your repository access token at https://account.akka.io"
3534 )
3635 // Return a URL that will fail with a clear error
3736 " https://repo.akka.io/MISSING_TOKEN/secure"
3837 }
3938 }
4039
4140 /** Akka Maven-style repository resolver */
42- def akkaMavenResolver : MavenRepository = " akka-secure-mvn" .at(akkaRepoUrl)
41+ private def akkaMavenResolver : MavenRepository = " akka-secure-mvn" .at(akkaRepoUrl)
4342
44- /** Akka Ivy-style repository resolver.
45- * Some Akka artifacts are published in Ivy format and require Ivy-style patterns.
43+ /** Akka Ivy-style repository resolver. Some Akka artifacts are published in Ivy format and
44+ * require Ivy-style patterns.
4645 */
47- def akkaIvyResolver : URLRepository =
46+ private def akkaIvyResolver : URLRepository =
4847 Resolver .url(" akka-secure-ivy" , url(akkaRepoUrl))(Resolver .ivyStylePatterns)
4948
5049 /** Both Akka resolvers (Maven and Ivy style) */
51- def akkaResolvers : Seq [Resolver ] = Seq (akkaMavenResolver, akkaIvyResolver)
50+ private def akkaResolvers : Seq [Resolver ] = Seq (akkaMavenResolver, akkaIvyResolver)
5251
5352 /** Helper to create Akka dependency with Scala 2.13 cross-version for Scala 3 compatibility */
54- def akkaModule (org : String , name : String , version : String ): ModuleID =
53+ private def akkaModule (org : String , name : String , version : String ): ModuleID =
5554 (org %% name % version).cross(CrossVersion .for3Use2_13)
5655
5756 /** Helper to create Akka test dependency with Scala 2.13 cross-version */
58- def akkaTestModule (org : String , name : String , version : String ): ModuleID =
57+ private def akkaTestModule (org : String , name : String , version : String ): ModuleID =
5958 (org %% name % version % Test ).cross(CrossVersion .for3Use2_13)
6059
60+ sealed trait ReleaseVersions {
61+ def akka_core : String
62+ def akka_http : String
63+ def akka_grpc : String
64+ def akka_persistence_r2dbc : String
65+ def akka_management : String
66+ def akka_projections : String
67+ def akka_kafka : String
68+ }
69+
6170 /** Version numbers for Akka 2024.10 release */
62- object V_24_10 {
71+ private object V_24_10 extends ReleaseVersions {
6372 val akka_core = " 2.10.0"
6473 val akka_http = " 10.7.0"
6574 val akka_grpc = " 2.5.0"
@@ -69,10 +78,10 @@ object Akka extends AutoPluginHelper {
6978 val akka_kafka = " 7.0.0"
7079 }
7180
72- /** Version numbers for Akka 25.10 release (latest as of Jan 2026)
73- * Version numbers from: https://doc.akka.io/libraries/akka-dependencies/current/
81+ /** Version numbers for Akka 25.10 release (latest as of Jan 2026) Version numbers from:
82+ * https://doc.akka.io/libraries/akka-dependencies/current/
7483 */
75- object V_25_10 {
84+ private object V_25_10 extends ReleaseVersions {
7685 val akka_core = " 2.10.14"
7786 val akka_http = " 10.7.3"
7887 val akka_grpc = " 2.5.10"
@@ -156,28 +165,59 @@ object Akka extends AutoPluginHelper {
156165 /** Configure Akka dependencies for a specific release.
157166 *
158167 * Automatically adds:
159- * - Akka repository resolvers (Maven and Ivy style) with tokenized URL from AKKA_LICENSE_KEY
160- * - Core Akka modules for the specified release
168+ * - Akka repository resolvers (Maven and Ivy style) with tokenized URL from AKKA_LICENSE_KEY
169+ * - Core Akka modules for the specified release
161170 *
162- * @param release The Akka release version ("25.10" or "24.10"). Default is latest (25.10).
163- * @param project The project to configure
164- * @return The configured project with Akka resolvers and core modules
171+ * @param release
172+ * The Akka release version ("25.10" or "24.10"). Default is latest (25.10).
173+ * @param project
174+ * The project to configure
175+ * @return
176+ * The configured project with Akka resolvers and core modules
165177 */
166- def forRelease (release : String = " " )(project : Project ): Project = {
167- val coreVersion = release match {
168- case " 2025.10" | " 25.10" | " latest" | " " => V_25_10 .akka_core
169- case " 2024.10" | " 24.10" => V_24_10 .akka_core
170- case other : String => throw new IllegalArgumentException (
171- s " Unknown Akka release: $other. Supported releases: 25.10 (latest), 24.10 "
172- )
178+ def forRelease (
179+ release : String = " " ,
180+ withHTTP : Boolean = false ,
181+ withGrpc : Boolean = false ,
182+ withPersistence : Boolean = false ,
183+ withProjections : Boolean = false ,
184+ withManagement : Boolean = false ,
185+ withKafka : Boolean = false
186+ )(project : Project ): Project = {
187+ val versions : ReleaseVersions = release match {
188+ case " 2025.10" | " 25.10" | " latest" | " " => V_25_10
189+ case " 2024.10" | " 24.10" => V_24_10
190+ case other : String =>
191+ throw new IllegalArgumentException (
192+ s " Unknown Akka release: $other. Supported releases: 25.10 (latest), 24.10 "
193+ )
173194 }
174195
175196 project.settings(
176197 resolvers ++= akkaResolvers,
177- libraryDependencies ++= coreModules(coreVersion)
198+ libraryDependencies ++= coreModules(versions.akka_core),
199+ libraryDependencies ++= coreTestModules(versions.akka_core),
200+ libraryDependencies ++= {
201+ Seq .empty[ModuleID ] ++ {
202+ if (withHTTP) httpModules(versions.akka_http) ++ httpTestModules(versions.akka_http)
203+ else Seq .empty[ModuleID ]
204+ } ++ {
205+ if (withGrpc) grpcModules(versions.akka_grpc) else Seq .empty[ModuleID ]
206+ } ++ {
207+ if (withPersistence) persistenceR2dbcModules(versions.akka_persistence_r2dbc)
208+ else Seq .empty[ModuleID ]
209+ } ++ {
210+ if (withProjections) projectionsModules(versions.akka_projections)
211+ else Seq .empty[ModuleID ]
212+ } ++ {
213+ if (withManagement) managementModules(versions.akka_management) else Seq .empty[ModuleID ]
214+ } ++ {
215+ if (withKafka) kafkaModules(versions.akka_kafka) else Seq .empty[ModuleID ]
216+ }
217+ }
178218 )
179219 }
180220
181- /** Configure Akka with latest release */
221+ /** Configure Akka with the latest release */
182222 def apply (project : Project ): Project = forRelease(" " )(project)
183223}
0 commit comments