google / ground-android

Ground mobile data collection app for Android
http://groundplatform.org
Apache License 2.0
245 stars 119 forks source link

[Code health] Create Android Studio template for license headers #2523

Open anandwana001 opened 4 months ago

anandwana001 commented 4 months ago

Step 1: Create a File Template for the License Header

Open Android Studio.

Go to File > Settings (or Android Studio > Preferences on macOS).

Navigate to Editor > File and Code Templates.

Select Includes from the left-hand side.

Click on the + button to create a new template.

Name your template, for example, License Header. Add your license text to the template.

/*
 * Copyright ${YEAR} Google LLC
 *
 * 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
 *
 *     https://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.
 */

Step 3: Share the Configuration with Team via GitHub Add the following files to your version control system (Git):

.idea/fileTemplates .idea/fileTemplates/includes .idea/fileTemplates/code These directories contain the file and code templates you configured.

git add .idea/fileTemplates git commit -m "Add license header templates" git push origin main

@shobhitagarwal1612 @sufyanAbbasi WDYT?

shobhitagarwal1612 commented 4 months ago

I tried the above steps and it didn't auto-insert a license to new kotlin files. @anandwana001 Does it work for you?