简体   繁体   English

使用两种配置编译gradle

[英]Compile gradle with two configuration

I have a gradle project. 我有一个gradle项目。 This project contains many modules. 该项目包含许多模块。 I would like to make 2 differents executables with some module activated or not. 我想制作2个不同的可执行文件,其中一些模块已激活或未激活。 I have one executable with module1 and module2 like follow: 我有一个可执行文件,其中module1和module2如下:

dependencies {
    compile project(':module1')
    compile project(':module2')
}

I would like a executable with module1 and module2, and another one with only module1. 我想要一个module1和module2的可执行文件,另一个只有module1。

For generate an executable I used launch4j and shadowjar. 为了生成可执行文件,我使用了launch4j和shadowjar。

How I can do that? 我怎么能这样做?

Thanks 谢谢

You could possibly use my java-flavours-plugin 你可以使用我的java-flavors-plugin

plugins {
    id "com.lazan.javaflavours" version "1.2"
}
javaFlavours {
    flavour 'version1'
    flavour 'version2'
}
dependencies {
    compile 'some:common-dependency:1.0'
    version1Compile project(':module1')
    version2Compile project(':module2')
}

Each flavour (eg version1 & version2) will have a jar task, the jar could be consumed by downstream modules/tasks. 每个flavor(例如version1和version2)都有一个jar任务,jar可以被下游模块/任务使用。 You can also reference sourceSets.version1.runtimeClasspath etc. 您还可以参考sourceSets.version1.runtimeClasspath等。

Note: The plugin supports flavour specific java sources and resources. 注意:该插件支持特定于flavor的java源和资源。 Not sure if you need that feature. 不确定您是否需要该功能。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 gradle的配置编译和运行时 - Configuration compile and runtime for gradle 在Gradle中创建具有附加编译依赖性的生产配置 - Create production configuration with additional compile dependency in Gradle Gradle 7.5 无法通过编译配置问题构建项目 - Gradle 7.5 cannot build project with compile configuration problem Gradle Drools 6.2无法解析配置&#39;:compile&#39;的所有依赖项 - Gradle Drools 6.2 Could not resolve all dependencies for configuration ':compile' Gradle 构建失败 [无法解析配置 ':compile' 的所有依赖项。] - Gradle build is failing [Could not resolve all dependencies for configuration ':compile'.] Gradle:解决后无法更改配置“:compile”的依赖项 - Gradle: Cannot change dependencies of configuration ':compile' after it has been resolved 使用 BuildConfig 插件的 java lib 无法使用 gradle 7.0.2(配置<compile>未找到) - java lib using BuildConfig plugin failed to compile using gradle 7.0.2 (Configuration <compile> not found) android gradle - 将两个纯java项目编译为dex - android gradle — compile two pure java projects to dex Gradle配置不适用于两组配置文件和依赖项 - Gradle Configuration doesn't work for two groups of config files and dependencies 我可以使用詹金斯矩阵配置计划两个gradle任务吗? - can i schedule two gradle tasks with jenkins matrix configuration?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM