Quantcast

IDEA plugin to add top level dependencies for multi-module build?

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

IDEA plugin to add top level dependencies for multi-module build?

mickknutson
This post was updated on .
I have the following build structure (shortened for clarity)


    buildscript {
        versions = [root: "1.0.0"]
   
        list1 = ["com.baselogic:common:${versions.root}"]
        list2 = ["com.baselogic:extended:${versions.root}"]    
 
        apply plugin: 'idea'

    }
   
    allprojects {}
   
    subprojects {}
   
    project('ch01') {}


    import com.yahoo.platform.yui.compressor.*
    import org.mozilla.javascript.*
   
    class SystemOutErrorReporter implements ErrorReporter {...}


When I run 'gradle idea' my intellij project that is generated has 'ch01' with the correct dependencies, but not the ROOT, or parent of the modules. it has no dependencies.

I need this because I am trying to have top level tasks that IDEA understands and unless I manually add the JARS to the root project, IDEA is complaining.
---
Thank You…

Mick Knutson, President, Certified Spring Instructor

BASE Logic, Inc.
Enterprise Architecture, Design, Training & Agile Consulting

Company: http://baselogic.com/blog/services/
---
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: IDEA plugin to add top level dependencies for multi-module build?

Peter Niederwieser
I don't see any top-level dependencies, unless you mean the build script dependencies (but those are irrelevant for IDEA project generation). What are you trying to achieve with applying the `idea` plugin in the build script section? That's not supported.

> I need this because I am trying to have top level tasks that IDEA understands

Can you clarify what you mean by that? Are you talking about the Gradle support in IDEA 11? That's independent of the `idea` plugin.

--
Peter Niederwieser
Principal Engineer, Gradleware
http://gradleware.com
Creator, Spock Framework
http://spockframework.org
Twitter: @pniederw
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: IDEA plugin to add top level dependencies for multi-module build?

mickknutson
Here is the full buildscript section along with the custom tasks I am running

buildscript {    

    apply plugin: 'idea'

    repositories {
        mavenCentral()
    }
    dependencies {
        classpath group: 'commons-codec', name: 'commons-codec', version: '1.2'

        // FIXME: Need to find out how to get global ${project.versions.yuicompressor}
        //classpath "com.yahoo.platform.yui:yuicompressor:${project.versions.yuicompressor}"
        classpath group: 'com.yahoo.platform.yui', name: 'yuicompressor', version: '2.4.6'
        classpath group: 'org.mozilla', name: 'rhino', version: '1.7R3'
        classpath files('../libs/yguard.jar')
        classpath fileTree(dir: 'libs', include: '*.jar')
    }
}

allprojects {...}

subprojects {...}

import com.yahoo.platform.yui.compressor.*
import org.mozilla.javascript.*

class SystemOutErrorReporter implements ErrorReporter {

    private String format(String arg0, String arg1, int arg2, String arg3, int arg4) {
        return String.format("%s%s at line %d, column %d:\n%s",
            arg0,
            arg1 == null ? "" : ":" + arg1,
            arg2,
            arg4,
            arg3);
    }

    @Override
    public void warning(String arg0, String arg1, int arg2, String arg3, int arg4) {
        System.out.println("WARNING: " + format(arg0, arg1, arg2, arg3, arg4));
    }

    @Override
    public void error(String arg0, String arg1, int arg2, String arg3, int arg4) {
        System.out.println("ERROR: " + format(arg0, arg1, arg2, arg3, arg4));
    }

    @Override
    public EvaluatorException runtimeError(String arg0, String arg1, int arg2, String arg3, int arg4) {
        System.out.println("RUNTIME ERROR: " + format(arg0, arg1, arg2, arg3, arg4));
        return new EvaluatorException(arg0);
    }
}


class CatPack extends DefaultTask {
    @InputDirectory
    File inputFolder;
    @OutputFile
    File outputFile;
    @TaskAction
    public void doCatPack() {
        def fw = new FileWriter(outputFile)
        inputFolder.eachFileMatch(~/.*\.js/) { File file ->
            def c = new JavaScriptCompressor(file.newReader(), new SystemOutErrorReporter())
            // 0 = line breaks after each rule, -1 = no line breaks
            c.compress(fw, -1, false, false, false, false)
        }
        fw.flush()
        fw.close()
    }
}

/**
 * Chapter 01: POJO\'s and Utilities
 */
project('ch01') {
    description = 'Chapter 01: POJO\'s and Utilities'
    dependencies {}
}


So all the submodules are fine, but not the root level so intellij does not recognize

import com.yahoo.platform.yui.compressor.*
import org.mozilla.javascript.*

Nor does it undertstand DefaultTask from gradle.


---
Thank You…

Mick Knutson, President, Certified Spring Instructor

BASE Logic, Inc.
Enterprise Architecture, Design, Training & Agile Consulting

Company: http://baselogic.com/blog/services/
---
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: IDEA plugin to add top level dependencies for multi-module build?

Peter Niederwieser
So you are talking about making the IDE understand Gradle build scripts? The `idea` plugin doesn't cover that, but I'm sure a future version of IDEA's own Gradle integration will.

--
Peter Niederwieser
Principal Engineer, Gradleware
http://gradleware.com
Creator, Spock Framework
http://spockframework.org
Twitter: @pniederw
Loading...