# Frequently asked questions about writing extensions

## Should you write an extension?

### Why would I want to write an extension?

See the [extension philosophy](/guides/writing-extensions/index.md#extension-philosophy). The [extension maturity matrix](/guides/extension-maturity-matrix/index.md) shows the kinds of capabilities extensions can offer. Another useful thing extensions can do is bundle other extensions. Have a look at the [Quarkus MicroProfile extension](https://quarkus.io/extensions/io.quarkiverse.microprofile/quarkus-microprofile/) for an example of aggregator extensions.

### Are there cases an extension isn't necessary?

Not every problem needs an extension! If you're just bundling up external libraries (that aren't already extensions) and making minor adjustments, you might not need an extension. For example, plain libraries can create new configuration elements and register classes with Jandex (this [blog shows how](https://www.loicmathieu.fr/wordpress/en/informatique/quarkus-tip-comment-ne-pas-creer-une-extension-quarkus/)).

## How do I know what kind of capabilities I might want to include in an extension?

Have a look at the [extension maturity matrix](/guides/extension-maturity-matrix/index.md).

## Bytecode transformation

### How can I change the code of things on the classpath?

A `BytecodeTransformerBuildItem` can be used to manipulate bytecode. For example, see this [blog about removed problematic bridge methods from a dependency](https://quarkus.io/blog/solving-problems-with-extensions/).

## CDI

### I'm working with CDI, and I don't know how to ...

The [CDI integration guide](/guides/cdi-integration/index.md) presents solutions to a number of CDI-related use cases for extension authors.

### I have transformed a user class to add an injected field, but CDI isn't working

What happens if an extension transforms a user class using `BytecodeTransformerBuildItem`, and replaces `@jakarta.annotation.Resource` with `@jakarta.inject.Inject`? The field will not be injected by Arc. Debugging will show the transformed class being loaded in the app, but it looks like Arc doesn't see the new code.

Arc-related transformations should generally be done with [AnnotationsTransformerBuildItem](https://github.com/quarkusio/quarkus/blob/main/extensions/arc/deployment/src/main/java/io/quarkus/arc/deployment/AnnotationsTransformerBuildItem.java). The reason is that *all* Quarkus's bytecode transformations are done after Jandex indexing. This means changes are never reflected back in Jandex.

Most extensions use Jandex as a source of truth to find out what to do. Those extensions won't see new/modified endpoints in the bytecode itself. The solution to this limitation is annotation transformers. You should also be aware that while Arc and Quarkus REST honour annotation transformers, not all extensions do.

### Something in my classpath has @Inject annotations, which are confusing CDI. How can I fix that?

You will need to implement an `AnnotationsTransformer` and strip out out the problematic injection sites. (Remember, if the use case involves CDI, it needs to be an `AnnotationsTransformer`, not a BytecodeTransformer`.) See link:https://quarkus.io/blog/solving-problems-with-extensions-2/[this blog] about on using an `AnnotationsTransformer` extension to clean non `@Inject\` annotations from the Airline library so that it can be used in CDI-enabled runtimes.

## Cross-cutting concerns

### How can I redirect application logging to an external service?

A `LogHandlerBuildItem` is a convenient way to redirect application logs. See this [worked example of an extension which directs output to AWS CloudWatch](https://quarkus.io/blog/quarkus-aws-cloudwatch_extension/).

### How can I ensure a build step always runs even if it doesn't produce anything consumed by another build step?

There are cases where an extension needs some of its build steps to run regardless of whether another part of the build process consumes any of its output (if such output even exists). One could argue that maybe such functionality shouldn't be put in a separate build step, but rather be part of another. However, it might make sense to run independent processing in separate build steps so that they can execute concurrently of other build tasks.

In that situation, you can annotate your build step with `@Produce(ServiceStartBuildItem.class)` to make your build step produce an automatically generated `ServiceStartBuildItem` which is consumed by an internal Quarkus build step thus ensuring that your build step is always "consumed" and therefore is included in the build process. Another option could also be to annotation your build step with `@Produce(ArtifactResultBuildItem.class)`, however, this item is not consumed by Quarkus in Dev mode so your build step won't take effect in that case.

## Build and hosting infrastructure for extensions

### Can I use Gradle to build my extension?

Yes, but it's not the most typical pattern. See the [Building Your First Extension Guide](/guides/building-my-first-extension/index.md#gradle-setup) for instructions on setting up a Gradle extension. Have a look at the [JobRunr extension](https://quarkus.io/extensions/org.jobrunr/quarkus-jobrunr/) for an example implementation.

### If I want my extension to be in code.quarkus.io, does it have to be in the Quarkiverse GitHub org?

Registering an extension in the catalog is independent from where the source code is. The [quarkiverse repository](https://hub.quarkiverse.io) has some shortcuts to make releasing and testing extensions easier, but any extension can [register into the catalog](https://hub.quarkiverse.io/checklistfornewprojects/#make-your-extension-available-in-the-tooling).

### My extension isn't showing up on extensions.quarkus.io

Every extension in the [extension catalog](https://github.com/quarkusio/quarkus-extension-catalog/tree/main/extensions) should appear in <http://code.quarkus.io>, <http://extensions.quarkus.io>, and the command line tools. The web pages at <http://extensions.quarkus.io> are refreshed a few times a delay, so there may be a delay in new extensions showing up there. To debug a missing extension, first:

- Check your extension is present in [Maven Central](https://central.sonatype.com/)
- Check the extension is included the [extensions catalog list](https://github.com/quarkusio/quarkus-extension-catalog/tree/main/extensions) (it only needs to be included once, and future versions will be automatically detected)
- Check if the extension is listed in the [Quarkus registry](https://registry.quarkus.io/q/swagger-ui/#/Client/get_client_extensions_all) list of all known extensions
- Check if there has been a green [build of the extensions site](https://github.com/quarkusio/extensions/actions/workflows/build_and_publish.yml) since updating the catalog

## Other topics

### What's the difference between a quickstart and a codestart?

Both codestarts and quickstarts are designed to help users get coding quickly. A codestarts is a generated application and a quickstart is browsable source code. Codestarts allow the creation of customised apps, which makes them quite powerful.
