
تقوم أداة سطر الأوامر هذه بصحة ملفات XML الخاصة بك للتنسيق المناسب. إذا لم يتم تنسيقها بشكل صحيح ، فإنه يطبع الفرق ويخرج بخطأ. يمكنك استخدامها بطريقتين: 1) لفشل بنيتك إذا لم يتم تنسيق أي ملفات XML-ish (على سبيل المثال ، XML ، XSD ، XSL ، أو XHTML) بشكل صحيح ، و 2) لتنسيقها بشكل صحيح باستخدام خيار- --fix .
اقرأ منشور المدونة هذا أولاً: مدقق نمط XCOP - XML .
تأكد من تثبيت Ruby ثم تثبيت الأداة:
$ gem install xcopقم بتشغيله محليًا وقراءة إخراجها:
$ xcop --helpللتحقق من تنسيق ملفات XML الخاصة بك ، فقط تمرير أسمائهم كوسائط:
$ xcop file1.xml file2.xml إذا لم يتم تنسيق ملفاتك بشكل صحيح ويشتكي xcop ، فيمكنك طلب "تجميلها" ، باستخدام -خيار --fix :
$ xcop --fix broken-file.xmlلإصلاح جميع الملفات في الدليل الذي يمكنك القيام به (لن تعمل إذا كانت أسماء الملفات الخاصة بك تحتوي على مسافات):
$ xcop --fix $( find . -name ' *.xml ' ) يمكنك وضع خيارات سطر الأوامر في ملف .xcop في الدليل حيث تبدأ xcop . يجب أن يأخذ كل خيار سطرًا واحدًا في الملف. سيتم إضافتها جميعًا إلى قائمة الخيارات التي تحددها. على سبيل المثال ، كما تم اقتراحه في منشور المدونة هذا:
--license=LICENSE.txt
--nocolor
--quiet
--include=**/*
--exclude=**/*.xsl
--exclude=**/*.html
يمكنك أيضًا إنشاء ملف ~/.xcop (في الدليل الرئيسي الخاص بك) ، والذي سيتم قراءته أيضًا وإضافته إلى خيارات سطر الأوامر.
Rakefile ؟هذا ما تحتاجه هناك:
require 'xcop/rake_task'
desc 'Run XCop on all XML/XSL files in all directories'
Xcop :: RakeTask . new ( :xcop ) do | task |
task . license = 'LICENSE.txt' # no license by default
task . quiet = true # FALSE by default
task . includes = [ '**/*.xml' , '**/*.xsl' ] # xml|xsd|xhtml|xsl|html by default
task . excludes = [ 'target/**/*' ] # empty by default
end قم بإنشاء ملف سير عمل جديد في مستودع تحت .github/workflows/xcop.yml :
---
name : XCOP
" on " :
# run on push to master events
push :
branches :
- master
# run on pull requests to master
pull_request :
branches :
- master
jobs :
build :
runs-on : ubuntu-latest
steps :
- uses : actions/checkout@v2
- uses : g4s8/xcop-action@master لتخصيص موقع الترخيص أو الملفات ، استخدم ترخيص الإجراءات license files :
- uses : g4s8/xcop-action@master
with :
license : MY_LICENSE.txt
files : " src/*.xml " pom.xml ؟يمكنك دمجها بمساعدة Maven-Antrun-Plugin:
< project >
[...]
< build >
[...]
< plugins >
[...]
< plugin >
< artifactId >maven-antrun-plugin</ artifactId >
< version >1.8</ version >
< executions >
< execution >
< phase >verify</ phase >
< configuration >
< target >
< apply executable = " xcop " failonerror = " true " >
< arg value = " --license " />
< arg value = " LICENSE.txt " />
< fileset dir = " . " >
< include name = " **/*.xml " />
< include name = " **/*.xsd " />
< exclude name = " target/**/* " />
< exclude name = " .idea/**/* " />
</ fileset >
</ apply >
</ target >
</ configuration >
< goals >
< goal >run</ goal >
</ goals >
</ execution >
</ executions >
</ plugin >
</ plugins >
</ build >
</ project >project.xml ؟شيء من هذا القبيل يجب أن يعمل:
< project >
[...]
< target name = " xcop " >
< apply executable = " xcop " failonerror = " true " >
< arg value = " --license " />
< arg value = " LICENSE.txt " />
< fileset dir = " . " >
< include name = " **/*.xml " />
< include name = " **/*.xsd " />
< exclude name = " target/**/* " />
< exclude name = " .idea/**/* " />
</ fileset >
</ apply >
</ target >
</ project >اقرأ هذه الإرشادات. تأكد من أن إنشاءك أخضر قبل المساهمة في طلب السحب الخاص بك. ستحتاج إلى تثبيت Ruby 2.3+ وتثبيت Bundler. ثم:
$ bundle update
$ bundle exec rake
إذا كان نظيفًا ولم ترى أي رسائل خطأ ، فأرسل طلب السحب الخاص بك.