-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #55 from gradle/am/swift
Add `swiftLibrary` and `swiftApplication` software types
- Loading branch information
Showing
25 changed files
with
231 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
swiftLibrary { | ||
swiftVersion = 5 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
public class Utils { | ||
public let welcome = "Welcome to the swift-utils library!" | ||
|
||
public init() { | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
swiftApplication { | ||
swiftVersion = 5 | ||
|
||
dependencies { | ||
implementation(project(":swift-util")) | ||
} | ||
} |
5 changes: 5 additions & 0 deletions
5
unified-prototype/testbed-swift-application/src/main/swift/main.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import Foundation | ||
import SwiftUtil | ||
|
||
print("Hello from Swift") | ||
print(Utils().welcome) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
swiftLibrary { | ||
swiftVersion = 5 | ||
|
||
dependencies { | ||
implementation(project(":swift-util")) | ||
} | ||
} |
5 changes: 5 additions & 0 deletions
5
unified-prototype/testbed-swift-library/src/main/swift/lib.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import SwiftUtil | ||
|
||
class Lib { | ||
let utils = Utils() | ||
} |
20 changes: 20 additions & 0 deletions
20
...n-common/src/main/java/org/gradle/api/experimental/common/HasApplicationDependencies.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package org.gradle.api.experimental.common; | ||
|
||
import org.gradle.api.Action; | ||
import org.gradle.api.tasks.Nested; | ||
import org.gradle.declarative.dsl.model.annotations.Configuring; | ||
import org.gradle.declarative.dsl.model.annotations.Restricted; | ||
|
||
/** | ||
* Something that has application dependencies. | ||
*/ | ||
@Restricted | ||
public interface HasApplicationDependencies { | ||
@Nested | ||
ApplicationDependencies getDependencies(); | ||
|
||
@Configuring | ||
default void dependencies(Action<? super ApplicationDependencies> action) { | ||
action.execute(getDependencies()); | ||
} | ||
} |
7 changes: 3 additions & 4 deletions
7
...e/api/experimental/jvm/HasJvmLibrary.java → ...mental/common/HasLibraryDependencies.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
...unified-plugin/plugin-jvm/src/main/java/org/gradle/api/experimental/java/JavaLibrary.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,12 @@ | ||
package org.gradle.api.experimental.java; | ||
|
||
import org.gradle.api.experimental.jvm.HasJavaTarget; | ||
import org.gradle.api.experimental.jvm.HasJvmLibrary; | ||
import org.gradle.api.experimental.common.HasLibraryDependencies; | ||
import org.gradle.declarative.dsl.model.annotations.Restricted; | ||
|
||
/** | ||
* A library implemented using a single version of Java. | ||
*/ | ||
@Restricted | ||
public interface JavaLibrary extends HasJavaTarget, HasJvmLibrary { | ||
public interface JavaLibrary extends HasJavaTarget, HasLibraryDependencies { | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 2 additions & 1 deletion
3
...e/unified-plugin/plugin-jvm/src/main/java/org/gradle/api/experimental/jvm/JvmLibrary.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,11 @@ | ||
package org.gradle.api.experimental.jvm; | ||
|
||
import org.gradle.api.experimental.common.HasLibraryDependencies; | ||
import org.gradle.declarative.dsl.model.annotations.Restricted; | ||
|
||
/** | ||
* A library that runs on the JVM and that is implemented using one or more versions of Java. | ||
*/ | ||
@Restricted | ||
public interface JvmLibrary extends HasJavaTargets, HasJvmLibrary { | ||
public interface JvmLibrary extends HasJavaTargets, HasLibraryDependencies { | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
...-plugin/plugin-kmp/src/main/java/org/gradle/api/experimental/kotlin/KotlinJvmLibrary.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,12 @@ | ||
package org.gradle.api.experimental.kotlin; | ||
|
||
import org.gradle.api.experimental.jvm.HasJavaTarget; | ||
import org.gradle.api.experimental.jvm.HasJvmLibrary; | ||
import org.gradle.api.experimental.common.HasLibraryDependencies; | ||
import org.gradle.declarative.dsl.model.annotations.Restricted; | ||
|
||
/** | ||
* A library implemented using Kotlin and that targets a single JVM version. | ||
*/ | ||
@Restricted | ||
public interface KotlinJvmLibrary extends HasJavaTarget, HasJvmLibrary { | ||
public interface KotlinJvmLibrary extends HasJavaTarget, HasLibraryDependencies { | ||
} |
30 changes: 30 additions & 0 deletions
30
unified-prototype/unified-plugin/plugin-swift/build.gradle.kts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
plugins { | ||
`kotlin-dsl` | ||
id("build-logic.publishing") | ||
} | ||
|
||
description = "Implements the declarative Swift DSL prototype" | ||
|
||
dependencies { | ||
implementation(project(":plugin-common")) | ||
} | ||
|
||
gradlePlugin { | ||
plugins { | ||
create("swift-library") { | ||
id = "org.gradle.experimental.swift-library" | ||
implementationClass = "org.gradle.api.experimental.swift.StandaloneSwiftLibraryPlugin" | ||
tags = setOf("declarative-gradle") | ||
} | ||
create("swift-application") { | ||
id = "org.gradle.experimental.swift-application" | ||
implementationClass = "org.gradle.api.experimental.swift.StandaloneSwiftApplicationPlugin" | ||
tags = setOf("declarative-gradle") | ||
} | ||
create("swift-ecosystem") { | ||
id = "org.gradle.experimental.swift-ecosystem" | ||
implementationClass = "org.gradle.api.experimental.swift.SwiftEcosystemPlugin" | ||
tags = setOf("declarative-gradle") | ||
} | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
...d-plugin/plugin-swift/src/main/java/org/gradle/api/experimental/swift/HasSwiftTarget.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package org.gradle.api.experimental.swift; | ||
|
||
import org.gradle.api.provider.Property; | ||
import org.gradle.declarative.dsl.model.annotations.Restricted; | ||
|
||
@Restricted | ||
public interface HasSwiftTarget { | ||
@Restricted | ||
Property<Integer> getSwiftVersion(); | ||
} |
29 changes: 29 additions & 0 deletions
29
...ift/src/main/java/org/gradle/api/experimental/swift/StandaloneSwiftApplicationPlugin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package org.gradle.api.experimental.swift; | ||
|
||
import org.gradle.api.Plugin; | ||
import org.gradle.api.Project; | ||
import org.gradle.api.experimental.swift.internal.SwiftPluginSupport; | ||
import org.gradle.api.internal.plugins.software.SoftwareType; | ||
import org.gradle.language.swift.SwiftComponent; | ||
import org.gradle.language.swift.plugins.SwiftApplicationPlugin; | ||
|
||
public abstract class StandaloneSwiftApplicationPlugin implements Plugin<Project> { | ||
@SoftwareType(name = "swiftApplication", modelPublicType = SwiftApplication.class) | ||
abstract public SwiftApplication getApplication(); | ||
|
||
@Override | ||
public void apply(Project project) { | ||
SwiftApplication application = getApplication(); | ||
|
||
project.getPlugins().apply(SwiftApplicationPlugin.class); | ||
|
||
linkDslModelToPlugin(project, application); | ||
} | ||
|
||
private void linkDslModelToPlugin(Project project, SwiftApplication application) { | ||
SwiftComponent model = project.getExtensions().getByType(SwiftComponent.class); | ||
SwiftPluginSupport.linkSwiftVersion(application, model); | ||
|
||
model.getImplementationDependencies().getDependencies().addAllLater(application.getDependencies().getImplementation().getDependencies()); | ||
} | ||
} |
29 changes: 29 additions & 0 deletions
29
...n-swift/src/main/java/org/gradle/api/experimental/swift/StandaloneSwiftLibraryPlugin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package org.gradle.api.experimental.swift; | ||
|
||
import org.gradle.api.Plugin; | ||
import org.gradle.api.Project; | ||
import org.gradle.api.experimental.swift.internal.SwiftPluginSupport; | ||
import org.gradle.api.internal.plugins.software.SoftwareType; | ||
import org.gradle.language.swift.plugins.SwiftLibraryPlugin; | ||
|
||
public abstract class StandaloneSwiftLibraryPlugin implements Plugin<Project> { | ||
@SoftwareType(name = "swiftLibrary", modelPublicType = SwiftLibrary.class) | ||
abstract public SwiftLibrary getLibrary(); | ||
|
||
@Override | ||
public void apply(Project project) { | ||
SwiftLibrary library = getLibrary(); | ||
|
||
project.getPlugins().apply(SwiftLibraryPlugin.class); | ||
|
||
linkDslModelToPlugin(project, library); | ||
} | ||
|
||
private void linkDslModelToPlugin(Project project, SwiftLibrary library) { | ||
org.gradle.language.swift.SwiftLibrary model = project.getExtensions().getByType(org.gradle.language.swift.SwiftLibrary.class); | ||
SwiftPluginSupport.linkSwiftVersion(library, model); | ||
|
||
model.getImplementationDependencies().getDependencies().addAllLater(library.getDependencies().getImplementation().getDependencies()); | ||
model.getApiDependencies().getDependencies().addAllLater(library.getDependencies().getApi().getDependencies()); | ||
} | ||
} |
8 changes: 8 additions & 0 deletions
8
...plugin/plugin-swift/src/main/java/org/gradle/api/experimental/swift/SwiftApplication.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package org.gradle.api.experimental.swift; | ||
|
||
import org.gradle.api.experimental.common.HasApplicationDependencies; | ||
import org.gradle.declarative.dsl.model.annotations.Restricted; | ||
|
||
@Restricted | ||
public interface SwiftApplication extends HasSwiftTarget, HasApplicationDependencies { | ||
} |
14 changes: 14 additions & 0 deletions
14
...in/plugin-swift/src/main/java/org/gradle/api/experimental/swift/SwiftEcosystemPlugin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package org.gradle.api.experimental.swift; | ||
|
||
import org.gradle.api.Plugin; | ||
import org.gradle.api.initialization.Settings; | ||
import org.gradle.api.internal.plugins.software.RegistersSoftwareTypes; | ||
|
||
@RegistersSoftwareTypes({ | ||
StandaloneSwiftLibraryPlugin.class, | ||
StandaloneSwiftApplicationPlugin.class}) | ||
public class SwiftEcosystemPlugin implements Plugin<Settings> { | ||
@Override | ||
public void apply(Settings target) { | ||
} | ||
} |
Oops, something went wrong.