在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称(OpenSource Name):ADTRAN/gradle-scala-multiversion-plugin开源软件地址(OpenSource Url):https://github.com/ADTRAN/gradle-scala-multiversion-plugin开源编程语言(OpenSource Language):Groovy 97.4%开源软件介绍(OpenSource Introduction):Scala Multi-Version PluginThis Gradle plugin allows a project to build against multiple versions of scala. You declare a list of scala versions
via a project property (e.g. compile "org.scala-lang:scala-library:%scala-version%" compile "org.scala-lang.modules:scala-parser-combinators_%%:1.0.4" Now when you run gradle tasks, they'll run once for each scala version. If you wish, you can also control which scala
versions get executed by default and override the default from the command line. Your jar file will also get the
appropriate suffix added (e.g. There's also a blog post about the plugin here. SetupAdding the PluginFirst, add the appropriate buildscript repository and dependency: buildscript { repositories { mavenCentral() } dependencies { classpath "com.adtran:scala-multiversion-plugin:1.+" } } Then apply the plugin using either the old style: apply plugin: "com.adtran.scala-multiversion-plugin" ...or the new style: plugins { id "com.adtran.scala-multiversion-plugin" } It's also available via plugins.gradle.org. For multi-project builds, it is recommended to apply the plugin individually to each relevant project/subproject. Setting Scala VersionsBefore use, you need to indicate which versions of scala you want to compile for by setting a Gradle property called
scalaVersions = 2.12.1, 2.11.8 Although you could also set (or override) it via the command line: gradle build -PscalaVersions=2.12.1,2.11.8 For multiproject builds, it is recommended that you set Updating DependenciesThe plugin allows you to use two different placeholders when declaring your dependencies which will then be substituted
with actual values before being resolved. The first is compile "org.scala-lang:scala-library:%scala-version%" The second placeholder is compile "org.scala-lang.modules:scala-parser-combinators_%%:1.0.4" These placeholders can also be configured. See Advanced Configuration. Other ThingsThis plugin will automatically append the scala version to the end of your artifact name (e.g.
Advanced ConfigurationThe only required configuration is to set the There are some tasks which should only be run once, even if multiple scala versions are being built. The "clean"
task, for example would wipe out previously generated artifacts if it ran before every recursive build invocation.
Also, if you have a multi-project build that contains some sub-projects that apply this plugin along with others that
don't (for example, a mixed scala/java/other project), then tasks will potentially be unnecessarily run multiple times
(once for each scala version) on the non-multi-version projects. Besides unnecessarily increasing build times, this
could cause problems with non-idempotent tasks (like artifact uploading). For this reason, you may optionally set the
You can also configure the placeholder values if they happen to cause a conflict, or you just like something else
aesthetically. To do so, add the following block in your scalaMultiVersion { scalaVersionPlaceholder = "%scala-version%" scalaSuffixPlaceholder = "_%%" }
UsageJust run gradle as usual. Any tasks you specify on the command line will be run once for each scala version selected (see section Advanced Configuration for details). Also potentially useful to your buildscript are several extra properties this plugin attaches to your project:
These could be useful, for example, if you wish to select a different dependency based on the scala version. For example: dependencies { if(scalaVersion.startsWith("2.12")) { compile "org.whatever:some-dependency:1.2.3" } else { compile "org.whatever:some-other-dependency:1.2.3" } } ExamplesRun All Versions by DefaultTo run your tasks for all scala versions by default, you would create a scalaVersions = 2.11.8, 2.12.1 Then you could run tasks like this...
Run a Single Version by DefaultIf you don't want to build for all versions by default, set scalaVersions = 2.11.8, 2.12.1 defaultScalaVersions = 2.12.1 Then run tasks like this...
Use with Composite BuildsGradle 3.1 introduced composite builds, which can be quite handy, especially when developing a library. Since this plugin is most useful for developing Scala libraries, it is helpful to note how this plugin interacts with composite builds. This plugin will cause the published artifact name to not match the project name (because it appends the scala suffix to
it). That means that just using includeBuild('../my-scala-library') { dependencySubstitution { substitute module('org.sample:my-scala-library_2.12') with project(':') } } If both projects use this plugin, then you are likely declaring your dependency on the included build using the includeBuild('../my-scala-library') { dependencySubstitution { substitute module('org.sample:my-scala-library_%%') with project(':') } } Known Limitations
Very Partial ChangelogVersion 2.0
LicenseThis project is licensed under the Apache License, Version 2.0 (http://www.apache.org/licenses/LICENSE-2.0). Copyright 2017, ADTRAN, Inc. ContributingIssues and pull requests are welcome if you have bugs/suggestions/improvements! |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论