[Fiware-middleware] Links and template-project to start with gradle

Dmitri Rubinstein Dmitri.Rubinstein at dfki.de
Wed Nov 12 10:19:02 CET 2014


Problem solved by adding this:

antlr4.extraArgs=['-package', 'com.kiara']

Now I finished porting my KIARA Maven project to Gradle (see 
attachment). Everything seems to work besides annotation problem:

warning: Supported source version 'RELEASE_6' from annotation processor 
'org.antlr.v4.runtime.misc.NullUsageProcessor' less than -source '1.7'

Best,

Dmitri

On 11/12/14 09:42, Dmitri Rubinstein wrote:
> I have also another problem. When I add following class:
>
> package com.kiara;
>
> public abstract class MyListener implements ExprListener {
>
> }
>
> in file: src/main/java/com/kiara/MyListener.java
>
> I get errors:
>
> /home/rubinste/proj_de3/kiara-gradle-template/src/main/java/com/kiara/MyListener.java:12:
> error: cannot find symbol
> public abstract class MyListener implements ExprListener {
>
> But having MyListener class in the default package works.
>
> Any ideas ?
>
> Best,
>
> Dmitri
>
> On 11/12/14 09:03, Marti Christof (mach) wrote:
>> Hi Dmitri
>>
>> This operator was introduced with Java 7 (javac 1.7), as many other
>> nice enhancements.
>> (Before you had to type Map<String,String> m = new
>> HashMap<String,String>() )
>> That is one of the reasons, I want to go to 1.7 or 1.8 asap.
>>
>> To fix this you must change the “sourceCompatibility" entry in
>> build.gradle to 1.7 or higher.
>> But then we start getting the problems with the antlr4 annotation
>> processor.
>> Another option would be to disable the annotation processor (?) or
>> provide our own version of (4.4.1) which is on the antlr4 master tree.
>>
>> BR,
>> Christof
>>
>>> On 12.11.2014, at 00:38, Dmitri Rubinstein
>>> <Dmitri.Rubinstein at dfki.de> wrote:
>>>
>>> I created gradle project with your project file, but diamond operator
>>> does not work:
>>>
>>> Map<String, String> m = new HashMap<>();
>>>
>>> Best,
>>>
>>> Dmitri
>>>
>>> On 11/11/14 20:32, Marti Christof (mach) wrote:
>>>> Hi everybody
>>>>
>>>> I put together some starter links about gradle and created a
>>>> template project for kiara, which adds some plugins and
>>>> configuration to support and integrate with antlr4, maven, eclipse
>>>> and IntelliJ Idea.
>>>>
>>>> Gradle-UserGuide & References:
>>>> http://www.gradle.org/docs/current/userguide/userguide.html
>>>> (you'll find almost everything there)
>>>> Gradle-Plugins registry: http://plugins.gradle.org
>>>> (e.g. the antlr4 plugin entry is here:
>>>> http://plugins.gradle.org/plugin/me.champeau.gradle.antlr4)
>>>>
>>>> Good-Intro about why and how (compared to Ant/Maven) from the
>>>> creator Hans Dockter (if you have time: 85’):
>>>> https://www.youtube.com/watch?v=5a91dBLX8Qc
>>>>
>>>> Here you’ll find the kiara-gradle-template project:
>>>> https://github.com/christofmarti/kiara-gradle-template
>>>> (it does not contain any KIARA specific files yet; only a typical
>>>> project hierarchy and configuration for the plugins)
>>>>
>>>> If you clone it, you can use "./gradlew” (resp. gradlew.bat) to call
>>>> the correct version of gradle, without preinstalling gradle. (e.g.
>>>> change to project dir and execute "./gradlew tasks" to list all
>>>> available tasks)
>>>> The main advantage of the wrapper is, that always the correct
>>>> version of the tool is used. If not available it will be downloaded
>>>> and installed locally from the path defined in
>>>> ./gradle/wrapper/gradle-wrapper.properties.
>>>>
>>>> To create eclipse project files type "./gradlew eclipse"
>>>> To create IntelliJ IDEA project files type "./gradlew idea"
>>>> "./gradlew build" builds and assembles the whole project (incl.
>>>> processing antlr4 files)
>>>> “./gradlew clean” removes all generated files (but not eclipse or
>>>> idea configs; use cleanEclipse or cleanIdea for this).
>>>>
>>>> I included a community plugin for antlr4. Sources have to be in
>>>> src/main/antlr4/ (configureable).
>>>> I had to add some Java version fixes, because the annotation
>>>> processor of antlr only supports Java 7&8 from version 4.4.1 which
>>>> is not yet in the repositories (see:
>>>> https://github.com/antlr/antlr4/issues/487)
>>>>
>>>>
>>>> @Dmitry:
>>>> If you have a maven (pom) project, you can create an initial gradle
>>>> configuration using:
>>>> "gradle init --type pom”
>>>> This needs a full gradle installation, not the wrapper
>>>> (see
>>>> http://www.gradle.org/docs/current/userguide/build_init_plugin.html#N14BBA
>>>> for details)
>>>>
>>>>
>>>> Best regards
>>>> Christof
>>>> ----
>>>> InIT Cloud Computing Lab - ICCLab http://blog.zhaw.ch/icclab
>>>> Institut of Applied Information Technology - InIT
>>>> Zurich University of Applied Sciences - ZHAW
>>>> School of Engineering
>>>> Phone: +41 58 934 70 63
>>>> Skype: christof-marti
>>>>
>>>>
>>>> _______________________________________________
>>>> Fiware-middleware mailing list
>>>> Fiware-middleware at lists.fi-ware.org
>>>> https://lists.fi-ware.org/listinfo/fiware-middleware
>>>>
>>>
>>> _______________________________________________
>>> Fiware-middleware mailing list
>>> Fiware-middleware at lists.fi-ware.org
>>> https://lists.fi-ware.org/listinfo/fiware-middleware
>>
>

-------------- next part --------------
// In this section you declare the used plugins
// community plugins
plugins {
    id "me.champeau.gradle.antlr4" version "0.1" // antlr4 community plugin. 
}

// internal plugins
apply plugin: 'java'
apply plugin: 'maven'   // only needed to generate POM or to upload artifacts to maven repos.
apply plugin: 'eclipse' // Eclipse integration
apply plugin: 'idea'	// InteliJ IDEA integration
apply plugin: 'project-report' 

//general properties
version = '0.0.1-SNAPSHOT'

description = """"""

// java plugin properties (until antlr 4.4 we have to set this to 1.6)
// (https://github.com/antlr/antlr4/issues/487)
sourceCompatibility = 1.7
targetCompatibility = 1.7

// temporary fix until we can switch to sourceCompatibility=1.7+
// (http://stackoverflow.com/a/20779740)
tasks.withType(JavaCompile) {
	options.bootClasspath = "$System.env.JAVA_HOME/jre/lib/rt.jar"
}

// maven-plugin properties
group = 'de.dfki.kiara'

// antlr4-plugin configuration
// make the Java compile task depend on the antlr4 task
compileJava.dependsOn antlr4
// add the generated source files to the list of java sources
sourceSets.main.java.srcDirs += antlr4.output
// add antlr4 to classpath
configurations {
   compile.extendsFrom antlr4
}

// In this section you declare where to find the dependencies of your project
// see also: http://www.gradle.org/docs/current/userguide/artifact_dependencies_tutorial.html#N10621
repositories {
    // You can declare any Maven/Ivy/file repository here.
    // e.g. for 'jcenter.bintray.com' for resolving your dependencies use:
    // jcenter()
    // and/or use the standard mavenCentral repositoy:
    mavenCentral()
    // and/or use use a custom maven repository:
    // maven { url "http://repo.mycompany.com/maven2" }
}

dependencies {
    compile group: 'org.antlr', name: 'antlr4', version:'4.2.2'
    compile group: 'com.google.guava', name: 'guava', version:'17.0'
    compile group: 'com.fasterxml.jackson.core', name: 'jackson-databind', version:'2.3.3'
    compile group: 'io.netty', name: 'netty-all', version:'4.0.21.Final'
    compile group: 'org.slf4j', name: 'slf4j-jdk14', version:'1.7.7'
    testCompile group: 'junit', name: 'junit', version:'4.10'
}

antlr4.source = project.file("src/main/antlr4")
antlr4.listener = true
antlr4.visitor = true
antlr4.extraArgs=['-package', 'de.dfki.kiara.idl']

// make the Java compile task depend on the antlr4 task
compileJava.dependsOn antlr4

// add the generated source files to the list of java sources
sourceSets.main.java.srcDirs += antlr4.output

// add antlr4 to classpath
configurations {
   compile.extendsFrom antlr4
}


More information about the Fiware-middleware mailing list

You can get more information about our cookies and privacy policies clicking on the following links: Privacy policy   Cookies policy