Quellcode durchsuchen

Add support for multiple gradle versions

main
Sindre Stephansen vor 2 Jahren
Ursprung
Commit
4389c0a10e
Signiert von: sindre <sindre@sindrestephansen.com> GPG-Schlüssel-ID: B06FC67D17A46ADE
5 geänderte Dateien mit 62 neuen und 24 gelöschten Zeilen
  1. +5
    -2
      README.md
  2. +9
    -2
      package-list.yaml
  3. +33
    -11
      sync/resolve-deps.sh
  4. +10
    -4
      sync/src/config.py
  5. +5
    -5
      sync/src/main.py

+ 5
- 2
README.md Datei anzeigen

@@ -20,13 +20,16 @@ maven:
mirrors: mirrors:
- "https://repo.maven.apache.org/maven2" - "https://repo.maven.apache.org/maven2"


# Specify configurations of kotlin version, plugins, and packages. For most packages the kotlin version doesn't matter.
# Specify configurations of kotlin version, gradle version, plugins, and packages.
# For most packages the kotlin version and gradle version doesn't matter. It probably matters for plugins.
configurations: configurations:
# A kotlin version without specific plugins and packages. This fetches the bare minimum of # A kotlin version without specific plugins and packages. This fetches the bare minimum of
# packages and plugins to be able to use that kotlin version.
# packages and plugins to be able to use that kotlin version, for the given gradle version.
- kotlin-version: "1.7.20" - kotlin-version: "1.7.20"
gradle-version: "7.0"
- kotlin-version: "1.8.20" - kotlin-version: "1.8.20"
gradle-version: "8.2.1"
# Plugins specific to this kotlin version, listed with their plugin ID, not the full package name. # Plugins specific to this kotlin version, listed with their plugin ID, not the full package name.
# Plugin versions can be a single version as a string, or a list of strings to fetch multiple versions. # Plugin versions can be a single version as a string, or a list of strings to fetch multiple versions.
plugins: plugins:


+ 9
- 2
package-list.yaml Datei anzeigen

@@ -8,22 +8,29 @@ maven:
- "https://plugins.gradle.org/m2" - "https://plugins.gradle.org/m2"


configurations: configurations:
# Specify configurations where the packages/plugins depend on a specific kotlin version.
# Specify configurations where the packages/plugins depend on a specific kotlin and/or gradle version.
- kotlin-version: "1.8.20" - kotlin-version: "1.8.20"
gradle-version: "7.6.2"
plugins: plugins:
com.expediagroup.graphql: ["7.0.0-alpha.5", "6.5.2"] com.expediagroup.graphql: ["7.0.0-alpha.5", "6.5.2"]


- kotlin-version: "1.8.0" - kotlin-version: "1.8.0"
gradle-version: "8.2.1"

- kotlin-version: "1.8.0"
gradle-version: "7.0"


- kotlin-version: "1.7.20" - kotlin-version: "1.7.20"
gradle-version: "8.2.1"
packages: packages:
org.slf4j:slf4j-api: "2.0.7" org.slf4j:slf4j-api: "2.0.7"


# The default configuration, where the kotlin version doesn't matter.
# The default configuration, where the kotlin and gradle version doesn't matter.
# This is kept as a separate configuration to make the ones above more obvious and easier to maintain. # This is kept as a separate configuration to make the ones above more obvious and easier to maintain.
# #
# Most packages should be placed here. # Most packages should be placed here.
- kotlin-version: "1.8.20" - kotlin-version: "1.8.20"
gradle-version: "8.2.1"
plugins: plugins:
org.panteleyev.jpackageplugin: "1.5.2" org.panteleyev.jpackageplugin: "1.5.2"
packages: packages:


+ 33
- 11
sync/resolve-deps.sh Datei anzeigen

@@ -24,33 +24,55 @@ wait_for_reposilite ()


# Main scipt # Main scipt


echo "Check that reposilite is running"
wait_for_reposilite

if [[ ! -f /package-list.yaml ]]; then if [[ ! -f /package-list.yaml ]]; then
echo "No /package-list.yaml file. Aborting" echo "No /package-list.yaml file. Aborting"
exit 255 exit 255
fi fi


export PROJECTS_DIR=/gradle-projects export PROJECTS_DIR=/gradle-projects
mkdir -p "$PROJECTS_DIR"
mkdir -p "${PROJECTS_DIR}"

export GRADLE_VERSIONS_DIR=/gradle-versions
mkdir -p "${GRADLE_VERSIONS_DIR}"


echo "Resolving packages and generating gradle config" echo "Resolving packages and generating gradle config"
mkdir -p /gradle
python3 --version python3 --version
if ! python3 src/main.py --repo="repo:80" --output-dir "$PROJECTS_DIR" /package-list.yaml; then if ! python3 src/main.py --repo="repo:80" --output-dir "$PROJECTS_DIR" /package-list.yaml; then
echo "Gradle generation failed" echo "Gradle generation failed"
exit 255 exit 255
fi fi


echo "Check that reposilite is running"
wait_for_reposilite

if [ $? -lt 30 ]; then if [ $? -lt 30 ]; then
for project in "$PROJECTS_DIR"/*; do
echo "-----------------------Config for $project-------------------------------"
echo "Running $project"
cat "$project/build.gradle.kts"
for path in "$PROJECTS_DIR"/*; do
version=$(basename "${path}")
gradle_path=${GRADLE_VERSIONS_DIR}/gradle-${version}

if [[ "${version}" -eq "${GRADLE_VERSION}" ]]; then
gradle_path=${GRADLE_HOME}
elif [[ ! -d "${gradle_path}" ]]; then
echo "Downloading gradle ${version}"
filename="gradle-${version}-bin.zip"
wget "https://services.gradle.org/distributions/${filename}"
unzip -q "${filename}" -d "${GRADLE_VERSIONS_DIR}"
rm "${filename}"

if [[ ! -d "${gradle_path}" ]]; then
echo "ERROR: Could not fetch gradle ${version}"
continue
fi
fi


echo "-----------------------Running gradle------------------------------------"
(cd "$project" && gradle -Dorg.gradle.jvmargs=-Xms4096m downloadDependencies --info)
for project in "${path}"/*; do
echo "-----------------------Config for $project-------------------------------"
echo "Running $project"
cat "$project/build.gradle.kts"

echo "-----------------------Running gradle------------------------------------"
(cd "$project" && "${gradle_path}/bin/gradle" --info -Dorg.gradle.jvmargs=-Xms4096m downloadDependencies)
done
done done
else else
echo "Can't connect to repository" echo "Can't connect to repository"


+ 10
- 4
sync/src/config.py Datei anzeigen

@@ -12,6 +12,7 @@ logger = logging.getLogger(__name__)
class Configuration: class Configuration:
name: str name: str
kotlin_version: str kotlin_version: str
gradle_version: str
plugins: dict[str, str] plugins: dict[str, str]
packages: list[str] packages: list[str]


@@ -85,15 +86,19 @@ def parse_config(path: Path) -> Optional[Config]:
configurations: list[Configuration] = [] configurations: list[Configuration] = []


for i, section in enumerate(data.get('configurations')): for i, section in enumerate(data.get('configurations')):
if (version := section.get('kotlin-version')) is None:
if (kotlin_version := section.get('kotlin-version')) is None:
error.append(f"Configuration {i} is missing 'kotlin-version'") error.append(f"Configuration {i} is missing 'kotlin-version'")


if (gradle_version := section.get('gradle-version')) is None:
error.append(f"Configuration {i} is missing 'gradle-version'")

plugins = handle_plugins(section.get('plugins', {})) plugins = handle_plugins(section.get('plugins', {}))
packages = handle_packages(section.get('packages', {})) packages = handle_packages(section.get('packages', {}))


configurations.append(Configuration( configurations.append(Configuration(
name=f'{version}-packages',
kotlin_version=version,
name=f'{kotlin_version}-packages',
kotlin_version=kotlin_version,
gradle_version=gradle_version,
plugins={}, plugins={},
packages=packages packages=packages
)) ))
@@ -102,7 +107,8 @@ def parse_config(path: Path) -> Optional[Config]:
for plugin_version in plugin_versions: for plugin_version in plugin_versions:
configurations.append(Configuration( configurations.append(Configuration(
name=f'version-plugins-{plugin}', name=f'version-plugins-{plugin}',
kotlin_version=version,
kotlin_version=kotlin_version,
gradle_version=gradle_version,
plugins={plugin: plugin_version}, plugins={plugin: plugin_version},
packages=[] packages=[]
)) ))


+ 5
- 5
sync/src/main.py Datei anzeigen

@@ -10,19 +10,19 @@ from gradle import create_gradle_build, create_gradle_settings
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)




async def resolve_kotlin(ident: str, kotlin: Configuration, output_dir: Path, mirrors: list[str], gradle_repo: str):
async def resolve_kotlin(ident: str, configuration: Configuration, output_dir: Path, mirrors: list[str], gradle_repo: str):
resolved_packages = [ resolved_packages = [
resolved resolved
for package in kotlin.packages
for package in configuration.packages
for resolved in await get_effective_packages(package, mirrors) for resolved in await get_effective_packages(package, mirrors)
] ]


path = output_dir / f"{ident}-kotlin-{kotlin.kotlin_version}"
path.mkdir()
path = output_dir / f"{configuration.gradle_version}/{ident}-kotlin-{configuration.kotlin_version}"
path.mkdir(parents=True)
logger.debug(f'Creating {path}') logger.debug(f'Creating {path}')


logger.debug('Generating build.gradle.kts') logger.debug('Generating build.gradle.kts')
gradle_build = create_gradle_build(kotlin.kotlin_version, kotlin.plugins, resolved_packages, gradle_repo)
gradle_build = create_gradle_build(configuration.kotlin_version, configuration.plugins, resolved_packages, gradle_repo)
(path / 'build.gradle.kts').write_text(gradle_build) (path / 'build.gradle.kts').write_text(gradle_build)


logger.debug('Generating settings.gradle.kts') logger.debug('Generating settings.gradle.kts')


Laden…
Abbrechen
Speichern