Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/*
* Copyright 2015-2023 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.grails.cli.profile
import java.util.regex.Matcher
import java.util.regex.Pattern
import groovy.transform.CompileStatic
import groovy.transform.ToString
import jline.console.completer.ArgumentCompleter
import jline.console.completer.Completer
import org.eclipse.aether.artifact.DefaultArtifact
import org.eclipse.aether.graph.Dependency
import org.eclipse.aether.graph.Exclusion
import org.eclipse.aether.util.graph.selector.ExclusionDependencySelector
import org.yaml.snakeyaml.LoaderOptions
import org.yaml.snakeyaml.Yaml
import org.yaml.snakeyaml.constructor.SafeConstructor
import grails.io.IOUtils
import grails.util.BuildSettings
import grails.util.CosineSimilarity
import org.grails.build.parsing.CommandLine
import org.grails.build.parsing.ScriptNameResolver
import org.grails.cli.interactive.completers.StringsCompleter
import org.grails.cli.profile.commands.CommandRegistry
import org.grails.cli.profile.commands.DefaultMultiStepCommand
import org.grails.cli.profile.commands.script.GroovyScriptCommand
import org.grails.config.NavigableMap
import org.grails.io.support.Resource
import static org.grails.cli.profile.ProfileUtil.createDependency
/**
* Abstract implementation of the profile class
*
* @author Graeme Rocher
* @since 3.1
*/
@CompileStatic
@ToString(includes = ['name'])
abstract class AbstractProfile implements Profile {
protected final Resource profileDir
protected String name
protected List parentProfiles
protected Map commandsByName
protected NavigableMap navigableConfig
protected ProfileRepository profileRepository
protected List dependencies = []
protected List repositories = []
protected List parentNames = []
protected List buildRepositories = []
protected List buildPlugins = []
protected List buildExcludes = []
protected List skeletonExcludes = []
protected List binaryExtensions = []
protected List executablePatterns = []
protected final List internalCommands = []
protected List buildMerge = null
protected List features = []
protected Set defaultFeaturesNames = []
protected Set requiredFeatureNames = []
protected String parentTargetFolder
protected final ClassLoader classLoader
protected ExclusionDependencySelector exclusionDependencySelector = new ExclusionDependencySelector()
protected String description = ''
protected String instructions = ''
protected String version = BuildSettings.package.implementationVersion
AbstractProfile(Resource profileDir) {
this(profileDir, AbstractProfile.getClassLoader())
}
AbstractProfile(Resource profileDir, ClassLoader classLoader) {
this.classLoader = classLoader
this.profileDir = profileDir
URL url = profileDir.getURL()
File jarFile = IOUtils.findJarFile(url)
Pattern pattern = ~/.+-(\d.+)\.jar/
String path
if (jarFile != null) {
path = jarFile.name
}
else if (url != null) {
String p = url.path
path = p.substring(0, p.indexOf('.jar') + 4)
}
if (path) {
Matcher matcher = pattern.matcher(path as CharSequence)
if (matcher.matches()) {
this.version = matcher.group(1)
}
}
}
@Override
String getName() {
name
}
String getVersion() {
version
}
protected void initialize() {
Resource profileYml = profileDir.createRelative('profile.yml')
Map profileConfig = new Yaml(new SafeConstructor(new LoaderOptions())).