Where do I get up-to-date versions of org.eclipse.jdt for Maven? - maven

I would like to use the Eclipse AST to generate source code. My project is managed by Maven and I would like to simply add dependencies for the compiler. Unfortunately, the most recent version I found in central is 3.3.0-v_771. The Tycho project offers newer versions. However, I found that the poms do not specify dependencies and I don't want to do that myself. I've spent quite some time googling for other sources but that's the best I could come up with.
Does anyone know of a better, maven-compliant way of getting JDT in Maven?

You can the use Maven-Eclipse-Plugin to deploy your Eclipse bundles to Maven on your own and then use these. An example command would be:
mvn eclipse:to-maven -DdeployTo=internal-nexus::default::http://myNexus/content/repositories/eclipse -DeclipseDir=C:/Eclipse
Alternatively you could purchase a license for Nexus Pro and provide Eclipse p2-Repositories as Maven repositories.

Now there is an other way. Some of the Eclipse Neon.2 jars are published as normal maven artifacts (pom files are user friendly, the standard dependency management of maven will work).
If you want to use jdt-core in your project you just need to add this:
<dependency>
<groupId>org.eclipse.jdt</groupId>
<artifactId>org.eclipse.jdt.core</artifactId>
<version>3.12.2</version>
</dependency>
... and you let maven do the rest for your. I have published a simple example how to use the java code formatter from eclipse in a simple java application.

Related

can you build a maven project inside of a gradle wrapper

It may be just that I have a general misunderstanding how gradle build works, but it feels to me that I can not build a maven file inside of a gradle build. Since gradle uses the gradle.build file, and maven uses a pom.xml, it does not seem as though I can do this. I have multiple maven projects that I would like to wrap up with a gradle wrapper. I can not find ANYTHING on whether this is even possible.
Both Maven and Gradle are build tools and you should only use one of them for a given project.
If you have existing Maven projects and like the functionality provided by the Gradle wrapper, there is a similar wrapper for Maven (note that this is currently a third-party plugin but they plan to include it in the upcoming release 3.7 of Maven).
Alternatively you could convert your projects entirely to Gradle.

Maven plugin Tycho -> when to use it and when not to use it

What is the purpose to use Maven Tycho plugins. I read here tycho is used for building eclipse plugins and OSGI bundle.
Questions:- Can not we build eclipse plugins and OSGI bundle just by using the plain old maven POM.xml file[by not using tycho plugin].
What does maven need tycho plugin to help it build eclipse plugin and OSGI bundles?
Why should we use Maven tycho plugin to build eclipse plugins and OSGI bundles?
When using maven (or other command line build tools) manifest.mf) in combination with Eclipse (or another IDE) the classpath ends up being written down twice - once in the pom.xml and once in the Eclipse .classpath (or, for OSGi, in the target platform and manifest.mf). This violates the DRY principle.
There are various solutions to this problem. One is something like m2e, where you use the pom.xml to generate the Eclipse .classpath. Alternatively, you can go in the other direction and start by getting things compiling in Eclipse, and then use a maven plugin to convert that Eclipse setup to a maven build. This is what Tycho does, with the extra wrinkle that it works from a PDE manifest + target platform rather than directly from the .classpath.
Maven doesn't have a built-in packaging type for OSGi bundles and/or Eclipse plugins. So unless you want to use the jar packaging type and manually add OSGi specifics, you need a Maven plug-in to help you with this.
Tycho is one of the plugins that add support for building OSGi bundles.

How to use scala.js from maven

Is there any way to use scala.js with Maven. I want to use scala.js in maven based project, and AFAIU, it's hard to integrate sbt with maven.
1) scalor-maven-plugin provides scala.js support
2) global remote shared parent pom.xml with scala.js profiles
3) gist examples of maven profiles which configure scala.js library and scala.js runtime projects
Unfortunately, this is not directly possible so far, because there is no Maven plugin enabling Scala.js.
Scala.js consists a few things:
A compiler plugin for scalac, which can be enabled with the Maven plugin for Scala.
Libraries of its own: scalajs-library, and optionally scalajs-javalibex.
Link-time tools: these are exposed directly within the sbt plugin, although the core of it is in a separate scalajs-tools library, which could be reused by a Maven plugin for Scala.js.
As of Scala.js 0.6.0, all these things are published on Maven Central, so can be resolved by Maven. (Except the sbt plugin with the sbt-specific parts, but that's not needed.)
As long as nobody actually develops a proper Maven plugin for Scala.js, the easiest might be to invoke the Command Line Interface of Scala.js from Maven to invoke the link-time tools (scalajsld in particular). I don't know Maven, but I assume it has tasks to invoke external command-line programs in its pipeline.
Edit: Updated for Scala.js 0.6.x: artifacts are now published on Maven Central.

How does Maven resolve sbt transitive dependencies? Is this Maven at all?

I have a maven project that depends on several sbt project, which in turn depends on more projects. Are these transitive dependencies being resolved by maven? E.g. in packing of assemby jar?
Let me answer this question with mine: How can you know what build tool was used in a dependency?
You can't unless the build tool leaves some files to let you guess what the build tool could have been. But still, they're just files that are generated as part of the publishing process so the other build tools could resolve dependencies.
That's the point of any build tool to let you integrate with the other build systems in a less troublesome way.
Maven requires pom.xml and an appropriate repository layout. sbt follows the rules while publishing project artifacts to Maven repositories.
Ivy requires other files in repositories and sbt does generate them (by default).
Gradle plugs itself in to the game by following Maven's standard files and directory layout.
Read about publish task. You may want to consult the official documentation of sbt. Start with http://www.scala-sbt.org/0.13/docs/Publishing.html.

RCP build with maven

How to build and package RCP (Rich client Platform) using Eclipse.
Is it possible to build as a .jar file.
I use Maven Tycho. I find it a lot easier to use than the PDE ant scripts.
The itp04 RCP example is a good project to get started.
We use Maven 3 and the sonatype-tycho plugin to build our Eclipse RCP-based application. It allows a plugin-first approach, i.e. you define the dependencies only in the plugin.xml using the editor of Eclipse. You don't have to care about dependencies in the pom.xml as these are managed by tycho.
There are detailed instructions at Apache Felix maven Bundle page on how to do this.
Alternatively, There are some quickstart maven archetypes you could download based on these instructions and experiment with.
I have wrapped PDE/Build by Maven manually. You can find an example in my answer to my own question:
How to set up Eclipse PDE/Build with Indigo?

Resources