quarkusio / quarkus

Quarkus: Supersonic Subatomic Java.
https://quarkus.io
Apache License 2.0
13.82k stars 2.69k forks source link

Quarkus cache : same package name in different modules causes error when compile java9 module #34776

Open EricLangenbronn opened 1 year ago

EricLangenbronn commented 1 year ago

Describe the bug

Hi,

try to add cache with CacheResult and a service using CacheManager on project with module-info.java CacheResult from : quarkus-cache-3.2.0.Final.jar CacheMananger from : quarkus-cache-runtime-spi-3.2.0.Final.jar

in module-info need :

` import io.quarkus.cache.CacheManager; import jakarta.inject.Singleton; import lombok.RequiredArgsConstructor;

@Singleton @RequiredArgsConstructor public class CacheClearer {

private final CacheManager cacheManager;

public void clearAllCaches() { for (String cacheName : cacheManager.getCacheNames()) { cacheManager.getCache(cacheName).ifPresent(cache -> cache.invalidateAll().await().indefinitely()); } } } `

`
import fr.gnss.constellation.ouranos.librairy.almanach.EphemerideType; import fr.gnss.constellation.ouranos.librairy.almanach.OrbitType; import fr.gnss.constellation.ouranos.librairy.almanach.sp3.Sp3FileName; import fr.gnss.constellation.ouranos.librairy.almanach.sp3.TimeCoordinateSatellitePosition; import fr.gnss.constellation.ouranos.librairy.coordinate.CartesianCoordinate3D; import fr.gnss.constellation.ouranos.sp3.Sp3FileNameUtils; import fr.gnss.constellation.ouranos.sp3.service.ISp3Service; import io.quarkus.cache.CacheKey; import io.quarkus.cache.CacheResult; import java.time.LocalDateTime; import java.util.List;

public abstract class AbstractOrbitDataService implements IOrbitDataService {

// -------------------- Services --------------------

protected final ISp3Service sp3Service;

// ------------------------ Constructeur(s) ------------------------

public AbstractOrbitDataService(ISp3Service sp3Service) { this.sp3Service = sp3Service; }

// -------------------- Methodes de l'interface --------------------

@Override @CacheResult(cacheName = "cartesian-position") public List<TimeCoordinateSatellitePosition> getCartesianPositionsForPeriod( @CacheKey LocalDateTime start, @CacheKey LocalDateTime end, @CacheKey EphemerideType ephemerideType, @CacheKey OrbitType orbitType) {

List<Sp3FileName> allSp3FileNameBetweenStartEnd = Sp3FileNameUtils.getAllSp3FileNameBetween2Date(ephemerideType, start, end, orbitType);

sp3Service.downloadsAndStoresIfNotExist(allSp3FileNameBetweenStartEnd);

return doProcessing(start, end, allSp3FileNameBetweenStartEnd);

}

protected abstract List<TimeCoordinateSatellitePosition> doProcessing( LocalDateTime start, LocalDateTime end, List allSp3FileNameBetweenStartEnd); } `

Expected behavior

No compilation error

Actual behavior

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.10.1:compile (default-compile) on project ouranos-rest-api: Compilation failure: Compilation failure: [ERROR] module ouranos.domain reads package io.quarkus.cache from both quarkus.cache.runtime.spi and quarkus.cache [ERROR] module ouranos.core reads package io.quarkus.cache from both quarkus.cache.runtime.spi and quarkus.cache [ERROR] /**/gnss.constellation/ouranos-core/src/main/java/module-info.java:[1,1] module ouranos.core reads package io.quarkus.cache from both quarkus.cache and quarkus.cache.runtime.spi

How to Reproduce?

No response

Output of uname -a or ver

Windows 11 Professionnel 22H2

Output of java -version

openjdk version "20.0.1" 2023-04-18 OpenJDK Runtime Environment Temurin-20.0.1+9 (build 20.0.1+9) OpenJDK 64-Bit Server VM Temurin-20.0.1+9 (build 20.0.1+9, mixed mode, sharing)

GraalVM version (if different from Java)

No response

Quarkus version or git rev

3.2.0.Final

Build tool (ie. output of mvnw --version or gradlew --version)

Apache Maven 3.6.3 (cecedd343002696d0abb50b32b541b8a6ba2883f) Maven home: E:\ApplicationPortable\maven\bin.. Java version: 20.0.1, vendor: Eclipse Adoptium, runtime: C:\Program Files\Eclipse Adoptium\jdk-20.0.1.9-hotspot Default locale: fr_FR, platform encoding: UTF-8 OS name: "windows 11", version: "10.0", arch: "amd64", family: "windows"

Additional information

No response

quarkus-bot[bot] commented 1 year ago

/cc @gwenneg (cache)

gsmet commented 1 year ago

Hmmm, yes, split packages are bad. We should fix this but we need to deprecate the original annotations as a first step.

gsmet commented 2 weeks ago

I created https://github.com/quarkusio/quarkus/discussions/44154 to discuss the possible solutions to this issue.