| @@ -20,13 +20,16 @@ maven: | |||
| mirrors: | |||
| - "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: | |||
| # 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" | |||
| gradle-version: "7.0" | |||
| - 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. | |||
| # Plugin versions can be a single version as a string, or a list of strings to fetch multiple versions. | |||
| plugins: | |||
| @@ -8,22 +8,29 @@ maven: | |||
| - "https://plugins.gradle.org/m2" | |||
| 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" | |||
| gradle-version: "7.6.2" | |||
| plugins: | |||
| com.expediagroup.graphql: ["7.0.0-alpha.5", "6.5.2"] | |||
| - kotlin-version: "1.8.0" | |||
| gradle-version: "8.2.1" | |||
| - kotlin-version: "1.8.0" | |||
| gradle-version: "7.0" | |||
| - kotlin-version: "1.7.20" | |||
| gradle-version: "8.2.1" | |||
| packages: | |||
| 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. | |||
| # | |||
| # Most packages should be placed here. | |||
| - kotlin-version: "1.8.20" | |||
| gradle-version: "8.2.1" | |||
| plugins: | |||
| org.panteleyev.jpackageplugin: "1.5.2" | |||
| packages: | |||
| @@ -24,33 +24,55 @@ wait_for_reposilite () | |||
| # Main scipt | |||
| echo "Check that reposilite is running" | |||
| wait_for_reposilite | |||
| if [[ ! -f /package-list.yaml ]]; then | |||
| echo "No /package-list.yaml file. Aborting" | |||
| exit 255 | |||
| fi | |||
| 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" | |||
| mkdir -p /gradle | |||
| python3 --version | |||
| if ! python3 src/main.py --repo="repo:80" --output-dir "$PROJECTS_DIR" /package-list.yaml; then | |||
| echo "Gradle generation failed" | |||
| exit 255 | |||
| fi | |||
| echo "Check that reposilite is running" | |||
| wait_for_reposilite | |||
| 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 | |||
| else | |||
| echo "Can't connect to repository" | |||
| @@ -12,6 +12,7 @@ logger = logging.getLogger(__name__) | |||
| class Configuration: | |||
| name: str | |||
| kotlin_version: str | |||
| gradle_version: str | |||
| plugins: dict[str, str] | |||
| packages: list[str] | |||
| @@ -85,15 +86,19 @@ def parse_config(path: Path) -> Optional[Config]: | |||
| configurations: list[Configuration] = [] | |||
| 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'") | |||
| if (gradle_version := section.get('gradle-version')) is None: | |||
| error.append(f"Configuration {i} is missing 'gradle-version'") | |||
| plugins = handle_plugins(section.get('plugins', {})) | |||
| packages = handle_packages(section.get('packages', {})) | |||
| configurations.append(Configuration( | |||
| name=f'{version}-packages', | |||
| kotlin_version=version, | |||
| name=f'{kotlin_version}-packages', | |||
| kotlin_version=kotlin_version, | |||
| gradle_version=gradle_version, | |||
| plugins={}, | |||
| packages=packages | |||
| )) | |||
| @@ -102,7 +107,8 @@ def parse_config(path: Path) -> Optional[Config]: | |||
| for plugin_version in plugin_versions: | |||
| configurations.append(Configuration( | |||
| name=f'version-plugins-{plugin}', | |||
| kotlin_version=version, | |||
| kotlin_version=kotlin_version, | |||
| gradle_version=gradle_version, | |||
| plugins={plugin: plugin_version}, | |||
| packages=[] | |||
| )) | |||
| @@ -10,19 +10,19 @@ from gradle import create_gradle_build, create_gradle_settings | |||
| 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 | |||
| for package in kotlin.packages | |||
| for package in configuration.packages | |||
| 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('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) | |||
| logger.debug('Generating settings.gradle.kts') | |||