egueli / TraCI4J

A high-level Java library to communicate with SUMO (Simulation of Urban MObility) through its TraCI protocol.
GNU General Public License v3.0
41 stars 27 forks source link

Upload Maven artifacts to Maven Central #22

Closed pfisterer closed 5 years ago

pfisterer commented 8 years ago

It would be very helpful if you could upload your maven artifacts to Maven Central (https://maven.apache.org/guides/mini/guide-central-repository-upload.html) so that others can easily use your library in other projects.

egueli commented 8 years ago

Thanks! I've never uploaded anything to Central, I'm reading some documentation now, may I ask to you if there's something unclear?

pfisterer commented 8 years ago

Thanks!

I can try to help. Just send me a message.

egueli commented 8 years ago

I tried to follow the guide at https://dzone.com/articles/deploy-maven-central; the main command seems to be mvn release:clean release:prepare release:perform -B -e After some edits to pom.xml the build is now successful, but when I log in to Sonatype/Nexus/OSSRH/whatever-that-is (https://oss.sonatype.org/#stagingRepositories) I don't see my repository, therefore there's nothing to release to Maven Central. But I see the artifact in https://oss.sonatype.org/#nexus-search;quick~traci4j

I'm not a DevOps expert so I don't understand where is the error here, or what I'm supposed to do now. Any clue?

For reference, I've committed the changes to pom.xml to master.

pfisterer commented 8 years ago

Thank you for picking this up. As far as I know, you cannot upload Snapshots to Maven Central.

Timkor commented 8 years ago

What's the current status on this?

pfisterer commented 8 years ago

Maybe this is helpful, too: https://blog.idrsolutions.com/2015/06/how-to-upload-your-java-artifact-to-maven-central/

pfisterer commented 8 years ago

Are you still working on this issue? If not, I can try to upload the artifacts (temporarily) to jcenter.

pfisterer commented 8 years ago

I've manually uploaded the binaries to Bintray in order to allow my students to use the current version. However, this is really just a quick and dirty hack.

To use it, add

        <repository>
            <snapshots>
                <enabled>false</enabled>
            </snapshots>
            <id>bintray-farberg-maven</id>
            <name>bintray</name>
            <url>http://dl.bintray.com/farberg/maven</url>
        </repository>

to you pom.xml and use the following dependecy:

        <dependency>
            <groupId>com.github.egueli</groupId>
            <artifactId>TraCI4J</artifactId>
            <version>2.5.0</version>
        </dependency>
egueli commented 8 years ago

Hi, sorry for not having picked it up for all this time. Do you think jcenter is easier to upload than Maven Central? I may try there. Honestly I felt discouraged to upload to MC after all the time spent with no avail. Thanks for the guide, I'll try to follow it this weekend.

pfisterer commented 8 years ago

The easiest way I'm aware of is this: https://blog.bintray.com/2014/02/11/bintray-as-pain-free-gateway-to-maven-central/. It will auto-sync the stuff to Maven Central.

Thanks for still investing time for this issue!

egueli commented 8 years ago

@pfisterer Ok, I'm attempting to deploy to Bintray. I'm putting my changes to the bintray branch. I'm at the step "Deploy: Deploy files to Bintray by running your build tool*.". I've ran mvn release:prepare and mvn deploy as explained here, but Maven stops with the message

Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.7:deploy (default-deploy) on project TraCI4J: Failed to deploy artifacts: Could not transfer artifact com.github.egueli:TraCI4J:jar:2.6-20160710.102743-1 from/to bintray-egueli-e_gueli (https://api.bintray.com/maven/egueli/e_gueli/TraCI4J/;publish=1): Failed to transfer file: https://api.bintray.com/maven/egueli/e_gueli/TraCI4J/;publish=1/com/github/egueli/TraCI4J/2.6-SNAPSHOT/TraCI4J-2.6-20160710.102743-1.jar. Return code is: 400, ReasonPhrase: Bad Request. -> [Help 1]

Seems like Bintray refuses the upload with a 400 Bad Request, but I have no further info. Any clue?

egueli commented 8 years ago

After trying to reproduce the upload with cURL, I see that the error is in the response body (and discarded by Maven): {"message":"Provided artifact path does not comply with Maven's convention"}

The command I used is somewhat like curl -v -X PUT -T target/TraCI4J-2.6-SNAPSHOT.jar -u egueli 'https://api.bintray.com/maven/egueli/e_gueli/TraCI4J/;publish=1/com/github/egueli/TraCI4J/2.6-SNAPSHOT/TraCI4J-2.6-20160711.201256-1.jar'.

I thought it was strange that the URL contains a snapshot version, so I tried modifying to curl -v -X PUT -T target/TraCI4J-2.5.jar -u egueli 'https://api.bintray.com/maven/egueli/e_gueli/TraCI4J/;publish=1/com/github/egueli/TraCI4J/2.5/TraCI4J-2.5.jar'

and the upload went fine!

Previously I got the approval from Bintray to include the TraCI4J package. Now I see the version 2.5 published in the package's Bintray page, but not in JCenter (http://jcenter.bintray.com/). Are there more steps to do?

pfisterer commented 8 years ago

Regarding your first comment: I guess it's because bintray does not accept SNAPSHOT versions.

Getting it included in JCenter seems to require just a few clicks: https://bintray.com/docs/usermanual/uploads/uploads_includingyourpackagesinjcenter.html

stefanobortoli commented 6 years ago

+1

halegreen commented 5 years ago

+1