Unnamed: 0
int64
0
305k
body
stringlengths
7
52.9k
name
stringlengths
1
185
200
String () { return myId; }
getId
201
Element () { return myOptions; }
getOptions
202
void (String id) { myId = id; }
setId
203
void (Element options) { myOptions = options; }
setOptions
204
String () { return myArtifactType; }
getArtifactType
205
boolean () { return myBuildOnMake; }
isBuildOnMake
206
String () { return myExternalSystemId; }
getExternalSystemId
207
String () { return myExternalSystemIdInInternalStorage; }
getExternalSystemIdInInternalStorage
208
String () { return myOutputPath; }
getOutputPath
209
Element () { return myRootElement; }
getRootElement
210
List<ArtifactPropertiesState> () { return myPropertiesList; }
getPropertiesList
211
void (List<ArtifactPropertiesState> propertiesList) { myPropertiesList = propertiesList; }
setPropertiesList
212
void (String artifactType) { myArtifactType = artifactType; }
setArtifactType
213
void (@NlsSafe String name) { myName = name; }
setName
214
void (String outputPath) { myOutputPath = outputPath; }
setOutputPath
215
void (boolean buildOnMake) { myBuildOnMake = buildOnMake; }
setBuildOnMake
216
void (String externalSystemId) { myExternalSystemId = externalSystemId; }
setExternalSystemId
217
void (String externalSystemIdInInternalStorage) { myExternalSystemIdInInternalStorage = externalSystemIdInInternalStorage; }
setExternalSystemIdInInternalStorage
218
void (Element rootElement) { myRootElement = rootElement; }
setRootElement
219
void (@NotNull JpsProject project, @NotNull Element componentTag) { List<JpsRemoteRepositoryDescription> result = new ArrayList<>(); List<Element> children = componentTag.getChildren(ELEMENT_TAG); for (Element repoElement : children) { String id = null; String name = null; String url = null; for (Element element : repoElement.getChildren(OPTION_TAG)) { String option = element.getAttributeValue("name"); String optionValue = element.getAttributeValue("value"); if (ID_PROPERTY.equals(option)) { id = optionValue; } else if (NAME_PROPERTY.equals(option)) { name = optionValue == null? "" : optionValue; } else if (URL_PROPERTY.equals(option)) { url = optionValue; } } if (id != null && url != null) { result.add(new JpsRemoteRepositoryDescription(id, name, url)); } } JpsRemoteRepositoriesConfiguration config = JpsRemoteRepositoryService.getInstance().getOrCreateRemoteRepositoriesConfiguration(project); if (!result.isEmpty()) { config.setRepositories(result); } }
loadExtension
220
JpsModuleSerializationDataExtensionImpl () { return new JpsModuleSerializationDataExtensionImpl(myBaseDirectory); }
createCopy
221
void (@NotNull JpsModuleSerializationDataExtensionImpl modified) { }
applyChanges
222
File () { return myBaseDirectory.toFile(); }
getBaseDirectory
223
JpsPathVariablesConfigurationImpl () { return new JpsPathVariablesConfigurationImpl(myPathVariables); }
createCopy
224
void (@NotNull JpsPathVariablesConfigurationImpl modified) { }
applyChanges
225
void (@NotNull String name, @NotNull String value) { myPathVariables.put(name, value); }
addPathVariable
226
void (@NotNull String name) { myPathVariables.remove(name); }
removePathVariable
227
String (@NotNull String name) { return myPathVariables.get(name); }
getUserVariableValue
228
JpsProjectSerializationDataExtensionImpl () { return new JpsProjectSerializationDataExtensionImpl(myBaseDirectory); }
createCopy
229
void (@NotNull JpsProjectSerializationDataExtensionImpl modified) { }
applyChanges
230
File () { return myBaseDirectory.toFile(); }
getBaseDirectory
231
void () { loadProject("/jps/model-serialization/testData/fileEncoding/fileEncoding.ipr"); JpsEncodingProjectConfiguration configuration = JpsEncodingConfigurationService.getInstance().getEncodingConfiguration(myProject); assertNotNull(configuration); assertEncoding("windows-1251", "dir/a.txt", configuration); assertEncoding("UTF-8", "dir/with-encoding.xml", configuration); assertEncoding("windows-1251", "dir/without-encoding.xml", configuration); assertEncoding("windows-1251", "dir/non-existent.xml", configuration); }
test
232
void (final String encoding, final String path, JpsEncodingProjectConfiguration configuration) { assertEquals(encoding, configuration.getEncoding(new File(getAbsolutePath(path)))); }
assertEncoding
233
void () { loadProject(SAMPLE_PROJECT_PATH); List<JpsArtifact> artifacts = getService().getSortedArtifacts(myProject); assertEquals(2, artifacts.size()); assertEquals("dir", artifacts.get(0).getName()); assertEquals("jar", artifacts.get(1).getName()); }
testLoadProject
234
JpsArtifactService () { return JpsArtifactService.getInstance(); }
getService
235
void () { doTest("jps/model-serialization/testData/compilerConfiguration/compilerConfiguration.ipr"); }
testLoadFromIpr
236
void () { doTest("jps/model-serialization/testData/compilerConfigurationDir"); }
testLoadFromDirectory
237
void (final String path) { loadProject(path); JpsJavaCompilerConfiguration configuration = JpsJavaExtensionService.getInstance().getCompilerConfiguration(myProject); assertNotNull(configuration); assertFalse(configuration.isClearOutputDirectoryOnRebuild()); assertFalse(configuration.isAddNotNullAssertions()); ProcessorConfigProfile defaultProfile = configuration.getDefaultAnnotationProcessingProfile(); assertTrue(defaultProfile.isEnabled()); assertFalse(defaultProfile.isObtainProcessorsFromClasspath()); String srcDir = JpsPathUtil.urlToPath(getUrl("src")); assertEquals(FileUtil.toSystemDependentName(srcDir), defaultProfile.getProcessorPath()); assertEquals("b", defaultProfile.getProcessorOptions().get("a")); assertEquals("d", defaultProfile.getProcessorOptions().get("c")); assertEquals("gen", defaultProfile.getGeneratedSourcesDirectoryName(false)); JpsCompilerExcludes excludes = configuration.getCompilerExcludes(); assertSameElements(excludes.getExcludedFiles(), new File(srcDir, "A.java")); assertSameElements(excludes.getExcludedDirectories(), new File(srcDir, "nonrec")); assertSameElements(excludes.getRecursivelyExcludedDirectories(), new File(srcDir, "rec")); assertFalse(isExcluded(excludes, "src/nonrec/x/Y.java")); assertTrue(isExcluded(excludes, "src/nonrec/Y.java")); assertTrue(isExcluded(excludes, "src/rec/x/Y.java")); assertTrue(isExcluded(excludes, "src/rec/Y.java")); assertTrue(isExcluded(excludes, "src/A.java")); assertFalse(isExcluded(excludes, "src/B.java")); JpsJavaCompilerOptions options = configuration.getCurrentCompilerOptions(); assertNotNull(options); assertEquals(512, options.MAXIMUM_HEAP_SIZE); assertFalse(options.DEBUGGING_INFO); assertTrue(options.GENERATE_NO_WARNINGS); assertEquals("-Xlint", options.ADDITIONAL_OPTIONS_STRING); final Map<String, String> override = options.ADDITIONAL_OPTIONS_OVERRIDE; assertEquals(2, override.size()); assertEquals("-param_1", override.get("mod_1")); assertEquals("-param_2", override.get("mod_2")); JpsValidationConfiguration validationConfiguration = configuration.getValidationConfiguration(); assertTrue(validationConfiguration.isValidateOnBuild()); assertTrue(validationConfiguration.isValidatorEnabled("Jasper Validator")); assertFalse(validationConfiguration.isValidatorEnabled("Hibernate Validator")); assertTrue(validationConfiguration.isValidatorEnabled("JPA Validator")); }
doTest
238
boolean (JpsCompilerExcludes excludes, final String path) { return excludes.isExcluded(JpsPathUtil.urlToFile(getUrl(path))); }
isExcluded
239
void () { loadProject(SAMPLE_PROJECT_PATH); assertEquals("sampleProject", myProject.getName()); checkSampleProjectConfiguration(getTestDataAbsoluteFile(SAMPLE_PROJECT_PATH).toFile()); }
testLoadProject
240
void () { loadProject(SAMPLE_PROJECT_IPR_PATH); assertEquals("sampleProject", myProject.getName()); checkSampleProjectConfiguration(getTestDataAbsoluteFile(SAMPLE_PROJECT_IPR_PATH).toFile().getParentFile()); }
testLoadIprProject
241
void (File baseDirPath) { assertTrue(FileUtil.filesEqual(baseDirPath, JpsModelSerializationDataService.getBaseDirectory(myProject))); List<JpsModule> modules = myProject.getModules(); assertEquals(3, modules.size()); JpsModule main = modules.get(0); assertEquals("main", main.getName()); JpsModule util = modules.get(1); assertEquals("util", util.getName()); JpsModule xxx = modules.get(2); assertEquals("xxx", xxx.getName()); assertTrue(FileUtil.filesEqual(new File(baseDirPath, "util"), JpsModelSerializationDataService.getBaseDirectory(util))); List<JpsLibrary> libraries = myProject.getLibraryCollection().getLibraries(); assertEquals(3, libraries.size()); List<JpsDependencyElement> dependencies = util.getDependenciesList().getDependencies(); assertEquals(4, dependencies.size()); JpsSdkDependency sdkDependency = assertInstanceOf(dependencies.get(0), JpsSdkDependency.class); assertSame(JpsJavaSdkType.INSTANCE, sdkDependency.getSdkType()); JpsSdkReference<?> reference = sdkDependency.getSdkReference(); assertNotNull(reference); assertEquals("1.5", reference.getSdkName()); assertInstanceOf(dependencies.get(1), JpsModuleSourceDependency.class); assertInstanceOf(dependencies.get(2), JpsLibraryDependency.class); assertInstanceOf(dependencies.get(3), JpsLibraryDependency.class); JpsSdkDependency inheritedSdkDependency = assertInstanceOf(main.getDependenciesList().getDependencies().get(0), JpsSdkDependency.class); JpsSdkReference<?> projectSdkReference = inheritedSdkDependency.getSdkReference(); assertNotNull(projectSdkReference); assertEquals("1.6", projectSdkReference.getSdkName()); assertEquals(getUrl("xxx/output"), JpsJavaExtensionService.getInstance().getOutputUrl(xxx, true)); assertEquals(getUrl("xxx/output"), JpsJavaExtensionService.getInstance().getOutputUrl(xxx, false)); }
checkSampleProjectConfiguration
242
void () { String relativePath = "/jps/model-serialization/testData/run-configurations/run-configurations.ipr"; Path absolutePath = getTestDataAbsoluteFile(relativePath); loadProject(relativePath); assertEquals("run-configurations", myProject.getName()); assertTrue(FileUtil.filesEqual(absolutePath.getParent().toFile(), JpsModelSerializationDataService.getBaseDirectory(myProject))); }
testFileBasedProjectNameAndBaseDir
243
void () { loadProject("/jps/model-serialization/testData/run-configurations-dir"); assertEquals("run-configurations-dir", myProject.getName()); }
testDirectoryBasedProjectName
244
void () { loadProject("/jps/model-serialization/testData/imlUnderDotIdea"); JpsModule module = assertOneElement(myProject.getModules()); JpsModuleSourceRoot root = assertOneElement(module.getSourceRoots()); assertEquals(getUrl("src"), root.getUrl()); }
testImlUnderDotIdea
245
void () { loadProject("/jps/model-serialization/testData/testModuleProperties/testModuleProperties.ipr"); List<JpsModule> modules = myProject.getModules(); assertEquals(2, modules.size()); JpsModule testModule = modules.get(0); assertEquals("testModule", testModule.getName()); JpsModule productionModule = modules.get(1); assertEquals("productionModule", productionModule.getName()); assertNull(JpsJavaExtensionService.getInstance().getTestModuleProperties(productionModule)); JpsTestModuleProperties testModuleProperties = JpsJavaExtensionService.getInstance().getTestModuleProperties(testModule); assertNotNull(testModuleProperties); assertEquals("productionModule", testModuleProperties.getProductionModuleReference().getModuleName()); assertSame(productionModule, testModuleProperties.getProductionModule()); }
testTestModuleProperties
246
void () { loadProject("/jps/model-serialization/testData/testInvalidLanguageLevel/testInvalidLanguageLevel.ipr"); List<JpsModule> modules = myProject.getModules(); assertEquals(1, modules.size()); JpsModule testModule = modules.get(0); assertEquals("testModule", testModule.getName()); JpsJavaModuleExtension moduleExtension = JpsJavaExtensionService.getInstance().getModuleExtension(testModule); assertNull(moduleExtension.getLanguageLevel()); JpsJavaProjectExtension projectExtension = JpsJavaExtensionService.getInstance().getProjectExtension(myProject); assertEquals(LanguageLevel.JDK_1_6, projectExtension.getLanguageLevel()); }
testInvalidLanguageLevel
247
void () { String projectPath = "/jps/model-serialization/testData/excludePatterns"; loadProject(projectPath + "/excludePatterns.ipr"); JpsModule module = assertOneElement(myProject.getModules()); JpsExcludePattern pattern = assertOneElement(module.getExcludePatterns()); assertEquals("*.class", pattern.getPattern()); assertEquals(assertOneElement(module.getContentRootsList().getUrls()), pattern.getBaseDirUrl()); }
testExcludePatterns
248
void () { loadProject("/jps/model-serialization/testData/projectSdkWithoutType/projectSdkWithoutType.ipr"); JpsSdkReference<JpsDummyElement> reference = myProject.getSdkReferencesTable().getSdkReference(JpsJavaSdkType.INSTANCE); assertNotNull(reference); assertEquals("1.6", reference.getSdkName()); }
testProjectSdkWithoutType
249
void () { loadProject("/jps/model-serialization/testData/invalidDependencyScope/invalidDependencyScope.ipr"); JpsModule module = assertOneElement(myProject.getModules()); List<JpsDependencyElement> dependencies = module.getDependenciesList().getDependencies(); assertEquals(3, dependencies.size()); JpsJavaDependencyExtension extension = JpsJavaExtensionService.getInstance().getDependencyExtension(dependencies.get(2)); assertNotNull(extension); assertEquals(JpsJavaDependencyScope.COMPILE, extension.getScope()); }
testInvalidDependencyScope
250
void () { loadProject("/jps/model-serialization/testData/duplicatedModuleLibrary/duplicatedModuleLibrary.ipr"); JpsModule module = assertOneElement(myProject.getModules()); List<JpsDependencyElement> dependencies = module.getDependenciesList().getDependencies(); assertEquals(4, dependencies.size()); JpsLibrary lib1 = assertInstanceOf(dependencies.get(2), JpsLibraryDependency.class).getLibrary(); assertNotNull(lib1); assertSameElements(lib1.getRootUrls(JpsOrderRootType.COMPILED), getUrl("data/lib1")); JpsLibrary lib2 = assertInstanceOf(dependencies.get(3), JpsLibraryDependency.class).getLibrary(); assertNotSame(lib1, lib2); assertNotNull(lib2); assertSameElements(lib2.getRootUrls(JpsOrderRootType.COMPILED), getUrl("data/lib2")); }
testDuplicatedModuleLibrary
251
void () { loadProject("/jps/model-serialization/testData/matryoshka/.idea"); JpsJavaProjectExtension extension = JpsJavaExtensionService.getInstance().getProjectExtension(myProject); assertNotNull(extension); assertEquals(getUrl("out"), extension.getOutputUrl()); }
testDotIdeaUnderDotIdea
252
void () { loadProject(SAMPLE_PROJECT_PATH); checkEncodingConfigurationInSampleProject(); }
testLoadEncoding
253
void () { loadProject(SAMPLE_PROJECT_IPR_PATH); checkEncodingConfigurationInSampleProject(); }
testLoadEncodingIpr
254
void () { JpsEncodingConfigurationService service = JpsEncodingConfigurationService.getInstance(); assertEquals("UTF-8", service.getProjectEncoding(myModel)); JpsEncodingProjectConfiguration configuration = service.getEncodingConfiguration(myProject); assertNotNull(configuration); assertEquals("UTF-8", configuration.getProjectEncoding()); assertEquals("windows-1251", configuration.getEncoding(new File(getAbsolutePath("util")))); assertEquals("windows-1251", configuration.getEncoding(new File(getAbsolutePath("util/foo/bar/file.txt")))); assertEquals("UTF-8", configuration.getEncoding(new File(getAbsolutePath("other")))); }
checkEncodingConfigurationInSampleProject
255
void () { String projectPath = "/jps/model-serialization/testData/resourceRoots/"; loadProject(projectPath + "resourceRoots.ipr"); JpsModule module = assertOneElement(myProject.getModules()); List<JpsModuleSourceRoot> roots = module.getSourceRoots(); assertSame(JavaSourceRootType.SOURCE, roots.get(0).getRootType()); checkResourceRoot(roots.get(1), false, ""); checkResourceRoot(roots.get(2), true, ""); checkResourceRoot(roots.get(3), true, "foo"); }
testResourceRoots
256
void () { loadProject("/jps/model-serialization/testData/missingModuleSourcesOrderEntry/missingModuleSourcesOrderEntry.ipr"); JpsModule module = assertOneElement(myProject.getModules()); List<JpsDependencyElement> dependencies = module.getDependenciesList().getDependencies(); assertEquals(2, dependencies.size()); assertInstanceOf(dependencies.get(0), JpsSdkDependency.class); assertInstanceOf(dependencies.get(1), JpsModuleSourceDependency.class); }
testMissingModuleSourcesOrderEntry
257
void (JpsModuleSourceRoot root, boolean forGenerated, String relativeOutput) { assertSame(JavaResourceRootType.RESOURCE, root.getRootType()); JavaResourceRootProperties properties = root.getProperties(JavaResourceRootType.RESOURCE); assertNotNull(properties); assertEquals(forGenerated, properties.isForGeneratedSources()); assertEquals(relativeOutput, properties.getRelativeOutputPath()); }
checkResourceRoot
258
void () { String projectPath = "/jps/model-serialization/testData/unloadedModule"; loadProject(projectPath); assertEquals("main", assertOneElement(myProject.getModules()).getName()); }
testUnloadedModule
259
void () { loadProject("/jps/model-serialization/testData/missingImlFile/missingImlFile.ipr"); assertEmpty(myProject.getModules()); }
testMissingImlFile
260
void () { loadProject("/jps/model-serialization/testData/missingContentUrlAttribute/missingContentUrlAttribute.ipr"); JpsModule module = assertOneElement(myProject.getModules()); assertEquals("missingContentUrlAttribute", module.getName()); }
testMissingContentUrlAttribute
261
void () { long start = System.nanoTime(); loadProjectByAbsolutePath(PathManager.getHomePath()); assertTrue(myProject.getModules().size() > 0); System.out.println("JpsProjectSerializationTest: " + myProject.getModules().size() + " modules, " + myProject.getLibraryCollection().getLibraries().size() + " libraries and " + JpsArtifactService.getInstance().getArtifacts(myProject).size() + " artifacts loaded in " + TimeUnit.NANOSECONDS.toMillis(System.nanoTime() - start) + "ms"); }
testLoadIdeaProject
262
void () { loadProject("/jps/model-serialization/testData/excludesInLibraries"); JpsLibrary library = assertOneElement(myProject.getLibraryCollection().getLibraries()); assertEquals("junit", library.getName()); assertEquals(JpsPathUtil.getLibraryRootUrl(new File(getAbsolutePath("lib/junit.jar"))), assertOneElement(library.getRoots(JpsOrderRootType.COMPILED)).getUrl()); }
testExcludesInLibraries
263
void () { JpsMavenRepositoryLibraryDescriptor properties = loadLibrary("plain"); assertEquals("junit", properties.getGroupId()); assertEquals("junit", properties.getArtifactId()); assertEquals("3.8.1", properties.getVersion()); assertTrue(properties.isIncludeTransitiveDependencies()); assertEmpty(properties.getExcludedDependencies()); }
testPlain
264
void () { JpsMavenRepositoryLibraryDescriptor properties = loadLibrary("without-transitive-dependencies"); assertFalse(properties.isIncludeTransitiveDependencies()); assertEmpty(properties.getExcludedDependencies()); }
testWithoutTransitiveDependencies
265
void () { JpsMavenRepositoryLibraryDescriptor properties = loadLibrary("with-excluded-dependencies"); assertTrue(properties.isIncludeTransitiveDependencies()); assertSameElements(properties.getExcludedDependencies(), "org.apache.httpcomponents:httpclient"); }
testWithExcludedDependencies
266
JpsMavenRepositoryLibraryDescriptor (String name) { loadProject("/jps/model-serialization/testData/repositoryLibraries"); JpsLibrary library = myProject.getLibraryCollection().findLibrary(name); assertNotNull(library); assertSame(JpsRepositoryLibraryType.INSTANCE, library.getType()); JpsTypedLibrary<JpsSimpleElement<JpsMavenRepositoryLibraryDescriptor>> typed = library.asTyped(JpsRepositoryLibraryType.INSTANCE); assertNotNull(typed); return typed.getProperties().getData(); }
loadLibrary
267
void () { loadGlobalSettings(OPTIONS_DIR); final List<JpsLibrary> libraries = myModel.getGlobal().getLibraryCollection().getLibraries(); assertEquals(3, libraries.size()); assertEquals("Gant", libraries.get(0).getName()); final JpsLibrary sdk1 = libraries.get(1); assertEquals("1.5", sdk1.getName()); final JpsLibrary sdk2 = libraries.get(2); assertEquals("1.6", sdk2.getName()); }
testLoadSdksAndGlobalLibraries
268
void () { loadGlobalSettings(OPTIONS_DIR); JpsPathVariablesConfiguration configuration = JpsModelSerializationDataService.getPathVariablesConfiguration(myModel.getGlobal()); assertNotNull(configuration); assertEquals("/home/nik/.m2/repository", configuration.getUserVariableValue(PathMacrosImpl.MAVEN_REPOSITORY)); assertThat(configuration.getAllUserVariables()).hasSize(1); }
testLoadPathVariables
269
void () { loadGlobalSettings(OPTIONS_DIR); assertEquals("windows-1251", JpsEncodingConfigurationService.getInstance().getGlobalEncoding(myModel.getGlobal())); }
testLoadEncoding
270
void () { loadGlobalSettings(OPTIONS_DIR); assertEquals("CVS;.svn;", myModel.getGlobal().getFileTypesConfiguration().getIgnoredPatternString()); }
testLoadIgnoredFiles
271
void (final String relativePath) { loadProjectByAbsolutePath(getTestDataFileAbsolutePath(relativePath)); }
loadProject
272
void (String path) { myProjectHomePath = FileUtilRt.toSystemIndependentName(path); if (myProjectHomePath.endsWith(".ipr")) { myProjectHomePath = PathUtil.getParentPath(myProjectHomePath); } try { JpsProjectLoader.loadProject(myProject, getPathVariables(), Paths.get(path)); } catch (IOException e) { throw new RuntimeException(e); } }
loadProjectByAbsolutePath
273
String (String relativePath) { return VfsUtilCore.pathToUrl(getAbsolutePath(relativePath)); }
getUrl
274
String (String relativePath) { return myProjectHomePath + "/" + relativePath; }
getAbsolutePath
275
void (final String optionsDir) { try { String optionsPath = getTestDataFileAbsolutePath(optionsDir); Map<String,String> pathVariables = getPathVariables(); JpsPathVariablesConfiguration configuration = JpsModelSerializationDataService.getOrCreatePathVariablesConfiguration(myModel.getGlobal()); for (Map.Entry<String, String> entry : pathVariables.entrySet()) { configuration.addPathVariable(entry.getKey(), entry.getValue()); } JpsGlobalLoader.loadGlobalSettings(myModel.getGlobal(), optionsPath); } catch (IOException e) { throw new RuntimeException(e); } }
loadGlobalSettings
276
String (@NotNull String relativePath) { return PathManagerEx.findFileUnderProjectHome(relativePath, getClass()).getAbsolutePath(); }
getTestDataFileAbsolutePath
277
Path (@NotNull String relativePath) { return Paths.get(getTestDataFileAbsolutePath(relativePath)); }
getTestDataAbsoluteFile
278
Element (@NotNull Path imlFile) { JpsMacroExpander expander = JpsProjectLoader.createModuleMacroExpander(Collections.emptyMap(), imlFile); return JpsLoaderBase.loadRootElement(imlFile, expander); }
loadModuleRootTag
279
void () { doTest("jps/model-serialization/testData/run-configurations/run-configurations.ipr"); }
testLoadIpr
280
void () { doTest("jps/model-serialization/testData/run-configurations-dir"); }
testLoadDirectoryBased
281
void (final String relativePath) { loadProject(relativePath); List<JpsTypedRunConfiguration<JpsApplicationRunConfigurationProperties>> configurations = ContainerUtil.newArrayList(myProject.getRunConfigurations(JpsApplicationRunConfigurationType.INSTANCE)); assertEquals(2, configurations.size()); JpsTypedRunConfiguration<JpsApplicationRunConfigurationProperties> shared = configurations.get(0); assertEquals("shared", shared.getName()); assertEquals("xxx.Main2", shared.getProperties().getMainClass()); JpsTypedRunConfiguration<JpsApplicationRunConfigurationProperties> main = configurations.get(1); assertEquals("Main", main.getName()); assertEquals("xxx.Main", main.getProperties().getMainClass()); List<JpsRunConfiguration> all = myProject.getRunConfigurations(); JpsRunConfiguration junit = findByName(all, "test"); JpsRunConfigurationType type = ((JpsTypedRunConfiguration)junit).getType(); assertEquals("JUnit", assertInstanceOf(type, JpsUnknownRunConfigurationType.class).getTypeId()); }
doTest
282
JpsRunConfiguration (List<JpsRunConfiguration> configurations, String name) { for (JpsRunConfiguration configuration : configurations) { if (configuration.getName().equals(name)) { return configuration; } } throw new AssertionFailedError("'" + name + "' run configuration not found"); }
findByName
283
void (JpsModel model) { Map<String, Object> variables = new HashMap<>(); variables.put("project", model.getProject()); variables.put("global", model.getGlobal()); try { new GroovyShell(new Binding(variables)).evaluate(myScriptFile); } catch (IOException e) { throw new RuntimeException(e); } }
run
284
void (String[] args) { Standalone instance = new Standalone(); List<String> projectPaths; try { projectPaths = Args.parse(instance, args); } catch (Exception e) { printUsageAndExit(); return; } if (projectPaths.isEmpty()) { System.out.println("Path to project is not specified"); printUsageAndExit(); } if (projectPaths.size() > 1) { System.out.println("Only one project can be specified"); printUsageAndExit(); } final String projectPath = (new File(projectPaths.get(0))).getAbsolutePath(); int exitCode = instance.loadAndRunBuild(FileUtil.toCanonicalPath(projectPath)); System.exit(exitCode); }
main
285
void () { Args.usage(System.err, new Standalone()); System.exit(1); }
printUsageAndExit
286
int (final String projectPath) { String globalOptionsPath = null; if (configPath != null) { File optionsDir = new File(configPath, "options"); if (!optionsDir.isDirectory()) { System.err.println("'" + configPath + "' is not valid config path: " + optionsDir.getAbsolutePath() + " not found"); return 1; } globalOptionsPath = optionsDir.getAbsolutePath(); } ParameterizedRunnable<JpsModel> initializer = null; String scriptPath = initializationScriptPath; if (scriptPath != null) { File scriptFile = new File(scriptPath); if (!scriptFile.isFile()) { System.err.println("Script '" + scriptPath + "' not found"); return 1; } initializer = new GroovyModelInitializer(scriptFile); } if (modules.length == 0 && artifacts.length == 0 && !allModules && !allArtifacts) { System.err.println("Nothing to compile: at least one of --modules, --artifacts, --all-modules or --all-artifacts parameters must be specified"); return 1; } JpsModelLoaderImpl loader = new JpsModelLoaderImpl(projectPath, globalOptionsPath, false, initializer); Set<String> modulesSet = Set.of(modules); List<String> artifactsList = Arrays.asList(artifacts); File dataStorageRoot; if (cacheDirPath != null) { dataStorageRoot = new File(cacheDirPath); } else { dataStorageRoot = Utils.getDataStorageRoot(projectPath); } ConsoleMessageHandler consoleMessageHandler = new ConsoleMessageHandler(); long start = System.nanoTime(); try { runBuild(loader, dataStorageRoot, !incremental, modulesSet, allModules, artifactsList, allArtifacts, true, consoleMessageHandler); } catch (Throwable t) { System.err.println("Internal error: " + t.getMessage()); t.printStackTrace(); } System.out.println("Build finished in " + Utils.formatDuration(TimeUnit.NANOSECONDS.toMillis(System.nanoTime() - start))); return consoleMessageHandler.hasErrors() ? 1 : 0; }
loadAndRunBuild
287
void (BuildMessage msg) { String messageText; if (msg instanceof CompilerMessage) { CompilerMessage compilerMessage = (CompilerMessage) msg; if (compilerMessage.getSourcePath() == null) { messageText = msg.getMessageText(); } else if (compilerMessage.getLine() < 0) { messageText = compilerMessage.getSourcePath() + ": " + msg.getMessageText(); } else { messageText = compilerMessage.getSourcePath() + "(" + compilerMessage.getLine() + ":" + compilerMessage.getColumn() + "): " + msg.getMessageText(); } } else { messageText = msg.getMessageText(); } if (messageText.isEmpty()) return; if (msg.getKind() == BuildMessage.Kind.ERROR) { System.err.println("Error: " + messageText); hasErrors = true; } else if (msg.getKind() != BuildMessage.Kind.PROGRESS || !messageText.startsWith("Compiled") && !messageText.startsWith("Copying")) { System.out.println(messageText); } }
processMessage
288
boolean () { return hasErrors; }
hasErrors
289
void (DirContainer container) { containers.add(container); }
addDir
290
void (JarContainer container) { containers.add(container); }
addJar
291
void (ZipContainer container) { containers.add(container); }
addZip
292
void (RenamedFileContainer container) { containers.add(container); }
addRenamedFile
293
void (ExtractedDirContent content) { containers.add(content); }
addExtractedDir
294
void (IdeaModule module) { containers.add(new FileSetContainer(module)); }
addModule
295
void (IdeaModuleTests module) { containers.add(new FileSetContainer(module)); }
addModuleTests
296
void (FileSet fileSet) { containers.add(new FileSetContainer(fileSet)); }
addFileset
297
void (File dir) { destDir = dir; }
setTodir
298
File () { return destDir; }
getDestDir
299
File (String name) { File localTmp = new File(tempDir, "_" + counter + "/"); counter++; localTmp.mkdirs(); return new File(localTmp, name); }
allocateTempFile