maven publish jar to .ivy - scala

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 :)

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.

M2Eclipse: Automatically execute Maven when pom.xml changes?

For an Eclipse plugin project I need a p2 local repository to be automatically deployed with dependencies defined in the pom.
The best way (or the only way that really works) to do so is to use org.reficio plugin p2-maven-plugin.
Therefore I created a general project in Eclipse to prepare and hold the repository and a pom.xml that generates this repository.
When I execute the goal p2:site the repository is created successfully.
Now I am trying to make Eclipse with M2Eclipse to automatically execute that goal whenever the file pom.xml has ben changed (e.g. the user has added a new dependency or the file has been changed because an updated file has been downloaded from the SCM repository.
Is there a way to make M2Eclipse respectively it's Maven Project Builder to execute this phase automatically?

How to publish open source library to my nexus server with sbt

I want to publish an open source library to my own remote nexus repo. I try to change .sbt files for the library but sbt publish still tries to release using the normal sonatype nexus repo. sbt publish-local works fine for a different local project so I think that maybe I can deploy this lib without changing the .sbt files to my remote nexus.
Can I publish this lib only with added credentials in the command line?

How to publish multiple jar files to repository sbt

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.

maven - inter workspace dependencies

i am using eclipse and maven integration.
maven install puts the resources to the local repositories. local repositories is divided into "local repository" and "workspace projects" as shown in eclipse view "Maven Repositories".
The resource is unvailable to be linked by other projects of a different workspace. is there a way having "maven install" to put shnapshots to the "top" local repository available for any project?
or do i missunterstand the concept?
Workspace projects is a just a convenience feature provided by the m2e plugin where it resolves the dependencies to projects in the current workspace if the artifact specification (group id, artifact id and version) matches that of a project in the workspace. If there are no matches, m2e just uses the jar in the .m2/repo folder as the dependency.
The benefit of this feature is that you don't have to maven build and install the dependency projects continuously, your code changes are reflected immediately in the dependent project.
However, this is just a convenience feature and you can always do a maven install in a dependency project and refresh the dependent project to get the change reflected there.
TL;DR just do a usual maven install on your dependency project and refresh any workspace. It should work.