سؤال

السيناريو هو ما يلي: لدي حزمة Java ( myapp.config ) يحتوي على جميع الفئات المشروح من Jaxb، والتي أود إنشاء ملف مخطط XML الخاص بي. في الحزمة، هناك أيضا ملف package-info.java يحتوي على التوضيحية xmlschema على عنصر الحزمة، مما ساري في الحزمة بأكملها: giveacodicetagpre.

عندما أقوم بتشغيل أداة سطر الأوامر التي تأتي مع JDK، giveacodicetagpre.

أحصل على النتيجة الصحيحة: يحتوي عنصر الجذر في ملف schema1.xsd وسمات أخرى ضرورية: giveacodicetagpre.

ومع ذلك، عندما أريد إجراء نفس المهمة داخل البرنامج النصي الخاص بي، giveacodicetagpre.

يبدو أن أداة Schemagen تتجاهل تماما التعليقات التوضيحية مساحة الاسم، لأنه في ملف Schema1.xsd ، لا يوجد أي أثر لهم: giveacodicetagpre.

عندما أقوم بتشغيل المهمة schemagen في verbose و debug الوضع، يصبح من الواضح أن الأداة تقوم بتحميل جميع . Java الملفات، باستثناء package-info.java ، لهذا السبب لا يعرف أي شيء عن مساحات الأسماء.

هل قابلت هذا السلوك الغريب من قبل؟ لماذا تقوم أداة سطر الأوامر بمعالجة ملف معلومات الحزمة، ومهمة النمل لا؟ ماذا علي أن أفعل لجعل عمل مهمة النمل؟

شكرا مقدما،
BUC

هل كانت مفيدة؟

المحلول

Fortunately I found the solution, I post it for those who run into the same problem in the future:

The reason it did not work is that I called the schemagen task in the wrong way (this can happen, if there is so little documentation or examples as in the case of schemagen). Instead of writing:

<schemagen srcdir="src/myapp/config" destdir="dist">
    <include name="*.java"/>
</schemagen>

You should move the specific part of the path into the include element:

<schemagen srcdir="src" destdir="dist">
    <include name="myapp/config/*.java"/>
</schemagen>

I'm still not sure why this is happening, but this way, the schemagen processor recognizes that the myapp/config directory in fact designates the java package myapp.config and by knowing that it is a package, it will also read the package info file.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top