Including specific classes of dependent project in Jar Task

I have requirement of building a custom jar by including specific classes from a dependent project.

I has task rule added to build.gradle file which is building a jar by inculding the classes from the current project but i want to add classes from the dependent project which match certain package name. Any help is appreciated

ProjectA is the dependent project which is included as compile time dependency

 tasks.addRule('Pattern: Feed<feed>') { String taskName->
    if (taskName.startsWith("Feed")) {
        task(taskName,type : Jar) {
            def feed = taskName -'Feed'
            classifier = ver
            baseName = feed

            from(project(':projectA')){ //doesn't work
                include 'com/lim/dw/**'
            from(sourceSets.main.output) {
                include 'com/dw/feeds/'+datasource+'/common/*'