How to publish multiple jar files to repository sbt - scala

I have multi module project and using Build.scala to build. I am using nexus repository to publish.
Project structure is like
NLP
Core
Project1
Project2
Now say Project1 depends on Core and Project2 depends on Core and Project1 and lastly main project has dependency on all these jars.
When I do publishTo nlp.jar and pom.xml gets published to repository
I also would like to publish jars from other projects as well so those are available to consumer project. However somehow I am able to publish only nlp.jar and other projects jar and pom files are not getting published.
I tried to even look at following link however that did not help.
publish jar files with sbt (3rd party)
Thanks for help in advance.

Related

Is there a way to add GitHub projects to a GitHub Java *Ant* repository as dependencies

I am looking for a way to add GitHub projects to a GitHub java ant repository as dependencies. I saw that Maven project can handle dependencies and GitHub automatically add them to the dependencies graph. It is useful for workflows, such as Java CI.
I found that it would be possible to register dependencies for the repository, for example by adding extra-files like requirements.txt (found it for Python projects), but could someone explain me what is such text configuration files syntax for Java Ant projects, and how to use it then inside the repository, or in the Java CI workflow.
I tried to add Java jar libraries names in the ant file build.xml, in the CLASSPATH definition, but it is not what GitHub expects for Java CI dependencies.
Thank you very much in advance.

how to create a scala sbt project model which represents a model to other sbt projects?

i have a scala js sbt project, i developped in this project new user interface components.
the person p1 has a project with the same structure (same build.properties & plugins.sbt), how can he access to my user interface components.
Should i add some specification in build.sbt ?
If you want to share some project settings, you can create a sbt plugin - it will allow you to have some common settings, add dependencies to other sbt plugins and even override their configuration. See for example sbt-softwaremill as a example of plugin that is used to share some commons between projects.
It won't magically update all configs, because:
build.properties is evaluated before the sbt code is run
you have to add this plugin to plugins.sbt
you have to create project structure in each project
Any more config sharing than that is theoretically possible by e.g. using git submodules and commiting symlinks to repo, but that would be pretty wrong - any change to one project would result in a change in another project, and you have them separated for a reason - if both projects were the same you would have one project in the first place.
And if you are need to share the code itself, you can build the code, publish it to an artifactory and add dependency in another project.
But that's only if you really have two projects, and it's entirely possible that you just need to have one git project with different branches, where ever developer would work on their own branch and then merge changes to common branch, bacause that's the point of using git.

Maven Dependencies not downloaded for the Jar artifact in local repository using archiva

I am trying to setup a organization wide maven repository. I have installed archiva as a service and added a mirror in my local settings.xml of maven to disable the maven central.
I have uploaded my project1's jar into archiva internal repository. I use the groupid, artifactid and version number of the project1's jar in my project2's POM.xml. I see that that project1's jar has been added into maven dependencies. But the project1's dependencies are not downloaded.
I created the jar for project1 using maven build (using goal as "package"). What changes are needed in project1's POM.xml or any other configuration to make it work.
The issue was I was just uploading the jar. I was making a mistake of not uploading the POM.xml along with it. This resolved the issue for me.

maven publish jar to .ivy

I have a maven project, which will produce a jar file, and I want to use it in another sbt project. Is there any method to publish the jar file to .ivy rather than in .m2?
I try to put the jar file in the libs under the sbt project, but it does not work. and use the mvn install the jar to the .m2 does not work too.
As I understand it you have a maven project and an SBT project. The SBT project depends on the artifact produced by your maven project.
You ask how to publish the maven produced artifact to your local .ivy so it can be picked up by the SBT project.
you can probably achieve that using an ant task in the maven build.
However I'd like to suggest different angles :
Make the sbt project aware of the local .m2
Simply add resolvers += Resolver.mavenLocal to your sbt build definition, if you don't want to pollute the main build definition, add that line to a local.sbt file alongside the main build defition. SBT merges all the .sbt files found at the project root.
Publish to a controlled repository
This is especially useful if you want the build to be easily reproduceable outside of your local machine.
The idea is simply to publish the maven project to an actual server, either an internal nexus/artifactory server for proprietary code or to a public artefact hosting (such as bintray)
I use bintray all the time to publish custom builds of opensource projects while I wait for PRs to be merged in master and published an the official build.
Add your artifact server as a resolver to the SBT project and you are good to go :)

Update project version and versions in other projects dependencies

Suppose you have 2 projects in the same Eclipse workspace. I'll call them project1 and project2.
project1 is in 1.0.0 version;
project2 is in 1.2.0 version;
project1 has project2 as its dependency;
project2 isn't a child of project1.
What I'm trying to achieve is:
I want to update the project2 version to 1.3.0 (for example), and update the dependency version in project1 to reference the new version of project2. Is there any automated way to do that with Maven/Eclipse or I'll have to do manually?
I think there is no direct way with Maven. However I would try a different approach:
project1 writes its version number in a properties file, something like project1.version = 1.0.0. This can be easily done using filtering.
project2 reads the properties using the properties-maven-plugin and the dependency to project1 uses something like <version>project1.version</version>.
However I find this approach strange. I think that your two projects are very close and should be sharing a parent pom and have the same version, or you should handle this manually, because a version update is never trivial and should be done with caution (and testing).