How to publish sbt plugin to nexus repositories? - sbt

I am new to sbt plugin publishing and I have just rewrote some features of an exist plugin. It has been working locally sine I ran publish-local on sbt console. Now, I want publish it to nexus repositories. Are there any good tutorial to do it?

Right now, publishing sbt-plugins to nexus repos can cause some issues, but generally, this should apply: http://www.scala-sbt.org/0.13/docs/Using-Sonatype.html
Additionally, you want to make sure in your plugin's build.sbt file:
sbtPlugin := true
publishMavenStyle := true.
There are a few issue currently:
sbt-plugins are not legitimate maven artifacts, which is why most sbt plugins are published to "raw" repositories in this fashion: http://www.scala-sbt.org/0.13/docs/Bintray-For-Plugins.html
Nexus, sometimes, will generate pom.xml files for ivy-deployed artifacts. This can seriously mess with sbt's resolution.
That said, a few users are, and have been, successfully deploying plugins to maven central or nexus repositories. We're actively working on sbt-ivy integration currently, so you will hopefully see more guidance in the nexus + sbt area soon.

Related

Cannot see the builds after publishing the artifacts

I am new to Artifactory and just going through the guides and trying out some sample code.
I am trying to publish a maven artifact to my artifactory server. I have followed the following steps to do it:
Through the "Set me up" tool, get the settings.xml file for maven.
Download and place the settings.xml file to the ~/.m2 folder
Clone the maven example repo from the artifactory examples available on git.
Update the pom.xml file and add the distributionManagement tag provided in the "Set me up" window.
Publish the code using mvn deploy
The binaries are published to the artifactory server and are available in the Artifact Repository Browser window. But I do not see any corresponding builds in the Build Browser. I also do not get any builds if I try to fetch them using the REST API
What am I missing? I followed the above steps because I saw it on the Introduction to Artifactory webinar video. Is there any setting that I need to change to see the builds in the Build Browser window?
I am using Artifactory Version 5.10.3 (OSS)
I think there is a misunderstanding, the maven example plugin is used for publishing artifacts to Artifactory, however, it doesn't publish Build Info.
In order for you to publish build info to Artifactory, you will either need to use CI server with Artifactory plugin (for example, Jenkins, Bamboo, Teamcity) or use the Maven Artifactory plugin:
https://www.jfrog.com/confluence/display/RTF/Maven+Artifactory+Plugin
That have the build information publish step inside.

SBT publishing snapshots to sonatype

I am working on a project and the source got open sourced and we've decided to publish to maven central.
https://github.com/mdsol/mauth-java-client/tree/refactor/publish_to_sonatype
Currently we are publishing to an internal repo and it allows publishing of SNAPSHOTS with timestamps so we can publish multiple time the same snapshot version. However, it looks like sonatype doesn't allow uploading with timestamps or overwriting.
How do I delete existing snapshot of sonatype so new one can be published as part of the sbt build? Also, do I sonatypeRelease the snapshots?
You have to create a Sonatype account, and then log in via their web front-end: https://oss.sonatype.org/
Once you did a sbt publishSigned, for example, you can then search for your package in the (staging) repositories and, if you are indeed logged in while doing that, delete or release it. (I found that sbt sonatypeRelease did not reliably release my package. So I ended up using their web front-end exclusively for the latter.)
This is outlined, more or less, also in the official sbt documentation:
https://www.scala-sbt.org/1.x/docs/Using-Sonatype.html#Third+-+Publish+to+the+staging+repository

Nexus error "Could not find artifact" when the same Nexus displays artifact metadata

On the Sonatype.com website I can read the following
Nexus is a repository manager. It allows you to proxy, collect, and
manage your dependencies so that you are not constantly juggling a
collection of JARs. It makes it easy to distribute your software.
Internally, you configure your build to publish artifacts to Nexus and
they then become available to other developers. You get the benefits
of having your own ‘central’, and there is no easier way to
collaborate.
The part about "constantly juggling a collection of JAR" I find intriguing.
I my experience, this is exactly what the Nexus process looks like.
As an example. My build is failing with message
[ERROR] Failed to execute goal on project myproject: Could not resolve dependencies for project myproject:jar:1.0.0-SNAPSHOT: Could not find artifact net.sf.saxon:saxon-dom:jar:9.0 in nexus (https://mynexus:8443/nexus/content/groups/public/)
So supposedly the Nexus repo at https://mynexus:8443/nexus/content/groups/public/ does not contain this artifact.
Using the Nexus web interface I can however search and find this particular artifact. It is located in the Jboss Maven2 repo.
What I can also do is navigate the index of the Public Repositories and find this particular artifact saxon-dom version 9.0 manually by expanding the tree navigator. It is in the folder net\sf\saxon.
So my conclusion is that Nexus is exactly not doing what it is claiming to be doing. It is not helping me manage dependencies - I have to resolve those manually.
What results is exactly like constantly juggling collections of jars. I have to manually download those and put them on the class path in order to perform a build.
As a Repository Manager it does not look very useful.
As it turns out, I needed to wrap my brain around the way that Nexus deals with missing dependencies.
This issue I think that artifact saxon-dom was once part of the repo but removed at some point. See https://repository.jboss.org/nexus/content/groups/public/net/sf/saxon/saxon-dom/
So there still is some metadata but not the jar and the pom.
When I search for the artifact Nexus finds it based on this metadata. In search results I can see the jar and pom.
Now I mistakenly thought that the artifacts are found and in the repo. This is not the case because if we try to download the jar you see message similar to below.
So Nexus caches the 404, the fact that it was unable to find the artifact. But it is completely unclear in the UI that the result is a cached 404.

Apache Karaf dependency on network

I am using Apache Karaf 2.3.0, and deploying my bundles as Activator bundles. At some place ver rarely I face a problem where my karaf does not start up the bundles. But I see that when i start the container on such boxes with the network(on my Linux box) brought down, it starts up. I am just a bit confused as to what is the dependency that Karaf is having on the network, that is stopping it from resoving all the bundles. From my application specific bundle code, I am not specifically using the network.
What is the dependency of Karaf on the network?
Karaf deploys bundles as maven artifacts, sometimes it will try to figure out to use the latest from the repository. I think there has been a fix for this behavior already. You should use the latest 2.3.9 instead of 2.3.0. There has been a lot of improvements regarding this topic.
EDIT - Question Answers:
1) Karaf sometimes tries to load the artifacts from the local maven repository and after that from the system folder. This is a regression that has been fixed.
2) Yes this issue has been fixed on all current versions.
3) I would always go for version 3.0.2 since this is in line with future enhancements. 2.4. was introduced to have OSGi 5 capabilities with supporting the "Older" feature set, especially the command syntax which has been changed with 3.0
4) yes and has been made default with 3.0.x and 2.3.x
Got it running. It was indeed maven i believe. resolv.conf file on my linux box had ip entries in it which probably made maven to look outside, but was not getting a proper response. Removed the mvn urls from the /etc/ file and restarted the karaf and it started.
But i am yet confused as to how this works on the other boxes... thanks Achim

Flex Mojo Maven Compile Question

I am trying to get the flex mojos maven compiler to run my projects.
Anyone with feedback on the below information is appreciated.
I am using this configuration for the maven compiler plugin and for
some reason every time I run the clean install on my SWF project I
still see the following in the compile step for the app.
info.rvin.mojo
flex-compiler-mojo
true
true
-compiler.accessible=false
-compiler.actionscript-file-encoding UTF-8
-compiler.allow-source-path-overlap=false
-compiler.as3=true
-compiler.debug=false
That means I can not connect to my app via the Flex Builder's debug
tool. Any thoughts on how I should properly configure the plugin in
the pom.xml?
Thanks!
adam, we're just starting to build out the chapter on flexmojos in Maven: The Definitive Guide. For starters, use the new plugin groupId, artifactId that is listed in that chapter. velo moved the flexmojos project over to the Sonatype Forge a few months ago, and we're just getting the 3.0 release out.
To anyone out there reading this: remember Maven is a build tool; it only (typically) executes (parts of) your code as a consequence of executing the tests you've implemented.

Resources