#866 Maven + Fantom ?

stephanos Sun 13 Dec 2009

Hi folks,

I have no experience with Fantom yet - but it looks cool and so I want to include it in my programming exercise site http://codingkata.org.

For that to happen I need to compile the Fantom source code to bytecode via Maven. I wasn't able to find a plugin - is there one? Alternatively could it be done via the antrun plugin?

Kind regards, stephanos

brian Sun 13 Dec 2009

I'm sure the jfrog guys can provide some good advice since they do both Artifactory and the Fantom IntelliJ plugin.

freddy33 Sun 13 Dec 2009

We already thought about this, but it leads to 2 issues:

  1. Fan output should be a pod file and an optional jar file (from jstub)
  2. Using like suggested for OSGi the fantom.{podName}.{version} as GAV is going to be very hard to manage

To solve them we need:

  1. Create a small fantom compiler plugin executing the normal build.pod than emitting the class files under the standard maven output
  2. Make the above plugin register the pod as produced artifact so maven will deploy it
  3. Add some kind of "vendorName" value to the pod identification so the full ID will be: {vendorName}.{podName}.{version}

Frankly it feels awkward, since using the current build of Fantom is way easier than Maven. What I started to think about (play around) is how to declare a Maven dependency directly in the pod declaration. For example, Depends("maven:com.nitido:jtoaster 1.0.4") for including the Java twitter API.

Fantom build will need to download and install the jar respecting Maven convention (I don't know if you want that!).

Anyway, one of our user proposed to develop this plugin, I will asked him again.

tompalmer Tue 15 Dec 2009

Side note, I've been wondering if there might be value in exporting Fan metadata into standard jars, whether as resource files or as metadata on Java classes. Either might allow pure jar export of Fan pods. Maybe not needed right away, but something to keep in mind for the future perhaps.

LightDye Tue 4 Jun 2013

Is this possible yet? I haven't found how to do this in a Build Script.

What I started to think about (play around) is how to declare a Maven dependency directly in the pod declaration. For example, Depends("maven:com.nitido:jtoaster 1.0.4") for including the Java twitter API.

Could anyone point me in the right direction, please?

SlimerDude Tue 4 Jun 2013

You could try using the Maven Exec plugin or the AntRun plugin to call build.fan:

http://sanchitbahal.wordpress.com/2011/09/19/maven-exec-plugin-vs-maven-antrun-plugin-for-running-command-line-tool/

LightDye Tue 4 Jun 2013

Thanks SlimerDude, but instead of running build.fan from Maven, what I want is to specify Java dependencies within build.fan referring to Java libraries on Maven repositories. Dependencies just like this:

<dependency>
    <groupId>group-a</groupId>
    <artifactId>artifact-b</artifactId>
    <version>1.0</version>
    <type>bar</type>
    <scope>runtime</scope>
</dependency>

but obviously using Fantom syntax instead of XML. I want my project to be mainly Fantom based but I may need to invoke Java libraries for specific tasks and I don't want to manage the dependencies manually. Is this possible?

SlimerDude Tue 4 Jun 2013

Hi LightDye, if I read you right, you want to download your java dependencies using maven.

There's nothing for Fantom out there that I know of, but I guess you could have build.fan call a Maven goal which does it:

http://stackoverflow.com/questions/7908090/downloading-all-maven-dependencies-to-a-directory-not-in-repository

LightDye Thu 6 Jun 2013

Hi SlimerDude, thanks for the link. I haven't tried this approach yet but it looks promising.

if I read you right, you want to download your java dependencies using maven.

Well, ideally not using Maven but rather a Fantom native "client" of Maven repositories, so that I can specify Java dependencies within build.fan, for example:

using build
class MyBuild : BuildScript {
  new make() {
    ...
    depends = ["sys 1.0+"]
    maven_repos ["central,http://repo1.maven.org/maven2"]
    maven = ["com.jayway.restassured,rest-assured,1.7.2,jar,test"]
    ...
  }
}

Then if I type build test in a command prompt from my project's root folder, I would expect Fantom to check if rest-assured-1.7.2.jar exists in %FAN_HOME%\lib\java\ext\win32-x86 (assuming I'm running Windows) but if it doesn't then go off and download it from any of the declared maven repos along with its dependencies and save them all in Fantom's Java libs folder. This would be the ideal world... and I want a pony too :-).

In essence what I want to achieve is not having to manage Java dependencies manually...

  1. Try to compile and it fails because a jar file is missing
  2. Manually download the required jar file and copy it where Fantom can see it
  3. Try to compile again and fail again because the new jar depends on something else, etc.

I guess the alternatives are to create Fantom wrappers for required Java libraries and add them to Fantom's repo or develop native Fantom libraries, but the problem is that it requires maintenance and puts impedance to reusing the rich Java libraries universe.

DISCLAIMER: rest-assured is just an example. I'm not using rest-assured in my project yet but I'm thinking of using it, unless there is a Fantom pod for testing REST services. I believe that enabling Fantom to use maven repositories to resolve Java dependencies would ease the usage of Java libraries from Fantom.

tcolar Thu 6 Jun 2013

You might also want to look into how others have done maven integration, for example gradle of groovy or "lein" of clojure which both integrate maven.

katox Fri 7 Jun 2013

Leiningen of Clojure just wraps Sonatype's Aether library. The wrapper can be found here: https://github.com/cemerick/pomegranate

So wrapping Aether is probably the way to go for Fantom too if you want to add maven dependencies.

SlimerDude Fri 5 Jul 2013

But how do you download Aether Library without a Fantom -> Maven downloading tool!?

Wrapping Aether does sound like the way to go, as transitive dependency resolution when you have conflicts is a nightmare. Plus Aether seems to handle POM parsing and such (for transitive dependencies).

qualidafial Thu 1 Aug 2013

Now might be a good time to take a look at Tesla. This is a side project by Jason van Zyl (creator of Maven) to enable polyglot use of Maven.

I've seen one fork of the project that automatically created an in-memory POM for Eclipse bundles using the OSGi manifest. It might be possible to do something similar with Fantom pods, by searching for build.fan files and automagically generating a POM from that. Might be cool.

tcolar Mon 5 Aug 2013

I also came across this today: https://github.com/adept-dm/adept/wiki

Meant to be a new JVM package manager, haven't looked it into it much yet, but I've never been a Maven fan so hoping this is better.

Login or Signup to reply.