公開用のテスト フィクスチャを設定する
コレクションでコンテンツを整理
必要に応じて、コンテンツの保存と分類を行います。
テスト フィクスチャの公開に特別な構成は必要ありませんが、
パブリケーションの
機能メカニズム
追加の構成が必要です。
アーティファクトの座標が groupId:artifactId:version
である場合、Gradle はテスト フィクスチャ アーティファクトが座標 groupId:artifactId-test-fixtures:version
のケーパビリティを宣言していると想定します。この宣言は、現時点ではテスト フィクスチャ サポートによっても Maven Publish プラグインによっても自動的に行われないため、手動で行う必要があります。
Gradle は、プロジェクトの名前、グループ、バージョンからケーパビリティを作成します。これら 3 つすべてを、公開用に設定されている artifactId
、groupId
、version
に合わせてセットアップする必要があります。
プロジェクト名は、デフォルトではプロジェクトのパスの最後のセグメントです。したがって、パスが :path:to:mylibrary
であるプロジェクトのデフォルトの名前は mylibrary
です。これを artifactId
に使用したくない場合は、プロジェクト名を変更する必要があります。
プロジェクト名を変更するには、次の 2 つの方法があります。
- プロジェクトのフォルダ名を変更する。これにより、プロジェクト名つまりプロジェクトの Gradle パスが変更されるため、そのプロジェクトへのすべての依存関係を更新する必要があります。プロジェクト名とフォルダを同じにすると、初期の再編成作業が増える可能性はありますが混乱を抑えることができます。
- プロジェクトのフォルダ名を変更せずに Gradle のプロジェクト名を変更する。この方法では、ソースのバージョニングへの影響を回避できますが、プロジェクトの場所と名前が分離します。
Gradle のプロジェクト名を変更するには、settings.gradle
ファイルに次のコードを挿入します。
Groovy
include ':path:to:mylibrary'
project(':path:to:mylibrary').name = 'my-library'
Kotlin
include(":path:to:mylibrary")
project(":path:to:mylibrary").name = "my-library"
このコードは、プロジェクトの新しいパスを :path:to:my-library
に割り当てています。
groupId
のデフォルト値はビルド名で、通常はルートフォルダの名前になります。version
の値は、デフォルトでは未指定となります。グループ ID またはバージョンの値を変更するには、プロジェクト レベルの build.gradle
ファイル(Groovy)または build.gradle.kts
(Kotlin スクリプト)のプロパティ(group
または version
)を設定します。
Groovy
group = 'com.my-company'
version = '1.0'
Kotlin
group = "com.my-company"
version = "1.0"
このページのコンテンツやコードサンプルは、コンテンツ ライセンスに記載のライセンスに従います。Java および OpenJDK は Oracle および関連会社の商標または登録商標です。
最終更新日 2025-07-27 UTC。
[null,null,["最終更新日 2025-07-27 UTC。"],[],[],null,["# Configure test fixtures for publication\n\nWhile publishing test fixtures doesn't require any particular configuration\nof the publication, the\n[capability mechanism](https://docs.gradle.org/current/userguide/component_capabilities.html)\nused to handle fixtures does require an additional configuration.\n\nFor a given artifact with coordinates `groupId:artifactId:version`, Gradle\nexpects that the test fixtures artifact declares a capability with coordinates\n`groupId:artifactId-test-fixtures:version`. This is not currently done\nautomatically by either the test fixture support or the Maven Publish Plugin,\nand therefore must be done manually.\n\nGradle creates the capability from the project's name, group, and version.\nAll three must be set up to match the `artifactId`, `groupId`, and `version` set\nin the publication.\n\nThe project's name is the last segment of its path by default, so the default\nname of a project with the path `:path:to:mylibrary` is `mylibrary`. If this is\nnot what you want to use for `artifactId`, then you need to change your project\nname.\n\nThere are two options for renaming your project:\n\n- Rename the folder of the project. This changes the project name, or the Gradle path of the project, so all dependencies on the project need to be updated. While keeping the project name and folder the same might create more reorganization work initially, it reduces confusion.\n- Rename the project in Gradle without renaming the folder of the project. This avoids the impact on source versioning, but it splits the project location and name.\n\nTo rename the project in Gradle, insert the following code in the\n`settings.gradle` file: \n\n### Groovy\n\n```groovy\ninclude ':path:to:mylibrary'\nproject(':path:to:mylibrary').name = 'my-library'\n```\n\n### Kotlin\n\n```kotlin\ninclude(\":path:to:mylibrary\")\nproject(\":path:to:mylibrary\").name = \"my-library\"\n```\n\nThis code assigns the new path of the project to `:path:to:my-library`.\n\nThe value `groupId` defaults to the build name, which is generally the name of\nthe root folder, and the value `version` is by default unspecified. To change\nthe values of the group ID or version, set the `group` and `version` properties,\nrespectively, in your project-level `build.gradle` file (for Groovy) or\n`build.gradle.kts` (for Kotlin script): \n\n### Groovy\n\n```groovy\ngroup = 'com.my-company'\nversion = '1.0'\n```\n\n### Kotlin\n\n```kotlin\ngroup = \"com.my-company\"\nversion = \"1.0\"\n```"]]