Skip to content

Commit

Permalink
Solve ClassPathResourceLoader issue with jar
Browse files Browse the repository at this point in the history
Copying a few lines of code from `ClassPathUtils.processAsPath`
  • Loading branch information
ia3andy committed Jul 7, 2020
1 parent 21ac86e commit 67cf27a
Show file tree
Hide file tree
Showing 74 changed files with 1,017 additions and 471 deletions.
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
package bundled.buildtool.gradle.base

pluginManagement {
repositories {
mavenLocal()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: gradle
type: buildtool
spec:
base:
local-data:
data:
quarkus.plugin.id: io.quarkus
version.kotlin: 1.3.72
version.scala: 2.12.8
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
package bundled.buildtool.gradle.java

{#include build-layout}
{#plugins}
plugins {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
package bundled.buildtool.gradle.kotlin

{#include build-layout}
{#plugins}
plugins {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
package bundled.buildtool.gradle.scala

{#include build-layout}
{#plugins}
plugins {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
---
name: maven
type: buildtool
default: true
type-fallback: true
spec:
base:
local-data:
data:
version.kotlin: 1.3.72
version.scala: 2.12.8
version.scala-maven-plugin: 4.1.1
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
---
name: config-properties
type: config
default: true
type-fallback: true
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
---
name: config-yaml
type: config
type: config
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
---
name: java
type: language
default: true
type-fallback: true
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ ref: commandmode
example: true
spec:
base:
local-data:
data:
greeting.message: "hello"
greeting.default-name: "commando"
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
name: docker
preselected: true
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
name: quarkus
type: project
default: true
type-fallback: true
spec:
base:
shared-data:
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ ref: resteasy
example: true
spec:
base:
local-data:
data:
rest.path: "/hello"
rest.response: "hello"
test-dependencies:
Expand Down
111 changes: 111 additions & 0 deletions independent-projects/tools/codestarts/codestarts.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
= Quarkus - Codestarts

This guide explains how to create and configure a Quarkus Codestart for an extension.

== Description

"Codestarts" is the name we gave to our Quarkus quickstart code generation system. Codestarts are meant to provide a personalized Quarkus getting started experience and really show the Quarkus breadth.
Quarkus extension are able to provide one or more well defined codestarts which will contain all the necessary resources to bring user who pick that extension, everything he needs to get started with it.

== How it works

There are two kinds of codestarts contributing to generating a project,
the kind where we require to have only one for a project (called single) and the others (called other).

Singles:

* project: The base (ex: a Quarkus project)
* buildtool: The build tool (ex: Maven, Gradle, Gradle with Kotlin DSL)
* language: The coding language (ex: Java, Kotlin, Scala)
* config: The config type (ex: yaml, properties)
* [custom]: Any custom type that must be single

Others: Whats comes on top as addition (ex: dockerfiles, example code for extensions, ...)

Each codestart consists of:

. a specific directory
. a codestart.yml file
. optionally some templates which follow a structure and naming conventions

*NOTE* The codestart.yml file and the directory structure follow the same principle, it can optionally contain a base and/or some language overrides.

=== Example codestart:

Directory structure

* my-codestart/codestart.yml
* my-codestart/base/
* my-codestart/java/
* my-codestart/kotlin/

codestart.yml:
[source,yaml]
----
name: my-codestart
spec:
base:
...
java:
...
----

=== Project generation

When generating a Quarkus project:

. codestarts to use are resolved depending on the input
. codestarts shared data is processed to make it available for all codestarts
. The relevant files are processed:
** Only the files that are related to the selected language are processed
** The files are processed differently based on a naming convention.
** The data is used to render Qute templates
** We always process in this order: language, project, buildtool, config, custom, other.

The data used to generate a specific codestart is a merge of:

. The data of the codestart to generate
. All codestarts "shared" data
. The user input
. Some specific post processing (ex: adding dependencies)

*NOTE* The data (shared or not) can also be specific to a language.

=== Directory structure

*NOTE* `codestart.yml` is the only required file.

* codestart.yml must be at the root of the codestart
* `./base` contains all the files that will be processed
* `./[languageName]` contains all the files that will be processed if the specified language has been selected (overriding base)

=== codestart.yml

codestart.yml:
[source,yaml]
----
name: the unique name - REQUIRED
ref: the reference name (not unique) to use for extension matching (else the name is used)
type: the type [other (default), project, buildtool, language, config] or any custom type
type-fallback: flag to indicate that it should be selected as fallback when no codestart has been selected with type - SINGLE
preselected: flag to indicate that it should be pre-selected - OTHER.
example: flag to indicate that it is optional example code that can be disabled by the user - OTHER.
spec:
[base or language name]: the specification (base, java, ...)
data: a flat map of data to use only for this codestart
shared-data: a flat map of data to use accross all codestarts
dependencies: a list of dependencies to add when this is selected
test-dependencies: a list of test dependencies to add when this is selected
----

=== Files naming convention

* containing `.qute` will be processed with Qute
* containing `.include-qute` is used as a Qute template for inclusion.

Example: When using `{#include [name]}` in a template, it will look for `[name].include-qute` in the language dir, then in the base dir.

* containing `.append` will be appended together
* other files are just copied

*NOTE* there is also something specific for `pom.xml` but this should not be available out of internal codestarts.
61 changes: 61 additions & 0 deletions independent-projects/tools/codestarts/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-tools-parent</artifactId>
<version>999-SNAPSHOT</version>
</parent>

<artifactId>quarkus-devtools-codestarts</artifactId>
<name>Quarkus - Dev tools - Codestarts</name>

<dependencies>
<dependency>
<groupId>io.quarkus.qute</groupId>
<artifactId>qute-generator</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-bootstrap-app-model</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-platform-descriptor-api</artifactId>
</dependency>
<dependency>
<groupId>io.fabric8</groupId>
<artifactId>maven-model-helper</artifactId>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.dataformat</groupId>
<artifactId>jackson-dataformat-yaml</artifactId>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package io.quarkus.devtools.project.codegen.codestarts;
package io.quarkus.devtools.codestarts;

import static io.quarkus.devtools.project.codegen.codestarts.CodestartData.mergeMaps;
import static io.quarkus.devtools.codestarts.CodestartData.mergeMaps;

import java.util.Map;
import java.util.stream.Stream;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package io.quarkus.devtools.project.codegen.codestarts;
package io.quarkus.devtools.codestarts;

import java.util.HashMap;
import java.util.Map;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package io.quarkus.devtools.project.codegen.codestarts;
package io.quarkus.devtools.codestarts;

public class CodestartException extends RuntimeException {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
package io.quarkus.devtools.project.codegen.codestarts;
package io.quarkus.devtools.codestarts;

import io.quarkus.bootstrap.model.AppArtifactKey;
import io.quarkus.platform.descriptor.QuarkusPlatformDescriptor;
import java.util.Collection;
import java.util.Collections;
import java.util.Map;

public class CodestartInput {
Expand All @@ -11,14 +12,28 @@ public class CodestartInput {
private final boolean includeExample;
private final Map<String, Object> data;

public CodestartInput(QuarkusPlatformDescriptor descriptor, Collection<AppArtifactKey> extensions, boolean includeExample,
private CodestartInput(QuarkusPlatformDescriptor descriptor, Collection<AppArtifactKey> extensions, boolean includeExample,
Map<String, Object> data) {
this.descriptor = descriptor;
this.extensions = extensions;
this.includeExample = includeExample;
this.data = data;
}

private CodestartInput(QuarkusPlatformDescriptor descriptor) {
this(descriptor, Collections.emptyList(), false, Collections.emptyMap());
}

public static CodestartInput empty(QuarkusPlatformDescriptor descriptor) {
return new CodestartInput(descriptor);
}

public static CodestartInput of(QuarkusPlatformDescriptor descriptor, Collection<AppArtifactKey> extensions,
boolean includeExample,
Map<String, Object> data) {
return new CodestartInput(descriptor, extensions, includeExample, data);
}

public QuarkusPlatformDescriptor getDescriptor() {
return descriptor;
}
Expand Down
Loading

0 comments on commit 67cf27a

Please sign in to comment.