Skip to content

Commit 79882d8

Browse files
authored
Fetching dependencies declared in swift-java.config (#191)
1 parent f63150a commit 79882d8

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+1872
-471
lines changed

.github/scripts/validate_sample.sh

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#!/bin/bash
2+
3+
# shellcheck disable=SC2034
4+
declare -r GREEN='\033[0;32m'
5+
declare -r BOLD='\033[1m'
6+
declare -r RESET='\033[0m'
7+
8+
declare -r sampleDir="$1"
9+
declare -r CI_VALIDATE_SCRIPT='ci-validate.sh'
10+
11+
echo ""
12+
echo ""
13+
echo "========================================================================"
14+
printf "Validate sample '${BOLD}%s${RESET}' using: " "$sampleDir"
15+
cd "$sampleDir" || exit
16+
if [[ $(find . -name ${CI_VALIDATE_SCRIPT} -maxdepth 1) ]]; then
17+
echo -e "Custom ${BOLD}${CI_VALIDATE_SCRIPT}${RESET} script..."
18+
./${CI_VALIDATE_SCRIPT} || exit
19+
elif [[ $(find . -name 'build.gradle*' -maxdepth 1) ]]; then
20+
echo -e "${BOLD}Gradle${RESET} build..."
21+
./gradlew build || ./gradlew build --info # re-run to get better failure output
22+
else
23+
echo -e "${BOLD}SwiftPM${RESET} build..."
24+
swift build || exit
25+
fi
26+
27+
echo -e "Validated sample '${BOLD}${sampleDir}${RESET}': ${BOLD}passed${RESET}."
28+
cd - || exit
29+
30+
echo
31+
printf "Done validating sample: %s" "${sampleDir}"
32+
echo -e "${GREEN}done${RESET}."

.github/scripts/validate_samples.sh

Lines changed: 0 additions & 37 deletions
This file was deleted.

.github/workflows/pull_request.yml

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,18 @@ jobs:
8282
- uses: actions/checkout@v4
8383
- name: Prepare CI Environment
8484
uses: ./.github/actions/prepare_env
85-
- name: Verify Samples (All)
86-
run: .github/scripts/validate_samples.sh
85+
- name: "Verify Sample: JavaDependencySampleApp"
86+
run: .github/scripts/validate_sample.sh Samples/JavaDependencySampleApp
87+
- name: "Verify Sample: JavaKitSampleApp"
88+
run: .github/scripts/validate_sample.sh Samples/JavaKitSampleApp
89+
- name: "Verify Sample: JavaProbablyPrime"
90+
run: .github/scripts/validate_sample.sh Samples/JavaProbablyPrime
91+
- name: "Verify Sample: JavaSieve"
92+
run: .github/scripts/validate_sample.sh Samples/JavaSieve
93+
- name: "Verify Sample: SwiftAndJavaJarSampleLib"
94+
run: .github/scripts/validate_sample.sh Samples/SwiftAndJavaJarSampleLib
95+
- name: "Verify Sample: SwiftKitSampleApp"
96+
run: .github/scripts/validate_sample.sh Samples/SwiftKitSampleApp
8797
# TODO: Benchmark compile crashes in CI, enable when nightly toolchains in better shape.
8898
# - name: Build (Swift) Benchmarks
8999
# run: "swift package --package-path Benchmarks/ benchmark list"

.licenseignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,4 +42,5 @@ gradlew.bat
4242
**/ci-validate.sh
4343
**/DO_NOT_EDIT.txt
4444
Plugins/**/_PluginsShared
45-
Plugins/**/0_PLEASE_SYMLINK*
45+
Plugins/**/0_PLEASE_SYMLINK*
46+
Plugins/PluginsShared/JavaKitConfigurationShared

JavaKit/build.gradle

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
//===----------------------------------------------------------------------===//
2+
//
3+
// This source file is part of the Swift.org open source project
4+
//
5+
// Copyright (c) 2024 Apple Inc. and the Swift.org project authors
6+
// Licensed under Apache License v2.0
7+
//
8+
// See LICENSE.txt for license information
9+
// See CONTRIBUTORS.txt for the list of Swift.org project authors
10+
//
11+
// SPDX-License-Identifier: Apache-2.0
12+
//
13+
//===----------------------------------------------------------------------===//
14+
15+
plugins {
16+
id("build-logic.java-library-conventions")
17+
}
18+
19+
group = "org.swift.javakit"
20+
version = "1.0-SNAPSHOT"
21+
22+
repositories {
23+
mavenCentral()
24+
}
25+
26+
java {
27+
toolchain {
28+
languageVersion.set(JavaLanguageVersion.of(22))
29+
}
30+
}
31+
32+
dependencies {
33+
implementation("dev.gradleplugins:gradle-api:8.10.1")
34+
35+
testImplementation(platform("org.junit:junit-bom:5.10.0"))
36+
testImplementation("org.junit.jupiter:junit-jupiter")
37+
}
38+
39+
tasks.test {
40+
useJUnitPlatform()
41+
testLogging {
42+
events("passed", "skipped", "failed")
43+
}
44+
}
45+
46+
// Copy the gradle wrapper we're using into the resulting jar's resources.
47+
// We'll use it to bootstrap dependencies (and gradle!) if there is none yet.
48+
tasks.processResources {
49+
from('gradlew') {
50+
into 'gradle/'
51+
}
52+
from('gradlew.bat') {
53+
into 'gradle/'
54+
}
55+
from('../gradle/wrapper/gradle-wrapper.jar') {
56+
into 'gradle/wrapper/'
57+
}
58+
from('../gradle/wrapper/gradle-wrapper.properties') {
59+
into 'gradle/wrapper/'
60+
}
61+
}
62+
63+
//task fatJar(type: Jar) {
64+
// archiveBaseName = 'java-kit-fat-jar'
65+
// duplicatesStrategy = DuplicatesStrategy.EXCLUDE
66+
// from { configurations.runtimeClasspath.collect { it.isDirectory() ? it : zipTree(it) } }
67+
// with jar
68+
//}
69+
70+
// Task necessary to bootstrap
71+
task printRuntimeClasspath {
72+
def runtimeClasspath = sourceSets.main.runtimeClasspath
73+
inputs.files(runtimeClasspath)
74+
doLast {
75+
println("CLASSPATH:${runtimeClasspath.asPath}")
76+
}
77+
}

JavaKit/gradlew

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../gradlew

JavaKit/gradlew.bat

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../gradlew.bat
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
//===----------------------------------------------------------------------===//
2+
//
3+
// This source file is part of the Swift.org open source project
4+
//
5+
// Copyright (c) 2024 Apple Inc. and the Swift.org project authors
6+
// Licensed under Apache License v2.0
7+
//
8+
// See LICENSE.txt for license information
9+
// See CONTRIBUTORS.txt for the list of Swift.org project authors
10+
//
11+
// SPDX-License-Identifier: Apache-2.0
12+
//
13+
//===----------------------------------------------------------------------===//
14+
15+
package org.swift.javakit.annotations;
16+
17+
import java.lang.annotation.Retention;
18+
import java.lang.annotation.RetentionPolicy;
19+
20+
/**
21+
* Since some public methods may not appear as used in Java source code, but are used by Swift,
22+
* we can use this source annotation to mark such entry points to not accidentally remove them with
23+
* "safe delete" refactorings in Java IDEs which would be unaware of the usages from Swift.
24+
*/
25+
@SuppressWarnings("unused") // used from Swift
26+
@Retention(RetentionPolicy.SOURCE)
27+
public @interface UsedFromSwift {
28+
}

0 commit comments

Comments
 (0)