Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

1517 discovery of template sets #1585

Merged
Merged
Show file tree
Hide file tree
Changes from 74 commits
Commits
Show all changes
83 commits
Select commit Hold shift + click to select a range
84e84cd
First implementation of settings.xml mapping
Zylesto Sep 19, 2022
ce9f29a
Completed mapping of the needed components, refactoring, added JavaDo…
Zylesto Sep 20, 2022
9e7aff7
Added test class, removed unnecessary code
Zylesto Sep 20, 2022
f08db65
#1530 added maven settings password decryption
jan-vcapgemini Sep 21, 2022
2a059f5
#1530 adjusted test method name
jan-vcapgemini Sep 21, 2022
f2d10c3
Added tests, did refactoring
Zylesto Sep 21, 2022
185a88f
Added missing JavaDocs, tests are now using asserThat(), more improve…
Zylesto Sep 22, 2022
470fef5
#1530 added basic authentication type
jan-vcapgemini Sep 22, 2022
d5ab73e
#1530 renamed REST search API constants
jan-vcapgemini Sep 22, 2022
3ecf453
#1530 handle template-set.xml
jan-vcapgemini Sep 22, 2022
c64c221
#1530 added some fixes
jan-vcapgemini Sep 22, 2022
2ffebe7
#1530 cleaned up exceptions
jan-vcapgemini Sep 22, 2022
8a1114c
Switched from javax to jakarta, resolved comments from the pull request
Zylesto Sep 23, 2022
799d3f8
Tidied up code
Zylesto Sep 23, 2022
695a195
Changed path generation
Zylesto Sep 26, 2022
db54378
Added unmarshalling for mirrors, added loading of active profiles, ad…
Zylesto Sep 28, 2022
63d2d64
added function, which returns repositories of all active profiles
Zylesto Sep 28, 2022
a21b028
#1530 improved log messages
jan-vcapgemini Sep 28, 2022
4342cc5
Added utils to operate with mirrors specified in maven's settings.xml
Zylesto Sep 28, 2022
22ecc10
Optimized MavenSettingsUtilTest, added first code of MavenMirrorUtilTest
Zylesto Sep 28, 2022
e79ca1d
Fixed bugs, added tests for matchPattern
Zylesto Sep 29, 2022
7f55ba3
Completed MavenMirrorUtil class, completed tests
Zylesto Sep 30, 2022
db383c7
determined active profiles, added method to determine repositories of…
Zylesto Oct 4, 2022
b9beb7f
Minor optimisations
Zylesto Oct 5, 2022
1aeac3d
Added collection of servers private key and passphrase
Zylesto Oct 11, 2022
ace51f2
Refactoring of classes in a new maven module
Zylesto Oct 12, 2022
a6cbffa
#1530 added exception messages to constants
jan-vcapgemini Oct 12, 2022
ebf601c
#1530 adjusted exception handling
jan-vcapgemini Oct 12, 2022
93fd81f
Merge branch 'template-set-deployables' into 1517-discovery-of-templa…
Zylesto Oct 12, 2022
37a5eb0
Merge branch '1530-discover-settings-xml-credentials' into 1517-disco…
Zylesto Oct 12, 2022
2198b0d
Fixed merge bugs
Zylesto Oct 12, 2022
efdba12
#1517 Refactoring
Zylesto Oct 12, 2022
fc699a1
#1517 Added proxy to http client
Zylesto Oct 12, 2022
5a9b7ef
#1517 added eclipse project files
jan-vcapgemini Oct 13, 2022
2f803dd
Removed MavenSettingsUtil
Zylesto Oct 13, 2022
26a5f91
Merge branch '1517-discovery-of-template-sets' of https://github.com/…
Zylesto Oct 13, 2022
47267b0
#1517 changed the process of getting active profiles
Zylesto Oct 14, 2022
a11bd03
#1517 added multiple tests
Zylesto Oct 14, 2022
d73d682
#1517 improved WireMock log messages
jan-vcapgemini Oct 14, 2022
68b1b51
Merge branch '1517-discovery-of-template-sets' of https://github.com/…
jan-vcapgemini Oct 14, 2022
579a64d
#1517 introduced server credentials
jan-vcapgemini Oct 17, 2022
7f29166
#1517 Added proxy util and tests
Zylesto Oct 17, 2022
4bceabf
#1517 removed exceptions
jan-vcapgemini Oct 17, 2022
80d0819
Merge branch '1517-discovery-of-template-sets' of https://github.com/…
jan-vcapgemini Oct 17, 2022
95bedea
#1517 Reworked MavenProxyUtil, updated tests
Zylesto Oct 19, 2022
6a8ffad
#1517 replaced more exceptions with log messages
jan-vcapgemini Oct 19, 2022
aea9988
Merge branch '1517-discovery-of-template-sets' of https://github.com/…
jan-vcapgemini Oct 19, 2022
95e433b
#1517 implemented requested changes
jan-vcapgemini Oct 20, 2022
8845093
#1517 Combined ArtifactRetriever with MavenSearch
Zylesto Oct 21, 2022
debd619
#1517 ArtifactRetriever test preperation
Zylesto Oct 21, 2022
3b9aa70
#1517 added first ArtifactRetriever tests
jan-vcapgemini Oct 21, 2022
a6289d6
#1517 added proxy server authentication
jan-vcapgemini Oct 21, 2022
5df0b0c
#1517 split test classes
jan-vcapgemini Oct 24, 2022
a6b7bf8
#1517 re-organized test resources
jan-vcapgemini Oct 24, 2022
41bcbd0
#1517 fixed ArtifactRetriever proxy test
jan-vcapgemini Oct 25, 2022
c63b264
#1517 Added ArtivactRetrieverReader
Zylesto Oct 25, 2022
f642165
Merge branch '1517-discovery-of-template-sets' of https://github.com/…
Zylesto Oct 26, 2022
a3a7f4c
Removed unused test
Zylesto Oct 26, 2022
9854b78
#1517 removed util package from mavensearch
jan-vcapgemini Nov 3, 2022
34833f9
#1517 optimizations
jan-vcapgemini Nov 3, 2022
5b8e0bd
#1517 renamed reader models
jan-vcapgemini Nov 4, 2022
c222183
#1517 removed util package from mavensearch
jan-vcapgemini Nov 4, 2022
3e9951c
#1517 added template set version and tests
jan-vcapgemini Nov 4, 2022
e81e456
#1517 renamed MavenReaderTest resource folder
jan-vcapgemini Nov 4, 2022
6b81f91
#1517 set java version to 11
jan-vcapgemini Nov 4, 2022
9b66633
#1517 Removed java 11 dependency
Zylesto Nov 7, 2022
9c8f476
#1517 removed java 11 dependencies
Zylesto Nov 7, 2022
e865b32
#1517 replaced List.of with simple List
jan-vcapgemini Nov 8, 2022
0540319
#1517 implemented requested changes
jan-vcapgemini Nov 9, 2022
87504b1
#1517 implemented requested changes
jan-vcapgemini Nov 9, 2022
827fc1a
#1517 implemented requested changes
jan-vcapgemini Nov 9, 2022
a373555
#1517 implemented requested changes
jan-vcapgemini Nov 9, 2022
a400a73
#1517 adjusted javadocs and class name
jan-vcapgemini Nov 9, 2022
2d9cda4
#1517 Removed exceptions from tests, added javaDocs
Zylesto Nov 11, 2022
c992176
#1517 implemented requested changes
jan-vcapgemini Nov 11, 2022
d6776a5
#1517 adjusted artifact reader
jan-vcapgemini Nov 14, 2022
bb81d85
#1517 introduced new TemplateSet entity
jan-vcapgemini Nov 14, 2022
594ed56
#1517 implemented requested changes
jan-vcapgemini Dec 12, 2022
9439893
#1517 implemented requested changes
jan-vcapgemini Dec 14, 2022
2f9bcf5
#1517 implemented requested changes
jan-vcapgemini Dec 14, 2022
dfab702
#1517 #1517 implemented requested changes
jan-vcapgemini Dec 14, 2022
e2b5c0b
#1517 implemented requested changes
jan-vcapgemini Dec 14, 2022
1c17fdb
#1517 implemented requested changes
jan-vcapgemini Dec 14, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion cobigen-templates/pom.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<groupId>com.devonfw.cobigen.templates</groupId>
<artifactId>templates-parent</artifactId>
Expand Down
18 changes: 15 additions & 3 deletions cobigen/cobigen-core-api/pom.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<artifactId>core-api</artifactId>
<name>CobiGen Core - API</name>
Expand Down Expand Up @@ -66,6 +65,19 @@
<version>2.27.2</version>
<scope>test</scope>
</dependency>

<!-- Needed for settings.xml decryption -->
<dependency>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-sec-dispatcher</artifactId>
<version>2.0</version>
</dependency>

<dependency>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-cipher</artifactId>
<version>2.0</version>
</dependency>
</dependencies>

<build>
Expand All @@ -83,4 +95,4 @@
</plugin>
</plugins>
</build>
</project>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ public class ConfigurationConstants {
/** Templates configuration file name */
public static final String TEMPLATES_CONFIG_FILENAME = "templates.xml";

/** Template Set configuration file name */
public static final String TEMPLATE_SET_CONFIG_FILENAME = "template-set.xml";

/** Filename of the {@link Properties} used to customize cobigen properties and template relocation. */
public static final String COBIGEN_PROPERTIES = "cobigen.properties";

Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,6 @@

import com.devonfw.cobigen.api.constants.MavenConstants;
import com.devonfw.cobigen.api.exception.CobiGenRuntimeException;
import com.devonfw.cobigen.api.exception.RestSearchResponseException;
import com.devonfw.cobigen.api.util.to.SearchResponseFactory;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.google.common.collect.Lists;
import com.google.common.hash.Hashing;
import com.google.common.io.ByteSource;
Expand All @@ -42,6 +39,12 @@ public class MavenUtil {
/** Logger instance. */
private static final Logger LOG = LoggerFactory.getLogger(MavenUtil.class);

/** Stores the user home */
private static File userHome;

/** Stores the maven path */
private static Path mavenPath;

/**
* Executes a Maven class path build command which will download all the transitive dependencies needed for the CLI
*
Expand All @@ -54,7 +57,7 @@ public static void cacheMavenClassPath(Path pomFile, Path cpFile) {

LOG.info("Calculating class path for {} and downloading the needed maven dependencies. Please be patient...",
pomFile);
List<String> args = Lists.newArrayList(SystemUtil.determineMvnPath().toString(), "dependency:build-classpath",
List<String> args = Lists.newArrayList(determineMvnPath().toString(), "dependency:build-classpath",
"-Dmdep.outputFile=" + cpFile.toString());
if (pomFile.getFileSystem().provider().getClass().getSimpleName().equals("ZipFileSystemProvider")) {
pomFile = createCachedPomFromJar(pomFile, cpFile.getParent());
Expand All @@ -77,7 +80,7 @@ public static void resolveDependencies(Path mvnProjectRoot) {
LOG.info(
"Resolving maven dependencies for maven project {} to be able to make use of reflection in templates. Please be patient...",
mvnProjectRoot);
List<String> args = Lists.newArrayList(SystemUtil.determineMvnPath().toString(), "dependency:resolve");
List<String> args = Lists.newArrayList(determineMvnPath().toString(), "dependency:resolve");
runCommand(mvnProjectRoot, args);
LOG.debug("Downloaded dependencies successfully.");
}
Expand All @@ -99,7 +102,7 @@ public static void resolveDependencies(Path pomFile, Path mvnProjectRoot) {
pomFile = createCachedPomFromJar(pomFile, mvnProjectRoot);
}

List<String> args = Lists.newArrayList(SystemUtil.determineMvnPath().toString());
List<String> args = Lists.newArrayList(determineMvnPath().toString());
args.add("-f");
args.add(pomFile.toString());
args.add("dependency:resolve");
Expand Down Expand Up @@ -185,19 +188,57 @@ public static String generatePomFileHash(Path pomFile) {
return pomFileHash;
}

/**
* Determines maven home path if it was not set yet and returns it
*
* @return Path to maven home
*/
private static Path determineMvnPath() {

if (mavenPath == null) {
mavenPath = SystemUtil.determineMvnPath();
}
return mavenPath;
}

/**
* Determines maven home path if it was not set yet and returns it
*
* @return File path to user home
*/
private static File getUserHome() {

if (userHome == null) {
userHome = SystemUtils.getUserHome();
}
return userHome;
}

/**
* @return the maven repository path
*/
public static Path determineMavenRepositoryPath() {

LOG.info("Determine maven repository path");
String m2Repo = runCommand(SystemUtils.getUserHome().toPath(),
Lists.newArrayList(SystemUtil.determineMvnPath().toString(), "help:evaluate",
"-Dexpression=settings.localRepository", "-DforceStdout"));
String m2Repo = runCommand(getUserHome().toPath(), Lists.newArrayList(determineMvnPath().toString(),
"help:evaluate", "-Dexpression=settings.localRepository", "-DforceStdout"));
LOG.debug("Determined {} as maven repository path.", m2Repo);
return Paths.get(m2Repo);
}

/**
* Returns maven's settings.xml as a string by using maven evaluate
*
* @return the maven's settings.xml as string
*/
public static String determineMavenSettings() {

LOG.info("Determine content of maven's settings.xml");
String mavenSettings = runCommand(getUserHome().toPath(),
Lists.newArrayList(determineMvnPath().toString(), "help:evaluate", "-Dexpression=settings", "-DforceStdout"));
return mavenSettings;
}

/**
* Execute any command in the given execution directory with the given arguments
*
Expand Down Expand Up @@ -343,27 +384,4 @@ public static Path getProjectRoot(Path inputFile, boolean topLevel) {
LOG.debug("Project root could not be found.");
return null;
}

/**
* Retrieves a list of download URLs by groupId from the specified repository search REST API using authentication
* with bearer token
*
* @param baseUrl String of the repository server URL
* @param groupId the groupId to search for
* @param authToken bearer token to use for authentication
* @return List of artifact download URLS or null if an error occurred
*/
public static List<URL> retrieveMavenArtifactsByGroupId(String baseUrl, String groupId, String authToken) {

try {

return SearchResponseFactory.searchArtifactDownloadLinks(baseUrl, groupId, authToken);
} catch (RestSearchResponseException | JsonProcessingException | MalformedURLException e) {
LOG.error("Unable to get artifacts from {} by groupId {}", baseUrl, groupId, e);
// TODO: Handle Eclipse, CLI and MavenPlugin here (f.e. with a new Exception)
return null;
}

}

}
Loading