Skip to content
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
27 changes: 27 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: CI

on:
push:
branches: [main]
pull_request:
branches: [main]

jobs:
build:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Set up JDK
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'corretto'

- name: Setup Gradle
uses: gradle/gradle-build-action@v2

- name: Execute Gradle build
run: ./gradlew clean build publish
32 changes: 32 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Eclipse
.classpath
.project
.settings/

# Intellij
.idea/
*.iml
*.iws

# Fleet
.fleet/

# VSCode
bin/

# Mac
.DS_Store

# Maven
target/
**/dependency-reduced-pom.xml

# Gradle
**/.gradle
build/
*/out/
*/*/out/
/wrapper

# Smithy
.smithy.lsp.log
31 changes: 31 additions & 0 deletions .scripts/list_services
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#!/bin/bash


# a script for listing out all services within a directory, and assumes a service will contain a `service/` directory.
# Was used to generate the initial version properties for all services by piping the output into update_versions:
# > .scripts/list_services . | xargs .scripts/update_versions -p gradle.properties -s

# Check if directory is provided
if [ $# -ne 1 ]; then
echo "usage: $0 <directory>" >&2
exit 1
fi

SCAN_DIR="$1"

# Check if the directory exists
if [ ! -d "$SCAN_DIR" ]; then
echo "$0: $SCAN_DIR: No such directory" >&2
exit 1
fi

# Change to the target directory
cd "$SCAN_DIR" || exit 1

# Iterate through all directories, find those with service subdirectory,
# and sort the output
for dir in */; do
if [ -d "${dir}service" ]; then
echo "${dir%/}"
fi
done | sort
87 changes: 87 additions & 0 deletions .scripts/update_versions
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
#!/usr/bin/env python3

import argparse
import logging
from pathlib import Path
from typing import Set

DEFAULT_VERSION = "1.0.0"

logger = logging.getLogger(__name__)
logging.basicConfig(
level=logging.INFO,
format="%(asctime)s.%(msecs)03d - %(levelname)s - %(message)s",
datefmt="%Y-%m-%dT%H:%M:%S",
)


def main(properties_file: Path, projects: Set[str]):
if not properties_file.is_file():
raise ValueError(f"Properties file {properties_file} does not exist")

properties = read_properties(properties_file)

for project in sorted(projects):
project_key = f"model.{project}.version"
if project_key not in properties:
logger.info(
f"Project ({project_key}) not found in properties file, setting to ({DEFAULT_VERSION})"
)
properties[project_key] = DEFAULT_VERSION
else:
version = properties[project_key]
major, minor, patch = version.split(".")
patch = int(patch) + 1
properties[project_key] = f"{major}.{minor}.{patch}"
logger.info(
f"Updated version for ({project_key}) to ({properties[project_key]})"
)
properties[project_key] = properties[project_key]
write_properties(properties_file, properties)


def read_properties(properties_file: Path) -> dict:
lines = properties_file.read_text().split()
# read each line, if it is empty, skip it
properties = {}
for line in lines:
if line.isspace():
continue
# split the line on the first '='
key, value = line.split("=", 1)
properties[key.strip()] = value.strip()
return properties


def write_properties(properties_file: Path, properties: dict):
properties_text = "\n".join([f"{key}={value}" for key, value in properties.items()])
properties_file.write_text(properties_text)


if __name__ == "__main__":
parser = argparse.ArgumentParser(
description="Update versions of service model packages controlled via gradle.properties"
)

parser.add_argument(
"--properties",
"-p",
dest="properties",
type=Path,
required=True,
help="The gradle.properties file that contains the versions.",
)

parser.add_argument(
"--services",
"-s",
dest="services",
type=str,
nargs="+",
required=True,
help="A list of projects to update the versions of.",
)

args = parser.parse_args()

main(args.properties, set(args.services))
29 changes: 29 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
plugins {
`java-platform`
`maven-publish`
alias(libs.plugins.jreleaser)
id("api-models-aws.publishing-conventions")
}

subprojects {
afterEvaluate {
apply {
plugin("api-models-aws.model-conventions")
}
}
}

// Configuration for the "all" package (which depends on all the subprojects)
dependencies {
constraints {
subprojects.forEach {
api(it)
}
}
}

tasks {
build {
mustRunAfter(clean)
}
}
16 changes: 16 additions & 0 deletions buildSrc/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
plugins {
`kotlin-dsl`
}

repositories {
mavenCentral()
gradlePluginPortal()
}

dependencies {
implementation(libs.smithy.gradle.base)
implementation(libs.smithy.gradle.jar)

// https://github.com/gradle/gradle/issues/15383
implementation(files(libs.javaClass.superclass.protectionDomain.codeSource.location))
}
2 changes: 2 additions & 0 deletions buildSrc/gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
org.gradle.parallel=true
org.gradle.jvmargs='-Dfile.encoding=UTF-8'
8 changes: 8 additions & 0 deletions buildSrc/settings.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// Ensure version library is available to buildSrc plugins
dependencyResolutionManagement {
versionCatalogs {
create("libs") {
from(files("../gradle/libs.versions.toml"))
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
plugins {
`java-library`
id("software.amazon.smithy.gradle.smithy-jar")
id("api-models-aws.publishing-conventions")
}

repositories {
mavenLocal()
mavenCentral()
}

//// Workaround per: https://github.com/gradle/gradle/issues/15383
val Project.libs get() = the<org.gradle.accessors.dm.LibrariesForLibs>()

dependencies {
implementation(libs.smithy.aws.cloudformation.traits)
implementation(libs.smithy.aws.endpoints)
implementation(libs.smithy.aws.iam.traits)
implementation(libs.smithy.aws.smoke.test.model)
implementation(libs.smithy.aws.traits)
implementation(libs.smithy.protocol.traits)
implementation(libs.smithy.model)
implementation(libs.smithy.rules.engine)
implementation(libs.smithy.smoke.test.traits)
implementation(libs.smithy.waiters)
}

smithy {
format = false
smithyBuildConfigs.set(project.objects.fileCollection())
}

sourceSets {
main {
smithy {
srcDir(project.projectDir.path + "/service")
}
}
}

tasks {
build {
mustRunAfter(clean)
}
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
plugins {
`maven-publish`
}

group = "software.amazon.api.models"
version = project.property("model.${project.name}.version")!!

publishing {
repositories {
// JReleaser's `publish` task publishes to all repositories, so only configure one.
maven {
name = "localStaging"
url = rootProject.layout.buildDirectory.dir("staging").get().asFile.toURI()
}
}

publications {
create<MavenPublication>("maven") {
if (project != rootProject) {
from(components["java"])
} else {
from(components["javaPlatform"])
}
}
}
}
Loading
Loading