gradle jdk11 模块化导入非模块化jar示例


1. build.gradle

plugins {
    id 'java'
    id 'application'
}

group 'org.example'
version '1.0-SNAPSHOT'
sourceCompatibility = 11
targetCompatibility = 11
mainClassName = 'com.bingco.Setup'

repositories {
    mavenLocal()
    mavenCentral()
}

dependencies {
    testCompile group: 'junit', name: 'junit', version: '4.12'
    implementation 'com.alibaba:fastjson:1.2.70'
}

compileJava {
    options.compilerArgs += ['--module-path', classpath.asPath]
}

2. module-info.java

/**
 * 

模块化配置 *

* create: 2020/11/23
* email: bingco.zn@gmail.com
* * @author zhan_bingcong * @since jdk8+ */ module test.main { requires fastjson; exports com.bingco; }