Skip to content

Commit

Permalink
Document example for MultiPlatformGenerator
Browse files Browse the repository at this point in the history
  • Loading branch information
samrocketman committed Jul 29, 2023
1 parent 5abe2fc commit f668a52
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 1 deletion.
4 changes: 3 additions & 1 deletion resources/platforms.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ defaults:
stability: stable
sudo: sudo
supported_platforms:
default:
default: &default-platform
alpine3:
friendlyName: Alpine 3.x
language:
Expand All @@ -25,5 +25,7 @@ supported_platforms:
- env
- jdk
- python
amd64: *default-platform
arm64: *default-platform
restrictions: {
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,48 @@ package net.gleske.jervis.lang
import net.gleske.jervis.exceptions.MultiPlatformJervisYamlException
import net.gleske.jervis.tools.YamlOperator


/**
Creates a multi-platform generator similar to a LifecycleGenerator but
multi-plaform and multi-os capable when building matrix combinations.
<h2>Sample usage</h2>
<p>To run this example, clone Jervis and execute <tt>./gradlew console</tt>
to bring up a <a href="http://groovy-lang.org/groovyconsole.html" target="_blank">Groovy Console</a>
with the classpath set up.</p>
<pre><code class="language-groovy">
import net.gleske.jervis.lang.MultiPlatformGenerator
import net.gleske.jervis.lang.MultiPlatformValidator
MultiPlatformValidator platforms = new MultiPlatformValidator()
platforms.loadPlatformsString(new File('resources/platforms.yaml').text)
platforms.getToolchainFiles().each { String fileName -&gt;
if(!new File("resources/${fileName}.yaml").exists()) { return }
platforms.loadToolchainsString(fileName, new File("resources/${fileName}.yaml").text)
}
platforms.getLifecycleFiles().each { String fileName -&gt;
if(!new File("resources/${fileName}.yaml").exists()) { return }
platforms.loadLifecyclesString(fileName, new File("resources/${fileName}.yaml").text)
}
platforms.getGeneratorFromJervis(yaml: 'language: shell')
MultiPlatformGenerator platformGenerator = new MultiPlatformGenerator(platforms)
platformGenerator.loadMultiPlatformYaml(yaml: '''
language: shell
jenkins:
platform:
- amd64
- arm64
os:
- alpine3
- ubuntu2204
''')
platformGenerator.generateToolchainSection()
</code></pre>
*/
class MultiPlatformGenerator implements Serializable {
final MultiPlatformValidator platforms_obj
Map rawJervisYaml
Expand Down

0 comments on commit f668a52

Please sign in to comment.