dcendents / android-maven-gradle-plugin

Abandoned. This is now supported by the android build plugin: https://developer.android.com/studio/build/maven-publish-plugin

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

ArtifactId is not set

briantisse opened this issue · comments

Hi,

as stated in the document I have added an rootProject='myArtifactId', but unfortunately this doesn'T work. In my pom there is an entry <artifactId>app</artifactId>

Is there a way to set this artifactId in the build.gradle file? I am also using the maven-plugin to upload it to a remote-repository and there I also have to specify the following:

//settings for android-maven-plugin
group = POM_GROUP
version = VERSION_NAME
//artifactID = POM_ARTIFACT_ID  <-- this doesn't work unfortunately


//settings for upload to remote-repository
uploadArchives {
    repositories {
        mavenDeployer {
            beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) }

            pom.groupId = POM_GROUP
            pom.artifactId = POM_ARTIFACT_ID
            pom.version = VERSION_NAME
            ...
      }

So I have duplicated code. Once for the uploadArchivesTask and once for the

Has anyone found a solution for this, yet? cc @briantisse @dcendents

In my case the artifactId seems to always default back to the module name which is library (for most Android projects)...

I have the same problem. How to set the value of artifactId ?

@briantisse @jenzz Have you solved this problem?

I have not solved this problem..

Hi,

Sorry I completely missed this issue, will have to work on my email filters.

First of all I personally think the artifactId should be the same as the project name. This default to the project folder. For single projects, this can be a problem as people can checkout/clone the project and name it whatever they want. But this can be easily set in the file settings.gradle to make sure you get consistent behaviour whatever the name the person chose when they cloned it.

rootProject.name = theName // as defined in gradle.properties

Now in a multi-project build, you do not get this problem, as the project name is under your control through the folder name, which cannot be modified when you clone the project. However as @jenzz mentioned, it makes sense for it to be named library within a project but also needs a "wider" name across all projects.

I think there are 2 ways to handle that, hopefully one of them can help you.

First option, change the project name.
This has to be done in the settings.gradle file at the root of the multi-project (settings.gradle in sub-projects are ignored).

You can still set it as a property in the sub-project gradle.properties and do something like this to use its value:

include 'submodule'

rootProject.name = theName

def submoduleProject = project(':submodule')
def submoduleProps = new Properties()
submoduleProps.load(new FileInputStream(new File(submoduleProject.projectDir, 'gradle.properties')))
submoduleProject.name = submoduleProps.getProperty('theName')

So from now on the module name will be set to whatever value you choose and not the folder name, this will change the gradle commands when you want to run part of the build.

e.g.: when before you would run "gradlew library:test", you now need to run something like "gradlew overriddenName:test"

Second option, simply change the value of archiveBaseName in build.gradle

project.archivesBaseName = 'archive-name'

This will be used by the maven (and my modified android-maven) plugin when it installs the artifact. The drawback is there is a mismatch between the project name and its maven artifact, which can make it harder over time to properly identify them when the number of projects increase over time.

Please le me know if either solution can fix your problem.

Cheers

@dcendents Change the value of archiveBaseName maybe is a nice solution, but I found the pom file was still uploaded to the 'library' folder.

@msdx are you sure?

Here is the output of a sample project without any configuration:

[INFO] Installing E:\dev\gradle-samples-0.14.4\multiproject\library\build\outputs\aar\library-release.aar 
to E:\dev\m2\repository\multiproject\library\1.0\library-1.0.aar

Here's the same output after I set the archivesBaseName:

[INFO] Installing E:\dev\gradle-samples-0.14.4\multiproject\library\build\outputs\aar\library-release.aar 
to E:\dev\m2\repository\multiproject\setInBuildScript\1.0\setInBuildScript-1.0.aar

The generated pom is also consistent with it:

<?xml version="1.0" encoding="UTF-8"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <modelVersion>4.0.0</modelVersion>
  <groupId>multiproject</groupId>
  <artifactId>setInBuildScript</artifactId>
  <version>1.0</version>
  <packaging>aar</packaging>
  <dependencies>
    <dependency>
      <groupId>multiproject</groupId>
      <artifactId>baseLibrary</artifactId>
      <version>1.0</version>
      <scope>compile</scope>
    </dependency>
    <dependency>
      <groupId>multiproject</groupId>
      <artifactId>util</artifactId>
      <version>1.0</version>
      <scope>compile</scope>
    </dependency>
  </dependencies>
</project>

If you get a different behaviour I would double-check your gradle script(s).

The content in pom file was right, but the location of this pom file was incorrect.

I set the value of project.archivesBaseName, and executed gradle bintray --info, here is the result:

Version 'msdx/maven/AndroidSnippet/0.3' does not exist. Attempting to creating it...
Created version '0.3'.                 
Uploading to https://api.bintray.com/content/msdx/maven/AndroidSnippet/0.3/com/githang/androidsnippet/0.3/androidsnippet-0.3-javadoc.jar...
Uploaded to 'https://api.bintray.com/content/msdx/maven/AndroidSnippet/0.3/com/githang/androidsnippet/0.3/androidsnippet-0.3-javadoc.jar'.
Uploading to https://api.bintray.com/content/msdx/maven/AndroidSnippet/0.3/com/githang/androidsnippet/0.3/androidsnippet-0.3-sources.jar...
Uploaded to 'https://api.bintray.com/content/msdx/maven/AndroidSnippet/0.3/com/githang/androidsnippet/0.3/androidsnippet-0.3-sources.jar'.
Uploading to https://api.bintray.com/content/msdx/maven/AndroidSnippet/0.3/com/githang/androidsnippet/0.3/androidsnippet-0.3.aar...
Uploaded to 'https://api.bintray.com/content/msdx/maven/AndroidSnippet/0.3/com/githang/androidsnippet/0.3/androidsnippet-0.3.aar'.
Uploading to https://api.bintray.com/content/msdx/maven/AndroidSnippet/0.3/com/githang/library/0.3/library-0.3.pom...
Uploaded to 'https://api.bintray.com/content/msdx/maven/AndroidSnippet/0.3/com/githang/library/0.3/library-0.3.pom'.
Published 'msdx/maven/AndroidSnippet/0.3'.
:library:bintrayUpload (Thread[main,5,main]) completed. Took 5.208 secs.

Why the pom file was uploaded to library folder ? How should I do it?

I'd used another published script and my problem has be solved now. Anyway, thank you for your advice because it it useful for me to solve the other problem in my previous script.
Here is my script that I use it to publish my projects: https://github.com/msdx/gradle-publish

I will close this issue, @briantisse hasn't confirmed if the problem is fixed by my recommendations but it is a bit out of scope as well. This is how gradle and the maven plugin works, I cannot alter the android-maven-plugin if I want to stay compatible with the standard maven plugin.

@dcendents I'm seeing the same behavior as @msdx. My POM contains the correct details after making the changes discussed in this thread, but the POM gets deployed to the incorrect path on Bintray (exactly as msdx described - the POM gets deployed to the project name instead of artifact id (although the contents of the POM are correct). I'm also following up with the Bintray plugin folks to figure out where the problem is.

@INRIX-Owais-Ali it looks like you have an issue with the bintray plugin. You'll have to check with them if their plugin will use the value of archivesBaseName or not.

Thanks Daniel, I managed to track down the issue in the Bintray plugin and they are taking a look.

For everyone's reference, I think they're tracking the issue here:
bintray/gradle-bintray-plugin#81

@INRIX-Owais-Ali Do you find the solution about the incorrect path? This problem trouble me also.

It looks like Bintray plugin folks are going to fix it - exactly how is still TBD (I think). Ways to work around it for now (in no particular order):

  1. Change the name of your module to match what you would like the artifact to be called
  2. Manually upload the POM

Thank you! I have tried Bintray plugin, and it works after some toss about.