การใช้ maven deploy-file

Aug 20 2020

กำลังอ่านเอกสาร ของdeploy:deploy-file(https://maven.apache.org/plugins/maven-deploy-plugin/deploy-file-mojo.html) ดูเหมือนว่าพารามิเตอร์ที่จำเป็นเท่านั้นคือพารามิเตอร์ที่จำเป็น<file>, <repositoryId> and <url>อย่างไรก็ตามเมื่อฉันรัน:

mvn deploy:deploy-file -Durl={url} -DrepositoryId={repoId} -Dfile=D:\Users\nunito\IdeaProjects\calzada\target\calzada.zip

ฉันได้รับข้อผิดพลาดนี้:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.8.2:deploy-file (default-cli) on project oib-kw-guards-web: The artifact i
nformation is incomplete or not valid:
[ERROR]   [0]  'groupId' is missing.
[ERROR]   [1]  'artifactId' is missing.
[ERROR]   [2]  'version' is missing.

คำตอบ

3 VonC Aug 22 2020 at 14:42

ฉันมักจะใช้deploy:deploy-fileในบรรทัดคำสั่งเมื่อฉันมีสิ่งประดิษฐ์ของบุคคลที่สามที่ไม่มีpom.xml:

cmd /v /c "set a=an-artifact-name&& set g=com.company.xxx&& \
mvn deploy:deploy-file -Dfile=C:\path\to\!a!.jar -Dpackaging=jar -DgroupId=!g! -DartifactId=!a! \
-Dversion=1.0-DEV-SNAPSHOT -DrepositoryId=nexus \
-Durl=http://company.com/nexus/content/repositories/company-snapshots/"

สิ่งที่คุณต้องทำคือแก้ไขaและgที่จุดเริ่มต้นของคำสั่ง

คุณสามารถเพิ่มเวอร์ชัน v ได้หากคุณมีเวอร์ชันที่เฉพาะเจาะจงและวางไว้ในส่วนรุ่นของ Nexus ของคุณ:

cmd /v /c "set a=an-artifact-name&& set g=com.company.xxx&& && set v=1.2.3&& \
mvn deploy:deploy-file -Dfile=C:\path\to\!a!.jar -Dpackaging=jar -DgroupId=!g! -DartifactId=!a! \
-Dversion=!v! -DrepositoryId=nexus \
-Durl=http://company.com/nexus/content/repositories/company-releases/"
2 JFabianMeier Aug 25 2020 at 15:00

หน้าปลั๊กอิน "การใช้งาน" (https://maven.apache.org/plugins/maven-deploy-plugin/usage.html) รัฐ:

หากไม่ได้ระบุข้อมูลที่จำเป็นต่อไปนี้ไม่ทางใดก็ทางหนึ่งเป้าหมายจะล้มเหลว:

  • ไฟล์อาร์ติแฟกต์เพื่อปรับใช้
  • กลุ่มอาร์ติแฟกต์เวอร์ชันและแพ็กเกจของไฟล์เพื่อปรับใช้ สิ่งเหล่านี้สามารถนำมาจาก pomFile ที่ระบุและเขียนทับหรือระบุโดยใช้บรรทัดคำสั่ง เมื่อ pomFile มีส่วนพาเรนต์สามารถพิจารณา groupId ของพาเรนต์ได้หากไม่ได้ระบุ groupId เพิ่มเติมสำหรับโปรเจ็กต์ปัจจุบันหรือบนบรรทัดรับคำสั่ง
  • ข้อมูลที่เก็บ: url ที่จะปรับใช้และการแม็พ repositoryId กับส่วนเซิร์ฟเวอร์ในไฟล์ settings.xml หากคุณไม่ระบุ repositoryId Maven จะพยายามดึงข้อมูลการพิสูจน์ตัวตนโดยใช้ id 'remote-repository'

ดังนั้นคุณต้องระบุพิกัดหรือให้ไฟล์ POM