깊게 중첩된 계층 구조에서 저작권 헤더 교체

깊게 중첩된 계층 구조에서 저작권 헤더 교체

우리 프로젝트는 오픈 소스이므로 모든 저작권 헤더를 새 라이센스로 대체해야 합니다. 이 프로젝트는 중첩된 폴더 계층 구조에 걸쳐 약 1500개의 C++/Obj-C/Java 파일로 구성됩니다.

헤더는 다양한 형식으로 1~5줄에 걸쳐 있으므로 정규식으로 헤더를 모두 찾을 수 있다고 보장할 수는 없습니다.

여기서는 어떤 접근 방식을 취하시겠습니까?

예:

C++ 파일:

/*******************************************************************************
 * Copyright 1996: Börk Börk Inc. All Rights
 * Reserved. Proprietary and Confidential information of BOBO. Disclosure,
 * Use, or Reproduction without written authorization of BOBO is prohibited.
 *******************************************************************************/
#ifndef Things_cpp
#define Things_cpp

#include <LibOne.hpp>
#include <LibTwo.hpp>


Namespacington::ClassName::HereBeMethod(void)
{
}
#endif

자바 파일:

package com.bork.bork.boooork;

/*******************************************************
 * Copyright 1996: Börk Börk Inc. All Rights Reserved.
 * Proprietary and Confidential information of BOBO. 
 * Disclosure, Use, or Reproduction without written 
 * authorization of BOBO is prohibited.
 *******************************************************

import java.util.List;

/**
 * <p>
 * Callback interface/protocol for a proxy factory.
 * </p>
 */

@SuppressWarnings("all")
public interface ProxyFactorize
{
    /**
     * <p>
     * Do the thing
     * </p>
     * @param bork Spices
     * @param borkbork Condiments
     */

    void apply(double bork, double borkbork);

}

Obj-C 파일:

/*******************************************************
 * Copyright 1996: Börk Börk Inc.
 * All Rights Reserved.
 * Proprietary and Confidential information of BOBO. 
 * Disclosure, Use, or Reproduction without written 
 * authorization of BOBO is prohibited.
 ********************************************************/

#import <Bork/Booork.h>
@class Biorjk;

/**
 * Bork bork bork booooork
 *
 * @warning Bork?
 *
 * @warning Bork
 *
 */
@interface Biorjk : Borkburk

@end

모든 파일에 적용할 새 라이센스:

/* Copyright 2015 Bork Bork
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License. */

답변1

헤더가 너무 다르면 정규식을 사용해도 모두 잡을 수 있을지 확신할 수 없다면 가장 강력한 도구인 Regex가 필요합니다. 모든 파일을 체크아웃하고 하위 폴더의 모든 파일에 대해 정규식 기반 교체를 수행하십시오. 그런 다음 수정되지 않은 파일을 확인하고 일부 헤더를 살펴보고 해당 헤더를 조정된 정규식으로 바꾸십시오. 완료될 때까지 반복하세요. 완료되면 단일 체크인을 수행하십시오.

이것이 유일한 방법입니다.

3개의 예제 파일 중 2개에서 작동하는 간단하고 일회용 정규식은 다음과 같습니다.

[^\{\}\(\)\/]{0,200}(\/\*[*\s]*[Cc]opyright[^\n\r]*Börk Börk[a-zA-Z0-9\s\*,.]*\*\/)

여기서 테스트할 수 있습니다:https://regex101.com/

해당 파일의 형식이 잘못되고 저작권 주석이 끝나지 않고 대신 실수로 import 문도 포함되기 때문에 두 번째 파일과 일치하지 않습니다.

여러 파일에서 정규식 대체를 수행하는 도구가 많이 있습니다. 그 중 하나를 사용하세요.

답변2

나는 한때http://code.mycila.com/license-maven-plugin/내 소스 파일에 라이센스 헤더를 추가합니다. (기존 라이센스를 제거할 필요는 없었지만 플러그인 문서에는 헤더도 제거할 수 있다고 나와 있습니다.)

관련 정보