<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/configuring-maven-for-compiled-and-tested-code-in-javadoc-ospvbui5t" -->

---
title: Configuring Maven For Compiled And Tested Code In Javadoc
description: JDK 18 introduces the @snippet Javadoc tag (JEP 413) that embeds external source files into API documentation. To ensure those snippet files are compiled and...
canonical: https://daily.dev/posts/configuring-maven-for-compiled-and-tested-code-in-javadoc-ospvbui5t
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: Configuring Maven For Compiled And Tested Code In Javadoc | daily.dev
og:description: JDK 18 introduces the @snippet Javadoc tag (JEP 413) that embeds external source files into API documentation. To ensure those snippet files are compiled and...
og:url: https://daily.dev/posts/configuring-maven-for-compiled-and-tested-code-in-javadoc-ospvbui5t
og:image: https://api.daily.dev/og/posts/oSPvBui5t.png
og:image:alt: Configuring Maven For Compiled And Tested Code In Javadoc
og:image:width: 1200
og:image:height: 630
og:locale: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Configuring Maven For Compiled And Tested Code In Javadoc

**[nipafx \(Nicolai Parlog\)](https://daily.dev/sources/nipafx)** · 6 min read · 0 upvotes · 0 comments

## Summary

JDK 18 introduces the @snippet Javadoc tag (JEP 413) that embeds external source files into API documentation. To ensure those snippet files are compiled and tested in a Maven build, you need to: add a src/demo/java source tree using the Codehaus Build Helper plugin, configure Maven Surefire to pick up *Demo.java files, and set the --snippet-path option on the Javadoc plugin. The post also covers folder structure nuances for snippet path resolution and how to use Maven profiles to gracefully handle builds on JDK versions older than 18 that don't support the @snippet tag.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://nipafx.dev/javadoc-snippets-maven>

---

Tags: [#java](https://daily.dev/tags/java), [#maven](https://daily.dev/tags/maven)

[View this post on daily.dev](https://daily.dev/posts/configuring-maven-for-compiled-and-tested-code-in-javadoc-ospvbui5t)

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"TechArticle","headline":"Configuring Maven For Compiled And Tested Code In Javadoc","url":"https://daily.dev/posts/configuring-maven-for-compiled-and-tested-code-in-javadoc-ospvbui5t","mainEntityOfPage":{"@type":"WebPage","@id":"https://daily.dev/posts/configuring-maven-for-compiled-and-tested-code-in-javadoc-ospvbui5t"},"datePublished":"2026-03-16T08:13:50.504Z","dateModified":"2026-03-16T08:21:08.451Z","description":"JDK 18 introduces the @snippet Javadoc tag (JEP 413) that embeds external source files into API documentation. To ensure those snippet files are compiled and...","image":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/b3611850ba5bb6c4234cff3086d2c619?_a=AQAEuop","thumbnailUrl":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/b3611850ba5bb6c4234cff3086d2c619?_a=AQAEuop","isAccessibleForFree":true,"articleSection":"nipafx (Nicolai Parlog)","inLanguage":"en","publisher":{"@type":"Organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180}},"author":{"@type":"Organization","name":"nipafx (Nicolai Parlog)","logo":"https://media.daily.dev/image/upload/s--H_Echo_u--/f_auto,q_auto/v1773648772/logos/nipafx?_a=BAMAMiiu0","url":"https://daily.dev/sources/nipafx"},"commentCount":0,"discussionUrl":"https://daily.dev/posts/configuring-maven-for-compiled-and-tested-code-in-javadoc-ospvbui5t","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":0},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":0}],"keywords":"java,maven","timeRequired":"PT6M"}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"nipafx (Nicolai Parlog)","item":"https://daily.dev/sources/nipafx"},{"@type":"ListItem","position":3,"name":"Configuring Maven For Compiled And Tested Code In Javadoc"}]}
```

