-
Notifications
You must be signed in to change notification settings - Fork 12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Initial gradle build #212
Open
midttuna
wants to merge
22
commits into
Draegerwerk:main
Choose a base branch
from
midttuna:sdccc-gradle
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Initial gradle build #212
Changes from 19 commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
29d5e2e
Initial gradle build
midttuna b7e632b
gradle permission denied fix
midttuna ac934f1
fix java version complaint
midttuna bb5685d
fix java version complaint
midttuna c0e3114
typos, whitespace, number of parallel tests
midttuna e7cad0e
add target directory for downloaded licenses
midttuna a97d900
blind infinite typos
midttuna 28c14a9
case sensitive
midttuna 32fe0f1
new line eof
midttuna 58a5a17
Merge branch 'Draegerwerk:main' into sdccc-gradle
midttuna 74b1800
whitespace and test
midttuna 8e2a069
review changes
midttuna 21fb49e
versioning
midttuna 7b650f3
remove unnecessary
midttuna 63c4e1e
permission error revert
midttuna fd1b39b
bracket
midttuna 1c2cda0
Merge branch 'Draegerwerk:main' into sdccc-gradle
midttuna 8e1caa7
move versions from java-conventions.
midttuna 4b8639e
make writeable
midttuna e05b749
composite build instead of buildsrc and fix review remarks
midttuna 4d965d8
remove hardcoded versions
midttuna 3bd828d
typos, remove test jar and move versions to catalog
midttuna File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
/* | ||
* This file was generated by the Gradle 'init' task. | ||
*/ | ||
|
||
|
||
plugins { | ||
id("com.draeger.medical.java-conventions") | ||
id("org.somda.sdc.xjc") | ||
} | ||
|
||
val jaxb: Configuration by configurations.creating | ||
val schemaDir = "src/main" | ||
|
||
|
||
dependencies { | ||
api(libs.org.glassfish.jaxb.jaxb.core) | ||
api(libs.org.glassfish.jaxb.jaxb.runtime) | ||
api(libs.jakarta.xml.bind.jakarta.xml.bind.api) | ||
api(libs.io.github.threeten.jaxb.threeten.jaxb.core) | ||
api(libs.org.jvnet.jaxb.jaxb.plugins) | ||
api(libs.org.checkerframework.checker.qual) | ||
api(libs.org.jetbrains.annotations) | ||
|
||
testImplementation(libs.org.junit.jupiter.junit.jupiter.api) | ||
testImplementation(libs.org.junit.jupiter.junit.jupiter.engine) | ||
|
||
jaxb(libs.org.jetbrains.annotations) | ||
jaxb(libs.org.jvnet.jaxb.jaxb.plugin.annotate) | ||
ldeichmann marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
|
||
description = "SDCri is a set of Java libraries that implements a network communication framework conforming " + | ||
"with the IEEE 11073 SDC specifications. This project implements the model for IEEE 11073-10207." | ||
|
||
xjc { | ||
jaxbClasspath = jaxb | ||
schemaLocation = layout.projectDirectory.dir(schemaDir) | ||
args = listOf( | ||
"-Xannotate", | ||
ldeichmann marked this conversation as resolved.
Show resolved
Hide resolved
|
||
) | ||
} | ||
|
||
description = "BICEPS model" | ||
|
||
val testsJar by tasks.registering(Jar::class) { | ||
archiveClassifier.set("tests") | ||
from(sourceSets["test"].output) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
val defaultVersion = "9.1.0-SNAPSHOT" | ||
val actualVersion = project.findProperty("revision") ?: defaultVersion | ||
val actualRevision = project.findProperty("changelist") ?: "" | ||
|
||
group = "com.draeger.medical" | ||
version = "$actualVersion$actualRevision" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/* | ||
* This file was generated by the Gradle 'init' task. | ||
*/ | ||
|
||
plugins { | ||
// Support convention plugins written in Kotlin. Convention plugins are build scripts in 'src/main' that automatically become available as plugins in the main build. | ||
`kotlin-dsl` | ||
} | ||
|
||
repositories { | ||
// Use the plugin portal to apply community plugins in convention plugins. | ||
gradlePluginPortal() | ||
} | ||
|
||
gradlePlugin { | ||
plugins { | ||
create("XjcPlugin") { | ||
id = "org.somda.sdc.xjc" | ||
implementationClass = "org.somda.sdc.XjcPlugin" | ||
} | ||
create("licenseReport") { | ||
id = "com.example.license-report" | ||
implementationClass = "LicenseReportPlugin" | ||
} | ||
} | ||
} | ||
|
||
dependencies { | ||
implementation("com.github.jk1:gradle-license-report:2.9") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
import com.github.jk1.license.LicenseReportExtension | ||
import com.github.jk1.license.ModuleData | ||
import com.github.jk1.license.ProjectData | ||
import com.github.jk1.license.render.ReportRenderer | ||
import org.gradle.api.Project | ||
import java.io.File | ||
import java.net.URL | ||
|
||
class LicenseDownloaderRenderer( | ||
private val outputDirName: String = "downloaded-licenses" | ||
) : ReportRenderer { | ||
|
||
companion object { | ||
private const val CONNECT_TIMEOUT = 5000 // 5 seconds | ||
private const val READ_TIMEOUT = 10000 // 10 seconds | ||
} | ||
|
||
private lateinit var project: Project | ||
private lateinit var outputDir: File | ||
private val downloadedLicenses = mutableSetOf<String>() | ||
|
||
override fun render(data: ProjectData) { | ||
project = data.project | ||
val config = project.extensions.getByType(LicenseReportExtension::class.java) | ||
outputDir = File(config.outputDir, outputDirName) | ||
outputDir.mkdirs() | ||
|
||
data.allDependencies.forEach { moduleData -> | ||
val moduleName = "${moduleData.group}-${moduleData.name}-${moduleData.version}" | ||
val licenseDetails = extractPomLicenseDetails(moduleData) | ||
|
||
if (licenseDetails.isNotEmpty()) { | ||
licenseDetails.forEach { (licenseUrl, fileName) -> | ||
try { | ||
if (downloadedLicenses.add(licenseUrl)) { | ||
downloadLicense(licenseUrl, moduleName, fileName) | ||
} else { | ||
project.logger.lifecycle("Skipping duplicate license download for $licenseUrl") | ||
} | ||
} catch (e: Exception) { | ||
project.logger.warn("Failed to download license from $licenseUrl for $moduleName: ${e.message}") | ||
} | ||
} | ||
} else { | ||
project.logger.warn("No POM license URLs found for $moduleName") | ||
} | ||
} | ||
} | ||
|
||
private fun extractPomLicenseDetails(moduleData: ModuleData): List<Pair<String, String>> { | ||
val licenseDetails = mutableListOf<Pair<String, String>>() | ||
|
||
moduleData.poms.forEach { pomData -> | ||
pomData.licenses.forEach { license -> | ||
val url = license.url?.trim() | ||
val fileName = license.name ?: "LICENSE" | ||
if (!url.isNullOrEmpty()) { | ||
licenseDetails.add(url to fileName) | ||
} | ||
} | ||
} | ||
|
||
return licenseDetails | ||
} | ||
|
||
private fun downloadLicense(licenseUrl: String, moduleName: String, fileName: String) { | ||
val sanitizedUrl = licenseUrl.trim() | ||
val url = URL(sanitizedUrl) | ||
|
||
val connection = url.openConnection() | ||
connection.connectTimeout = CONNECT_TIMEOUT | ||
connection.readTimeout = READ_TIMEOUT | ||
connection.connect() | ||
|
||
val contentType = connection.contentType ?: "application/octet-stream" | ||
|
||
val extension = when { | ||
contentType.contains("text/html", ignoreCase = true) -> ".html" | ||
contentType.contains("text/plain", ignoreCase = true) -> ".txt" | ||
contentType.contains("application/pdf", ignoreCase = true) -> ".pdf" | ||
contentType.contains("text/markdown", ignoreCase = true) -> ".md" | ||
else -> ".txt" | ||
} | ||
|
||
val file = File(outputDir, "$fileName$extension") | ||
|
||
connection.getInputStream().use { input -> | ||
file.outputStream().use { output -> | ||
input.copyTo(output) | ||
} | ||
} | ||
|
||
project.logger.lifecycle("Downloaded license for $moduleName from $licenseUrl to $file") | ||
} | ||
|
||
} |
38 changes: 38 additions & 0 deletions
38
buildSrc/src/main/kotlin/com.draeger.medical.java-conventions.gradle.kts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
/* | ||
* This file was generated by the Gradle 'init' task. | ||
*/ | ||
|
||
plugins { | ||
`java-library` | ||
`maven-publish` | ||
} | ||
|
||
repositories { | ||
mavenLocal() | ||
|
||
maven { | ||
url = uri("https://maven.pkg.github.com/Draegerwerk/t2iapi") | ||
} | ||
|
||
mavenCentral() | ||
|
||
maven { | ||
url = uri("https://oss.sonatype.org/content/repositories/snapshots") | ||
} | ||
} | ||
|
||
val javaVersion = property("javaVersion").toString() | ||
|
||
java { | ||
sourceCompatibility = JavaVersion.toVersion(javaVersion) | ||
targetCompatibility = JavaVersion.toVersion(javaVersion) | ||
} | ||
|
||
tasks.withType<JavaCompile>() { | ||
options.release.set(javaVersion.toInt()) | ||
ldeichmann marked this conversation as resolved.
Show resolved
Hide resolved
|
||
options.encoding = "UTF-8" | ||
} | ||
|
||
tasks.withType<Javadoc>() { | ||
options.encoding = "UTF-8" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
// buildSrc/src/main/kotlin/license-report.gradle.kts | ||
|
||
plugins { | ||
id("com.github.jk1.dependency-license-report") | ||
} | ||
|
||
licenseReport { | ||
renderers = arrayOf( | ||
com.github.jk1.license.render.XmlReportRenderer(), | ||
com.github.jk1.license.render.SimpleHtmlReportRenderer(), | ||
LicenseDownloaderRenderer(), | ||
) | ||
} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I forgot to remove the SNAPSHOT part in my example, otherwise RELEASE_VERSION would be
9.1.0-SNAPSHOT
, but we only care about the actual version numbers here.Has led to having
SDCcc-9.1.0-SNAPSHOT-SNAPSHOT-executable-win64.zip
as a file name, which is just a bit odd.