我有一个基于JDK 11的项目,我想在我的java项目中使用Manifold (http://manifold.systems/)。
我的build.gradle:
plugins {
id 'java'
}
//
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
repositories {
maven { url 'https://oss.sonatype.org/content/repositories/snapshots/' }
}
dependencies {
implementation 'org.projectlombok:lombok:1.18.18'
implementation "io.vavr:vavr:0.10.3"
implementation 'systems.manifold:manifold-science:2021.1.25'
compileOnly 'org.projectlombok:lombok:1.18.20'
annotationProcessor 'org.projectlombok:lombok:1.18.20'
annotationProcessor group: 'systems.manifold', name: 'manifold-ext', version: '2021.1.25'
testCompileOnly 'org.projectlombok:lombok:1.18.20'
testAnnotationProcessor 'org.projectlombok:lombok:1.18.20'
testAnnotationProcessor 'org.openjdk.jmh:jmh-generator-annprocess'
testImplementation 'org.junit.jupiter:junit-jupiter-engine'
}
test {
useJUnitPlatform()
testLogging {
events "passed", "skipped", "failed"
}
}我试过这个:
import java.math.BigDecimal;
@Extension
public abstract class ManBigDecimalExt implements ComparableUsing<BigDecimal> {
/**
* Supports binary operator {@code +}
*/
public static BigDecimal plus(@This BigDecimal thiz, BigDecimal that) {
return thiz.add(that);
}
}但报告指出,没有找到这些“宣言”注释:
@Extension
@This我该怎么办?
发布于 2021-10-09 16:12:05
谢谢你的网页,它帮了很多忙!在浏览了你寄给我的网页后,我找到了解决办法。实际上,在库systems.manifold中,您提到的注释不存在。添加另一个名为manifold-science或manifold-ext的实现,
implementation 'systems.manifold:manifold-science:2021.1.25-SNAPSHOT'或
implementation 'systems.manifold:manifold-ext:2021.1.25-SNAPSHOT'并且,添加另一个存储库以获取该库,
maven { url 'https://oss.sonatype.org/content/repositories/snapshots/' }别忘了导入库,
import manifold.ext.rt.api.Extension;
import manifold.ext.rt.api.This;
import manifold.ext.rt.api.ComparableUsing;希望这能解决问题:D
发布于 2021-10-10 01:47:30
项目快速参考提供指向所有Manifold依赖项的链接,每个依赖项都提供自己的安装文档。
用于流形扩展的安装文档,您似乎正在使用:
plugins {
id 'java'
}
group 'com.example'
version '1.0-SNAPSHOT'
targetCompatibility = 11
sourceCompatibility = 11
repositories {
jcenter()
maven { url 'https://oss.sonatype.org/content/repositories/snapshots/' }
}
configurations {
// give tests access to annotationProcessor dependencies
testImplementation.extendsFrom annotationProcessor
}
dependencies {
implementation 'systems.manifold:manifold-ext-rt:2021.1.25'
testCompile 'junit:junit:4.12'
// Add manifold to -processorpath for javac
annotationProcessor group: 'systems.manifold', name: 'manifold-ext', version: '2021.1.25'
}
if (JavaVersion.current() != JavaVersion.VERSION_1_8 &&
sourceSets.main.allJava.files.any {it.name == "module-info.java"}) {
tasks.withType(JavaCompile) {
// if you DO define a module-info.java file:
options.compilerArgs += ['-Xplugin:Manifold', '--module-path', it.classpath.asPath]
}
} else {
tasks.withType(JavaCompile) {
// If you DO NOT define a module-info.java file:
options.compilerArgs += ['-Xplugin:Manifold']
}
}更新:
根据您最近的更新,您需要进行以下更改:
-Xplugin:Manifold的if/ with语句。implements ComparableUsing<BigDecimal>从您的ManBigDecimalExt中删除,因为它复制了已经在多种科学中实现的接口。此外,加法也是重复的;BigDecimal算法已经被manifold-science所支持。https://stackoverflow.com/questions/69484799
复制相似问题