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

Fix issue with generated model name in generated pojos #918

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
@@ -1,14 +1,34 @@
package com.regnosys.rosetta.config.file;


import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.net.MalformedURLException;
import java.net.URL;
import java.nio.file.Paths;
import java.util.Optional;

import javax.inject.Provider;

public class RosettaConfigurationFileProvider implements Provider<URL> {
public static final String FILE_NAME = "rosetta-config.yml";
private static final Logger LOGGER = LoggerFactory.getLogger(RosettaConfigurationFileProvider.class);
public static final String ROSETTA_CONFIG_FILE_PROPERTY = "rosetta.config.file";

@Override
public URL get() {
return Thread.currentThread().getContextClassLoader().getResource(FILE_NAME);
return Optional.ofNullable(System.getProperty(ROSETTA_CONFIG_FILE_PROPERTY))
.map(this::getUrl)
.orElse(Thread.currentThread().getContextClassLoader().getResource(FILE_NAME));
}

private URL getUrl(String rosettaConfigFile) {
try {
return Paths.get(rosettaConfigFile).toUri().toURL();
} catch (MalformedURLException e) {
LOGGER.error("System variable path to rosetta config file invalid: {}", rosettaConfigFile, e);
return null;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,12 @@
package com.regnosys.rosetta.maven;

import java.io.File;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;

import com.regnosys.rosetta.config.file.RosettaConfigurationFileProvider;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugins.annotations.Parameter;
import org.eclipse.xtext.builder.standalone.LanguageAccess;
Expand All @@ -38,6 +41,9 @@
// which makes this implementation too hacky.
public abstract class AbstractRosettaGeneratorMojo extends AbstractXtextGeneratorMojo {

@Parameter(property = "rosetta.config.file")
private String rosettaConfigFile;

@Parameter(defaultValue = "true")
boolean addOutputDirectoriesToCompileSourceRoots = Boolean.TRUE;

Expand Down Expand Up @@ -76,6 +82,9 @@ protected Module createModule() {

@Override
protected void internalExecute() throws MojoExecutionException {
if (rosettaConfigFile != null) {
System.setProperty(RosettaConfigurationFileProvider.ROSETTA_CONFIG_FILE_PROPERTY, rosettaConfigFile);
}
if (addOutputDirectoriesToCompileSourceRoots) {
configureMavenOutputs();
}
Expand Down