Reverted copyright+author changes. WIP dependency ID.
parent
4bb465ddfa
commit
ed1df0ab26
|
@ -36,7 +36,7 @@ object Extras {
|
|||
// set for the project
|
||||
const val description = "License definitions and legal management plugin for the Gradle build system"
|
||||
const val group = "com.dorkbox"
|
||||
const val version = "1.6.1"
|
||||
const val version = "1.4.1"
|
||||
|
||||
// set as project.ext
|
||||
const val name = "Gradle Licensing Plugin"
|
||||
|
|
|
@ -17,13 +17,12 @@ package dorkbox.license
|
|||
|
||||
import License
|
||||
import java.time.LocalDate
|
||||
import java.util.*
|
||||
|
||||
class LicenseData(val name: String, val license: License) : Comparable<LicenseData> {
|
||||
/**
|
||||
* Copyright
|
||||
*/
|
||||
val copyrights = ArrayList<Int>()
|
||||
val copyrights = mutableListOf<Int>()
|
||||
|
||||
/**
|
||||
* If not specified, will use the current year
|
||||
|
@ -35,7 +34,7 @@ class LicenseData(val name: String, val license: License) : Comparable<LicenseDa
|
|||
/**
|
||||
* URL
|
||||
*/
|
||||
val urls = ArrayList<String>()
|
||||
val urls = mutableListOf<String>()
|
||||
|
||||
/**
|
||||
* Specifies the URLs this project is located at
|
||||
|
@ -47,7 +46,7 @@ class LicenseData(val name: String, val license: License) : Comparable<LicenseDa
|
|||
/**
|
||||
* Notes
|
||||
*/
|
||||
val notes = ArrayList<String>()
|
||||
val notes = mutableListOf<String>()
|
||||
|
||||
/**
|
||||
* Specifies any extra notes (or copyright info) as needed
|
||||
|
@ -56,22 +55,10 @@ class LicenseData(val name: String, val license: License) : Comparable<LicenseDa
|
|||
notes.add(note)
|
||||
}
|
||||
|
||||
/**
|
||||
* Copyright WITH Author info
|
||||
*/
|
||||
val copyrightAndAuthors = ArrayList<Pair<Int, String>>()
|
||||
|
||||
/**
|
||||
* If not specified, will use the current year
|
||||
*/
|
||||
fun author(copyright: Int, author:String) {
|
||||
copyrightAndAuthors.add(Pair(copyright, author))
|
||||
}
|
||||
|
||||
/**
|
||||
* AUTHOR
|
||||
*/
|
||||
val authors = ArrayList<String>()
|
||||
val authors = mutableListOf<String>()
|
||||
|
||||
/**
|
||||
* Specifies the authors of this project
|
||||
|
@ -100,7 +87,6 @@ class LicenseData(val name: String, val license: License) : Comparable<LicenseDa
|
|||
if (name != other.name) return false
|
||||
if (license != other.license) return false
|
||||
if (copyrights != other.copyrights) return false
|
||||
if (copyrightAndAuthors != other.copyrightAndAuthors) return false
|
||||
if (urls != other.urls) return false
|
||||
if (notes != other.notes) return false
|
||||
if (authors != other.authors) return false
|
||||
|
@ -112,7 +98,6 @@ class LicenseData(val name: String, val license: License) : Comparable<LicenseDa
|
|||
var result = name.hashCode()
|
||||
result = 31 * result + license.hashCode()
|
||||
result = 31 * result + copyrights.hashCode()
|
||||
result = 31 * result + copyrightAndAuthors.hashCode()
|
||||
result = 31 * result + urls.hashCode()
|
||||
result = 31 * result + notes.hashCode()
|
||||
result = 31 * result + authors.hashCode()
|
||||
|
@ -153,14 +138,12 @@ class LicenseData(val name: String, val license: License) : Comparable<LicenseDa
|
|||
b.append(SPACER).append(it).append(NL)
|
||||
}
|
||||
|
||||
val hasCopyrightElsewhere = license.copyrightAndAuthors.isNotEmpty()
|
||||
|
||||
b.append(SPACER).append("Copyright")
|
||||
if (!hasCopyrightElsewhere && license.copyrights.isEmpty()) {
|
||||
if (license.copyrights.isEmpty()) {
|
||||
// append the current year
|
||||
b.append(" ").append(LocalDate.now().year)
|
||||
}
|
||||
else if (license.copyrights.isNotEmpty()) {
|
||||
else {
|
||||
license.copyrights.forEach {
|
||||
b.append(" ").append(it).append(",")
|
||||
}
|
||||
|
@ -173,10 +156,6 @@ class LicenseData(val name: String, val license: License) : Comparable<LicenseDa
|
|||
b.append(SPACR1).append(it).append(NL)
|
||||
}
|
||||
|
||||
license.copyrightAndAuthors.forEach {
|
||||
b.append(SPACR1).append("Copyright ${it.first}, ${it.second}").append(NL)
|
||||
}
|
||||
|
||||
if (license.license === License.CUSTOM) {
|
||||
license.notes.forEach {
|
||||
b.append(fixSpace(it, SPACER, 1)).append(NL)
|
||||
|
|
|
@ -29,6 +29,9 @@ internal open class LicenseInjector : DefaultTask() {
|
|||
didWork = buildLicenseFiles(outputDir, licenses) && buildLicenseFiles(rootDir, licenses)
|
||||
}
|
||||
|
||||
/**
|
||||
* @return true when there is work that needs to be done
|
||||
*/
|
||||
private fun checkLicenseFiles(outputDir: File, licenses: MutableList<LicenseData>): Boolean {
|
||||
var needsToDoWork = false
|
||||
if (!outputDir.exists()) outputDir.mkdirs()
|
||||
|
@ -54,6 +57,9 @@ internal open class LicenseInjector : DefaultTask() {
|
|||
return needsToDoWork
|
||||
}
|
||||
|
||||
/**
|
||||
* @return true when there is work that has be done
|
||||
*/
|
||||
private fun buildLicenseFiles(outputDir: File, licenses: MutableList<LicenseData>): Boolean {
|
||||
var hasDoneWork = false
|
||||
|
||||
|
@ -63,7 +69,7 @@ internal open class LicenseInjector : DefaultTask() {
|
|||
val licenseFile = File(outputDir, "LICENSE")
|
||||
|
||||
if (fileIsNotSame(licenseFile, licenseText)) {
|
||||
// write out the LICENSE and various license files
|
||||
// write out the LICENSE files
|
||||
licenseFile.writeText(licenseText)
|
||||
hasDoneWork = true
|
||||
}
|
||||
|
@ -74,6 +80,7 @@ internal open class LicenseInjector : DefaultTask() {
|
|||
val sourceText = license.licenseText
|
||||
|
||||
if (fileIsNotSame(file, sourceText)) {
|
||||
// write out the various license text files
|
||||
file.writeText(sourceText)
|
||||
hasDoneWork = true
|
||||
}
|
||||
|
@ -89,10 +96,6 @@ internal open class LicenseInjector : DefaultTask() {
|
|||
* @return TRUE if the file IS NOT THE SAME, FALSE if the file IS THE SAME
|
||||
*/
|
||||
private fun fileIsNotSame(outputFile: File, sourceText: String): Boolean {
|
||||
if (outputFile.canRead()) {
|
||||
return !(sourceText.toByteArray() contentEquals outputFile.readBytes())
|
||||
}
|
||||
|
||||
return true
|
||||
return !(outputFile.canRead() && sourceText.toByteArray() contentEquals outputFile.readBytes())
|
||||
}
|
||||
}
|
||||
|
|
|
@ -107,11 +107,10 @@ class LicensePlugin : Plugin<Project> {
|
|||
// we associate the artifact group + id + (start) version as a license.
|
||||
// if a license for a dependency is UNKNOWN, then we emit a warning to the user to add it as a pull request
|
||||
// if a license version is not specified, then we use the default
|
||||
// val projectLicenses = mutableSetOf<String>()
|
||||
// for (dependency in extension.projectDependencies) {
|
||||
// dependency.group + dependency.name
|
||||
//
|
||||
// }
|
||||
val projectLicenses = mutableSetOf<String>()
|
||||
for (dependency in extension.projectDependencies) {
|
||||
println("DEP: " + dependency.group + dependency.name)
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue