Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fetching dependencies declared in swift-java.config #191

Merged
merged 25 commits into from
Dec 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
d8a215c
implemented resolving
ktoso Nov 29, 2024
cb115ba
add a sample
ktoso Nov 29, 2024
3254f8b
work on sample such that we download and use the dependencies
ktoso Dec 2, 2024
1d4d25f
sample is now generating config from pulled dependency
ktoso Dec 3, 2024
cb9e729
importing all classes from a classpath
ktoso Dec 4, 2024
3005895
silence warnings
ktoso Dec 5, 2024
366a76c
ignore cloned repo in sample
ktoso Dec 5, 2024
6c3ab5c
Simplify how we run JavaSieve sample
ktoso Dec 5, 2024
d65fa59
validate JavaSieve in CI
ktoso Dec 5, 2024
c9d815c
wip
ktoso Dec 5, 2024
4d0b38f
first time JavaDependencySample showing a fetched dependency working!
ktoso Dec 5, 2024
e2391ed
fix shellcheck
ktoso Dec 6, 2024
0502ac1
fix JavaSieve ci-validate because it uses too old gradle
ktoso Dec 6, 2024
b3cfc74
fix license ignore with the symlink
ktoso Dec 6, 2024
7f47bcd
give up on JavaSieve checking in CI
ktoso Dec 6, 2024
9992890
avoid warnings adding not existing hardcoded paths to classpath
ktoso Dec 6, 2024
47915d2
use cached DependencyResolver classpath from file
ktoso Dec 6, 2024
8c23a23
writing swift-java.classpath per module now
ktoso Dec 6, 2024
561efe2
Fetch and wrap dependencies as build plugin now works!
ktoso Dec 9, 2024
69212ce
validate samples with independent runs
ktoso Dec 9, 2024
aa4e11f
cleanup JavaKit's DependencyResolver
ktoso Dec 9, 2024
c54fef9
validate in CI with before building JavaKit's dependency resovler
ktoso Dec 9, 2024
0e8e5a6
Make bootstrapping from NOTHING possible by having JavaKit include gr…
ktoso Dec 9, 2024
08fc774
fix CI warnings on license and shellcheck
ktoso Dec 9, 2024
4aae988
fix license formatting
ktoso Dec 9, 2024
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
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
Loading