# Java Configuration Options
Source: https://speakeasy.com/docs/speakeasy-reference/generation/java-config

import { Table } from "@/mdx/components";



This section details the available configuration options for the Java SDK. All configuration is managed in the `gen.yaml` file under the `java` section.

## Version and general configuration

```yml
java:
  version: 1.2.3
  projectName: "openapi"
  description: "A description of your SDK"
```

<Table
  data={[
    {
      name: "version",
      required: "true",
      default: "0.0.1",
      description: "The current version of the SDK.",
    },
    {
      name: "projectName",
      required: "true",
      default: "openapi",
      description:
        "Assigns Gradle `rootProject.name`, which names the Gradle build. See [Gradle Naming](https://docs.gradle.org/current/userguide/multi_project_builds.html#naming_recommendations).",
    },
    {
      name: "description",
      required: "false",
      default: "SDK enabling Java developers to easily integrate with the {CompanyName} API.",
      description:
        "A description of the SDK that will be included in the generated Gradle build file.",
    },
  ]}
  columns={[
    { key: "name", header: "Name" },
    { key: "required", header: "Required" },
    { key: "default", header: "Default Value" },
    { key: "description", header: "Description" },
  ]}
/>

## Publishing

```yml
java:
  groupID: "com.mycompany"
  artifactID: "my-sdk"
  githubURL: "https://github.com/mycompany/my-sdk"
  companyName: "My Company"
  companyURL: "https://www.mycompany.com"
  companyEmail: "support@mycompany.com"
```

<Table
  data={[
    {
      name: "groupID",
      required: "true",
      default: "org.openapis",
      description:
        "The group ID used for namespacing the package. Typically the reversed domain of an organization.",
    },
    {
      name: "artifactID",
      required: "true",
      default: "openapi",
      description:
        "The artifact ID used for namespacing the package, usually the name of the project.",
    },

    {
      name: "githubURL",
      required: "for publishing",
      default: "github.com/owner/repo",
      description:
        "The GitHub URL where the artifact is hosted. Sets metadata required by Maven.",
    },
    {
      name: "companyName",
      required: "for publishing",
      default: "My Company",
      description: "The name of your company. Sets metadata required by Maven.",
    },
    {
      name: "companyURL",
      required: "for publishing",
      default: "www.mycompany.com",
      description:
        "Your company's homepage URL. Sets metadata required by Maven.",
    },
    {
      name: "companyEmail",
      required: "for publishing",
      default: "info@mycompany.com",
      description:
        "A support email address for your company. Sets metadata required by Maven.",
    },
  ]}
  columns={[
    { key: "name", header: "Name" },
    { key: "required", header: "Required" },
    { key: "default", header: "Default Value" },
    { key: "description", header: "Description" },
  ]}
/>

## Base package name

This package will be where the primary SDK class is located
(and sub-packages will hold various types of associated generated classes):

```yaml
java:
  packageName: com.mycompany.sdk
```

## Additional Dependencies

```yml
java:
  additionalDependencies:
    - "implementation:com.fasterxml.jackson.core:jackson-databind:2.12.3"
    - "testImplementation:junit:junit:4.13.2"
```

<Table
  data={[
    {
      name: "additionalDependencies",
      required: "false",
      default: "[]",
      description:
        "Adds additional dependencies to include in `build.gradle`. Format: `scope:groupId:artifactId:version`.",
    },
    {
      name: "additionalPlugins",
      required: "false",
      default: "[]",
      description:
        'Adds additional plugins to include in `build.gradle`. Format: `id("plugin.id") version "x.x.x"`.',
    },
  ]}
  columns={[
    { key: "name", header: "Name" },
    { key: "required", header: "Required" },
    { key: "default", header: "Default Value" },
    { key: "description", header: "Description" },
  ]}
/>

## License

```yml
java:
  license:
    name: "The MIT License (MIT)"
    url: "https://mit-license.org/"
    shortName: "MIT"
```

<Table
  data={[
    {
      name: "license",
      required: "false",
      default: "MIT License",
      description:
        "License information. Defaults to the MIT license if not provided.",
    },
  ]}
  columns={[
    { key: "name", header: "Name" },
    { key: "required", header: "Required" },
    { key: "default", header: "Default Value" },
    { key: "description", header: "Description" },
  ]}
/>

## Method and parameter management

```yml
java:
  maxMethodParams: 4
```

<Table
  data={[
    {
      name: "[maxMethodParams](/docs/customize/methods)",
      required: "false",
      default: "4",
      description:
        "Maximum number of parameters before an input object is created. `0` means input objects are always used.",
    },
  ]}
  columns={[
    { key: "name", header: "Name" },
    { key: "required", header: "Required" },
    { key: "default", header: "Default Value" },
    { key: "description", header: "Description" },
  ]}
/>

## Security configuration

```yml
java:
  flattenGlobalSecurity: true
```

<Table
  data={[
    {
      property: "[flattenGlobalSecurity](/docs/customize/authentication/overview)",
      description:
        "Enables inline security credentials during SDK instantiation. **Recommended: `true`**",
      type: "boolean",
      default: "true",
    },
  ]}
  columns={[
    { key: "property", header: "Property" },
    { key: "description", header: "Description" },
    { key: "type", header: "Type" },
    { key: "default", header: "Default" },
  ]}
/>

## Import management

```yml
java:
  imports:
    paths:
      callbacks: models/callbacks
      errors: models/errors
      operations: models/operations
      shared: models/components
      webhooks: models/webhooks
```

<Table
  data={[
    {
      field: "paths",
      required: "false",
      default: "{}",
      description:
        "Customizes where different parts of the SDK (e.g., callbacks, errors, and operations) will be imported from.",
    },
  ]}
  columns={[
    { key: "field", header: "Field" },
    { key: "required", header: "Required" },
    { key: "default", header: "Default Value" },
    { key: "description", header: "Description" },
  ]}
/>

### Import paths

<Table
  data={[
    {
      component: "callbacks",
      default: "models/callbacks",
      description: "The directory where callback models will be imported from.",
    },
    {
      component: "errors",
      default: "models/errors",
      description: "The directory where error models will be imported from.",
    },
    {
      component: "operations",
      default: "models/operations",
      description:
        "The directory where operation models (i.e., API endpoints) will be imported from.",
    },
    {
      component: "shared",
      default: "models/components",
      description:
        "The directory for shared components, such as reusable schemas and data models, imported from the OpenAPI spec.",
    },
    {
      component: "webhooks",
      default: "models/webhooks",
      description:
        "The directory for webhook models, if your SDK includes support for webhooks.",
    },
  ]}
  columns={[
    { key: "component", header: "Component" },
    { key: "default", header: "Default Value" },
    { key: "description", header: "Description" },
  ]}
/>

## Error and response handling

```yml
java:
  clientServerStatusCodesAsErrors: false
```

<Table
  data={[
    {
      name: "clientServerStatusCodesAsErrors",
      required: "false",
      default: "true",
      description:
        "Whether to treat 4xx and 5xx status codes as errors. Options: `true` or `false`.",
    },
  ]}
  columns={[
    { key: "name", header: "Name" },
    { key: "required", header: "Required" },
    { key: "default", header: "Default Value" },
    { key: "description", header: "Description" },
  ]}
/>