/** * Tries to guess the packaging of the archive - whether it's an EAR, WAR, JAR. * Maybe not needed as we can rely on the suffix? */ private static String guessPackaging(ProjectModel projectModel) { String projectType = projectModel.getProjectType(); if (projectType != null) return projectType; LOG.warning("WINDUP-983 getProjectType() returned null for: " + projectModel.getRootFileModel().getPrettyPath()); String suffix = StringUtils.substringAfterLast(projectModel.getRootFileModel().getFileName(), "."); if ("jar war ear sar har ".contains(suffix+" ")){ projectModel.setProjectType(suffix); // FIXME: Remove when WINDUP-983 is fixed. return suffix; } // Should we try something more? Used APIs? What if it's a source? return "unknown"; }
/** * Tries to guess the packaging of the archive - whether it's an EAR, WAR, JAR. * Maybe not needed as we can rely on the suffix? */ private static String guessPackaging(ProjectModel projectModel) { String projectType = projectModel.getProjectType(); if (projectType != null) return projectType; LOG.warning("WINDUP-983 getProjectType() returned null for: " + projectModel.getRootFileModel().getPrettyPath()); String suffix = StringUtils.substringAfterLast(projectModel.getRootFileModel().getFileName(), "."); if ("jar war ear sar har ".contains(suffix+" ")){ projectModel.setProjectType(suffix); // FIXME: Remove when WINDUP-983 is fixed. return suffix; } // Should we try something more? Used APIs? What if it's a source? return "unknown"; }
/** * Gets the project model used for shared libraries (libraries duplicated in multiple places within one or * more applications). */ public ProjectModel getOrCreateSharedLibsProject() { ProjectService service = new ProjectService(getGraphContext()); ProjectModel sharedLibsProject = service.getByUniqueID(SHARED_LIBS_UNIQUE_ID); if (sharedLibsProject == null) { sharedLibsProject = service.create(); sharedLibsProject.setName(SHARED_LIBS_APP_NAME); sharedLibsProject.setUniqueID(SHARED_LIBS_UNIQUE_ID); sharedLibsProject.setProjectType(ProjectModel.TYPE_VIRTUAL); // attach a directory to it, as we generally assume that all projects have a location on disk Path archivesDirectory = WindupConfigurationService.getArchivesPath(getGraphContext()); Path sharedLibsPath = archivesDirectory.resolve("shared-libs-" + RandomStringUtils.randomAlphabetic(6)).resolve(SHARED_LIBS_FILENAME); PathUtil.createDirectory(sharedLibsPath, "shared libs virtual app"); FileModel sharedLibsFileModel = new FileService(getGraphContext()).createByFilePath(sharedLibsPath.toString()); ApplicationModel applicationModel = GraphService.addTypeToModel(getGraphContext(), sharedLibsFileModel, ApplicationModel.class); applicationModel.setApplicationName(SHARED_LIBS_FILENAME); sharedLibsProject.setRootFileModel(sharedLibsFileModel); sharedLibsProject.addFileModel(sharedLibsFileModel); // attach this to the configuration, so that reporting treats it as a standalone app WindupConfigurationModel configuration = WindupConfigurationService.getConfigurationModel(getGraphContext()); configuration.addInputPath(sharedLibsFileModel); } return sharedLibsProject; }
/** * Gets the project model used for shared libraries (libraries duplicated in multiple places within one or * more applications). */ public ProjectModel getOrCreateSharedLibsProject() { ProjectService service = new ProjectService(getGraphContext()); ProjectModel sharedLibsProject = service.getByUniqueID(SHARED_LIBS_UNIQUE_ID); if (sharedLibsProject == null) { sharedLibsProject = service.create(); sharedLibsProject.setName(SHARED_LIBS_APP_NAME); sharedLibsProject.setUniqueID(SHARED_LIBS_UNIQUE_ID); sharedLibsProject.setProjectType(ProjectModel.TYPE_VIRTUAL); // attach a directory to it, as we generally assume that all projects have a location on disk Path archivesDirectory = WindupConfigurationService.getArchivesPath(getGraphContext()); Path sharedLibsPath = archivesDirectory.resolve("shared-libs-" + RandomStringUtils.randomAlphabetic(6)).resolve(SHARED_LIBS_FILENAME); PathUtil.createDirectory(sharedLibsPath, "shared libs virtual app"); FileModel sharedLibsFileModel = new FileService(getGraphContext()).createByFilePath(sharedLibsPath.toString()); ApplicationModel applicationModel = GraphService.addTypeToModel(getGraphContext(), sharedLibsFileModel, ApplicationModel.class); applicationModel.setApplicationName(SHARED_LIBS_FILENAME); sharedLibsProject.setRootFileModel(sharedLibsFileModel); sharedLibsProject.addFileModel(sharedLibsFileModel); // attach this to the configuration, so that reporting treats it as a standalone app WindupConfigurationModel configuration = WindupConfigurationService.getConfigurationModel(getGraphContext()); configuration.addInputPath(sharedLibsFileModel); } return sharedLibsProject; }
projectModel.setProjectType(extension);
projectModel.setProjectType(extension);