Gradle 在两个目录之一中无法解析 java 11 模块的包
Gradle cannot resolve package for java 11 module when in one of two directories
我正在尝试编译包含混合 java 和 groovy 代码的 java 11 模块,但编译一直失败并显示以下消息:
package is empty or does not exist: my.sample.map
我更改了 GroovyCompile
任务以使用 java 11 个编译标志:
tasks.withType(GroovyCompile) {
doFirst {
options.compilerArgs += [
'--module-path', classpath.asPath,
'-verbose',
'--module-source-path', ["$rootProject.projectDir/*/src/main/{java,groovy}/",
"$rootProject.projectDir/*/src/main/"].join(File.pathSeparator)
]
}
}
我尝试编译的模块具有以下文件夹结构:
my.sample.module
└── src
├── main
│ ├── groovy
│ │ └── my
│ │ └── sample
│ │ └── map
│ │ ├── MapComponent.groovy
│ │ └── MapViewPerspective.groovy
│ ├── java
│ │ └── my
│ │ └── sample
│ │ └── map
│ │ └── config
│ │ └── MapViewConfig.java
│ ├── module-info.java
│ └── resources
│ └── MapView.fxml
└── test
module-info.java
内容如下:
module my.sample.module {
exports my.sample.map.config;
exports my.sample.map;
requires javafx.fxml;
requires javafx.controls;
requires org.codehaus.groovy;
...
}
经过数小时的尝试解决此问题后,我看到的唯一问题是它跳过了 groovy
文件夹,只在 java
文件夹中查找内容。
然后我尝试在 java
文件夹中的包 my.sample.map
中添加一个空的 class ,编译继续进行,但编译 class 时失败groovy
文件夹中的 es 需要 java
文件夹中的 MapViewConfig
。
我做错了什么?我想我必须更新用于编译的 class 路径,但我不确定要添加哪些 class 路径。
根据 Groovy release notes,Groovy 3 尚不支持 Java 模块系统,但正在慢慢进行更改。
Groovy 3 is making changes to allow the codebase to move towards the
compliant rules and allow Groovy users to begin the migration process.
Groovy 4 is our target version for fully-compliant artifacts but you
can start getting your classes ready ahead of time while using Groovy
3.
看起来 Groovy 4 是我们必须等待的黄金版本。至少他们正在努力,所以我们只能耐心等待。
我正在尝试编译包含混合 java 和 groovy 代码的 java 11 模块,但编译一直失败并显示以下消息:
package is empty or does not exist: my.sample.map
我更改了 GroovyCompile
任务以使用 java 11 个编译标志:
tasks.withType(GroovyCompile) {
doFirst {
options.compilerArgs += [
'--module-path', classpath.asPath,
'-verbose',
'--module-source-path', ["$rootProject.projectDir/*/src/main/{java,groovy}/",
"$rootProject.projectDir/*/src/main/"].join(File.pathSeparator)
]
}
}
我尝试编译的模块具有以下文件夹结构:
my.sample.module
└── src
├── main
│ ├── groovy
│ │ └── my
│ │ └── sample
│ │ └── map
│ │ ├── MapComponent.groovy
│ │ └── MapViewPerspective.groovy
│ ├── java
│ │ └── my
│ │ └── sample
│ │ └── map
│ │ └── config
│ │ └── MapViewConfig.java
│ ├── module-info.java
│ └── resources
│ └── MapView.fxml
└── test
module-info.java
内容如下:
module my.sample.module {
exports my.sample.map.config;
exports my.sample.map;
requires javafx.fxml;
requires javafx.controls;
requires org.codehaus.groovy;
...
}
经过数小时的尝试解决此问题后,我看到的唯一问题是它跳过了 groovy
文件夹,只在 java
文件夹中查找内容。
然后我尝试在 java
文件夹中的包 my.sample.map
中添加一个空的 class ,编译继续进行,但编译 class 时失败groovy
文件夹中的 es 需要 java
文件夹中的 MapViewConfig
。
我做错了什么?我想我必须更新用于编译的 class 路径,但我不确定要添加哪些 class 路径。
根据 Groovy release notes,Groovy 3 尚不支持 Java 模块系统,但正在慢慢进行更改。
Groovy 3 is making changes to allow the codebase to move towards the compliant rules and allow Groovy users to begin the migration process. Groovy 4 is our target version for fully-compliant artifacts but you can start getting your classes ready ahead of time while using Groovy 3.
看起来 Groovy 4 是我们必须等待的黄金版本。至少他们正在努力,所以我们只能耐心等待。