Skip to content

Commit

Permalink
Fetching dependencies declared in swift-java.config (#191)
Browse files Browse the repository at this point in the history
  • Loading branch information
ktoso authored Dec 10, 2024
1 parent f63150a commit 79882d8
Show file tree
Hide file tree
Showing 45 changed files with 1,872 additions and 471 deletions.
32 changes: 32 additions & 0 deletions .github/scripts/validate_sample.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/bin/bash

# shellcheck disable=SC2034
declare -r GREEN='\033[0;32m'
declare -r BOLD='\033[1m'
declare -r RESET='\033[0m'

declare -r sampleDir="$1"
declare -r CI_VALIDATE_SCRIPT='ci-validate.sh'

echo ""
echo ""
echo "========================================================================"
printf "Validate sample '${BOLD}%s${RESET}' using: " "$sampleDir"
cd "$sampleDir" || exit
if [[ $(find . -name ${CI_VALIDATE_SCRIPT} -maxdepth 1) ]]; then
echo -e "Custom ${BOLD}${CI_VALIDATE_SCRIPT}${RESET} script..."
./${CI_VALIDATE_SCRIPT} || exit
elif [[ $(find . -name 'build.gradle*' -maxdepth 1) ]]; then
echo -e "${BOLD}Gradle${RESET} build..."
./gradlew build || ./gradlew build --info # re-run to get better failure output
else
echo -e "${BOLD}SwiftPM${RESET} build..."
swift build || exit
fi

echo -e "Validated sample '${BOLD}${sampleDir}${RESET}': ${BOLD}passed${RESET}."
cd - || exit

echo
printf "Done validating sample: %s" "${sampleDir}"
echo -e "${GREEN}done${RESET}."
37 changes: 0 additions & 37 deletions .github/scripts/validate_samples.sh

This file was deleted.

14 changes: 12 additions & 2 deletions .github/workflows/pull_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,18 @@ jobs:
- uses: actions/checkout@v4
- name: Prepare CI Environment
uses: ./.github/actions/prepare_env
- name: Verify Samples (All)
run: .github/scripts/validate_samples.sh
- name: "Verify Sample: JavaDependencySampleApp"
run: .github/scripts/validate_sample.sh Samples/JavaDependencySampleApp
- name: "Verify Sample: JavaKitSampleApp"
run: .github/scripts/validate_sample.sh Samples/JavaKitSampleApp
- name: "Verify Sample: JavaProbablyPrime"
run: .github/scripts/validate_sample.sh Samples/JavaProbablyPrime
- name: "Verify Sample: JavaSieve"
run: .github/scripts/validate_sample.sh Samples/JavaSieve
- name: "Verify Sample: SwiftAndJavaJarSampleLib"
run: .github/scripts/validate_sample.sh Samples/SwiftAndJavaJarSampleLib
- name: "Verify Sample: SwiftKitSampleApp"
run: .github/scripts/validate_sample.sh Samples/SwiftKitSampleApp
# TODO: Benchmark compile crashes in CI, enable when nightly toolchains in better shape.
# - name: Build (Swift) Benchmarks
# run: "swift package --package-path Benchmarks/ benchmark list"
3 changes: 2 additions & 1 deletion .licenseignore
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,5 @@ gradlew.bat
**/ci-validate.sh
**/DO_NOT_EDIT.txt
Plugins/**/_PluginsShared
Plugins/**/0_PLEASE_SYMLINK*
Plugins/**/0_PLEASE_SYMLINK*
Plugins/PluginsShared/JavaKitConfigurationShared
77 changes: 77 additions & 0 deletions JavaKit/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
//===----------------------------------------------------------------------===//
//
// This source file is part of the Swift.org open source project
//
// Copyright (c) 2024 Apple Inc. and the Swift.org project authors
// Licensed under Apache License v2.0
//
// See LICENSE.txt for license information
// See CONTRIBUTORS.txt for the list of Swift.org project authors
//
// SPDX-License-Identifier: Apache-2.0
//
//===----------------------------------------------------------------------===//

plugins {
id("build-logic.java-library-conventions")
}

group = "org.swift.javakit"
version = "1.0-SNAPSHOT"

repositories {
mavenCentral()
}

java {
toolchain {
languageVersion.set(JavaLanguageVersion.of(22))
}
}

dependencies {
implementation("dev.gradleplugins:gradle-api:8.10.1")

testImplementation(platform("org.junit:junit-bom:5.10.0"))
testImplementation("org.junit.jupiter:junit-jupiter")
}

tasks.test {
useJUnitPlatform()
testLogging {
events("passed", "skipped", "failed")
}
}

// Copy the gradle wrapper we're using into the resulting jar's resources.
// We'll use it to bootstrap dependencies (and gradle!) if there is none yet.
tasks.processResources {
from('gradlew') {
into 'gradle/'
}
from('gradlew.bat') {
into 'gradle/'
}
from('../gradle/wrapper/gradle-wrapper.jar') {
into 'gradle/wrapper/'
}
from('../gradle/wrapper/gradle-wrapper.properties') {
into 'gradle/wrapper/'
}
}

//task fatJar(type: Jar) {
// archiveBaseName = 'java-kit-fat-jar'
// duplicatesStrategy = DuplicatesStrategy.EXCLUDE
// from { configurations.runtimeClasspath.collect { it.isDirectory() ? it : zipTree(it) } }
// with jar
//}

// Task necessary to bootstrap
task printRuntimeClasspath {
def runtimeClasspath = sourceSets.main.runtimeClasspath
inputs.files(runtimeClasspath)
doLast {
println("CLASSPATH:${runtimeClasspath.asPath}")
}
}
1 change: 1 addition & 0 deletions JavaKit/gradlew
1 change: 1 addition & 0 deletions JavaKit/gradlew.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
//===----------------------------------------------------------------------===//
//
// This source file is part of the Swift.org open source project
//
// Copyright (c) 2024 Apple Inc. and the Swift.org project authors
// Licensed under Apache License v2.0
//
// See LICENSE.txt for license information
// See CONTRIBUTORS.txt for the list of Swift.org project authors
//
// SPDX-License-Identifier: Apache-2.0
//
//===----------------------------------------------------------------------===//

package org.swift.javakit.annotations;

import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;

/**
* Since some public methods may not appear as used in Java source code, but are used by Swift,
* we can use this source annotation to mark such entry points to not accidentally remove them with
* "safe delete" refactorings in Java IDEs which would be unaware of the usages from Swift.
*/
@SuppressWarnings("unused") // used from Swift
@Retention(RetentionPolicy.SOURCE)
public @interface UsedFromSwift {
}
Loading

0 comments on commit 79882d8

Please sign in to comment.