Source, library and executable declaration order


(Michael Putters) #1

I’m a beginner when it comes to Groovy, so this is probably something silly. I have 2 libraries and want one to depend on the other:

sources {
    lib1 {
        ...
    }
    lib2 {
        cpp {
            lib libraries.lib1
        }
    }
}
  libraries {
    lib1 {
        ...
    }
    lib2 {
        ...
    }
}

The lib2 source set doesn’t know about the lib1 library since it has not been declared yet… is there some trick to lazily evaluate the dependency line? The other solution would be to do:

sources { lib1 { } }
library { lib1 { } }
sources { lib2 { cpp { lib libraries.lib1 } } }

But that seems like a dirty trick…


#2

There will be a review to the DSL and ordering in the coming months. In the meantime the second way is the correct way. More simply:

sources.lib2.cpp.lib libraries.lib1