Search in sources :

Example 1 with GAV

use of io.quarkus.maven.dependency.GAV in project quarkus by quarkusio.

the class GradleApplicationModelBuilder method initProjectModuleAndBuildPaths.

private WorkspaceModule.Mutable initProjectModuleAndBuildPaths(final Project project, ResolvedArtifact resolvedArtifact, ApplicationModelBuilder appModel, final ResolvedDependencyBuilder appDep, final JavaPluginConvention javaExt, PathList.Builder buildPaths, String sourceName, boolean test) {
    appDep.setWorkspaceModule().setReloadable();
    final WorkspaceModule.Mutable projectModule = appModel.getOrCreateProjectModule(new GAV(resolvedArtifact.getModuleVersion().getId().getGroup(), resolvedArtifact.getName(), resolvedArtifact.getModuleVersion().getId().getVersion()), project.getProjectDir(), project.getBuildDir()).setBuildFile(project.getBuildFile().toPath());
    final String classifier = toNonNullClassifier(resolvedArtifact.getClassifier());
    initProjectModule(project, projectModule, javaExt.getSourceSets().findByName(sourceName), sourceName, classifier);
    collectDestinationDirs(projectModule.getSources(classifier).getSourceDirs(), buildPaths);
    collectDestinationDirs(projectModule.getSources(classifier).getResourceDirs(), buildPaths);
    appModel.addReloadableWorkspaceModule(new GACT(resolvedArtifact.getModuleVersion().getId().getGroup(), resolvedArtifact.getName(), classifier, ArtifactCoords.TYPE_JAR));
    return projectModule;
}
Also used : GACT(io.quarkus.maven.dependency.GACT) WorkspaceModule(io.quarkus.bootstrap.workspace.WorkspaceModule) DefaultWorkspaceModule(io.quarkus.bootstrap.workspace.DefaultWorkspaceModule) GAV(io.quarkus.maven.dependency.GAV)

Example 2 with GAV

use of io.quarkus.maven.dependency.GAV in project quarkus by quarkusio.

the class GradleApplicationModelBuilder method getProjectArtifact.

public static ResolvedDependency getProjectArtifact(Project project, LaunchMode mode) {
    final ResolvedDependencyBuilder appArtifact = ResolvedDependencyBuilder.newInstance().setGroupId(project.getGroup().toString()).setArtifactId(project.getName()).setVersion(project.getVersion().toString());
    final JavaPluginConvention javaConvention = project.getConvention().findPlugin(JavaPluginConvention.class);
    if (javaConvention == null) {
        throw new GradleException("Failed to locate Java plugin extension in " + project.getPath());
    }
    final WorkspaceModule.Mutable mainModule = WorkspaceModule.builder().setModuleId(new GAV(appArtifact.getGroupId(), appArtifact.getArtifactId(), appArtifact.getVersion())).setModuleDir(project.getProjectDir().toPath()).setBuildDir(project.getBuildDir().toPath()).setBuildFile(project.getBuildFile().toPath());
    initProjectModule(project, mainModule, javaConvention.getSourceSets().findByName(SourceSet.MAIN_SOURCE_SET_NAME), SourceSet.MAIN_SOURCE_SET_NAME, ArtifactSources.MAIN);
    if (mode.equals(LaunchMode.TEST) || mode.equals(LaunchMode.DEVELOPMENT)) {
        initProjectModule(project, mainModule, javaConvention.getSourceSets().findByName(SourceSet.TEST_SOURCE_SET_NAME), SourceSet.TEST_SOURCE_SET_NAME, ArtifactSources.TEST);
    }
    final PathList.Builder paths = PathList.builder();
    collectDestinationDirs(mainModule.getMainSources().getSourceDirs(), paths);
    collectDestinationDirs(mainModule.getMainSources().getResourceDirs(), paths);
    return appArtifact.setWorkspaceModule(mainModule).setResolvedPaths(paths.build()).build();
}
Also used : JavaPluginConvention(org.gradle.api.plugins.JavaPluginConvention) GradleException(org.gradle.api.GradleException) PathList(io.quarkus.paths.PathList) WorkspaceModule(io.quarkus.bootstrap.workspace.WorkspaceModule) DefaultWorkspaceModule(io.quarkus.bootstrap.workspace.DefaultWorkspaceModule) ResolvedDependencyBuilder(io.quarkus.maven.dependency.ResolvedDependencyBuilder) GAV(io.quarkus.maven.dependency.GAV)

Example 3 with GAV

use of io.quarkus.maven.dependency.GAV in project quarkus by quarkusio.

the class LocalProject method toWorkspaceModule.

public WorkspaceModule toWorkspaceModule() {
    if (module != null) {
        return module;
    }
    final WorkspaceModule.Mutable moduleBuilder = WorkspaceModule.builder().setModuleId(new GAV(key.getGroupId(), key.getArtifactId(), getVersion())).setModuleDir(dir).setBuildDir(getOutputDir());
    final Build build = (modelBuildingResult == null ? getRawModel() : modelBuildingResult.getEffectiveModel()).getBuild();
    boolean addDefaultSourceSet = true;
    if (build != null && !build.getPlugins().isEmpty()) {
        for (Plugin plugin : build.getPlugins()) {
            if (!plugin.getArtifactId().equals("maven-jar-plugin")) {
                continue;
            }
            if (plugin.getExecutions().isEmpty()) {
                final DefaultArtifactSources src = processJarPluginExecutionConfig(plugin.getConfiguration(), false);
                if (src != null) {
                    addDefaultSourceSet = false;
                    moduleBuilder.addArtifactSources(src);
                }
            } else {
                for (PluginExecution e : plugin.getExecutions()) {
                    DefaultArtifactSources src = null;
                    if (e.getGoals().contains(ArtifactCoords.TYPE_JAR)) {
                        src = processJarPluginExecutionConfig(e.getConfiguration(), false);
                        addDefaultSourceSet &= !e.getId().equals("default-jar");
                    } else if (e.getGoals().contains("test-jar")) {
                        src = processJarPluginExecutionConfig(e.getConfiguration(), true);
                    }
                    if (src != null) {
                        moduleBuilder.addArtifactSources(src);
                    }
                }
            }
            break;
        }
    }
    if (addDefaultSourceSet) {
        moduleBuilder.addArtifactSources(new DefaultArtifactSources(ArtifactSources.MAIN, Collections.singletonList(new DefaultSourceDir(getSourcesSourcesDir(), getClassesDir())), collectMainResources(null)));
    }
    if (!moduleBuilder.hasTestSources()) {
        moduleBuilder.addArtifactSources(new DefaultArtifactSources(ArtifactSources.TEST, Collections.singletonList(new DefaultSourceDir(getTestSourcesSourcesDir(), getTestClassesDir())), collectTestResources(null)));
    }
    moduleBuilder.setBuildFile(getRawModel().getPomFile().toPath());
    moduleBuilder.setDependencyConstraints(getRawModel().getDependencyManagement() == null ? Collections.emptyList() : toArtifactDependencies(getRawModel().getDependencyManagement().getDependencies()));
    final Model model = modelBuildingResult == null ? rawModel : modelBuildingResult.getEffectiveModel();
    moduleBuilder.setDependencies(toArtifactDependencies(model.getDependencies()));
    return this.module = moduleBuilder.build();
}
Also used : DefaultArtifactSources(io.quarkus.bootstrap.workspace.DefaultArtifactSources) PluginExecution(org.apache.maven.model.PluginExecution) Build(org.apache.maven.model.Build) Model(org.apache.maven.model.Model) WorkspaceModule(io.quarkus.bootstrap.workspace.WorkspaceModule) GAV(io.quarkus.maven.dependency.GAV) DefaultSourceDir(io.quarkus.bootstrap.workspace.DefaultSourceDir) Plugin(org.apache.maven.model.Plugin)

Aggregations

WorkspaceModule (io.quarkus.bootstrap.workspace.WorkspaceModule)3 GAV (io.quarkus.maven.dependency.GAV)3 DefaultWorkspaceModule (io.quarkus.bootstrap.workspace.DefaultWorkspaceModule)2 DefaultArtifactSources (io.quarkus.bootstrap.workspace.DefaultArtifactSources)1 DefaultSourceDir (io.quarkus.bootstrap.workspace.DefaultSourceDir)1 GACT (io.quarkus.maven.dependency.GACT)1 ResolvedDependencyBuilder (io.quarkus.maven.dependency.ResolvedDependencyBuilder)1 PathList (io.quarkus.paths.PathList)1 Build (org.apache.maven.model.Build)1 Model (org.apache.maven.model.Model)1 Plugin (org.apache.maven.model.Plugin)1 PluginExecution (org.apache.maven.model.PluginExecution)1 GradleException (org.gradle.api.GradleException)1 JavaPluginConvention (org.gradle.api.plugins.JavaPluginConvention)1