پیکربندی تجهیزات تست برای انتشار
با مجموعهها، منظم بمانید
ذخیره و طبقهبندی محتوا براساس اولویتهای شما.
در حالی که انتشار تجهیزات آزمایشی به پیکربندی خاصی از نشریه نیاز ندارد، مکانیسم قابلیت مورد استفاده برای رسیدگی به وسایل نیاز به پیکربندی اضافی دارد.
برای یک مصنوع معین با مختصات groupId:artifactId:version
، Gradle انتظار دارد که مصنوع ثابت فیکسچر آزمایشی قابلیتی را با مختصات groupId:artifactId-test-fixtures:version
اعلام کند. این کار در حال حاضر بهطور خودکار توسط پشتیبانی دستگاه تست یا افزونه Maven Publish انجام نمیشود و بنابراین باید به صورت دستی انجام شود.
Gradle این قابلیت را از نام، گروه و نسخه پروژه ایجاد می کند. هر سه باید برای مطابقت با artifactId
، groupId
و version
تنظیم شده در انتشارات تنظیم شوند.
نام پروژه به طور پیش فرض آخرین بخش مسیر آن است، بنابراین نام پیش فرض پروژه با مسیر :path:to:mylibrary
mylibrary
است. اگر این چیزی نیست که می خواهید برای artifactId
استفاده کنید، باید نام پروژه خود را تغییر دهید.
دو گزینه برای تغییر نام پروژه شما وجود دارد:
- نام پوشه پروژه را تغییر دهید. این نام پروژه یا مسیر Gradle پروژه را تغییر می دهد، بنابراین تمام وابستگی های پروژه باید به روز شوند. در حالی که ثابت نگه داشتن نام و پوشه پروژه ممکن است در ابتدا کار سازماندهی مجدد بیشتری ایجاد کند، سردرگمی را کاهش می دهد.
- تغییر نام پروژه در Gradle بدون تغییر نام پوشه پروژه. این امر از تأثیر بر نسخهسازی منبع جلوگیری میکند، اما مکان و نام پروژه را تقسیم میکند.
برای تغییر نام پروژه در Gradle، کد زیر را در فایل settings.gradle
وارد کنید:
شیار
include ':path:to:mylibrary'
project(':path:to:mylibrary').name = 'my-library'
کاتلین
include(":path:to:mylibrary")
project(":path:to:mylibrary").name = "my-library"
این کد مسیر جدید پروژه را به :path:to:my-library
اختصاص می دهد.
مقدار groupId
به طور پیشفرض نام ساخت را انتخاب میکند که معمولاً نام پوشه ریشه است و version
مقدار به طور پیشفرض مشخص نشده است. برای تغییر مقادیر شناسه یا نسخه گروه، ویژگی های group
و version
را به ترتیب در فایل build.gradle
در سطح پروژه خود (برای Groovy) یا build.gradle.kts
(برای اسکریپت Kotlin) تنظیم کنید:
شیار
group = 'com.my-company'
version = '1.0'
کاتلین
group = "com.my-company"
version = "1.0"
محتوا و نمونه کدها در این صفحه مشمول پروانههای توصیفشده در پروانه محتوا هستند. جاوا و OpenJDK علامتهای تجاری یا علامتهای تجاری ثبتشده Oracle و/یا وابستههای آن هستند.
تاریخ آخرین بهروزرسانی 2025-07-29 بهوقت ساعت هماهنگ جهانی.
[[["درک آسان","easyToUnderstand","thumb-up"],["مشکلم را برطرف کرد","solvedMyProblem","thumb-up"],["غیره","otherUp","thumb-up"]],[["اطلاعاتی که نیاز دارم وجود ندارد","missingTheInformationINeed","thumb-down"],["بیشازحد پیچیده/ مراحل بسیار زیاد","tooComplicatedTooManySteps","thumb-down"],["قدیمی","outOfDate","thumb-down"],["مشکل ترجمه","translationIssue","thumb-down"],["مشکل کد / نمونهها","samplesCodeIssue","thumb-down"],["غیره","otherDown","thumb-down"]],["تاریخ آخرین بهروزرسانی 2025-07-29 بهوقت ساعت هماهنگ جهانی."],[],[],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```"]]