Skip to content
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

Various cleanup, dependency bumps, remove old snapshot stuff #83

Merged
merged 5 commits into from
Sep 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 0 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -301,22 +301,6 @@ another common reason that projects don't make it into the build.

### Learn more

##### Snapshots

Snapshots is an unsupported feature which is used internally in our CI.

`publish -PsnapshotMode=true -PpublishUrl=ihmcSnapshots`

Setting `snapshotMode=true` changes the version to `SNAPSHOT-$branchName-$integrationNumber` and enables parsing of versions
declared as `SNAPSHOT-*`, matching
them to artifacts found to be available on IHMC's Artifactory snapshots repos.

Gradle Plugin Site: https://plugins.gradle.org/plugin/us.ihmc.ihmc-build

Documentation on Confluence: https://confluence.ihmc.us/display/BUILD/New+Build+Configuration+Documentation

Presentation outlining the purpose of this project: https://docs.google.com/presentation/d/1xH8kKYqLaBkRXms_04nb_yyoV6MRchLO8EAtz9WqfZA/edit?usp=sharing

#### Testing Without Publishing to the Gradle Plugins Site

Use `gradle publishToMavenLocal`
Expand Down
10 changes: 5 additions & 5 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ plugins {
`kotlin-dsl`
`java-gradle-plugin`
`maven-publish`
id("com.gradle.plugin-publish") version "1.2.1"
id("com.gradle.plugin-publish") version "1.3.0"
}

group = "us.ihmc"
version = "0.29.7"
version = "0.29.800"

repositories {
maven { url = uri("https://plugins.gradle.org/m2/") } // needed for included plugins
Expand All @@ -16,12 +16,12 @@ dependencies {
api("ca.cutterslade.gradle:gradle-dependency-analyze:1.8.3") {
exclude("junit", "junit")
}
api("com.dorongold.plugins:task-tree:2.1.0")
api("com.dorongold.plugins:task-tree:4.0.0")
api("guru.nidi:graphviz-kotlin:0.18.1")
api("com.hierynomus:sshj:0.38.0")

testApi("org.junit.jupiter:junit-jupiter-api:5.8.2")
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:5.8.2")
testApi("org.junit.jupiter:junit-jupiter-api:5.10.3")
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:5.10.3")
}

tasks.withType<Test> {
Expand Down
51 changes: 30 additions & 21 deletions src/main/kotlin/us/ihmc/build/IHMCBuildExtension.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package us.ihmc.build

import groovy.util.Eval
import groovy.util.Node
import org.apache.commons.lang3.SystemUtils
import org.apache.commons.exec.OS
import org.gradle.api.GradleException
import org.gradle.api.JavaVersion
import org.gradle.api.Project
Expand Down Expand Up @@ -94,22 +94,22 @@ open class IHMCBuildExtension(val project: Project)
if (property.key as String == "group")
{
group = property.value as String
LogTools.info("Loaded group: " + group)
LogTools.info("Loaded group: $group")
}
if (property.key as String == "version")
{
version = property.value as String
LogTools.info("Loaded version: " + version)
LogTools.info("Loaded version: $version")
}
if (property.key as String == "vcsUrl")
{
vcsUrl = property.value as String
LogTools.info("Loaded vcsUrl: " + vcsUrl)
LogTools.info("Loaded vcsUrl: $vcsUrl")
}
if (property.key as String == "openSource")
{
openSource = Eval.me(property.value as String) as Boolean
LogTools.info("Loaded openSource: " + openSource)
LogTools.info("Loaded openSource: $openSource")
}
}
}
Expand Down Expand Up @@ -296,7 +296,7 @@ open class IHMCBuildExtension(val project: Project)
if (compatibilityVersionProperty != "CURRENT")
{
java.sourceCompatibility = JavaVersion.valueOf(compatibilityVersionProperty)
java.targetCompatibility = JavaVersion.valueOf(compatibilityVersionProperty);
java.targetCompatibility = JavaVersion.valueOf(compatibilityVersionProperty)
}
for (sourceSet in java.sourceSets)
{
Expand All @@ -312,7 +312,7 @@ open class IHMCBuildExtension(val project: Project)
if (compatibilityVersionProperty != "CURRENT")
{
javaSubproject.sourceCompatibility = JavaVersion.valueOf(compatibilityVersionProperty)
javaSubproject.targetCompatibility = JavaVersion.valueOf(compatibilityVersionProperty);
javaSubproject.targetCompatibility = JavaVersion.valueOf(compatibilityVersionProperty)
}
for (sourceSet in javaSubproject.sourceSets)
{
Expand All @@ -337,7 +337,7 @@ open class IHMCBuildExtension(val project: Project)
{
var modifiedDirectory = directory
if (sourceSetName == "main")
modifiedDirectory = "src/main/" + directory
modifiedDirectory = "src/main/$directory"

sourceSet(sourceSetName).java.srcDir(modifiedDirectory)
}
Expand All @@ -346,7 +346,7 @@ open class IHMCBuildExtension(val project: Project)
{
var modifiedDirectory = directory
if (sourceSetName == "main")
modifiedDirectory = "src/main/" + directory
modifiedDirectory = "src/main/$directory"

sourceSet(sourceSetName).resources.srcDir(modifiedDirectory)
}
Expand All @@ -358,10 +358,10 @@ open class IHMCBuildExtension(val project: Project)

fun sourceSetProject(sourceSetName: String): Project
{
if (sourceSetName == "main")
return project
return if (sourceSetName == "main")
project
else
return project.project(project.name + "-" + sourceSetName)
project.project(project.name + "-" + sourceSetName)
}

fun javaFXModule(moduleName: String, version: String): String
Expand All @@ -371,7 +371,7 @@ open class IHMCBuildExtension(val project: Project)

fun javaFXOSIdentifier(): String
{
var archSuffix = "";
var archSuffix = ""
val isARM64 = System.getProperty("os.arch").equals("aarch64")
|| System.getProperty("os.arch").equals("arm64")
|| System.getProperty("ihmc.build.javafxarm64", "false").equals("true")
Expand All @@ -380,9 +380,14 @@ open class IHMCBuildExtension(val project: Project)

return when
{
SystemUtils.IS_OS_WINDOWS -> "win" // No additional platforms for win
SystemUtils.IS_OS_MAC -> "mac$archSuffix"
else -> "linux$archSuffix"

OS.isFamilyWindows() -> "win" // No additional platforms for win
OS.isFamilyMac() -> "mac$archSuffix"
OS.isFamilyUnix() -> "linux$archSuffix"
else ->
{
throw RuntimeException("Unsupported javafx platform")
}
}
}

Expand Down Expand Up @@ -433,7 +438,7 @@ open class IHMCBuildExtension(val project: Project)
}
else if (artifactId.startsWith(includedBuild.name))
{
for (extraSourceSet in IHMCBuildProperties(project.logger, includedBuild.projectDir.toPath()).extraSourceSets)
for (extraSourceSet in IHMCBuildProperties(includedBuild.projectDir.toPath()).extraSourceSets)
{
if (artifactId == (includedBuild.name + "-$extraSourceSet"))
{
Expand All @@ -453,7 +458,7 @@ open class IHMCBuildExtension(val project: Project)

internal fun getExternalDependencyVersion(groupId: String, artifactId: String, declaredVersion: String): String
{
var externalDependencyVersion: String
val externalDependencyVersion: String

// For high-level projects depending on develop,
// use version: "source" to make sure you've got everything, and fail fast
Expand All @@ -468,10 +473,10 @@ open class IHMCBuildExtension(val project: Project)
}
else
{
var message = "$groupId:$artifactId's version is set to \"$declaredVersion\" and is not included in the build. Please put" +
val message = "$groupId:$artifactId's version is set to \"$declaredVersion\" and is not included in the build. Please put" +
" $artifactId in your composite build or use a release."
LogTools.error(message)
throw GradleException("[ihmc-build] " + message)
throw GradleException("[ihmc-build] $message")
}
}
else // Pass directly to gradle as declared
Expand Down Expand Up @@ -559,7 +564,9 @@ open class IHMCBuildExtension(val project: Project)
private fun Project.declarePublication(artifactName: String, sourceSet: SourceSet)
{
val publishing = extensions.getByType(PublishingExtension::class.java)
val publication = publishing.publications.create(sourceSet.name.capitalize(), MavenPublication::class.java)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

capitalize() is deprecated

val publication = publishing.publications.create(sourceSet.name.replaceFirstChar {
if (it.isLowerCase()) it.titlecase(Locale.getDefault()) else it.toString()
}, MavenPublication::class.java)
publication.groupId = group as String
publication.artifactId = artifactName
publication.version = version as String
Expand Down Expand Up @@ -606,6 +613,7 @@ open class IHMCBuildExtension(val project: Project)
implementationDependencies: HashSet<String>,
configurationName: String)
{
// TODO: cleanup
configurations.getByName(configurationName).resolvedConfiguration.run {
// Get each of the resolved artifacts for the configuration
// firstLevelModuleDependencies may not return all dependencies if they aren't resolved locally
Expand Down Expand Up @@ -656,6 +664,7 @@ open class IHMCBuildExtension(val project: Project)

private fun Project.findExclusions(exclusions: HashMap<String, HashSet<ExcludeRule>>, configurationName: String)
{
// TODO: cleanup
configurations.getByName(configurationName).dependencies.forEach { dependency ->
if (dependency is DefaultExternalModuleDependency)
{
Expand Down
2 changes: 1 addition & 1 deletion src/main/kotlin/us/ihmc/build/IHMCBuildLogTools.kt
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,6 @@ class IHMCBuildLogTools(val logger: Logger)

private fun ihmcBuildMessage(message: Any): String
{
return "[ihmc-build] " + message
return "[ihmc-build] $message"
}
}
32 changes: 15 additions & 17 deletions src/main/kotlin/us/ihmc/build/IHMCBuildProperties.kt
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
package us.ihmc.build

import groovy.util.Eval
import org.gradle.api.logging.Logger
import java.io.FileInputStream
import java.nio.file.Path
import java.util.*

class IHMCBuildProperties(val logger: Logger, val projectPath: Path) : Comparable<IHMCBuildProperties>
class IHMCBuildProperties(val projectPath: Path) : Comparable<IHMCBuildProperties>
{
var folderName = projectPath.fileName.toString()
var kebabCasedName: String = ""
Expand All @@ -23,31 +22,32 @@ class IHMCBuildProperties(val logger: Logger, val projectPath: Path) : Comparabl
{
if (propertyKey == "excludeFromCompositeBuild")
{
excludeFromCompositeBuild = (properties.get(propertyKey)!! as String).toBoolean()
excludeFromCompositeBuild = (properties[propertyKey]!! as String).toBoolean()
if (excludeFromCompositeBuild)
{
LogTools.info("Excluding " + folderName + ". Property excludeFromCompositeBuild = " + properties.get(propertyKey))
LogTools.info("Excluding " + folderName + ". Property excludeFromCompositeBuild = " + properties[propertyKey])
}
}
if (propertyKey == "isProjectGroup")
{
isProjectGroup = IHMCBuildTools.isProjectGroupCompatibility(properties.get(propertyKey)!! as String)
isProjectGroup = IHMCBuildTools.isProjectGroupCompatibility(properties[propertyKey]!! as String)
if (isProjectGroup)
{
LogTools.info("Found group: $folderName (isProjectGroup = $isProjectGroup) $projectPath")
}
}
if (propertyKey == "extraSourceSets")
{
extraSourceSets.addAll(Eval.me(properties.get(propertyKey)!! as String) as ArrayList<String>)
// TODO: cleanup
extraSourceSets.addAll(Eval.me(properties[propertyKey]!! as String) as ArrayList<String>)
}
}

kebabCasedName = kebabCasedNameCompatibilityDuplicate(folderName, properties)

for (i in 0 until extraSourceSets.size)
{
extraSourceSets.set(i, IHMCBuildTools.toKebabCased(extraSourceSets[i]))
extraSourceSets[i] = IHMCBuildTools.toKebabCased(extraSourceSets[i])
}

allArtifacts.add(kebabCasedName)
Expand All @@ -57,22 +57,20 @@ class IHMCBuildProperties(val logger: Logger, val projectPath: Path) : Comparabl
}
}

fun kebabCasedNameCompatibilityDuplicate(projectName: String, properties: Properties): String
private fun kebabCasedNameCompatibilityDuplicate(projectName: String, properties: Properties): String
{
if (properties.containsKey("kebabCasedName") && !(properties.get("kebabCasedName") as String).startsWith("$"))
return if (properties.containsKey("kebabCasedName") && !(properties["kebabCasedName"] as String).startsWith("$"))
{
return properties.get("kebabCasedName") as String
}
else if (properties.containsKey("title") && !(properties.get("title") as String).startsWith("$"))
properties["kebabCasedName"] as String
} else if (properties.containsKey("title") && !(properties["title"] as String).startsWith("$"))
{
return IHMCBuildTools.titleToKebabCase(properties.get("title") as String)
}
else
IHMCBuildTools.titleToKebabCase(properties["title"] as String)
} else
{
val defaultValue = IHMCBuildTools.toKebabCased(projectName)
LogTools.info("No value found for kebabCasedName. Using default value: $defaultValue")
properties.set("kebabCasedName", defaultValue)
return defaultValue
properties["kebabCasedName"] = defaultValue
defaultValue
}
}

Expand Down
Loading