android studio: 配置版权信息(转)

使用Android studio,在源码头部自动插入版权信息并且设置设置版权里面的内容。

官方文档链接:Copyright Profiles

一. 如何为新创建的文件自动添加版权信息?

选择"File" -> "Settings"

找到"Editor" -> "Copyright",点击 Copyright Profiles

点击面板左侧的“+”图标,新建一个你自己的版权声明模板

输入版权简介名称,版权文本,你还可以在文本中使用一些变量 ,这个做了总结(博客下面),有官方的版权信息变量表

填写完后,点击 Validate 按钮,确保模板是有效的。如果有效,会弹出下面的提示:

点击 Apply 按钮,应用这个模板

重新点击 Copyright ,在 default project copyright 中选择刚刚新建的版权模板名称,然后点击 Apply按钮

点击面板右侧的“+”图标,弹出的下拉菜单 Scope 选择 All,Copyright 选择刚刚新建的版权模板名称

这样就可以了,如果当你新建文件的时候,它会出现在你的文件源码头部:

二. 如何为现有的文件添加版权信息?

在文件顶部右键点击 弹出菜单 -> 选择Generate…

 

 在弹出的小窗口中选择“Copyright”,然后版权声明会自动添加到文件的最上面。

三. 如何一次为所有的文件添加版权信息?

在项目任何文件夹右键点击 弹出菜单,选择 Update Copyright…

这时候你可以选择把你的版权声明添加到整个项目中,你可以在弹出选框中选择需要添加版权的位置:

四. 版权信息变量表

4.1  附上我自己的版权信息配置

Copyright (c) $today.year Baidu.com, Inc. All Rights Reserved
 
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.

Authors: $username(yongdaimi@baidu.com.cn)

注意:前面不需要加“//” 或者 “ * ” 这种注释标记,当android studio 插入以上版权信息后,会自动把以上版权信息当做注释。

 参考链接:
1. Android studio版权信息配置详情(含图)

 

posted @ 2021-06-24 14:14  夜行过客  阅读(907)  评论(0)    收藏  举报