Hello. I have a rootproject with 2 subproject. And I want to publish them on bintray. To get started, I put the publication script in a separate file:
/*
Это просто блядский пиздец, товарищи. Сколько я не ебался, не получилось у меня
написать скрпит для юзания в allProjects. Вам кажется что этот код можно сделать лучше?
Ну так вперед! Но говно тут не просто так распихано...
*/
// Подготавливает maven-публикацию, которая будет использоваться в bintray
// Именно тут определяются артефакты для публикации
apply plugin: 'maven-publish'
publishing {
// afterEvaluate { // TODO: Этим говном я пытался подбирать имя проекта в allProjects после того как оно назначится
publications {
"$project.name"(MavenPublication) {
//from components.java // Артефакты по умолчанию. Отлючаем их, т.к. нам нужно артефакт main-модуля заменить на артефакт от api-модуля
groupId group
artifactId archivesBaseName
// version "0.4.0_1.7.10" // TODO: Это для дебага, ибо project.version может не подобраться в allProjects
version "${project.version}_1.7.10"
artifact deobfJar
artifact sourcesJar
artifact javadocJar
}
}
// }
}
// Публикация либы в bintray/jcenter
apply plugin: 'com.jfrog.bintray'
bintray {
user = 'rarescrap'
key = System.getenv('BINTRAY_KEY')
publications = ["$project.name"]
dryRun = true // Для тестов
pkg {
repo = 'minecraft'
name = 'weight-api'
licenses = ['GPL-3.0']
vcsUrl = 'https://github.com/RareScrap/WeightAPI.git'
version {
// afterEvaluate { // TODO: Точно такое же говно как и выше, но теперь для версии публикации на bintray. Не знаю поему, но case2 вообще не втупляет в эту запись
name = "0.4.0_1.7.10"
// name = "${project.version}_1.7.10" // TODO: Как раз из-за case2. Он просто ставит 0.4.0
released = new Date()
// }
}
}
}
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':publishWeightAPIPublicationToMavenLocal'.
> Failed to publish publication 'WeightAPI' to repository 'mavenLocal'
> Invalid publication 'WeightAPI': artifact file does not exist: 'C:\Users\DangerArea\Desktop\WeightAPI\build\libs\WeightAPI-dev.jar'
This happened due to the fact that the version was not set for the jar. I have added "afterEvaluate" so that the publication code correctly set the version:
apply plugin: 'maven-publish'
publishing {
afterEvaluate { // TODO: Этим говном я пытался подбирать имя проекта в allProjects после того как оно назначится
publications {
"$project.name"(MavenPublication) {
//from components.java // Артефакты по умолчанию. Отлючаем их, т.к. нам нужно артефакт main-модуля заменить на артефакт от api-модуля
groupId group
artifactId archivesBaseName
// version "0.4.0_1.7.10" // TODO: Это для дебага, ибо project.version может не подобраться в allProjects
version "${project.version}_1.7.10"
artifact deobfJar
artifact sourcesJar
artifact javadocJar
}
}
}
}
The result just hit me. The case2 subproject did not create its publication at all:
> Task :case1:bintrayUpload
Uploading to https://api.bintray.com/content/rarescrap/minecraft/weight-api/0.4.0_1.7.10/ru/rarescrap/weightapi/weightapi-case1/0.4.0_1.7.10/weightapi-case1-0.4.0_1.7.10-dev.jar...
Uploading to https://api.bintray.com/content/rarescrap/minecraft/weight-api/0.4.0_1.7.10/ru/rarescrap/weightapi/weightapi-case1/0.4.0_1.7.10/weightapi-case1-0.4.0_1.7.10-sources.jar...
Uploading to https://api.bintray.com/content/rarescrap/minecraft/weight-api/0.4.0_1.7.10/ru/rarescrap/weightapi/weightapi-case1/0.4.0_1.7.10/weightapi-case1-0.4.0_1.7.10-javadoc.jar...
Uploading to https://api.bintray.com/content/rarescrap/minecraft/weight-api/0.4.0_1.7.10/ru/rarescrap/weightapi/weightapi-case1/0.4.0_1.7.10/weightapi-case1-0.4.0_1.7.10.pom...
> Task :case2:bintrayUpload
Skipping upload for missing file 'C:\Users\DangerArea\Desktop\WeightAPI\examples\case2\build\libs\weightapi-case2-0.4.0-dev.jar'.
Skipping upload for missing file 'C:\Users\DangerArea\Desktop\WeightAPI\examples\case2\build\libs\weightapi-case2-0.4.0-sources.jar'.
Skipping upload for missing file 'C:\Users\DangerArea\Desktop\WeightAPI\examples\case2\build\libs\weightapi-case2-0.4.0-javadoc.jar'.
Skipping upload for missing file 'C:\Users\DangerArea\Desktop\WeightAPI\examples\case2\build\publications\case2\pom-default.xml'.
> Task :bintrayUpload
Uploading to https://api.bintray.com/content/rarescrap/minecraft/weight-api/0.4.0_1.7.10/ru/rarescrap/weightapi/weightapi/0.4.0_1.7.10/weightapi-0.4.0_1.7.10-dev.jar...
Uploading to https://api.bintray.com/content/rarescrap/minecraft/weight-api/0.4.0_1.7.10/ru/rarescrap/weightapi/weightapi/0.4.0_1.7.10/weightapi-0.4.0_1.7.10-sources.jar...
Uploading to https://api.bintray.com/content/rarescrap/minecraft/weight-api/0.4.0_1.7.10/ru/rarescrap/weightapi/weightapi/0.4.0_1.7.10/weightapi-0.4.0_1.7.10-javadoc.jar...
Uploading to https://api.bintray.com/content/rarescrap/minecraft/weight-api/0.4.0_1.7.10/ru/rarescrap/weightapi/weightapi/0.4.0_1.7.10/weightapi-0.4.0_1.7.10.pom...
That's what the command `gradlew bintrayUpload --dry-run" say:
As you can see the publication is not created for the case2. Guys, what am I doing wrong? How to write bintray publication script and put it into a separate file? At the same time, I want to apply it only once in allProjects, and not copy it to every build script. You can find all code here
@RareScrap Maybe my solution to the Bintray configuration sharing problem can be of help?
P.S. Enjoyed code comments above immensely; I hope you don't mind me re-using one of them in my write-up :)
Hello. I have a rootproject with 2 subproject. And I want to publish them on bintray. To get started, I put the publication script in a separate file:
Then I in the root project I did this:
And got this:
This happened due to the fact that the version was not set for the jar. I have added "afterEvaluate" so that the publication code correctly set the version:
The result just hit me. The case2 subproject did not create its publication at all:
That's what the command `gradlew bintrayUpload --dry-run" say:
As you can see the publication is not created for the case2. Guys, what am I doing wrong? How to write bintray publication script and put it into a separate file? At the same time, I want to apply it only once in
allProjects
, and not copy it to every build script. You can find all code here