سؤال

أنا جديد في مافن والعمل على إنشاء بناء لشركتي. لا نريد الاتصال بالمستودع المركزي في Maven، ولدينا بنية دليل مختلفة ل SRC وشمز الاختبار من المحدد في Super POM. أحسب أفضل طريقة للتعامل مع هذا هو إنشاء عميل سوبر بوم، لكنني أتساءل - أين أضع فعلا بوم سوبر حتى تتمكن بومس مشروعي؟ هل يذهب في مستودع في مكان ما؟ إذا كان الأمر كذلك حيث؟

شكرا، جيف

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

المحلول

اقتراحي هو أن تقوم بإنشاء POM الوالد التي يمكن للمشروعات التي يمكن أن تستمد منها إعداداتك. هذا POM POM هو ببساطة مشروع آخر من Maven 2، ولكن مع نوع "POM" بدلا من "Jar".

على سبيل المثال، هل يمكن أن يكون لديك الوالد بوم مثل هذا:

<project>
    <modelVersion>4.0.0</modelVersion>
    <groupId>com.company.projectname</groupId>
    <artifactId>projectname</artifactId>
    <packaging>pom</packaging>
    <version>1.0</version>
    <name>projectname</name>
    <dependencies>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.5</version>
            <scope>test</scope>
        </dependency>
    </dependencies>
    <properties>
        <superprop1>this property is available in all child projects</superprop1>
        <superprop2>this property is available in all child projects</superprop2>
        <superprop3>this property is available in all child projects</superprop3>
    </properties>
</project>

ويمكن للطفل بالمشروع أن يبدو هذا:

<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
    <parent>
        <artifactId>projectname</artifactId>
        <groupId>com.company.projectname</groupId>
        <version>1.0</version>
    </parent>
    <modelVersion>4.0.0</modelVersion>        
    <artifactId>child-project</artifactId>
    <packaging>jar</packaging>
    <name>child-project</name>
    <description>
        My child project
    </description>
</project>

كل ما تعلن عنه في الوالد بوم متاح الآن في الطفل بوم. في المثال، سيحصل مشروع الطفل تلقائيا على التبعية Junit المتاحة. سيضمن القيام بذلك بهذه الطريقة أيضا أن البيئة تعتبر تلقائيا مقارنة بحيث يتعين على كل مطور الفوضى مع Super Pom من تركيب الأفكار.

نصائح أخرى

ربما تكون صحيحة، فائقة بوم هو الطريق للذهاب في هذه الحالة. أما بالنسبة للمكان الذي تضعه، فستحتاج إلى إنشاء مستودع محلي من Maven وإعطاء المطورين الوصول إليها. فيما يلي بعض البرامج المفيدة (والمجانية):

بمجرد الحصول على مستودع التشغيل، ستحتاج إلى تعديل كل مطور إعداد إعداداتهم .xml للإشارة إلى خادم المستودع الجديد لديك إعداد. سيتم نشر Super POM التي تقوم بإنشائها في المستودع، لذلك بمجرد تكوينها لاستخدامها، فإن مافن سيسحب سوبر بوم لأسفل تلقائيا.

فيما يلي مثال على ملف إعدادات غير فعالة تم إنشاؤه:

u003C?xml version="1.0" encoding="UTF-8"?>u003Csettings xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd" xmlns="http://maven.apache.org/SETTINGS/1.0.0"n    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">u003Cprofiles>u003Cprofile>u003Crepositories>u003Crepository>u003Csnapshots>u003Cenabled> خاطئةu003C/enabled>u003C/snapshots>u003Cid> وسطu003C/id>u003Cname> الكلu003C/name>u003Curl> https://server.mycompany.com/artifactory/all.u003C/url>u003C/repository>u003Crepository>u003Csnapshots />u003Cid> لقطاتu003C/id>u003Cname> الكلu003C/name>u003Curl> https://server.mycompany.com/artifactory/all.u003C/url>u003C/repository>u003C/repositories>u003CpluginRepositories>u003CpluginRepository>u003Csnapshots>u003Cenabled> خاطئةu003C/enabled>u003C/snapshots>u003Cid> وسطu003C/id>u003Cname> الكلu003C/name>u003Curl> https://server.mycompany.com/artifactory/all.u003C/url>u003C/pluginRepository>u003CpluginRepository>u003Csnapshots />u003Cid> لقطاتu003C/id>u003Cname> الكلu003C/name>u003Curl> https://server.mycompany.com/artifactory/all.u003C/url>u003C/pluginRepository>u003C/pluginRepositories>u003Cid> Artifactory.u003C/id>u003C/profile>u003C/profiles>u003CactiveProfiles>u003CactiveProfile> Artifactory.u003C/activeProfile>u003C/activeProfiles>u003C/settings>
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top