当前位置: 首页 > news >正文

Maven Manifold 条件编译

Maven 配置

通过 Maven 的不同 profile 实现不同环境传递不同符号。另外 lombok 可以 manifold 一同使用,见下方配置。

<properties><maven.compiler.source>8</maven.compiler.source><maven.compiler.target>8</maven.compiler.target><lombok.version>1.18.24</lombok.version><manifold.version>2023.1.11</manifold.version>
</properties><profiles><!-- dev --><profile><id>dev</id><activation><activeByDefault>true</activeByDefault></activation><properties><profile.name>dev</profile.name></properties><build><plugins><plugin><groupId>org.apache.maven.plugins</groupId><artifactId>maven-compiler-plugin</artifactId><version>3.11.0</version><configuration><source>${maven.compiler.source}</source><target>${maven.compiler.target}</target><encoding>UTF-8</encoding><compilerArgs><!-- Configure manifold plugin--><arg>-Xplugin:Manifold</arg></compilerArgs><!-- Add the processor path for the plugin --><annotationProcessorPaths><path><groupId>org.projectlombok</groupId><artifactId>lombok</artifactId><version>${lombok.version}</version></path><path><groupId>systems.manifold</groupId><artifactId>manifold-preprocessor</artifactId><version>${manifold.version}</version></path></annotationProcessorPaths></configuration></plugin></plugins></build></profile><!-- jdbc --><profile><id>jdbc</id><properties><profile.name>jdbc</profile.name></properties><build><plugins><plugin><groupId>org.apache.maven.plugins</groupId><artifactId>maven-compiler-plugin</artifactId><version>3.11.0</version><configuration><source>${maven.compiler.source}</source><target>${maven.compiler.target}</target><encoding>UTF-8</encoding><compilerArgs><!-- Configure manifold plugin --><arg>-Xplugin:Manifold</arg><!-- 条件编译用到的符号在此处定义 --><arg>-AJDBC</arg></compilerArgs><!-- Add the processor path for the plugin --><annotationProcessorPaths><path><groupId>org.projectlombok</groupId><artifactId>lombok</artifactId><version>${lombok.version}</version></path><path><groupId>systems.manifold</groupId><artifactId>manifold-preprocessor</artifactId><version>${manifold.version}</version></path></annotationProcessorPaths></configuration></plugin></plugins></build></profile>
</profiles>

代码

#if JDBCSystem.out.println("JDBC");
#elseSystem.out.println("other");
#endif

 manifold 是极其强大的,远不止条件编译这么简单,有兴趣可以阅读以下两篇文章:

  1. Java 缺失的特性:扩展方法
  2. Java 缺失的特性:操作符重载

官方仓库

http://www.lryc.cn/news/109212.html

相关文章:

  • 4.数组与基本数学函数
  • python与深度学习(十六):CNN和宝可梦模型二
  • PTA 1030 Travel Plan
  • MFC、Qt、WPF?该用哪个?
  • 使用logback记录日志
  • 企业工程项目管理系统源码(三控:进度组织、质量安全、预算资金成本、二平台:招采、设计管理) em
  • 【安装】XMind2022XMind2020安装教程(资源)
  • Windows下QT Creator安装MinGW 32bit编译器
  • Emacs之解决键值绑定冲突问题(一百二十三)
  • 瞄准产业应用,大模型加持的深兰科技AI虚拟数字人落地业务场景
  • 【网络基础进阶之路】基于MGRE多点协议的实战详解
  • Spark、RDD、Hive 、Hadoop-Hive 和传统关系型数据库区别
  • [运维]python 启用http 文件服务
  • electron-builder 打包 exe 异常错误集锦
  • 14-5_Qt 5.9 C++开发指南_基于HTTP 协议的网络应用程序
  • Kotlin委托
  • 分布式协议与算法——CAP理论、ACID理论、BASE理论
  • 接口测试 Jmeter 接口测试 —— 请求 Headers 与传参方式
  • 【redis】redis部署1主2从3哨兵demo搭建示例
  • C++数据结构之平衡二叉搜索树(一)——AVL的实现(zig-zag/左右双旋/3+4重构)
  • 免疫疗法勘察兵——DC细胞
  • Django实现音乐网站 ⑷
  • 2023年华数杯数学建模C题思路 - 母亲身心健康对婴儿成长的影响
  • openGauss学习笔记-30 openGauss 高级数据管理-别名
  • C#实现多线程局域网扫描器的思路与具体代码
  • Redis秒杀:一人一单问题及初步解决
  • python 数据分析面试题:求分组排第n名的记录数据
  • eclipse常用快捷键
  • 什么是OCR?OCR技术详解
  • 【大模型】开源且可商用的大模型通义千问-7B(Qwen-7B)来了