Download compile and publish from within SBT Task - scala

I have a dependency on a project that is not published online, i need to download the Zip from github, compile it and publish local. So my dependency can be resolved.
Is there a way to do that with sbt. This code shows how to do the download part download a zip from url and extract it in resource using SBT but not the compile and publish part
Can anyone help or give pointer please.

If your purpose is only to depend on a project on github you don't need to go through all of that, you can simply directly depend on that project as in this:
https://stackoverflow.com/a/7550450/913053

Related

Publish a jar file to GitLab package repository

I have a scala project, and using SBT I was able to generate a jar file out of it.
My next challenge is to to publish the generated jar file into Gitlab's package repository so I can reference this jar file (module) in another scala project.
I found several resources for that, using MAVEN or SBT .. but not sure how do I start, because I'm new to it and I'm a bit lost. Is it possible to publish the file using SBT as well?
Reference 1: I'm lost in between GRADLE and MAVEN
Reference 2: I'm lost with this, because It's not clear to me how to achieve it and what is the relation in between the maven repository and the jar file.
Any simple guidance/clarification is greatly appreciated.
You should look at the SBT way of publishing: https://www.scala-sbt.org/1.x/docs/Publishing.html
And then adapt the "repository URL" to be the one of your Gitlab. And follow Gitlab documentation of any specific configuration must be defined.

How to make sbt download its own sources/javadoc?

I know that I can download the sources/java-doc for my dependencies using the update-classifiers task.
But it would also be interesting to be able to download the sbt sources/java-doc, as Intellij is not showing me any kind of documentation for sbt-related stuff. I've already checked on their website and they seem to only provide the binaries. I would like to avoid having to download their github project, if possible.
Thanks

adding google analytics jar via SBT to scala project

I want to add google analytics package/jar to a scala project with SBT. However I cannot find the URL of the project on http://mvnrepository.com/
I've also tried looking for it on google forums but to no avail.
I'm thinking of downloading the jar and adding it to sbt as an unmanaged jar. I think a jar is found at https://code.google.com/p/google-api-java-client/source/browse/com/google/apis/google-api-services-analytics/v3-1.3.3-beta?repo=mavenrepo&r=5f31c0ad06088b1762f414890cef93ba177ad4b8
but this is a maven repository. Now, instead of downloading the jar, I'd like to let SBT handle downloading of libs, but for this I need the URL of the maven repository that I just posted the link to where the google code is.
Question
Is there a way to figure out the URL to the maven repository where google analytics jar is stored (from the URL above)? Any other repository that has a copy of google analytics will also do.
I think this is what you want: http://mvnrepository.com/artifact/com.google.apis/google-api-services-analytics
In this case I just googled the artifact name ("google-api-services-analytics") but the structure of maven repositories tends to be very predictable. If you go one level up in the google code page you linked and check out maven-metadata.xml, that will tell you the group and artifact to look for in a repository.

Get a Hudson build with Maven

I have moved to Maven recently, and since it works fine for resources up to date in some repositories, it's not obvious for non-maven ones.
I have something very simple to achieve (in the idea), but that I am unable to express so far:
I need to compile my code with a jar that can be found here:
https://hudson.eclipse.org/hudson/view/WTP/job/cbi-wtp-wst.xsl.psychopath/ws/sourceediting/plugins/org.eclipse.wst.xml.xpath2.processor/target/
What do I have to put in my pom.xml to make Maven downloading the .jar + the java source + the javadoc, and eventually the other dependencies (actually IBM ICU, Xerces, JavaCup) that are mentionned in the supplied MANIFEST ?
I have read lots of documents, including those with a plugin called Tycho, but nothing helpfull for that simple task.
Thanks for your help.
Maven only works well if all artifacts needed for a build are contained in the local or a configured remote repository. So you have to do the following jobs:
Find out if eclipse plugins are deployed in a Maven2-style repository, and what the URL of that repository is.
Then find out which version of that plugin (artifact) you need.
Maven allows you to configure what will be copied locally: jar file, sources and api doc if you want to.
Maven should then be responsible to download as well all needed artifacts for the plugin you want to use.
After looking at the contents of the URL you gave us (especially the file p2content.xml), it looks like there should be a repository. I searched for the maven repository for org.eclipse.wst.xml.xpath2 and found the URL http://maven.eclipse.org/nexus/content/repositories/testing/org/eclipse/wst/org.eclipse.wst.xml.xpath2/1.1.0/org.eclipse.wst.xml.xpath2-1.1.0.pom
So the repository you are searching for is located at http://maven.eclipse.org/nexus. Just open it, search for example for xpath2, and Nexus, the repository software used there will you show the available artifacts. Depending on what was deployed to that repository, it may contain only the library, or have even sources and JavaDoc bundled with it. For the example above (xpath2), there seems to be only the POM itself and the library (the jar). If you take as example junit, you will find all versions and variants, even with sources.jar and javadoc.jar.
After you have found the needed artifact, you can include it in the dependency section of your POM. And you have to add http://maven.eclipse.org/nexus as a remote repository in the configuration of your Maven installation.
The question and its answer Get source JARs from Maven repository explain how to fetch sources and JavaDoc (if they are available).
You need a maven repository which contains this artifacts (i don't know, if Eclipse hosts a repository for their projects). You can also deploy manually the artifacts to a local repository on your computer.

Maven: Prevent upload of default-jar - only upload jar-with-dependencies

I'm evaluating Maven 3 at work. For several example projects I have to deploy them to a server (no repository), but that's not the problem.
In my current example-project I'm trying to upload only the "jar-with-dependencies".
and exactly that's my problem.
It all works fine, except that the main-artifact AND the jar-with-dependencies (created by the assembly-plugin) are uploaded.
How do I prevent Maven or rather the deploy-phase from uploading the main-jar and only upload a given or specified file (in this case, the assembly-file "jar-with-dependencies")?
Referring to the question Only create executable jar-with-dependencies in Maven, I can't just alter the packaging-setting to pom, because it will also prevent the assembly-plugin from adding my classes to the JAR file. It only creates a JAR file with the files of the dependencies.
I hope I'm clear about my problem, and you can help me ;)
if you just looking how to add a file to be deployed you can take a look here:
http://mojo.codehaus.org/build-helper-maven-plugin/attach-artifact-mojo.html
May be this helps. If not express your needs more in detail.
There seems to be no way to configure the deploy plugin to filter out some of the artifacts from a project and selectively deploy the others. Faced with a similar problem, we solved this with the ease-maven-plugin. It fit well into our release process but might not be the right choice for everyone as it mandates a two-step approach. During the build you would make a list of all artifacts and filter out those that you want deployed. In a second step, you then run mvn deploy on a separate project (or separate profile) in which the list of artifacts is attached to the project as the only artifacts which then get deployed. See the examples in the source code of the ease maven plugin to better understand how it works.
The original version is not able to filter out specific artifacts of a project. I have forked the project and added patches that add this.