Skip to content

Commit

Permalink
Use properties of grace-bom as variables for CreateAppCommand
Browse files Browse the repository at this point in the history
Closes gh-218
  • Loading branch information
rainboyan committed Mar 28, 2024
1 parent 86abb4f commit 906b727
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2012-2023 the original author or authors.
* Copyright 2012-2024 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.
Expand All @@ -18,6 +18,7 @@
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Properties;

/**
* {@link DependencyManagement} that delegates to one or more {@link DependencyManagement}
Expand All @@ -28,17 +29,25 @@
*/
public class CompositeDependencyManagement implements DependencyManagement {

private final Properties properties = new Properties();

private final List<DependencyManagement> delegates;

private final List<Dependency> dependencies = new ArrayList<>();

public CompositeDependencyManagement(DependencyManagement... delegates) {
this.delegates = Arrays.asList(delegates);
for (DependencyManagement delegate : delegates) {
this.properties.putAll(delegate.getProperties());
this.dependencies.addAll(delegate.getDependencies());
}
}

@Override
public Properties getProperties() {
return this.properties;
}

@Override
public List<Dependency> getDependencies() {
return this.dependencies;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2012-2023 the original author or authors.
* Copyright 2012-2024 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.
Expand All @@ -16,6 +16,7 @@
package org.grails.cli.compiler.dependencies;

import java.util.List;
import java.util.Properties;

/**
* An encapsulation of dependency management information.
Expand All @@ -25,6 +26,13 @@
*/
public interface DependencyManagement {

/**
* Returns the managed properties.
*
* @return the managed properties
*/
Properties getProperties();

/**
* Returns the managed dependencies.
*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2012-2023 the original author or authors.
* Copyright 2012-2024 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.
Expand All @@ -19,6 +19,7 @@
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Properties;

import org.apache.maven.model.Model;

Expand All @@ -32,11 +33,14 @@
*/
public class MavenModelDependencyManagement implements DependencyManagement {

private final Properties properties;

private final List<Dependency> dependencies;

private final Map<String, Dependency> byArtifactId = new LinkedHashMap<>();

public MavenModelDependencyManagement(Model model) {
this.properties = model.getProperties();
this.dependencies = extractDependenciesFromModel(model);
for (Dependency dependency : this.dependencies) {
this.byArtifactId.put(dependency.getArtifactId(), dependency);
Expand All @@ -57,6 +61,11 @@ private static List<Dependency> extractDependenciesFromModel(Model model) {
return dependencies;
}

@Override
public Properties getProperties() {
return this.properties;
}

@Override
public List<Dependency> getDependencies() {
return this.dependencies;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,9 @@ class CreateAppCommand extends ArgumentCompletingCommand implements ProfileRepos
if (grailsGradlePluginVersion != null) {
variables['grails-gradle-plugin.version'] = grailsGradlePluginVersion
}
mpr.profileDependencyVersions.getProperties().each {
variables[it.key.toString()] = it.value.toString()
}
}

Path appFullDirectory = Paths.get(cmd.baseDir.path, appname)
Expand Down

0 comments on commit 906b727

Please sign in to comment.