redhat-developer / redhat-developer/vscode-java
Wrong classpath with Gradle `compileOnly` like instructions
Nadie ha tomado este issue todavía.
- Lenguaje dominante
- TypeScript
- Estrellas
- 2.3k
- Forks
- 546
- Merge medio
- 20 h 1 min
- PR fusionados (30 d)
- 11
Descripción
We need to use the compileOnly in a gradle modules.
The expected behaviour is to have the dependency available at the compile time, but not at runtimes.
It's useful to create spring boot auto-configurations that load only if the dependency is present in the consumer module.
We have this declaration in a library:
dependencies {
compileOnly 'org.springframework.boot:spring-boot-starter-security'
}
In the application module we have this declaration:
dependencies {
implementation project(':libs:my-lib')
}
Running the following command, the project works as expected. The spring-boot-starter-security is not loaded.
./gradlew bootRun
But if we run the following configuration, the dependency is in classpath at runtime and the auto-configuration is applied at wrong.
{
"configurations": [
{
"type": "java",
"name": "Spring Boot-Application",
"request": "launch",
"cwd": "${workspaceFolder}",
"mainClass": "com.mycompany.Application",
"projectName": "application",
"args": ""
}
]
}
There is also dependency problems in test but I can't exactly explain what. There is some BeanDefinitionOverrideException that are not present running the ./gradlew test command.
Guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Línea de trabajo
Reproduce el proyecto con la dependencia compileOnly mostrada, comparando ./gradlew bootRun con la configuración de lanzamiento de Java en .vscode/launch.json. Rastrea el classpath ensamblado para el lanzamiento de VS Code y las ejecuciones de pruebas; se considera terminado cuando las dependencias compileOnly siguen disponibles para la compilación, pero están ausentes en tiempo de ejecución, coincidiendo con el comportamiento de Gradle.
Escrito por el modelo de indexación a partir del texto del issue.
Evaluación
- Stack tecnológico
- java, spring-boot, vscode
- Área
- build-system, devtools
- Tipo de issue
- Error
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Estado de actividad
- Estancado
- Claridad
- Bastante claro
- Aptitud para principiantes
- 35/100