/** * Initialize the annotations configuration * * @param annotatedProject Annotations configuration to initialize * @param project Project context */ @Defaults public void initializeAnnotationsConfig(AnnotatedProject annotatedProject, ProjectContext project) { Matcher matcher = ID_PATTERN.matcher(project.getName()); if (matcher.matches()) { annotatedProject.setId(matcher.group(1)); } matcher = VERSION_PATTERN.matcher(project.getVersion().toString()); if (matcher.matches()) { annotatedProject.setVersion(matcher.group(1)); } }
/** * Get the project description * * @return Project description */ public @Nullable String getDescription() { return getProject().getDescription(); }
/** * Get a property from the project or the environment * * First looks up the property value in the project's properties. If the property is not set, converts the property * name to upper underscore format and checks if the value is set in the environment. * * @param name Property name * @return Property value or <code>null</code> if the property does not exist */ public @Nullable String getProperty(String name) { String env = toEnvName(name); String property = name.toLowerCase(); String value = System.getProperty(env); if (value == null) { value = (String) getProject().findProperty(property); } return value; }
/** * Configure the Bintray plugin * * <ul> * <li>Set Bintray user and password from Gradle properties file or environment * <li>Configure the Bintray package * </ul> * * @param bintray Bintray plugin's configuration * @param projectConfig Project configuration * @param bintrayConfig Bintray configuration * @param project Project context */ @Defaults public void configureBintrayExtension(BintrayExtension bintray, ProjectConfig projectConfig, BintrayConfig bintrayConfig, ProjectContext project) { bintray.setUser(project.getProperty("bintray.user")); bintray.setKey(project.getProperty("bintray.key")); PackageConfig pkg = bintray.getPkg(); pkg.setName(project.getName()); pkg.setDesc(project.getDescription()); pkg.setRepo(bintrayConfig.getRepository()); pkg.setVcsUrl(projectConfig.getRepository().getConnection()); pkg.setWebsiteUrl(projectConfig.getWebsiteUrl()); pkg.setIssueTrackerUrl(projectConfig.getIssueTracker().getWebsiteUrl()); pkg.setLicenses(projectConfig.getLicense().getId()); VersionConfig version = pkg.getVersion(); version.setName(project.getVersion().toString()); version.setVcsTag(project.getName() + "-" + project.getVersion()); }
/** * Create a task to create the Github repository for the project * * @param tasks Task container to create tasks * @param project Project context to get project settings */ @Mutate public void createGithubTasks(ModelMap<Task> tasks, ProjectContext project) { tasks.create("configureGithubRepository", ConfigureGithubRepository.class, t -> { t.setDescription("Configure a Github repository for the project, creating it if necessary."); t.setGroup("build setup"); t.setGithubToken(project.getProperty("github.token")); t.setRepositoryName(project.getName()); t.setRepositoryDescription(project.getDescription()); }); tasks.named("configure", t -> { t.dependsOn("configureGithubRepository"); }); } }
/** * Initialize the Github configuration * * @param githubConfig Github configuration to initialize * @param project Project context */ @Defaults public void initializeGithubConfig(GithubConfig githubConfig, ProjectContext project) { githubConfig.setRepository(project.getName()); }
Nodes.setChildValue(dependencyNode, "groupId", this.project.getGroup()); Nodes.setChildValue(dependencyNode, "artifactId", artifact.getName()); Nodes.setChildValue(dependencyNode, "version", this.project.getVersion()); Nodes.setChildValue(dependencyNode, "scope", JavaPlugin.COMPILE_CONFIGURATION_NAME);
/** * Initialize the plugin bundle extension * * @param bundleExtension Plugin bundle extension to initialize * @param projectConfig Project configuration * @param project Project context */ @Defaults public void configureGradlePluginDevelopmentExtension(PluginBundleExtension bundleExtension, ProjectConfig projectConfig, ProjectContext project) { bundleExtension.setDescription(project.getDescription()); bundleExtension.setWebsite(projectConfig.getWebsiteUrl()); bundleExtension.setVcsUrl(projectConfig.getRepository().getWebsiteUrl()); for (PluginConfig plugin : bundleExtension.getPlugins()) { if (Strings.isNullOrEmpty(plugin.getDisplayName())) { plugin.setDisplayName(project.getDescription()); } } }
LOGGER.debug("Using Docker certificate path '{}'", docker.getCertPath()); registryCredentials.setUsername(project.getProperty("docker.user")); registryCredentials.setPassword(project.getProperty("docker.password")); registryCredentials.setEmail(project.getProperty("docker.email")); registryCredentials.setUrl(project.getProperty("docker.url"));
/** * @see me.seeber.gradle.plugin.AbstractProjectConfigPlugin#initialize() */ @Override protected void initialize() { checkGradleVersion(); ProjectContext context = new ProjectContext(getProject()); getProject().getExtensions().add("projectContext", context); RepositoryHandler repositories = getProject().getRepositories(); repositories.add(repositories.mavenLocal()); repositories.add(repositories.mavenCentral()); repositories.add(repositories.maven(r -> r.setUrl("https://plugins.gradle.org/m2"))); repositories.add(repositories.jcenter()); getProject().getConfigurations().all(c -> { c.resolutionStrategy(s -> { s.preferProjectModules(); s.cacheChangingModulesFor(0, "seconds"); }); }); }
parameters.map("destinationDir", () -> projectContext.getProjectDir()); });
/** * Configure the Bintray plugin * * <ul> * <li>Set Bintray user and password from Gradle properties file or environment * <li>Configure the Bintray package * </ul> * * @param bintray Bintray plugin's configuration * @param projectConfig Project configuration * @param bintrayConfig Bintray configuration * @param project Project context */ @Defaults public void configureBintrayExtension(BintrayExtension bintray, ProjectConfig projectConfig, BintrayConfig bintrayConfig, ProjectContext project) { bintray.setUser(project.getProperty("bintray.user")); bintray.setKey(project.getProperty("bintray.key")); PackageConfig pkg = bintray.getPkg(); pkg.setName(project.getName()); pkg.setDesc(project.getDescription()); pkg.setRepo(bintrayConfig.getRepository()); pkg.setVcsUrl(projectConfig.getRepository().getConnection()); pkg.setWebsiteUrl(projectConfig.getWebsiteUrl()); pkg.setIssueTrackerUrl(projectConfig.getIssueTracker().getWebsiteUrl()); pkg.setLicenses(projectConfig.getLicense().getId()); VersionConfig version = pkg.getVersion(); version.setName(project.getVersion().toString()); version.setVcsTag(project.getName() + "-" + project.getVersion()); }
/** * Create a task to create the Github repository for the project * * @param tasks Task container to create tasks * @param project Project context to get project settings */ @Mutate public void createGithubTasks(ModelMap<Task> tasks, ProjectContext project) { tasks.create("configureGithubRepository", ConfigureGithubRepository.class, t -> { t.setDescription("Configure a Github repository for the project, creating it if necessary."); t.setGroup("build setup"); t.setGithubToken(project.getProperty("github.token")); t.setRepositoryName(project.getName()); t.setRepositoryDescription(project.getDescription()); }); tasks.named("configure", t -> { t.dependsOn("configureGithubRepository"); }); } }
/** * Initialize the Github configuration * * @param githubConfig Github configuration to initialize * @param project Project context */ @Defaults public void initializeGithubConfig(GithubConfig githubConfig, ProjectContext project) { githubConfig.setRepository(project.getName()); }
Nodes.setChildValue(dependencyNode, "groupId", this.project.getGroup()); Nodes.setChildValue(dependencyNode, "artifactId", artifact.getName()); Nodes.setChildValue(dependencyNode, "version", this.project.getVersion()); Nodes.setChildValue(dependencyNode, "scope", JavaPlugin.COMPILE_CONFIGURATION_NAME);
/** * Initialize the plugin bundle extension * * @param bundleExtension Plugin bundle extension to initialize * @param projectConfig Project configuration * @param project Project context */ @Defaults public void configureGradlePluginDevelopmentExtension(PluginBundleExtension bundleExtension, ProjectConfig projectConfig, ProjectContext project) { bundleExtension.setDescription(project.getDescription()); bundleExtension.setWebsite(projectConfig.getWebsiteUrl()); bundleExtension.setVcsUrl(projectConfig.getRepository().getWebsiteUrl()); for (PluginConfig plugin : bundleExtension.getPlugins()) { if (Strings.isNullOrEmpty(plugin.getDisplayName())) { plugin.setDisplayName(project.getDescription()); } } }
/** * Get a property from the project or the environment * * First looks up the property value in the project's properties. If the property is not set, converts the property * name to upper underscore format and checks if the value is set in the environment. * * @param name Property name * @return Property value or <code>null</code> if the property does not exist */ public @Nullable String getProperty(String name) { String env = toEnvName(name); String property = name.toLowerCase(); String value = System.getProperty(env); if (value == null) { value = (String) getProject().findProperty(property); } return value; }
/** * @see me.seeber.gradle.plugin.AbstractProjectConfigPlugin#initialize() */ @Override protected void initialize() { checkGradleVersion(); ProjectContext context = new ProjectContext(getProject()); getProject().getExtensions().add("projectContext", context); RepositoryHandler repositories = getProject().getRepositories(); repositories.add(repositories.mavenLocal()); repositories.add(repositories.mavenCentral()); repositories.add(repositories.maven(r -> r.setUrl("https://plugins.gradle.org/m2"))); repositories.add(repositories.jcenter()); getProject().getConfigurations().all(c -> { c.resolutionStrategy(s -> { s.preferProjectModules(); s.cacheChangingModulesFor(0, "seconds"); }); }); }
parameters.map("destinationDir", () -> projectContext.getProjectDir()); });
/** * Initialize the annotations configuration * * @param annotatedProject Annotations configuration to initialize * @param project Project context */ @Defaults public void initializeAnnotationsConfig(AnnotatedProject annotatedProject, ProjectContext project) { Matcher matcher = ID_PATTERN.matcher(project.getName()); if (matcher.matches()) { annotatedProject.setId(matcher.group(1)); } matcher = VERSION_PATTERN.matcher(project.getVersion().toString()); if (matcher.matches()) { annotatedProject.setVersion(matcher.group(1)); } }