Search in sources :

Example 1 with ContentProvider

use of io.quarkus.bootstrap.resolver.TsArtifact.ContentProvider in project quarkus by quarkusio.

the class PackageAppTestBase method platformDescriptor.

protected TsDependency platformDescriptor() {
    if (platformDescriptor == null) {
        TsArtifact platformDescr = new TsArtifact("org.acme", "acme" + BootstrapConstants.PLATFORM_DESCRIPTOR_ARTIFACT_ID_SUFFIX, "1.0", "json", "1.0");
        platformDescr.setContent(new ContentProvider() {

            Path platformJson;

            @Override
            public Path getPath(Path workDir) throws IOException {
                if (platformJson == null) {
                    platformJson = workDir.resolve("platform-descriptor.json");
                    try (BufferedWriter writer = Files.newBufferedWriter(platformJson)) {
                        writer.write("platform descriptor");
                    }
                }
                return platformJson;
            }
        });
        platformDescr.install(repo);
        platformDescriptor = new TsDependency(platformDescr);
    }
    return platformDescriptor;
}
Also used : Path(java.nio.file.Path) TsArtifact(io.quarkus.bootstrap.resolver.TsArtifact) ContentProvider(io.quarkus.bootstrap.resolver.TsArtifact.ContentProvider) IOException(java.io.IOException) TsDependency(io.quarkus.bootstrap.resolver.TsDependency) BufferedWriter(java.io.BufferedWriter)

Example 2 with ContentProvider

use of io.quarkus.bootstrap.resolver.TsArtifact.ContentProvider in project quarkus by quarkusio.

the class PackageAppTestBase method platformProperties.

protected TsDependency platformProperties() {
    if (platformPropsDep == null) {
        TsArtifact platformProps = new TsArtifact("org.acme", "acme" + BootstrapConstants.PLATFORM_PROPERTIES_ARTIFACT_ID_SUFFIX, null, "properties", "1.0");
        platformProps.setContent(new ContentProvider() {

            Path propsFile;

            @Override
            public Path getPath(Path workDir) throws IOException {
                if (propsFile == null) {
                    Properties props = new Properties();
                    props.setProperty("platform.quarkus.native.builder-image", "builder-image-url");
                    propsFile = workDir.resolve("platform-properties.properties");
                    try (OutputStream os = Files.newOutputStream(propsFile)) {
                        props.store(os, "Test Quarkus platform properties");
                    }
                }
                return propsFile;
            }
        });
        platformProps.install(repo);
        platformPropsDep = new TsDependency(platformProps);
    }
    return platformPropsDep;
}
Also used : Path(java.nio.file.Path) TsArtifact(io.quarkus.bootstrap.resolver.TsArtifact) ContentProvider(io.quarkus.bootstrap.resolver.TsArtifact.ContentProvider) OutputStream(java.io.OutputStream) IOException(java.io.IOException) Properties(java.util.Properties) TsDependency(io.quarkus.bootstrap.resolver.TsDependency)

Aggregations

TsArtifact (io.quarkus.bootstrap.resolver.TsArtifact)2 ContentProvider (io.quarkus.bootstrap.resolver.TsArtifact.ContentProvider)2 TsDependency (io.quarkus.bootstrap.resolver.TsDependency)2 IOException (java.io.IOException)2 Path (java.nio.file.Path)2 BufferedWriter (java.io.BufferedWriter)1 OutputStream (java.io.OutputStream)1 Properties (java.util.Properties)1