├── .github ├── mergify.yml └── workflows │ ├── build-test.yml │ ├── dependency-graph.yml │ ├── publish.yml │ └── release-drafter.yml ├── .gitignore ├── .scala-steward.conf ├── LICENSE ├── README.md ├── build.sbt ├── project ├── build.properties ├── plugins.sbt └── project │ └── buildinfo.sbt └── src ├── main └── scala │ ├── PluginsAccessor.scala │ └── interplay │ ├── AutomaticModuleName.scala │ ├── Omnidoc.scala │ ├── PlayBuildBase.scala │ ├── PlayLibraryBase.scala │ ├── PlayNoPublishBase.scala │ ├── PlayRootProjectBase.scala │ ├── PlaySbtBuildBase.scala │ ├── PlaySbtLibraryBase.scala │ ├── PlaySbtPluginBase.scala │ ├── PlaySonatypeBase.scala │ ├── Playdoc.scala │ └── Versions.scala └── sbt-test └── interplay ├── library-with-plugin ├── .gitignore ├── build.sbt ├── project │ └── plugins.sbt └── test ├── library-with-root ├── .gitignore ├── build.sbt ├── project │ └── plugins.sbt └── test ├── library ├── .gitignore ├── build.sbt ├── project │ └── plugins.sbt └── test ├── plugin-with-root ├── .gitignore ├── build.sbt ├── project │ └── plugins.sbt └── test ├── plugin-without-cross-release ├── .gitignore ├── build.sbt ├── project │ └── plugins.sbt └── test └── plugin ├── .gitignore ├── build.sbt ├── project └── plugins.sbt └── test /.github/mergify.yml: -------------------------------------------------------------------------------- 1 | extends: .github 2 | -------------------------------------------------------------------------------- /.github/workflows/build-test.yml: -------------------------------------------------------------------------------- 1 | name: Check 2 | 3 | on: 4 | pull_request: 5 | 6 | push: 7 | branches: 8 | - main # Check branch after merge 9 | 10 | concurrency: 11 | # Only run once for latest commit per ref and cancel other (previous) runs. 12 | group: ci-${{ github.ref }} 13 | cancel-in-progress: true 14 | 15 | jobs: 16 | tests: 17 | name: Tests 18 | uses: playframework/.github/.github/workflows/cmd.yml@v3 19 | with: 20 | java: 17, 11 21 | scala: 2.12.x 22 | env: | 23 | BUILD_REASON=IndividualCI 24 | PGP_SECRET=Zm9v 25 | CI_COMMIT_TAG=foo 26 | cmd: sbt ++$MATRIX_SCALA "test ; publishLocal ; scripted" 27 | 28 | finish: 29 | name: Finish 30 | if: github.event_name == 'pull_request' 31 | needs: # Should be last 32 | - "tests" 33 | uses: playframework/.github/.github/workflows/rtm.yml@v3 34 | -------------------------------------------------------------------------------- /.github/workflows/dependency-graph.yml: -------------------------------------------------------------------------------- 1 | name: Dependency Graph 2 | on: 3 | push: 4 | branches: 5 | - main 6 | 7 | concurrency: 8 | # Only run once for latest commit per ref and cancel other (previous) runs. 9 | group: dependency-graph-${{ github.ref }} 10 | cancel-in-progress: true 11 | 12 | permissions: 13 | contents: write # this permission is needed to submit the dependency graph 14 | 15 | jobs: 16 | dependency-graph: 17 | name: Submit dependencies to GitHub 18 | runs-on: ubuntu-latest 19 | steps: 20 | - uses: actions/checkout@v3 21 | with: 22 | fetch-depth: 0 23 | ref: ${{ inputs.ref }} 24 | - uses: scalacenter/sbt-dependency-submission@v2 25 | -------------------------------------------------------------------------------- /.github/workflows/publish.yml: -------------------------------------------------------------------------------- 1 | name: Publish 2 | 3 | on: 4 | push: 5 | branches: # Snapshots 6 | - main 7 | tags: ["**"] # Releases 8 | release: 9 | types: [published] 10 | 11 | jobs: 12 | publish-artifacts: 13 | name: Publish / Artifacts 14 | uses: playframework/.github/.github/workflows/publish.yml@v3 15 | secrets: inherit 16 | -------------------------------------------------------------------------------- /.github/workflows/release-drafter.yml: -------------------------------------------------------------------------------- 1 | name: Release Drafter 2 | 3 | on: 4 | push: 5 | branches: 6 | - main 7 | 8 | jobs: 9 | update_release_draft: 10 | runs-on: ubuntu-latest 11 | steps: 12 | - uses: release-drafter/release-drafter@v5 13 | with: 14 | name: "Interplay $RESOLVED_VERSION" 15 | config-name: release-drafts/increasing-minor-version.yml # located in .github/ in the default branch within this or the .github repo 16 | commitish: ${{ github.ref_name }} 17 | env: 18 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 19 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | target 2 | .bsp/ 3 | .idea/ 4 | -------------------------------------------------------------------------------- /.scala-steward.conf: -------------------------------------------------------------------------------- 1 | pullRequests.frequency = "@monthly" 2 | 3 | commits.message = "${artifactName} ${nextVersion} (was ${currentVersion})" 4 | 5 | pullRequests.grouping = [ 6 | { name = "patches", "title" = "Patch updates", "filter" = [{"version" = "patch"}] } 7 | ] 8 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright [yyyy] [name of copyright owner] 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Interplay - Play Build plugins 2 | 3 | [![Twitter Follow](https://img.shields.io/twitter/follow/playframework?label=follow&style=flat&logo=twitter&color=brightgreen)](https://twitter.com/playframework) 4 | [![Discord](https://img.shields.io/discord/931647755942776882?logo=discord&logoColor=white)](https://discord.gg/g5s2vtZ4Fa) 5 | [![GitHub Discussions](https://img.shields.io/github/discussions/playframework/playframework?&logo=github&color=brightgreen)](https://github.com/playframework/playframework/discussions) 6 | [![StackOverflow](https://img.shields.io/static/v1?label=stackoverflow&logo=stackoverflow&logoColor=fe7a16&color=brightgreen&message=playframework)](https://stackoverflow.com/tags/playframework) 7 | [![YouTube](https://img.shields.io/youtube/channel/views/UCRp6QDm5SDjbIuisUpxV9cg?label=watch&logo=youtube&style=flat&color=brightgreen&logoColor=ff0000)](https://www.youtube.com/channel/UCRp6QDm5SDjbIuisUpxV9cg) 8 | [![Twitch Status](https://img.shields.io/twitch/status/playframework?logo=twitch&logoColor=white&color=brightgreen&label=live%20stream)](https://www.twitch.tv/playframework) 9 | [![OpenCollective](https://img.shields.io/opencollective/all/playframework?label=financial%20contributors&logo=open-collective)](https://opencollective.com/playframework) 10 | 11 | [![Build Status](https://github.com/playframework/interplay/actions/workflows/build-test.yml/badge.svg)](https://github.com/playframework/interplay/actions/workflows/build-test.yml) 12 | [![Maven](https://img.shields.io/maven-central/v/com.typesafe.play/interplay_2.13.svg?logo=apache-maven)](https://mvnrepository.com/artifact/com.typesafe.play/interplay_2.13) 13 | [![Repository size](https://img.shields.io/github/repo-size/playframework/interplay.svg?logo=git)](https://github.com/playframework/interplay) 14 | [![Scala Steward badge](https://img.shields.io/badge/Scala_Steward-helping-blue.svg?style=flat&logo=data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA4AAAAQCAMAAAARSr4IAAAAVFBMVEUAAACHjojlOy5NWlrKzcYRKjGFjIbp293YycuLa3pYY2LSqql4f3pCUFTgSjNodYRmcXUsPD/NTTbjRS+2jomhgnzNc223cGvZS0HaSD0XLjbaSjElhIr+AAAAAXRSTlMAQObYZgAAAHlJREFUCNdNyosOwyAIhWHAQS1Vt7a77/3fcxxdmv0xwmckutAR1nkm4ggbyEcg/wWmlGLDAA3oL50xi6fk5ffZ3E2E3QfZDCcCN2YtbEWZt+Drc6u6rlqv7Uk0LdKqqr5rk2UCRXOk0vmQKGfc94nOJyQjouF9H/wCc9gECEYfONoAAAAASUVORK5CYII=)](https://scala-steward.org) 15 | [![Mergify Status](https://img.shields.io/endpoint.svg?url=https://api.mergify.com/v1/badges/playframework/interplay&style=flat)](https://mergify.com) 16 | 17 | Interplay is a set of sbt plugins for Play builds, sharing common configuration between Play builds so that they can be configured in one place. 18 | 19 | ## Usage 20 | 21 | Ensure you're using sbt 0.13.15, by setting `sbt.version` in `project/build.properties`. 22 | 23 | Add the interplay plugin to `project/plugins.sbt`: 24 | 25 | ```scala 26 | addSbtPlugin("com.typesafe.play" % "interplay" % sys.props.get("interplay.version").getOrElse("2.1.2")) 27 | ``` 28 | 29 | By allowing the version to be overridden using system properties, this means the Play nightly builds can override it to use the latest version. 30 | 31 | Now which plugins you enable and what configuration you set depends on the structure of your build. In all cases, you should set `playBuildRepoName in ThisBuild` to be the name of the GitHub repository in the `playframework` organisation that the project lives in. 32 | 33 | ### Play libraries 34 | 35 | If your project is a simple library that gets used in a Play application then enable the `PlayLibrary` plugin on it. 36 | 37 | ### SBT plugins 38 | 39 | If your project is an sbt plugin, then enable the `PlaySbtPlugin` plugin on it. 40 | 41 | ### SBT libraries 42 | 43 | If your project is not an sbt plugin, but does get used by sbt, then enable the `PlaySbtLibrary` plugin on it. 44 | 45 | ### The root project 46 | 47 | If you have a root project that is just a meta project that aggregates all your projects together, but itself shouldn't be published, then enable the `PlayRootProject` plugin on it. 48 | 49 | ### Aggregating projects 50 | 51 | In general, your root project should aggregate all the projects you want to publish. If it aggregates projects that you don't want to publish, you can make them not published by enabling the `PlayNoPublish` plugin. 52 | 53 | ### Play docs 54 | 55 | If your project includes documentation that you want included in the main Play documentation, you can allow this by adding the `Playdoc` plugin to it. In that case you also will need to configure the `playdocDirectory` to point to the documentation directory. 56 | 57 | ## Releasing a new version 58 | 59 | See https://github.com/playframework/.github/blob/main/RELEASING.md 60 | -------------------------------------------------------------------------------- /build.sbt: -------------------------------------------------------------------------------- 1 | import _root_.interplay.ScalaVersions._ 2 | import buildinfo.BuildInfo._ 3 | 4 | // Customise sbt-dynver's behaviour to make it work with tags which aren't v-prefixed 5 | ThisBuild / dynverVTagPrefix := false 6 | 7 | // Sanity-check: assert that version comes from a tag (e.g. not a too-shallow clone) 8 | // https://github.com/dwijnand/sbt-dynver/#sanity-checking-the-version 9 | Global / onLoad := (Global / onLoad).value.andThen { s => 10 | dynverAssertTagVersion.value 11 | s 12 | } 13 | 14 | lazy val interplay = (project in file(".")) 15 | .enablePlugins(PlaySbtPlugin) 16 | 17 | description := "Base build plugin for all Play modules" 18 | 19 | addSbtPlugin("com.github.sbt" % "sbt-ci-release" % sbtCiReleaseVersion) 20 | 21 | libraryDependencies += "com.typesafe" % "config" % configVersion 22 | 23 | scalacOptions ++= Seq( 24 | "-release:11", 25 | "-Xlint", 26 | "-Ywarn-unused:imports", 27 | "-Xlint:nullary-unit", 28 | "-Ywarn-dead-code", 29 | ) 30 | 31 | javacOptions ++= Seq( 32 | "--release", "11", 33 | "-Xlint:deprecation", 34 | "-Xlint:unchecked", 35 | ) 36 | 37 | // Supply the sbt.version to the scripted tests so 38 | // that they can be run with either sbt 0.13 or 39 | // sbt 1. 40 | scriptedLaunchOpts += { 41 | val sbtV = (pluginCrossBuild / sbtVersion).value 42 | s"-Dsbt.version=$sbtV" 43 | } 44 | 45 | ThisBuild / playBuildRepoName := "interplay" 46 | 47 | enablePlugins(SbtPlugin) 48 | -------------------------------------------------------------------------------- /project/build.properties: -------------------------------------------------------------------------------- 1 | sbt.version=1.9.6 2 | -------------------------------------------------------------------------------- /project/plugins.sbt: -------------------------------------------------------------------------------- 1 | import java.util.Locale 2 | 3 | libraryDependencies ++= Seq( 4 | "org.scala-sbt" %% "scripted-plugin" % sbtVersion.value, 5 | "com.typesafe" % "config" % "1.4.3" 6 | ) 7 | 8 | addSbtPlugin("com.github.sbt" % "sbt-ci-release" % "1.5.12") 9 | 10 | lazy val build = (project in file(".")). 11 | enablePlugins(BuildInfoPlugin). 12 | settings( 13 | buildInfoKeys := libraryDependencies.value.map { module => 14 | val key = "-([a-z])".r.replaceAllIn(module.name, matched => matched.group(1).toUpperCase(Locale.ENGLISH)) + "Version" 15 | (key -> module.revision): BuildInfoKey 16 | } 17 | ) 18 | 19 | // The interplay "meta-build"—the stuff inside the `project` 20 | // directory—uses interplay as a plugin. Since we haven't run the 21 | // interplay "proper build"—the stuff in the root directory—yet we 22 | // can't just say "addSbtPlugin(..."interplay"...) we need to actually 23 | // compile the plugin sources as part of the meta-build. 24 | // 25 | // We do this by adding some of the interplay source directories to 26 | // the meta-build. This means that interplay will be compiled once as 27 | // part of the meta-build (but not published) and then *again* as part 28 | // of the proper build (where it is properly cross-compiled and 29 | // published). 30 | Compile / unmanagedSourceDirectories ++= Seq( 31 | baseDirectory.value.getParentFile / "src" / "main" / "scala" 32 | ) 33 | -------------------------------------------------------------------------------- /project/project/buildinfo.sbt: -------------------------------------------------------------------------------- 1 | addSbtPlugin("com.eed3si9n" % "sbt-buildinfo" % "0.11.0") -------------------------------------------------------------------------------- /src/main/scala/PluginsAccessor.scala: -------------------------------------------------------------------------------- 1 | package sbt 2 | 3 | /** 4 | * Work around sbts private[sbt] on some plugin functions 5 | */ 6 | object PluginsAccessor { 7 | 8 | /** 9 | * Exclude a plugin 10 | */ 11 | def exclude(plugin: AutoPlugin): Plugins.Basic = Plugins.Exclude(plugin) 12 | } 13 | -------------------------------------------------------------------------------- /src/main/scala/interplay/AutomaticModuleName.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) from 2022 The Play Framework Contributors , 2011-2021 Lightbend Inc. 3 | */ 4 | package interplay 5 | 6 | import sbt.Def 7 | import sbt._ 8 | import sbt.Keys._ 9 | 10 | /** 11 | * Helper to set Automatic-Module-Name in projects. 12 | * 13 | * !! DO NOT BE TEMPTED INTO AUTOMATICALLY DERIVING THE NAMES FROM PROJECT NAMES !! 14 | * 15 | * The names carry a lot of implications and DO NOT have to always align 1:1 with the group ids or package names, 16 | * though there should be of course a strong relationship between them. 17 | */ 18 | object AutomaticModuleName { 19 | private val AutomaticModuleName = "Automatic-Module-Name" 20 | 21 | def settings(name: String): Seq[Def.Setting[Task[Seq[PackageOption]]]] = Seq( 22 | Compile / packageBin / packageOptions += Package.ManifestAttributes(AutomaticModuleName -> name) 23 | ) 24 | } 25 | -------------------------------------------------------------------------------- /src/main/scala/interplay/Omnidoc.scala: -------------------------------------------------------------------------------- 1 | package interplay 2 | 3 | import sbt._ 4 | import sbt.Keys._ 5 | import sbt.Package.ManifestAttributes 6 | 7 | 8 | /** 9 | * This AutoPlugin adds the `Omnidoc-Source-URL` key on the MANIFEST.MF of artifact-sources.jar so 10 | * later Omnidoc can use that value to link scaladocs to GitHub sources. 11 | */ 12 | object Omnidoc extends AutoPlugin { 13 | 14 | object autoImport { 15 | lazy val omnidocGithubRepo = settingKey[String]("Github repository for source URL") 16 | lazy val omnidocSnapshotBranch = settingKey[String]("Git branch for development versions") 17 | lazy val omnidocTagPrefix = settingKey[String]("Prefix before git tagged versions") 18 | lazy val omnidocPathPrefix = settingKey[String]("Prefix before source directory paths") 19 | lazy val omnidocSourceUrl = settingKey[Option[String]]("Source URL for scaladoc linking") 20 | } 21 | 22 | val SourceUrlKey = "Omnidoc-Source-URL" 23 | 24 | override def requires = sbt.plugins.JvmPlugin 25 | 26 | override def trigger = noTrigger 27 | 28 | import autoImport._ 29 | 30 | override def projectSettings = Seq( 31 | omnidocSourceUrl := omnidocGithubRepo.?.value map { repo => 32 | val development: String = (omnidocSnapshotBranch ?? "main").value 33 | val tagged: String = (omnidocTagPrefix ?? "v").value + version.value 34 | val tree: String = if (isSnapshot.value) development else tagged 35 | val prefix: String = "/" + (omnidocPathPrefix ?? "").value 36 | val path: String = { 37 | val buildDir: File = (ThisBuild / baseDirectory).value 38 | val projDir: File = baseDirectory.value 39 | val rel: Option[String] = IO.relativize(buildDir, projDir) 40 | rel match { 41 | case None if buildDir == projDir => "" // Same dir (sbt 0.13) 42 | case Some("") => "" // Same dir (sbt 1.0) 43 | case Some(childDir) => prefix + childDir // Child dir 44 | case None => "" // Disjoint dirs (Rich: I'm not sure if this can happen) 45 | } 46 | } 47 | s"https://github.com/${repo}/tree/${tree}${path}" 48 | }, 49 | Compile / packageSrc / packageOptions ++= omnidocSourceUrl.value.toSeq map { url => 50 | ManifestAttributes(SourceUrlKey -> url) 51 | } 52 | ) 53 | 54 | } 55 | -------------------------------------------------------------------------------- /src/main/scala/interplay/PlayBuildBase.scala: -------------------------------------------------------------------------------- 1 | package interplay 2 | 3 | import sbt._ 4 | import sbt.Keys._ 5 | import sbt.plugins.JvmPlugin 6 | import xerial.sbt.Sonatype 7 | import com.jsuereth.sbtpgp.SbtPgp 8 | 9 | /** 10 | * Plugin that defines base settings for all Play projects 11 | */ 12 | object PlayBuildBase extends AutoPlugin { 13 | override def trigger = allRequirements 14 | override def requires = SbtPgp && JvmPlugin 15 | 16 | object autoImport { 17 | val playBuildRepoName = settingKey[String]("The name of the repository in the playframework GitHub organization") 18 | 19 | /** 20 | * Plugins configuration for a Play sbt plugin. 21 | */ 22 | def PlaySbtPlugin: Plugins = PlaySbtPluginBase 23 | 24 | /** 25 | * Plugins configuration for a Play sbt library. 26 | */ 27 | def PlaySbtLibrary: Plugins = PlaySbtLibraryBase 28 | 29 | /** 30 | * Plugins configuration for a Play library. 31 | */ 32 | def PlayLibrary: Plugins = PlayLibraryBase 33 | 34 | /** 35 | * Plugins configuration for a Play Root Project that doesn't get published. 36 | */ 37 | def PlayRootProject: Plugins = PlayRootProjectBase 38 | 39 | /** 40 | * Plugins configuration for a Play project that doesn't get published. 41 | */ 42 | def PlayNoPublish: Plugins = PlayNoPublishBase && PluginsAccessor.exclude(Sonatype) 43 | 44 | /** 45 | * Convenience function to get the Play version. Allows the version to be overridden by a system property, which is 46 | * necessary for the nightly build. 47 | */ 48 | def playVersion(version: String): String = sys.props.getOrElse("play.version", version) 49 | } 50 | 51 | import autoImport._ 52 | 53 | override def projectSettings = Seq( 54 | // General settings 55 | organization := "com.typesafe.play", 56 | organizationName := "The Play Framework Project", 57 | organizationHomepage := Some(url("https://playframework.com")), 58 | homepage := Some(url(s"https://github.com/playframework/${(ThisBuild / playBuildRepoName).value}")), 59 | licenses := Seq("Apache-2.0" -> url("http://www.apache.org/licenses/LICENSE-2.0.html")), 60 | 61 | scalacOptions ++= Seq("-deprecation", "-feature", "-unchecked", "-encoding", "utf8") ++ 62 | (CrossVersion.partialVersion(scalaVersion.value) match { 63 | case Some((2, 13)) => Seq("-Xsource:3", "-Xmigration") 64 | case _ => Seq.empty 65 | }), 66 | javacOptions ++= Seq("-encoding", "UTF-8", "-Xlint:-options"), 67 | 68 | resolvers ++= { 69 | if (isSnapshot.value) { 70 | Opts.resolver.sonatypeOssSnapshots 71 | } else { 72 | Nil 73 | } 74 | }, 75 | 76 | developers += Developer("playframework", "The Play Framework Contributors", "contact@playframework.com", url("https://github.com/playframework")), 77 | pomIncludeRepository := { _ => false } 78 | ) 79 | } 80 | -------------------------------------------------------------------------------- /src/main/scala/interplay/PlayLibraryBase.scala: -------------------------------------------------------------------------------- 1 | package interplay 2 | 3 | import sbt.{ AutoPlugin, ThisBuild } 4 | import sbt.Keys._ 5 | import interplay.Omnidoc.autoImport.omnidocGithubRepo 6 | import interplay.Omnidoc.autoImport.omnidocTagPrefix 7 | import sbt.librarymanagement.{ SemanticSelector, VersionNumber } 8 | 9 | /** 10 | * Base Plugin for Play libraries. 11 | * 12 | * - Publishes to sonatype 13 | * - Includes omnidoc configuration 14 | * - Cross builds the project 15 | */ 16 | object PlayLibraryBase extends AutoPlugin { 17 | 18 | override def trigger = noTrigger 19 | override def requires = PlayBuildBase && PlaySonatypeBase && Omnidoc 20 | 21 | import PlayBuildBase.autoImport._ 22 | 23 | override def projectSettings = Seq( 24 | omnidocGithubRepo := s"playframework/${(ThisBuild / playBuildRepoName).value}", 25 | omnidocTagPrefix := "", 26 | compile / javacOptions ++= Seq("--release", "11"), 27 | doc / javacOptions := Seq("-source", "11"), 28 | crossScalaVersions := Seq(scalaVersion.value, ScalaVersions.scala3), 29 | scalaVersion := (Seq(ScalaVersions.scala213, ScalaVersions.scala3) 30 | .filter(v => SemanticSelector(sys.props.get("scala.version").getOrElse(ScalaVersions.scala213)).matches(VersionNumber(v))) match { 31 | case Nil => sys.error("Unable to detect scalaVersion!") 32 | case Seq(version) => version 33 | case multiple => sys.error(s"Multiple crossScalaVersions matched query '${sys.props("scala.version")}': ${multiple.mkString(", ")}") 34 | }), 35 | ) 36 | } 37 | -------------------------------------------------------------------------------- /src/main/scala/interplay/PlayNoPublishBase.scala: -------------------------------------------------------------------------------- 1 | package interplay 2 | 3 | import sbt._ 4 | import sbt.Keys._ 5 | import sbt.Resolver 6 | import com.jsuereth.sbtpgp.PgpKeys 7 | 8 | object PlayNoPublishBase extends AutoPlugin { 9 | override def trigger = noTrigger 10 | override def requires = PlayBuildBase 11 | 12 | override def projectSettings = Seq( 13 | PgpKeys.publishSigned := {}, 14 | publish := {}, 15 | publishLocal := {}, 16 | publishTo := Some(Resolver.file("no-publish", crossTarget.value / "no-publish")) 17 | ) 18 | } 19 | -------------------------------------------------------------------------------- /src/main/scala/interplay/PlayRootProjectBase.scala: -------------------------------------------------------------------------------- 1 | package interplay 2 | 3 | import sbt._ 4 | 5 | /** 6 | * Base Plugin for a root project that doesn't get published. 7 | * 8 | * - Contains release configuration 9 | */ 10 | object PlayRootProjectBase extends AutoPlugin { 11 | override def trigger = noTrigger 12 | override def requires = PlayBuildBase && PlaySonatypeBase 13 | override def projectSettings = PlayNoPublishBase.projectSettings 14 | } 15 | -------------------------------------------------------------------------------- /src/main/scala/interplay/PlaySbtBuildBase.scala: -------------------------------------------------------------------------------- 1 | package interplay 2 | 3 | import sbt._ 4 | import sbt.Keys._ 5 | 6 | private[interplay] object PlaySbtBuildBase extends AutoPlugin { 7 | 8 | override def trigger = noTrigger 9 | override def requires = PlayBuildBase 10 | 11 | override def projectSettings = Seq( 12 | scalaVersion := ScalaVersions.scala212, 13 | crossScalaVersions := Seq(ScalaVersions.scala212), 14 | pluginCrossBuild / sbtVersion := SbtVersions.sbt19, 15 | compile / javacOptions ++= Seq("--release", "11"), 16 | doc / javacOptions := Seq("-source", "11") 17 | ) 18 | } 19 | -------------------------------------------------------------------------------- /src/main/scala/interplay/PlaySbtLibraryBase.scala: -------------------------------------------------------------------------------- 1 | package interplay 2 | 3 | import sbt.{ AutoPlugin } 4 | 5 | /** 6 | * Base Plugin for Play SBT libraries. 7 | * 8 | * - Publishes to sonatype 9 | */ 10 | object PlaySbtLibraryBase extends AutoPlugin { 11 | 12 | override def trigger = noTrigger 13 | override def requires = PlayBuildBase && PlaySbtBuildBase && PlaySonatypeBase 14 | 15 | } 16 | -------------------------------------------------------------------------------- /src/main/scala/interplay/PlaySbtPluginBase.scala: -------------------------------------------------------------------------------- 1 | package interplay 2 | 3 | import sbt._ 4 | import sbt.Keys._ 5 | import sbt.plugins.SbtPlugin 6 | import sbt.ScriptedPlugin.autoImport._ 7 | 8 | /** 9 | * Base Plugin for Play sbt plugins. 10 | * 11 | * - Publishes the plugin to sonatype 12 | * - Adds scripted configuration. 13 | */ 14 | object PlaySbtPluginBase extends AutoPlugin { 15 | 16 | override def trigger = noTrigger 17 | override def requires = PlaySonatypeBase && PlayBuildBase && PlaySbtBuildBase && SbtPlugin 18 | 19 | override def projectSettings = Seq( 20 | scriptedLaunchOpts += (version apply { v => s"-Dproject.version=$v" }).value 21 | ) 22 | } 23 | -------------------------------------------------------------------------------- /src/main/scala/interplay/PlaySonatypeBase.scala: -------------------------------------------------------------------------------- 1 | package interplay 2 | 3 | import sbt.AutoPlugin 4 | import xerial.sbt.Sonatype 5 | import xerial.sbt.Sonatype.autoImport.sonatypeProfileName 6 | 7 | /** 8 | * Base plugin for all projects that publish to sonatype (which is all of them!) 9 | */ 10 | object PlaySonatypeBase extends AutoPlugin { 11 | override def trigger = noTrigger 12 | override def requires = Sonatype 13 | 14 | override def projectSettings = Seq( 15 | sonatypeProfileName := "com.typesafe.play" 16 | ) 17 | } 18 | -------------------------------------------------------------------------------- /src/main/scala/interplay/Playdoc.scala: -------------------------------------------------------------------------------- 1 | package interplay 2 | 3 | import sbt._ 4 | import sbt.Keys._ 5 | import sbt.io.IO 6 | 7 | object Playdoc extends AutoPlugin { 8 | 9 | object autoImport { 10 | final val Docs = config("docs") 11 | val playdocDirectory = settingKey[File]("Base directory of play documentation") 12 | val playdocPackage = taskKey[File]("Package play documentation") 13 | } 14 | 15 | import autoImport._ 16 | 17 | override def requires = sbt.plugins.JvmPlugin 18 | 19 | override def trigger = noTrigger 20 | 21 | override def projectSettings = 22 | Defaults.packageTaskSettings(playdocPackage, playdocPackage / mappings) ++ 23 | Seq( 24 | playdocDirectory := (ThisBuild / baseDirectory).value / "docs" / "manual", 25 | playdocPackage / mappings := { 26 | val base: File = playdocDirectory.value 27 | base.allPaths.pair(IO.relativize(base.getParentFile(), _)) 28 | }, 29 | playdocPackage / artifactClassifier := Some("playdoc"), 30 | playdocPackage / artifact ~= { _.withConfigurations(Vector(Docs)) } 31 | ) ++ 32 | addArtifact(playdocPackage / artifact, playdocPackage) 33 | 34 | } 35 | -------------------------------------------------------------------------------- /src/main/scala/interplay/Versions.scala: -------------------------------------------------------------------------------- 1 | package interplay 2 | 3 | object ScalaVersions { 4 | val scala212 = "2.12.18" 5 | val scala213 = "2.13.12" 6 | val scala3 = "3.3.1" 7 | } 8 | 9 | object SbtVersions { 10 | val sbt19 = "1.9.6" 11 | } 12 | -------------------------------------------------------------------------------- /src/sbt-test/interplay/library-with-plugin/.gitignore: -------------------------------------------------------------------------------- 1 | target 2 | .bsp 3 | project/build.properties 4 | # global is created by scripted 5 | global 6 | -------------------------------------------------------------------------------- /src/sbt-test/interplay/library-with-plugin/build.sbt: -------------------------------------------------------------------------------- 1 | import interplay.ScalaVersions._ 2 | 3 | // Customise sbt-dynver's behaviour to make it work with tags which aren't v-prefixed 4 | (ThisBuild / dynverVTagPrefix) := false 5 | 6 | lazy val common: Seq[Setting[_]] = Seq( 7 | PgpKeys.publishSigned := { 8 | IO.write(crossTarget.value / "publish-version", s"${publishTo.value.get.name}:${version.value}") 9 | }, 10 | publish := { throw sys.error("Publish should not have been invoked") }, 11 | credentials := Seq(Credentials("Sonatype Nexus Repository Manager", "oss.sonatype.org", "sbt", "notcorrectpassword")) 12 | ) 13 | 14 | // What an actual project would look like 15 | lazy val `mock-root` = (project in file(".")) 16 | .settings( 17 | common, 18 | crossScalaVersions := Seq(scala212, scala213, scala3) 19 | ) 20 | .enablePlugins(PlayRootProject) 21 | .aggregate(`mock-library`, `mock-sbt-plugin`) // has a sbt plugin that will be built together with root project 22 | 23 | lazy val `mock-sbt-plugin` = (project in file("mock-sbt-plugin")) 24 | .enablePlugins(PlaySbtPlugin) 25 | .dependsOn(`mock-sbt-library`) 26 | .settings( 27 | common, 28 | ) 29 | 30 | lazy val `mock-sbt-library` = (project in file("mock-sbt-library")) 31 | .enablePlugins(PlaySbtLibrary) 32 | .settings(common) 33 | 34 | lazy val `mock-library` = (project in file("mock-library")) 35 | .enablePlugins(PlayLibrary) 36 | .settings(common) 37 | 38 | ThisBuild / playBuildRepoName := "mock" 39 | 40 | // Below this line is for facilitating tests 41 | 42 | InputKey[Unit]("contains") := { 43 | val args = Def.spaceDelimited().parsed 44 | val filename = args.head.replace("target/SCALA3/", s"target/scala-${crossScalaVersions.value.find(_.startsWith("3.")).getOrElse("")}/") 45 | val expected = args.tail.mkString(" ") 46 | val contents: String = IO.read(file(filename)) 47 | if (contents.contains(expected)) { 48 | println(s"Checked that $filename contains $expected") 49 | } else { 50 | throw sys.error(s"File $filename does not contain '$expected':\n$contents") 51 | } 52 | } 53 | 54 | ThisBuild / commands := { 55 | Seq("sonatypeRelease", "sonatypeBundleRelease").map { name => 56 | Command.command(name) { state => 57 | val extracted = Project.extract(state) 58 | IO.write(extracted.get(target) / "sonatype-release-version", extracted.get(version)) 59 | state 60 | } 61 | } ++ (ThisBuild / commands).value 62 | } 63 | -------------------------------------------------------------------------------- /src/sbt-test/interplay/library-with-plugin/project/plugins.sbt: -------------------------------------------------------------------------------- 1 | addSbtPlugin("com.typesafe.play" % "interplay" % sys.props("project.version")) -------------------------------------------------------------------------------- /src/sbt-test/interplay/library-with-plugin/test: -------------------------------------------------------------------------------- 1 | # Setup local git repo 2 | $ exec git init 3 | $ exec git checkout -b main 4 | # Need to configure name/email since on build server it's not set 5 | $ exec git config user.email sbt@example.com 6 | $ exec git config user.name sbt 7 | $ exec git add . 8 | $ exec git commit -m commit 9 | 10 | $ exec git tag 1.2.3 11 | 12 | # Setup remote git repo in target directory 13 | $ exec git init --bare $PWD/target/remote 14 | $ exec git remote add origin $PWD/target/remote 15 | $ exec git push origin main --tags 16 | $ exec git branch -u origin/main 17 | 18 | # A reload is necessary because sbt-release uses the initial state of the project to check if a .git folder exists (and errors if that check fails). 19 | # However, that initial state does not contain the above created .git folder (created via git init) yet. 20 | > reload 21 | 22 | > ci-release 23 | 24 | # Make sure publishSigned ran on every project with the right publish settings 25 | > contains target/SCALA3/publish-version no-publish:1.2.3 26 | > contains target/scala-2.13/publish-version no-publish:1.2.3 27 | > contains target/scala-2.12/publish-version no-publish:1.2.3 28 | > contains mock-sbt-plugin/target/scala-2.12/sbt-1.0/publish-version sonatype-local-bundle:1.2.3 29 | > contains mock-library/target/SCALA3/publish-version sonatype-local-bundle:1.2.3 30 | > contains mock-library/target/scala-2.13/publish-version sonatype-local-bundle:1.2.3 31 | 32 | # Make sure sonatypeRelease ran only in the root project 33 | > contains target/sonatype-release-version 1.2.3 34 | -$ exists mock-sbt-plugin/target/sonatype-release-version 35 | -$ exists mock-sbt-library/target/sonatype-release-version 36 | -$ exists mock-library/target/sonatype-release-version 37 | 38 | # Make sure the git repo was tagged 39 | $ exec git show 1.2.3 40 | -------------------------------------------------------------------------------- /src/sbt-test/interplay/library-with-root/.gitignore: -------------------------------------------------------------------------------- 1 | target 2 | .bsp 3 | project/build.properties 4 | # global is created by scripted 5 | global 6 | -------------------------------------------------------------------------------- /src/sbt-test/interplay/library-with-root/build.sbt: -------------------------------------------------------------------------------- 1 | import interplay.ScalaVersions._ 2 | 3 | // What an actual project would look like 4 | lazy val `mock-root` = (project in file(".")) 5 | .enablePlugins(PlayRootProject) 6 | .aggregate(`mock-library`) 7 | .settings( 8 | common, 9 | crossScalaVersions := Seq(scala212, scala213, scala3) 10 | ) 11 | 12 | lazy val `mock-library` = (project in file("mock-library")) 13 | .enablePlugins(PlayLibrary) 14 | .settings(common) 15 | 16 | ThisBuild / playBuildRepoName := "mock" 17 | 18 | // Customise sbt-dynver's behaviour to make it work with tags which aren't v-prefixed 19 | (ThisBuild / dynverVTagPrefix) := false 20 | 21 | // Below this line is for facilitating tests 22 | InputKey[Unit]("contains") := { 23 | val args = Def.spaceDelimited().parsed 24 | val filename = args.head.replace("target/SCALA3/", s"target/scala-${crossScalaVersions.value.find(_.startsWith("3.")).getOrElse("")}/") 25 | val contents = IO.read(file(filename)) 26 | val expected = args.tail.mkString(" ") 27 | if (!contents.contains(expected)) { 28 | throw sys.error(s"File ${filename} does not contain '$expected':\n$contents") 29 | } 30 | } 31 | 32 | def common: Seq[Setting[_]] = Seq( 33 | PgpKeys.publishSigned := { 34 | IO.write(crossTarget.value / "publish-version", s"${publishTo.value.get.name}:${version.value}") 35 | }, 36 | publish := { throw sys.error("Publish should not have been invoked") }, 37 | credentials := Seq(Credentials("Sonatype Nexus Repository Manager", "oss.sonatype.org", "sbt", "notcorrectpassword")) 38 | ) 39 | 40 | ThisBuild / commands := { 41 | Seq("sonatypeRelease", "sonatypeBundleRelease").map { name => 42 | Command.command(name) { state => 43 | val extracted = Project.extract(state) 44 | IO.write(extracted.get(target) / "sonatype-release-version", extracted.get(version)) 45 | state 46 | } 47 | } ++ (ThisBuild / commands).value 48 | } 49 | -------------------------------------------------------------------------------- /src/sbt-test/interplay/library-with-root/project/plugins.sbt: -------------------------------------------------------------------------------- 1 | addSbtPlugin("com.typesafe.play" % "interplay" % sys.props("project.version")) -------------------------------------------------------------------------------- /src/sbt-test/interplay/library-with-root/test: -------------------------------------------------------------------------------- 1 | # Setup local git repo 2 | $ exec git init 3 | $ exec git checkout -b main 4 | # Need to configure name/email since on build server it's not set 5 | $ exec git config user.email sbt@example.com 6 | $ exec git config user.name sbt 7 | $ exec git add . 8 | $ exec git commit -m commit 9 | 10 | $ exec git tag 1.2.3 11 | 12 | # Setup remote git repo in target directory 13 | $ exec git init --bare $PWD/target/remote 14 | $ exec git remote add origin $PWD/target/remote 15 | $ exec git push origin main --tags 16 | $ exec git branch -u origin/main 17 | 18 | # A reload is necessary because sbt-release uses the initial state of the project to check if a .git folder exists (and errors if that check fails). 19 | # However, that initial state does not contain the above created .git folder (created via git init) yet. 20 | > reload 21 | 22 | > ci-release 23 | 24 | # Make sure publishSigned ran on every project with the right publish settings 25 | > contains target/SCALA3/publish-version no-publish:1.2.3 26 | > contains target/scala-2.13/publish-version no-publish:1.2.3 27 | > contains target/scala-2.12/publish-version no-publish:1.2.3 28 | > contains mock-library/target/SCALA3/publish-version sonatype-local-bundle:1.2.3 29 | > contains mock-library/target/scala-2.13/publish-version sonatype-local-bundle:1.2.3 30 | 31 | # Make sure sonatypeRelease ran only in the root project 32 | > contains target/sonatype-release-version 1.2.3 33 | -$ exists mock-library/target/sonatype-release-version 34 | 35 | # Make sure the git repo was tagged 36 | $ exec git show 1.2.3 37 | -------------------------------------------------------------------------------- /src/sbt-test/interplay/library/.gitignore: -------------------------------------------------------------------------------- 1 | target 2 | .bsp 3 | project/build.properties 4 | # global is created by scripted 5 | global 6 | -------------------------------------------------------------------------------- /src/sbt-test/interplay/library/build.sbt: -------------------------------------------------------------------------------- 1 | lazy val `mock-library` = (project in file(".")) 2 | .enablePlugins(PlayLibrary) 3 | .settings(common: _*) 4 | 5 | ThisBuild / playBuildRepoName := "mock" 6 | 7 | // Customise sbt-dynver's behaviour to make it work with tags which aren't v-prefixed 8 | (ThisBuild / dynverVTagPrefix) := false 9 | 10 | // Below this line is for facilitating tests 11 | InputKey[Unit]("contains") := { 12 | val args = Def.spaceDelimited().parsed 13 | val filename = args.head.replace("target/SCALA3/", s"target/scala-${crossScalaVersions.value.find(_.startsWith("3.")).getOrElse("")}/") 14 | val contents = IO.read(file(filename)) 15 | val expected = args.tail.mkString(" ") 16 | if (!contents.contains(expected)) { 17 | throw sys.error(s"File ${filename} does not contain '$expected':\n$contents") 18 | } 19 | } 20 | 21 | TaskKey[Unit]("verifyOmnidocSourceUrl") := { 22 | import java.util.jar.JarFile 23 | 24 | val expected = "https://github.com/playframework/mock/tree/1.2.3" 25 | 26 | val sourceUrl = omnidocSourceUrl.value 27 | sourceUrl match { 28 | case Some(`expected`) => () 29 | case other => throw sys.error(s"Expected $expected source url, got $other") 30 | } 31 | 32 | val srcZip = (Compile / packageSrc).value 33 | val jarFile = new JarFile(srcZip) 34 | val manifest = jarFile.getManifest.getMainAttributes 35 | 36 | manifest.getValue(Omnidoc.SourceUrlKey) match { 37 | case `expected` => () 38 | case other => throw sys.error(s"Expected $expected source url, got $other") 39 | } 40 | jarFile.close() 41 | } 42 | 43 | def common: Seq[Setting[_]] = Seq( 44 | PgpKeys.publishSigned := { 45 | IO.write(crossTarget.value / "publish-version", s"${publishTo.value.get.name}:${version.value}") 46 | }, 47 | publish := { throw sys.error("Publish should not have been invoked") }, 48 | credentials := Seq(Credentials("Sonatype Nexus Repository Manager", "oss.sonatype.org", "sbt", "notcorrectpassword")) 49 | ) 50 | 51 | ThisBuild / commands := { 52 | Seq("sonatypeRelease", "sonatypeBundleRelease").map { name => 53 | Command.command(name) { state => 54 | val extracted = Project.extract(state) 55 | IO.write(extracted.get(target) / "sonatype-release-version", extracted.get(version)) 56 | state 57 | } 58 | } ++ (ThisBuild / commands).value 59 | } 60 | -------------------------------------------------------------------------------- /src/sbt-test/interplay/library/project/plugins.sbt: -------------------------------------------------------------------------------- 1 | addSbtPlugin("com.typesafe.play" % "interplay" % sys.props("project.version")) -------------------------------------------------------------------------------- /src/sbt-test/interplay/library/test: -------------------------------------------------------------------------------- 1 | # Setup local git repo 2 | $ exec git init 3 | $ exec git checkout -b main 4 | # Need to configure name/email since on build server it's not set 5 | $ exec git config user.email sbt@example.com 6 | $ exec git config user.name sbt 7 | $ exec git add . 8 | $ exec git commit -m commit 9 | 10 | $ exec git tag 1.2.3 11 | 12 | # Setup remote git repo in target directory 13 | $ exec git init --bare $PWD/target/remote 14 | $ exec git remote add origin $PWD/target/remote 15 | $ exec git push origin main --tags 16 | $ exec git branch -u origin/main 17 | 18 | $ exec git status 19 | $ exec git diff 20 | 21 | # A reload is necessary because sbt-release uses the initial state of the project to check if a .git folder exists (and errors if that check fails). 22 | # However, that initial state does not contain the above created .git folder (created via git init) yet. 23 | > reload 24 | 25 | > ci-release 26 | 27 | # Make sure publishSigned ran 28 | > contains target/SCALA3/publish-version sonatype-local-bundle:1.2.3 29 | > contains target/scala-2.13/publish-version sonatype-local-bundle:1.2.3 30 | 31 | # Make sure sonatypeRelease ran 32 | > contains target/sonatype-release-version 1.2.3 33 | 34 | # Make sure the git repo was tagged 35 | $ exec git show 1.2.3 36 | 37 | > verifyOmnidocSourceUrl 38 | -------------------------------------------------------------------------------- /src/sbt-test/interplay/plugin-with-root/.gitignore: -------------------------------------------------------------------------------- 1 | target 2 | .bsp 3 | project/build.properties 4 | # global is created by scripted 5 | global 6 | -------------------------------------------------------------------------------- /src/sbt-test/interplay/plugin-with-root/build.sbt: -------------------------------------------------------------------------------- 1 | import interplay.ScalaVersions._ 2 | 3 | // What an actual project would look like 4 | lazy val `mock-root` = (project in file(".")) 5 | .enablePlugins(PlayRootProject) 6 | .aggregate(`mock-sbt-plugin`) 7 | .settings( 8 | common, 9 | crossScalaVersions := Seq(scala212, scala213, scala3) 10 | ) 11 | 12 | lazy val `mock-sbt-plugin` = (project in file("mock-sbt-plugin")) 13 | .enablePlugins(PlaySbtPlugin) 14 | .settings(common) 15 | 16 | ThisBuild / playBuildRepoName := "mock" 17 | 18 | // Customise sbt-dynver's behaviour to make it work with tags which aren't v-prefixed 19 | (ThisBuild / dynverVTagPrefix) := false 20 | 21 | // Below this line is for facilitating tests 22 | InputKey[Unit]("contains") := { 23 | val args = Def.spaceDelimited().parsed 24 | val filename = args.head.replace("target/SCALA3/", s"target/scala-${crossScalaVersions.value.find(_.startsWith("3.")).getOrElse("")}/") 25 | val expected = args.tail.mkString(" ") 26 | val contents: String = IO.read(file(filename)) 27 | if (contents.contains(expected)) { 28 | println(s"Checked that $filename contains $expected") 29 | } else { 30 | throw sys.error(s"File $filename does not contain '$expected':\n$contents") 31 | } 32 | } 33 | 34 | def common: Seq[Setting[_]] = Seq( 35 | PgpKeys.publishSigned := { 36 | IO.write(crossTarget.value / "publish-version", s"${publishTo.value.get.name}:${version.value}") 37 | }, 38 | publish := { throw sys.error("Publish should not have been invoked") }, 39 | ) 40 | 41 | ThisBuild / commands := { 42 | Seq("sonatypeRelease", "sonatypeBundleRelease").map { name => 43 | Command.command(name) { state => 44 | val extracted = Project.extract(state) 45 | IO.write(extracted.get(target) / "sonatype-release-version", extracted.get(version)) 46 | state 47 | } 48 | } ++ (ThisBuild / commands).value 49 | } 50 | -------------------------------------------------------------------------------- /src/sbt-test/interplay/plugin-with-root/project/plugins.sbt: -------------------------------------------------------------------------------- 1 | addSbtPlugin("com.typesafe.play" % "interplay" % sys.props("project.version")) -------------------------------------------------------------------------------- /src/sbt-test/interplay/plugin-with-root/test: -------------------------------------------------------------------------------- 1 | # Setup local git repo 2 | $ exec git init 3 | $ exec git checkout -b main 4 | # Need to configure name/email since on build server it's not set 5 | $ exec git config user.email sbt@example.com 6 | $ exec git config user.name sbt 7 | $ exec git add . 8 | $ exec git commit -m commit 9 | 10 | $ exec git tag 1.2.3 11 | 12 | # Setup remote git repo in target directory 13 | $ exec git init --bare $PWD/target/remote 14 | $ exec git remote add origin $PWD/target/remote 15 | $ exec git push origin main --tags 16 | $ exec git branch -u origin/main 17 | 18 | # A reload is necessary because sbt-release uses the initial state of the project to check if a .git folder exists (and errors if that check fails). 19 | # However, that initial state does not contain the above created .git folder (created via git init) yet. 20 | > reload 21 | 22 | > ci-release 23 | 24 | # Make sure publishSigned ran on every project with the right publish settings 25 | $ exists target/scala-2.13/publish-version 26 | $ exists target/scala-2.12/publish-version 27 | > contains target/SCALA3/publish-version no-publish:1.2.3 28 | > contains target/scala-2.13/publish-version no-publish:1.2.3 29 | > contains target/scala-2.12/publish-version no-publish:1.2.3 30 | > contains mock-sbt-plugin/target/scala-2.12/sbt-1.0/publish-version sonatype-local-bundle:1.2.3 31 | 32 | # Make sure sonatypeBundleRelease ran only in the root project 33 | > contains target/sonatype-release-version 1.2.3 34 | -$ exists mock-sbt-plugin/target/sonatype-release-version 35 | 36 | # Make sure the git repo was tagged 37 | $ exec git show 1.2.3 38 | -------------------------------------------------------------------------------- /src/sbt-test/interplay/plugin-without-cross-release/.gitignore: -------------------------------------------------------------------------------- 1 | target 2 | .bsp/ 3 | project/build.properties 4 | # global is created by scripted 5 | global 6 | -------------------------------------------------------------------------------- /src/sbt-test/interplay/plugin-without-cross-release/build.sbt: -------------------------------------------------------------------------------- 1 | 2 | // What an actual project would look like 3 | lazy val `mock-sbt-plugin` = (project in file(".")) 4 | .enablePlugins(PlaySbtPlugin) 5 | .settings( 6 | common, 7 | ) 8 | 9 | ThisBuild / playBuildRepoName := "mock-without-cross-release" 10 | 11 | // Customise sbt-dynver's behaviour to make it work with tags which aren't v-prefixed 12 | (ThisBuild / dynverVTagPrefix) := false 13 | 14 | // Below this line is for facilitating tests 15 | 16 | InputKey[Unit]("contains") := { 17 | val args = Def.spaceDelimited().parsed 18 | val filename = args.head.replace("target/SCALA3/", s"target/scala-${crossScalaVersions.value.find(_.startsWith("3.")).getOrElse("")}/") 19 | val expected = args.tail.mkString(" ") 20 | val contents: String = IO.read(file(filename)) 21 | if (contents.contains(expected)) { 22 | println(s"Checked that $filename contains $expected") 23 | } else { 24 | throw sys.error(s"File $filename does not contain '$expected':\n$contents") 25 | } 26 | } 27 | 28 | def common: Seq[Setting[_]] = Seq( 29 | PgpKeys.publishSigned := { 30 | IO.write(crossTarget.value / "publish-version", s"${publishTo.value.get.name}:${version.value}") 31 | }, 32 | publish := { throw sys.error("Publish should not have been invoked") }, 33 | ) 34 | 35 | ThisBuild / commands := { 36 | Seq("sonatypeRelease", "sonatypeBundleRelease").map { name => 37 | Command.command(name) { state => 38 | val extracted = Project.extract(state) 39 | IO.write(extracted.get(target) / "sonatype-release-version", extracted.get(version)) 40 | state 41 | } 42 | } ++ (ThisBuild / commands).value 43 | } 44 | -------------------------------------------------------------------------------- /src/sbt-test/interplay/plugin-without-cross-release/project/plugins.sbt: -------------------------------------------------------------------------------- 1 | addSbtPlugin("com.typesafe.play" % "interplay" % sys.props("project.version")) -------------------------------------------------------------------------------- /src/sbt-test/interplay/plugin-without-cross-release/test: -------------------------------------------------------------------------------- 1 | # Setup local git repo 2 | $ exec git init 3 | $ exec git checkout -b main 4 | # Need to configure name/email since on build server it's not set 5 | $ exec git config user.email sbt@example.com 6 | $ exec git config user.name sbt 7 | $ exec git add . 8 | $ exec git commit -m commit 9 | 10 | $ exec git tag 1.2.3 11 | 12 | # Setup remote git repo in target directory 13 | $ exec git init --bare $PWD/target/remote 14 | $ exec git remote add origin $PWD/target/remote 15 | $ exec git push origin main --tags 16 | $ exec git branch -u origin/main 17 | 18 | # A reload is necessary because sbt-release uses the initial state of the project to check if a .git folder exists (and errors if that check fails). 19 | # However, that initial state does not contain the above created .git folder (created via git init) yet. 20 | > reload 21 | 22 | > ci-release 23 | 24 | # Make sure publishSigned ran 25 | > contains target/scala-2.12/sbt-1.0/publish-version sonatype-local-bundle:1.2.3 26 | 27 | # Make sure it does not run cross release 28 | -$ exists target/scala-2.10/sbt-0.13/publish-version 29 | 30 | # Make sure sonatypeRelease ran 31 | > contains target/sonatype-release-version 1.2.3 32 | 33 | # Make sure the git repo was tagged 34 | $ exec git show 1.2.3 35 | -------------------------------------------------------------------------------- /src/sbt-test/interplay/plugin/.gitignore: -------------------------------------------------------------------------------- 1 | target 2 | .bsp 3 | project/build.properties 4 | # global is created by scripted 5 | global 6 | -------------------------------------------------------------------------------- /src/sbt-test/interplay/plugin/build.sbt: -------------------------------------------------------------------------------- 1 | // What an actual project would look like 2 | lazy val `mock-sbt-plugin` = (project in file(".")) 3 | .enablePlugins(PlaySbtPlugin) 4 | .settings( 5 | common, 6 | ) 7 | 8 | 9 | // Customise sbt-dynver's behaviour to make it work with tags which aren't v-prefixed 10 | (ThisBuild / dynverVTagPrefix) := false 11 | 12 | ThisBuild / playBuildRepoName := "mock" 13 | 14 | // Below this line is for facilitating tests 15 | InputKey[Unit]("contains") := { 16 | val args = Def.spaceDelimited().parsed 17 | val filename = args.head.replace("target/SCALA3/", s"target/scala-${crossScalaVersions.value.find(_.startsWith("3.")).getOrElse("")}/") 18 | val contents = IO.read(file(filename)) 19 | val expected = args.tail.mkString(" ") 20 | if (!contents.contains(expected)) { 21 | throw sys.error(s"File ${filename} does not contain '$expected':\n$contents") 22 | } 23 | } 24 | 25 | def common: Seq[Setting[_]] = Seq( 26 | PgpKeys.publishSigned := { 27 | IO.write(crossTarget.value / "publish-version", s"${publishTo.value.get.name}:${version.value}") 28 | }, 29 | publish := { throw sys.error("Publish should not have been invoked") }, 30 | ) 31 | 32 | ThisBuild / commands := { 33 | Seq("sonatypeRelease", "sonatypeBundleRelease").map { name => 34 | Command.command(name) { state => 35 | val extracted = Project.extract(state) 36 | IO.write(extracted.get(target) / "sonatype-release-version", extracted.get(version)) 37 | state 38 | } 39 | } ++ (ThisBuild / commands).value 40 | } 41 | -------------------------------------------------------------------------------- /src/sbt-test/interplay/plugin/project/plugins.sbt: -------------------------------------------------------------------------------- 1 | addSbtPlugin("com.typesafe.play" % "interplay" % sys.props("project.version")) -------------------------------------------------------------------------------- /src/sbt-test/interplay/plugin/test: -------------------------------------------------------------------------------- 1 | # Setup local git repo 2 | $ exec git init 3 | $ exec git checkout -b main 4 | # Need to configure name/email since on build server it's not set 5 | $ exec git config user.email sbt@example.com 6 | $ exec git config user.name sbt 7 | $ exec git add . 8 | $ exec git commit -m commit 9 | 10 | $ exec git tag 1.2.3 11 | 12 | # Setup remote git repo in target directory 13 | $ exec git init --bare $PWD/target/remote 14 | $ exec git remote add origin $PWD/target/remote 15 | $ exec git push origin main --tags 16 | $ exec git branch -u origin/main 17 | 18 | # A reload is necessary because sbt-release uses the initial state of the project to check if a .git folder exists (and errors if that check fails). 19 | # However, that initial state does not contain the above created .git folder (created via git init) yet. 20 | > reload 21 | 22 | > ci-release 23 | 24 | # Make sure publishSigned ran 25 | > contains target/scala-2.12/sbt-1.0/publish-version sonatype-local-bundle:1.2.3 26 | 27 | # Make sure sonatypeRelease ran 28 | > contains target/sonatype-release-version 1.2.3 29 | 30 | # Make sure the git repo was tagged 31 | $ exec git show 1.2.3 32 | --------------------------------------------------------------------------------