From 3add1c9c5b29fca28ce5c49d8c040166ca8ba411 Mon Sep 17 00:00:00 2001 From: Roland Praml Date: Thu, 19 Oct 2023 14:41:36 +0200 Subject: [PATCH] fix(descriptions-javadoc): put descriptions in META-INF folder (via #971) --- .../description/JavaDocDescriptionsProcessor.java | 6 ++++-- .../description/ProcessDescriptionsTest.java | 14 +++++++------- .../java/io/qameta/allure/util/ResultsUtils.java | 4 ++-- 3 files changed, 13 insertions(+), 11 deletions(-) diff --git a/allure-descriptions-javadoc/src/main/java/io/qameta/allure/description/JavaDocDescriptionsProcessor.java b/allure-descriptions-javadoc/src/main/java/io/qameta/allure/description/JavaDocDescriptionsProcessor.java index 1ee9c5209..ca1fa6f8d 100644 --- a/allure-descriptions-javadoc/src/main/java/io/qameta/allure/description/JavaDocDescriptionsProcessor.java +++ b/allure-descriptions-javadoc/src/main/java/io/qameta/allure/description/JavaDocDescriptionsProcessor.java @@ -46,6 +46,8 @@ @SupportedAnnotationTypes("io.qameta.allure.Description") public class JavaDocDescriptionsProcessor extends AbstractProcessor { + private static final String ALLURE_DESCRIPTIONS_FOLDER = "META-INF/allureDescriptions/"; + private Filer filer; private Elements elementUtils; private Messager messager; @@ -85,8 +87,8 @@ public boolean process(final Set annotations, final Round final String hash = generateMethodSignatureHash(el.getEnclosingElement().toString(), name, typeParams); try { - final FileObject file = filer.createResource(StandardLocation.CLASS_OUTPUT, - "allureDescriptions", hash); + final FileObject file = filer.createResource(StandardLocation.CLASS_OUTPUT, "", + ALLURE_DESCRIPTIONS_FOLDER + hash); try (Writer writer = file.openWriter()) { writer.write(docs); } diff --git a/allure-descriptions-javadoc/src/test/java/io/qameta/allure/description/ProcessDescriptionsTest.java b/allure-descriptions-javadoc/src/test/java/io/qameta/allure/description/ProcessDescriptionsTest.java index d285ea178..850b63ae6 100644 --- a/allure-descriptions-javadoc/src/test/java/io/qameta/allure/description/ProcessDescriptionsTest.java +++ b/allure-descriptions-javadoc/src/test/java/io/qameta/allure/description/ProcessDescriptionsTest.java @@ -31,7 +31,7 @@ */ class ProcessDescriptionsTest { - private static final String ALLURE_PACKAGE_NAME = "allureDescriptions"; + private static final String ALLURE_DESCRIPTIONS_FOLDER = "META-INF/allureDescriptions/"; @Test void captureDescriptionTest() { @@ -58,8 +58,8 @@ void captureDescriptionTest() { Compilation compilation = compiler.compile(source); assertThat(compilation).generatedFile( StandardLocation.CLASS_OUTPUT, - ALLURE_PACKAGE_NAME, - expectedMethodSignatureHash + "", + ALLURE_DESCRIPTIONS_FOLDER + expectedMethodSignatureHash ); } @@ -121,8 +121,8 @@ void captureDescriptionParametrizedTestWithGenericParameterTest() { Compilation compilation = compiler.compile(source); assertThat(compilation).generatedFile( StandardLocation.CLASS_OUTPUT, - ALLURE_PACKAGE_NAME, - expectedMethodSignatureHash + "", + ALLURE_DESCRIPTIONS_FOLDER + expectedMethodSignatureHash ); } @@ -154,8 +154,8 @@ void captureDescriptionParametrizedTestWithPrimitivesParameterTest() { Compilation compilation = compiler.compile(source); assertThat(compilation).generatedFile( StandardLocation.CLASS_OUTPUT, - ALLURE_PACKAGE_NAME, - expectedMethodSignatureHash + "", + ALLURE_DESCRIPTIONS_FOLDER + expectedMethodSignatureHash ); } } diff --git a/allure-java-commons/src/main/java/io/qameta/allure/util/ResultsUtils.java b/allure-java-commons/src/main/java/io/qameta/allure/util/ResultsUtils.java index 4893dd4d5..12596f129 100644 --- a/allure-java-commons/src/main/java/io/qameta/allure/util/ResultsUtils.java +++ b/allure-java-commons/src/main/java/io/qameta/allure/util/ResultsUtils.java @@ -97,7 +97,7 @@ public final class ResultsUtils { public static final String LANGUAGE_LABEL_NAME = "language"; private static final Logger LOGGER = LoggerFactory.getLogger(ResultsUtils.class); - private static final String ALLURE_DESCRIPTIONS_PACKAGE = "allureDescriptions/"; + private static final String ALLURE_DESCRIPTIONS_FOLDER = "META-INF/allureDescriptions/"; private static final String MD_5 = "MD5"; private static String cachedHost; @@ -305,7 +305,7 @@ public static Optional getJavadocDescription(final ClassLoader classLoad name, parameterTypes); - return readResource(classLoader, ALLURE_DESCRIPTIONS_PACKAGE + signatureHash) + return readResource(classLoader, ALLURE_DESCRIPTIONS_FOLDER + signatureHash) .map(desc -> separateLines() ? desc.replace("\n", "
") : desc); }