Skip to content
This repository has been archived by the owner on Feb 11, 2022. It is now read-only.

Invalid POM: Missing some attributes #19

Closed
jenzz opened this issue Jan 30, 2015 · 28 comments
Closed

Invalid POM: Missing some attributes #19

jenzz opened this issue Jan 30, 2015 · 28 comments

Comments

@jenzz
Copy link
Contributor

jenzz commented Jan 30, 2015

Hi there!

It looks like the plugin is missing to generate some attributes that are required by Bintray to sync with Maven Central:

Invalid POM: /com/jenzz/materialpreference/1.0/materialpreference-1.0.pom:
Project name missing,
Project description missing,
Project URL missing,
License information missing,
SCM URL missing,
Developer information missing

Dropping existing partial staging repository.

I have provided all those information as you can see in my build.gradle.

Any ideas?

@xrigau
Copy link
Contributor

xrigau commented Jan 30, 2015

Hi @jenzz

Seems like bintray have released newer versions of the plugin and our plugin is using an old one. We'll look into this to see if there's any API change and fix it.

Thanks for reporting and we'll keep you updated!

@ouchadam
Copy link
Contributor

Very odd! Cloning your project and running -PdryRun=true correctly deploys the artifact and poms to my .m2. We just double checked the api by doing a release and that also still works.

Out of interest are you running the
./gradlew clean build bintrayUpload -PbintrayUser=BINTRAY_USERNAME -PbintrayKey=BINTRAY_KEY -PdryRun=false command from the project root?

@jenzz
Copy link
Contributor Author

jenzz commented Jan 30, 2015

@ouchadam Yep, that's what I'm doing.

Deployment works fine, but if you check the contents of the generated pom.xml, you can see that the a/m attrs are missing:

<?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>com.jenzz</groupId>
  <artifactId>materialpreference</artifactId>
  <version>1.0</version>
  <packaging>aar</packaging>
  <dependencies>
    <dependency>
      <groupId>com.android.support</groupId>
      <artifactId>appcompat-v7</artifactId>
      <version>21.0.3</version>
      <scope>runtime</scope>
    </dependency>
  </dependencies>
</project>

So Bintray is complaining about it when you're trying to push it through to Maven Central. I do that via their web UI.
The issue seems to be that the package doesn't comply with the Maven Central requirements which according to that link require the presence of name, description and url. And potentially license & dev infos...

@xrigau
Copy link
Contributor

xrigau commented Jan 30, 2015

Are you trying to sync with Maven Central?? So this error doesn't happen at build time but once you're logged in bintray?

If that's the case I'll raise it as an issue - we need to add the ability to add more fields to the generated pom such as contributors, author, url, etc.

We haven't used the Maven Central synchronisation yet and that's why we haven't faced this issue

@jenzz
Copy link
Contributor Author

jenzz commented Jan 30, 2015

@xrigau Fair enough. That's exactly what's happening.
Those fields seem to be optional for Bintray, but mandatory for Maven Central.

So looking at the plugin code, I think it's the maven publication closure that needs to be extended.
I might send a PR for this, if I don't get tied up..

@ouchadam
Copy link
Contributor

pr welcome!

@ZacSweers
Copy link
Contributor

What's the latest on this? I'm stuck in the same situation

@ouchadam
Copy link
Contributor

Internally we stopped releasing to maven central once jcenter came about so this doesn't have the highest priority.

But the change seems pretty simple , would just be a case of hooking up to the existing keys from here https://github.com/bintray/gradle-bintray-plugin/blob/master/src/main/groovy/com/jfrog/bintray/gradle/BintrayExtension.groovy
to here https://github.com/novoda/bintray-release/blob/master/core/src/main/groovy/com/novoda/gradle/release/BintrayConfiguration.groovy

Missing fields like Developers would fall under attributes

@ZacSweers
Copy link
Contributor

I see. Are you sure about that second link? Seems like everything's hooked up fine there, it's the closure that @jenzz linked that seems to need things: https://github.com/novoda/bintray-release/blob/master/core/src/main/groovy/com/novoda/gradle/release/ReleasePlugin.groovy#L24-L34

If you agree, I can take a crack at a PR.

@ZacSweers
Copy link
Contributor

Been taking a look at it. I'm not sure what you mean by this line though:

Missing fields like Developers would fall under attributes

What attributes/where are those set?

Also, how do you test this? I took a look at the contributing info and it mentioned tests, but there are no tests in this project.

@ouchadam
Copy link
Contributor

my bad I got confused with the bintray and publication extensions, in that case it's a bit simpler.

ignore my previous comment!

We're delegating to this https://github.com/bintray/gradle-bintray-plugin/blob/master/src/main/groovy/com/jfrog/bintray/gradle/BintrayUploadTask.groovy#L424

Which in turn calls publication.asNormalisedPublication().pomFile, Publication comes from the maven-publish plugin if you wanted to manually test in a sandboxed project.

Unfortunately because we're a little new to the whole groovy testing it's been put on the back burner..... so don't worry too much about the tests, unless you want to show us how it's done!

@ZacSweers
Copy link
Contributor

It seems like it would be too late there wouldn't it? Doing it in the maven publication seems to be the right place, but I'm not sure how to go about setting up tests for groovy. I tried configuring my own in my project as specified here, but I get the same exception as in the last comment of #24. How do you guys normally test it?

@ouchadam
Copy link
Contributor

I meant the maven publication like you said. I just posted a fix for the task name issue
#42

As for testing, I'm currently having to release the plugin locally and then use it to release another project. It's a bad flow but for now it works

@blundell
Copy link
Contributor

so maybe we do need #30 ?

@ouchadam
Copy link
Contributor

#30 is the same flow just the dummy project is within the codebase. anddddd whether or not it should live there is another discussion!

@ZacSweers
Copy link
Contributor

I see. I'll wait until that fix is released so I can test the custom publication, otherwise I don't think I can afford the time to work on it right now because I don't have time to learn pushing it locally or how to write groovy tests :/

@jjhesk
Copy link

jjhesk commented Apr 30, 2015

add this to your gradle build file:

apply plugin: 'maven'
task createPom << {
    pom {
        project {
            name project.POM_DESCRIPTION
            packaging project.POM_PACKAGING
            description project.POM_DESCRIPTION
            url project.POM_URL
            version project.VERSION_NAME

            scm {
                url project.POM_SCM_CONNECTION
                connection project.POM_SCM_CONNECTION
                developerConnection project.POM_SCM_CONNECTION
            }

            licenses {
                license {
                    name project.POM_LICENCE_NAME
                }
            }

            developers {
                developer {
                    id project.POM_DEVELOPER_ID
                    name project.POM_DEVELOPER_NAME
                    email project.POM_EMAIL
                }
            }
        }
    }.writeTo("pom.xml")
}

and then go to the build selection tab and create a new task callback and name it as createPom

@ZacSweers
Copy link
Contributor

@jjhesk could you elaborate a bit on that? Where to use it, when to call the task, etc?

@ZacSweers
Copy link
Contributor

Specifically, the example you just gave just creates a pom.xml file in the top level of the project or wherever your build.gradle file is. How would you integrate that easily with this plugin?

@ZacSweers
Copy link
Contributor

I got it working, here's my repo for example: https://github.com/hzsweers/barber/blob/master/build.gradle#L42-L83

Basically, you have to hook the task @jjhesk described into the build process, and schedule it to run sometime after the plugin generates its default POM file but before upload. I have it set up to only configure this when bintrayUpload was one of the gradle tasks passed, and reuse the same configuration for both subprojects by using some logic to determine what values to put (packaging, name, etc)

@jjhesk jjhesk mentioned this issue May 19, 2015
@elektrojunge
Copy link

Hi guys,
I just stumbled over this and thanks to @hzsweers solution I got it working in no time.
Why don't you guys add it to your readme.md? I'll happily submit a PR that contains this.
Cheers!

@blundell
Copy link
Contributor

@elektrojunge pull requests welcome, I'll look out for it to review/merge 😺

@elektrojunge
Copy link

#70

Not sure if the Wiki would be a better place for this. Do with it whatever you want. ;)

@yilylong
Copy link

@jjhesk @hzsweers I did accroding to
https://github.com/novoda/bintray-release/wiki/Add-support-for-syncing-to-maven-central
but i got an error like below when build :
“Cannot invoke method doLast() on null object”

@aheadlcx
Copy link

@hzsweers @jjhesk @yilylong I get the same result as @yilylong .
Anyone could help.
thanks in advance

@qinglinyi
Copy link

@yilylong @aheadlcx I just add:

 gradle.taskGraph.whenReady { taskGraph ->
            def pomTask = taskGraph.getAllTasks().find {
                it.path == ":$project.name:generatePomFileForMavenPublication"
            }
            if (pomTask == null) return;
            pomTask.doLast {...

and right module name in:

if (IS_UPLOADING && project.name in['compiler','api']) {...

@ashishraval21
Copy link

Hey all ,
I am stuck in the same issue like "Missing Some Attributes".
give me some solution to what i can do for that. I have not idea how to solve that issue.
Thanks in advance.

@blundell
Copy link
Contributor

continue conversation on #96

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests