كيف أتأكد من أن إشعارات حقوق الطبع والنشر مصاحبة لجميع ملفاتي المصدرية الخاصة ببناء Java-maven؟

StackOverflow https://stackoverflow.com/questions/1821742

سؤال

هل هناك طريقة قياسية يفرض بها الأشخاص إدراج إشعارات حقوق الطبع والنشر في إصدارات Java/maven الخاصة بهم؟أدرك أنه لا ينبغي أن يكون ذلك ضروريًا نظرًا لأن المنتج نفسه مكتوب، وإذا كان لدى شخص ما المصدر الخاص بي، فأنا أواجه مشكلات أكبر بكثير، ولكن يُطلب مني التحقق وكنت أتساءل عما إذا كان checkstyle أو PMD أو أي شيء آخر يتعامل مع هذا تلقائيًا .

هل هناك أداة تتولى التحقق من حقوق النشر؟

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

المحلول

على نعم ، أو Checkstyle (و مخضرم-checkstyle -plugin ) تستطيع أن تفعل ذلك، فإنه يمكن التأكد من أن كل الملفات المصدر تفعل تحتوي على رأس الترخيص. وضع هذا الرأس في ملف نصي واستخدام headerLocation لتشير عليه (ويستخدم من قبل LICENSE.txt الافتراضي).

ودعونا نقول لكم تريد استخدام checkstyle.license لإشعارات حقوق التأليف والنشر الخاصة بك. لمتعددة حدات بناء، والنهج هو معيار لإنشاء وحدة مخصصة لاستضافة الموارد Checkstyle (انظر <لأ href = "http://maven.apache.org/plugins/maven-checkstyle-plugin/examples/multi-module -config.html "يختلط =" نوفولو noreferrer "> Multimodule التكوين ):

whizbang
|-- pom.xml
|-- build-tools
|   |-- src
|   |   `-- main
|   |       `-- resources
|   |           `-- whizbang
|   |               |-- checkstyle.xml
|   |               `-- checkstyle.license
|   `-- pom.xml
|-- core
|-- gui
|-- jmx
`-- src

وبعد ذلك، تشمل Checkstyle التكوين في مستوى أعلى pom.xml.

<pluginManagement>
  <plugins>
    <!-- Apply checkstyle rules and fail the build in case of errors. The
         checkstyle config files are taken from the build-tools JAR module.-->
    <plugin>
      <groupId>org.apache.maven.plugins</groupId>
      <artifactId>maven-checkstyle-plugin</artifactId>
      <!-- Lock down plugin version for build reproducibility -->
      <version>2.4</version>
      <dependencies>
        <dependency>
          <groupId>com.example.whizbang</groupId>
          <artifactId>build-tools</artifactId>
          <version>1.0</version>
        </dependency>
      </dependencies>
      <configuration>
        <consoleOutput>true</consoleOutput>
        <configLocation>whizbang/checkstyle.xml</configLocation>
        <headerLocation>whizbang/checkstyle.license</headerLocation>
      </configuration>
      <executions>
        <execution>
          <goals>
            <goal>check</goal>
          </goals>
        </execution>
      </executions>
    </plugin>
    ...
  </plugins>
</pluginManagement>

وهذا الإعداد ستضمن رأس المؤلف موجود في الملفات المصدر (وتطبيق قواعد Checkstyle أخرى ولكن هذه قصة أخرى). تكييفه ليتناسب مع احتياجاتك.

نصائح أخرى

لقد وجدتhttp://code.google.com/p/maven-license-plugin/يبدو معقولا جدا

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