-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Build native executable artifacts (#87)
* build and publish native artifacts #6 * update tests to use native artifact * bugfix for plugin working directory resolution * update build to resolve plugin config relatively * bump project version
- Loading branch information
1 parent
b978f5f
commit 7fef300
Showing
11 changed files
with
163 additions
and
60 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,81 @@ | ||
// The following dependency needs to exist on the 'buildscript' classpath | ||
// 'com.google.guava:guava:27.0.1-jre' | ||
// It is currently added via the buildSrc project | ||
import com.google.common.io.ByteStreams | ||
|
||
// Native artifact generation based off of | ||
// https:/salesforce/grpc-java-contrib/tree/master/canteen | ||
|
||
def platforms = ["osx-x86_64", "linux-x86_64", "windows-x86_64"] | ||
|
||
Task bootJarTask = tasks.getByName("bootJar") | ||
File bootJarFile = bootJarTask.archiveFile.get().asFile | ||
|
||
platforms.each { platform -> | ||
|
||
// Resolve the canteen bootstrap artifact | ||
Configuration config = project.configurations.create("canteenBootstrapLocator_$platform") { | ||
visible = false | ||
transitive = false | ||
extendsFrom = [] | ||
} | ||
Map<String, String> notation = [ | ||
group: "com.salesforce.servicelibs", | ||
name: "canteen-bootstrap", | ||
version: "1.0.0", | ||
classifier: platform, | ||
ext: "exe", | ||
] | ||
Dependency dep = project.dependencies.add(config.name, notation) | ||
File bootstrapFile = config.fileCollection(dep).singleFile | ||
File destinationArtifactFile = new File(bootJarTask.destinationDirectory.get().asFile, | ||
bootJarFile.name.replace("jvm8.jar", platform + ".exe")) | ||
|
||
// Create task to copy the original jar and embed the | ||
// canteen bootstrap executable for the target platform | ||
Task canteenTask = task("canteenArtifact_$platform"){ | ||
group = "canteen" | ||
dependsOn("bootJar") | ||
// Add files for UP-TO-DATE checks | ||
inputs.files(bootJarFile) | ||
outputs.files(destinationArtifactFile) | ||
doLast { | ||
// Build the bootstrap file | ||
OutputStream targetStream = new FileOutputStream(destinationArtifactFile) | ||
InputStream bootstrapStream = new FileInputStream(bootstrapFile) | ||
ByteStreams.copy(bootstrapStream, targetStream); | ||
InputStream sourceStream = new FileInputStream(bootJarFile) | ||
ByteStreams.copy(sourceStream, targetStream); | ||
targetStream.flush() | ||
targetStream.close() | ||
sourceStream.close() | ||
bootstrapStream.close() | ||
destinationArtifactFile.setExecutable(true); | ||
} | ||
} | ||
|
||
artifacts { | ||
archives(destinationArtifactFile) { | ||
builtBy canteenTask | ||
classifier platform | ||
} | ||
} | ||
|
||
publishing { | ||
publications { | ||
mavenPublication(MavenPublication) { | ||
artifact(destinationArtifactFile.absolutePath) { | ||
builtBy canteenTask | ||
classifier platform | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
task buildCanteenArtifacts{ | ||
group = "canteen" | ||
platforms.each { platform -> | ||
dependsOn("canteenArtifact_$platform") | ||
} | ||
} |
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
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 |
---|---|---|
|
@@ -31,6 +31,8 @@ bootJar { | |
} | ||
} | ||
|
||
apply from: "${rootProject.projectDir}/canteen.gradle" | ||
|
||
jar.enabled = true | ||
|
||
artifacts { | ||
|
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 |
---|---|---|
|
@@ -83,6 +83,8 @@ bootJar { | |
} | ||
} | ||
|
||
apply from: "${rootProject.projectDir}/canteen.gradle" | ||
|
||
jar.enabled = true | ||
|
||
artifacts { | ||
|
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