使用瞬态scala依赖项优化SpringXD项目的gradle

使用瞬态scala依赖项优化SpringXD项目的gradle,scala,gradle,spring-xd,Scala,Gradle,Spring Xd,我正在从事一个项目,该项目包含spring XD的一系列模块子项目,这些模块子项目恰好对使用Scala的非模块子项目具有暂时依赖性: ext { springXdVersion = '1.1.0.RELEASE' moduleProjects = subprojects.findAll { project -> project.path.startsWith(':modules.')} javaProjects = subprojects - (moduleProjec

我正在从事一个项目,该项目包含spring XD的一系列模块子项目,这些模块子项目恰好对使用Scala的非模块子项目具有暂时依赖性:

ext {
  springXdVersion = '1.1.0.RELEASE'
  moduleProjects  = subprojects.findAll { project -> project.path.startsWith(':modules.')}
  javaProjects    = subprojects - (moduleProjects + nonJavaProjects)
}

configure(moduleProjects) { moduleProject ->
  apply plugin: 'spring-xd-module'
}

project('core-dependency') {
  apply plugin: 'scala'
  // configuration/dependencies
}

project('modules.source.example') {
  dependencies {
    provided(":core-dependency")
  }
}

// More modules bearing resemblance to modules.source.example
核心依赖关系最终设置在xd容器的类路径中,并以这种方式在运行时提供给模块

不幸的是,对于使用它的每个模块,似乎都会重新编译核心依赖项(这尤其昂贵,因为它还包括scala编译)。这会导致构建以北运行30分钟,我想在此基础上进行改进。有没有办法缩短构建时间?理想情况下,我希望不必重新编译核心依赖项,但考虑到bootRepackage似乎负责为每个模块触发它,我不确定如何实现这一点。我也尝试过其他技巧,比如并行,但到目前为止,这样做只能冻结我的系统。我正在使用Gradle2.1

我应该注意到,gradle概要文件报告指出,对于每个模块,大部分时间都在configureModule步骤中,根据spring xd repo,该步骤如下所示:

project.task('configureModule') << {
            project.configurations.provided.resolvedConfiguration.firstLevelModuleDependencies.each {
                excludeTransitiveDependencies(project, it)
            }
        }

project.task('configureModule')scala依赖项来自SpringXD中的
Spark streaming
集成。我们正在努力消除对
spring xd dirty
的火花依赖性,并将其从模块中提供:


您所依赖的具体非模块子项目是什么?如果是
spring-xd-module
,那么您可以尝试1.2.0.M1,其中我们将spark依赖项从
spring-xd-module
移动到
spring-xd-dirty

,在configureModule步骤中,所有项目都会评估可传递的提供依赖项,核心依赖项就是。速度放缓是由于核心依赖依赖依赖依赖的依赖项数量过多造成的,因此需要扫描。由于configureModule扫描核心依赖项太费时,因此我们希望避免它,并且我们知道需要将其从模块FATJAR中排除,因此适当的操作过程是从提供的配置中删除核心依赖项,并直接将其从FATJAR中排除

为此,gradle构建脚本修改如下:

ext {
  springXdVersion = '1.1.0.RELEASE'
  moduleProjects  = subprojects.findAll { project -> project.path.startsWith(':modules.')}
  javaProjects    = subprojects - (moduleProjects + nonJavaProjects)
}

configure(moduleProjects) { moduleProject ->
  apply plugin: 'spring-xd-module'

  configurations{
    core
    compile.extendsFrom(core)
  }

configurations.exported.exclude module: 'core-dependency'
}

project('core-dependency') {
  apply plugin: 'scala'
  // configuration/dependencies
}

project('modules.source.example') {
  dependencies {
    core project(":core-dependency")
  }
}

// More modules bearing resemblance to modules.source.example

“核心”配置本质上是第二个“提供的”配置,configureModule任务不会拾取该配置,从而避免对其进行耗时的评估。它也被排除在“导出”配置之外,该配置的内容决定了bootRepackage构建的fat jar中的内容。

该子项目是一个内部依赖项;一个由内部开发的工具组成的子项目,这些工具通常在我们的模块之间使用。我可能有一个可行的解决方案:我创建了一个名为core的配置,并将compile设置为从中扩展(这意味着它将编译该配置以及提供的范围)。由于不再提供我的核心依赖项,它将不涉及configureModule任务的ExcludeTransitionDependencies。这把我的身材从35分钟缩短到了2分钟。我现在正在测试我的工件的功能。不幸的是,这产生了将模块FATJAR与该核心依赖项及其依赖项打包在一起的副作用,从而达不到目的。
configurations.exported.exclude module:'core dependency'
能够修复最后一条注释中的问题。导出的配置由springxd模块插件引入,该插件用于确定fatjar中的内容。