[ggl2-users] Re: How to create a ggl Maven project "from scratch"?

  • From: Victor Gonzalez <victor.gonzalez@xxxxxxxxxx>
  • To: ggl2-users@xxxxxxxxxxxxx
  • Date: Fri, 21 Dec 2012 15:52:48 +0100

Hi Thomas,

Your pom.xml seems good to me. I don't know exactly what your problem is or
what error are you getting, but I'll try to explain what I've done to have
a new GGL2 project with Maven working:

Create the project with the src-ggl directory and a sample library:
$ cd /tmp
$ mkdir t4ggl
$ cd t4ggl/
$ mkdir -p src-ggl/ggl

Put the following content into src-ggl/ggl/example.ggl:
library ggl.example;

alg myAlg() returns double {
return 0.42;
}

Put your pom.xml in the root of the t4ggl project. Compile and package:
$ gglc
Compilation OK.
$ mvn package
...

And that's it. In the target directory there is a jar that can be added to
the classpath of some other GGL2 project and use the library like this:

import ggl.example;
show myAlg();

It's important to notice that the GGL2 compilation must be performed
explicitly before calling mvn package. Maybe it is possible to include the
GGL2 compilation into the maven build lifecycle, but right now I don't know
how to do it.

Also, in order to configure the project for the GGL2 environment, you would
need to add this to your pom.xml:

...
<build>
<outputDirectory>bin</outputDirectory>
...
</build>
...

so the output folder is bin and not target/classes. Thus, GGL2 won't give
strange compilation errors. Then, simply:

$ mvn eclipse:eclipse

and import the project into GGL2.

I hope you can use this to have it working. Please, let us know if you
still have problems. Good luck! =)
Víctor.


2012/12/20 Thomas LEDUC <thomas.leduc@xxxxxxxxxxxxxx>

> Dear GGL2 developers & users,
>
> I would like to compile and pack a set of Java classes (and JAR
> dependencies) and ggl script into a single JAR file with dependencies.
> I'm used to use the Maven project management tool.
>
> My aim is to deliver some devs (based on both ggl scripts and native
> java developments) into a single external JAR file that can enrich the
> Java build path of any new ggl project.
>
> To that purpose, I've tried to adapt the pom.xml file of my Maven
> project. unfortunately, the below content does not seem to be suitable.
> Could you please tell me how to do? I would like to write a simple
> tutorial entitled "How to produce your own GGL plugin using Maven and
> the binaries of the 1M6 release".
>
> Thanks once again for your help.
>
> Thomas
>
> PS: the pom.xml I've tested in vain
>
> <project xmlns="http://maven.apache.org/POM/4.0.0";
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
>    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
> http://maven.apache.org/maven-v4_0_0.xsd";>
>    <modelVersion>4.0.0</modelVersion>
>    <groupId>org.t4ggl</groupId>
>    <artifactId>t4ggl</artifactId>
>    <packaging>jar</packaging>
>    <version>0.0.1</version>
>    <name>t4ggl</name>
>    <url>http://maven.apache.org</url>
>
>    <properties>
>       <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
>       <installDir>target/lib</installDir>
>    </properties>
>
>    <repositories>
>       <repository>
>          <id>org.gearscape.ggl</id>
>          <name>GGL Repository</name>
>          <url>http://www.fergonco.es/maven-repo</url>
>       </repository>
>    </repositories>
>
>    <dependencies>
>       <dependency>
>          <groupId>junit</groupId>
>          <artifactId>junit</artifactId>
>          <version>3.8.1</version>
>          <scope>test</scope>
>       </dependency>
>
>       <dependency>
>          <groupId>com.vividsolutions</groupId>
>          <artifactId>jts</artifactId>
>          <version>1.12</version>
>       </dependency>
>       <dependency>
>          <groupId>jfree</groupId>
>          <artifactId>jfreechart</artifactId>
>          <version>1.0.13</version>
>       </dependency>
>       <dependency>
>          <groupId>jfree</groupId>
>          <artifactId>jcommon</artifactId>
>          <version>1.0.16</version>
>       </dependency>
>
>       <dependency>
>          <groupId>org.gearscape.ggl</groupId>
>          <artifactId>runtime</artifactId>
>          <version>1.0.1</version>
>       </dependency>
>
>       <dependency>
>          <groupId>com.ximpleware</groupId>
>          <artifactId>vtd-xml</artifactId>
>          <version>2.10</version>
>       </dependency>
>       <dependency>
>          <groupId>org.apache.xmlbeans</groupId>
>          <artifactId>xmlbeans</artifactId>
>          <version>2.4.0</version>
>       </dependency>
>       <dependency>
>          <groupId>commons-io</groupId>
>          <artifactId>commons-io</artifactId>
>          <version>2.0.1</version>
>       </dependency>
>       <dependency>
>          <groupId>joda-time</groupId>
>          <artifactId>joda-time</artifactId>
>          <version>2.0</version>
>       </dependency>
>    </dependencies>
>
>    <build>
>       <resources>
>          <resource>
>             <directory>src-ggl</directory>
>          </resource>
>       </resources>
>       <plugins>
>          <plugin>
>             <artifactId>maven-eclipse-plugin</artifactId>
>             <version>2.8</version>
>             <configuration>
>                <classpathContainers>
>
> <classpathContainer>org.eclipse.jdt.launching.JRE_CONTAINER
>                   </classpathContainer>
>                   <classpathContainer>org.gearscape.ggl.GGL_CONTAINER
>                   </classpathContainer>
>                </classpathContainers>
>                <additionalProjectnatures>
>                   <projectnature>org.eclipse.xtext.ui.shared.xtextNature
>                   </projectnature>
>                </additionalProjectnatures>
>                <buildcommands>
>                   <buildcommand>org.eclipse.xtext.ui.shared.xtextBuilder
>                   </buildcommand>
>
> <buildcommand>org.eclipse.jdt.core.javabuilder</buildcommand>
>                </buildcommands>
>                <sourceIncludes>
>                   <sourceInclude>**/*.ggl</sourceInclude>
>                   <sourceInclude>**/log4j.properties</sourceInclude>
>                </sourceIncludes>
>             </configuration>
>          </plugin>
>          <plugin>
>             <artifactId>maven-dependency-plugin</artifactId>
>             <version>2.1</version>
>             <executions>
>                <execution>
>                   <phase>install</phase>
>                   <goals>
>                      <goal>copy</goal>
>                      <goal>copy-dependencies</goal>
>                   </goals>
>                   <configuration>
>                      <artifactItems>
>                         <artifactItem>
>                            <groupId>${project.groupId}</groupId>
>
> <artifactId>${project.artifactId}</artifactId>
>                            <version>${project.version}</version>
>                            <type>${project.packaging}</type>
>                         </artifactItem>
>                      </artifactItems>
>                      <outputDirectory>${installDir}</outputDirectory>
>                   </configuration>
>                </execution>
>             </executions>
>          </plugin>
>          <plugin>
>             <groupId>org.codehaus.mojo</groupId>
>             <artifactId>build-helper-maven-plugin</artifactId>
>             <version>1.7</version>
>             <executions>
>                <execution>
>                   <phase>generate-sources</phase>
>                   <goals>
>                      <goal>add-source</goal>
>                   </goals>
>                   <configuration>
>                      <sources>
>                         <source>src-ggl</source>
>                         <source>src-gen</source>
>                      </sources>
>                   </configuration>
>                </execution>
>             </executions>
>          </plugin>
>
>          <plugin>
>             <artifactId>maven-assembly-plugin</artifactId>
>             <version>2.3</version>
>             <configuration>
>                <descriptorRefs>
>                   <descriptorRef>jar-with-dependencies</descriptorRef>
>                </descriptorRefs>
>             </configuration>
>             <executions>
>                <execution>
>                   <id>make-assembly</id> <!-- this is used for
> inheritance merges -->
>                   <phase>package</phase> <!-- bind to the packaging
> phase -->
>                   <goals>
>                      <goal>single</goal>
>                   </goals>
>                </execution>
>             </executions>
>          </plugin>
>       </plugins>
>    </build>
> </project>
>
> --
> Thomas LEDUC
>
> UMR CNRS/MCC 1563 - Laboratoire CERMA
> Tel : +33 (0) 240 597 599 ---  Fax : +33 (0) 240 591 177
> ensa Nantes - 6, quai F. Mitterrand - BP 16202 - F-44262 NANTES cedex 2
>
>
>

Other related posts: