Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

331
Vistas
Java: How to access metafile information from maven failsafe plugin?

I want to access information like implementation version stored in the jar file. This seems to work quite well, in any technique but always based on the classloader.

If i want to test in my maven environment, of course i cannot use the surefire plugin, because this is prior to packaging in jar. Thus I must use failsafe plugin.

But then neither of the technique works, most probably, because of some dark magic concerning classloaders.

The simplest way to get implementation version is just

this.getClass().getPackage().getImplementationVersion()

which reads from META-INF/MANIFEST.MF in the jar which looks sth like

Name: eu/simuline/octave/
Extension-name: eu.simuline.octave
Specification-Version: 0.7
Implementation-Version: 0.7-SNAPSHOT

Maybe extension is not needed, what is needed is the section name which is derived from the package name in an obvious way (trailing slash seems vital;-) ). But as said, this works only in productive context, not within tests with failsafe plugin. Then the java code returns 0.7-SNAPSHOT, else it just returns null, which means according to the api docs, that the version is unknown... well.

What can I do to include meta info in maven tests???

over 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

I did some research on the failsafe plugin. For example running with

mvn -X verify

unveils

INFO] --- maven-failsafe-plugin:3.0.0-M5:verify (run-tests) @ javaoctave ---
[DEBUG] Configuring mojo org.apache.maven.plugins:maven-failsafe-plugin:3.0.0-M5:verify from plugin realm ClassRealm[plugin>org.apache.maven.plugins:maven-failsafe-plugin:3.0.0-M5, parent: jdk.internal.loader.ClassLoaders$AppClassLoader@277050dc]
[DEBUG] Configuring mojo 'org.apache.maven.plugins:maven-failsafe-plugin:3.0.0-M5:verify' with basic configurator -->
[DEBUG]   (s) basedir = /home/ernst/OpenSource/OctaveInJavaGit/octaveInJava/javaoctave
[DEBUG]   (s) reportsDirectory = /home/ernst/OpenSource/OctaveInJavaGit/octaveInJava/javaoctave/target/failsafe-reports
[DEBUG]   (f) session = org.apache.maven.execution.MavenSession@1416a80a
[DEBUG]   (s) skip = false
[DEBUG]   (f) summaryFile = /home/ernst/OpenSource/OctaveInJavaGit/octaveInJava/javaoctave/target/failsafe-reports/failsafe-summary.xml
[DEBUG]   (s) testClassesDirectory = /home/ernst/OpenSource/OctaveInJavaGit/octaveInJava/javaoctave/target/test-classes
[DEBUG]   (s) testFailureIgnore = false
[DEBUG] -- end configuration --
[DEBUG] Failsafe report directory: /home/ernst/OpenSource/OctaveInJavaGit/octaveInJava/javaoctave/target/failsafe-reports

Note the testClassesDirectory. I thought that the plugin accesses the jar created in the preceeding lifecycle phase package
but obviously this is not true and there seems to be no way to do so. Thus all the stuff does not work.

I filed a feature/enhancement request to fix that.

No idea whether they like my idea.

over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda