|
3 | 3 | * |
4 | 4 | * https://mcdev.io/ |
5 | 5 | * |
6 | | - * Copyright (C) 2025 minecraft-dev |
| 6 | + * Copyright (C) 2026 minecraft-dev |
7 | 7 | * |
8 | 8 | * This program is free software: you can redistribute it and/or modify |
9 | 9 | * it under the terms of the GNU Lesser General Public License as published |
|
19 | 19 | */ |
20 | 20 |
|
21 | 21 | import org.cadixdev.gradle.licenser.header.HeaderStyle |
| 22 | +import org.cadixdev.gradle.licenser.tasks.LicenseTask |
22 | 23 | import org.gradle.accessors.dm.LibrariesForLibs |
23 | 24 | import org.jetbrains.kotlin.gradle.dsl.JvmDefaultMode |
24 | 25 | import org.jetbrains.kotlin.gradle.dsl.JvmTarget |
@@ -128,14 +129,58 @@ intellijPlatform { |
128 | 129 | } |
129 | 130 |
|
130 | 131 | license { |
131 | | - header.set(resources.text.fromFile(rootProject.layout.projectDirectory.file("copyright.txt"))) |
| 132 | + header.set(resources.text.fromString($$""" |
| 133 | + Minecraft Development for IntelliJ |
| 134 | +
|
| 135 | + https://mcdev.io/ |
| 136 | +
|
| 137 | + Copyright (C) ${year} minecraft-dev |
| 138 | +
|
| 139 | + This program is free software: you can redistribute it and/or modify |
| 140 | + it under the terms of the GNU Lesser General Public License as published |
| 141 | + by the Free Software Foundation, version 3.0 only. |
| 142 | +
|
| 143 | + This program is distributed in the hope that it will be useful, |
| 144 | + but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 145 | + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 146 | + GNU General Public License for more details. |
| 147 | +
|
| 148 | + You should have received a copy of the GNU Lesser General Public License |
| 149 | + along with this program. If not, see <https://www.gnu.org/licenses/>. |
| 150 | + """.trimIndent())) |
| 151 | + |
| 152 | + properties { |
| 153 | + set("year", "2026") |
| 154 | + } |
| 155 | + |
132 | 156 | style["flex"] = HeaderStyle.BLOCK_COMMENT.format |
133 | 157 | style["bnf"] = HeaderStyle.BLOCK_COMMENT.format |
134 | 158 |
|
135 | 159 | val endings = listOf("java", "kt", "kts", "groovy", "gradle.kts", "xml", "properties", "html", "flex", "bnf") |
136 | 160 | include(endings.map { "**/*.$it" }) |
137 | 161 | } |
138 | 162 |
|
| 163 | +tasks.withType(LicenseTask::class).configureEach { |
| 164 | + val changedFiles = if (rootProject.ext.has("changedFiles")) { |
| 165 | + @Suppress("UNCHECKED_CAST") |
| 166 | + rootProject.ext["changedFiles"] as Set<File> |
| 167 | + } else { |
| 168 | + val unstagedFiles = git("diff", "--name-only").lines() |
| 169 | + val stagedFiles = git("diff", "--staged", "--name-only").lines() |
| 170 | + var changedFiles = (unstagedFiles + stagedFiles) |
| 171 | + .filter { it.isNotBlank() } |
| 172 | + .map(project::file) |
| 173 | + .toSet() |
| 174 | + rootProject.ext["changedFiles"] = changedFiles |
| 175 | + changedFiles |
| 176 | + } |
| 177 | + doFirst { |
| 178 | + files = files.filter { |
| 179 | + it in changedFiles |
| 180 | + } |
| 181 | + } |
| 182 | +} |
| 183 | + |
139 | 184 | idea { |
140 | 185 | module { |
141 | 186 | excludeDirs.add(file(intellijPlatform.sandboxContainer.get())) |
|
0 commit comments