How to overwrite artifactId for Android Gradle library project?
Asked Answered
E

0

4

I created an Android library project using Android Studio with the following directory structure:

├── build.gradle
├── gradle
├── gradle.properties
├── gradlew
├── gradlew.bat
├── local.properties
├── settings.gradle
├── FooBar.iml
└── FooBar Library

When I want to publish the library to my local Maven repository I encounter the following error:

Execution failed for task ':Foobar Library:publishMavenPublicationToMavenLocal'.
> Failed to publish publication 'maven' to repository 'MavenLocal'
   > Invalid publication 'maven': 
     artifactId is not a valid Maven identifier ([A-Za-z0-9_\-.]+).

Please notice that the folder "FooBar Library" contains a space. How can I set the artifactId for Gradle so I can overwrite the default artifactId?


Side note: If you are using uploadArchives in favor of maven-publish you can rename the artifactId setting archivesBaseName as follows:

archivesBaseName = "foobar-library"
Estrella answered 15/2, 2014 at 16:7 Comment(4)
Why not changing the name Foobar-Library?Ephram
@Ephram There are situations where you cannot change the setup. I believe there should be a way to overwrite the artifactId somehow.Estrella
The point is the artifactId identifier has a format which is defined which can't be changed. In Java you have some rules for package names or java class names would you try to change them as well ? Does simply not work.Ephram
@Ephram It works for uploadArchives so it should work for maven-publish as well.Estrella

© 2022 - 2024 — McMap. All rights reserved.