1 /* 2 * Copyright (C) 2023 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package com.android.tools.metalava.model.source 18 19 import com.android.tools.metalava.model.Codebase 20 import com.android.tools.metalava.model.ModelOptions 21 import java.io.Closeable 22 import java.io.File 23 24 /** 25 * Manages environmental resources, e.g. temporary directories, file caches, etc. needed while 26 * processing source files. 27 * 28 * This will clean up any resources on [close]. 29 */ 30 interface EnvironmentManager : Closeable { 31 32 /** 33 * Create a [SourceParser] that can be used to create [Codebase] related objects. 34 * 35 * @param codebaseConfig the [Codebase.Config] to pass through to the created [Codebase]s. 36 * @param javaLanguageLevel the java language level as a string, e.g. 1.8, 17, etc. 37 * @param kotlinLanguageLevel the kotlin language level as a string, e.g. 1.8, etc. 38 * @param modelOptions a set of model specific options provided by the caller. 39 * @param jdkHome the optional path to the jdk home directory. 40 */ createSourceParsernull41 fun createSourceParser( 42 codebaseConfig: Codebase.Config, 43 javaLanguageLevel: String = DEFAULT_JAVA_LANGUAGE_LEVEL, 44 kotlinLanguageLevel: String = DEFAULT_KOTLIN_LANGUAGE_LEVEL, 45 modelOptions: ModelOptions = ModelOptions.empty, 46 allowReadingComments: Boolean = true, 47 jdkHome: File? = null, 48 ): SourceParser 49 } 50 51 const val DEFAULT_JAVA_LANGUAGE_LEVEL = "1.8" 52 const val DEFAULT_KOTLIN_LANGUAGE_LEVEL = "1.9" 53