use of org.commonjava.maven.ext.core.state.JSONState in project pom-manipulation-ext by release-engineering.
the class JSONManipulator method applyChanges.
/**
* Apply the json changes to the specified file(s).
*/
@Override
public Set<Project> applyChanges(final List<Project> projects) throws ManipulationException {
final JSONState state = session.getState(JSONState.class);
if (!session.isEnabled() || !state.isEnabled()) {
logger.debug(getClass().getSimpleName() + ": Nothing to do!");
return Collections.emptySet();
}
final Set<Project> changed = new HashSet<>();
final List<JSONState.JSONOperation> scripts = state.getJSONOperations();
for (final Project project : projects) {
if (project.isExecutionRoot()) {
for (JSONState.JSONOperation operation : scripts) {
internalApplyChanges(project, operation);
changed.add(project);
}
break;
}
}
return changed;
}
use of org.commonjava.maven.ext.core.state.JSONState in project pom-manipulation-ext by release-engineering.
the class JSONManipulator method init.
/**
* Initialize the {@link JSONState} state holder in the {@link ManipulationSession}. This state holder detects
* configuration from the Maven user properties (-D properties from the CLI) and makes it available for
* later.
*/
@Override
public void init(final ManipulationSession session) throws ManipulationException {
this.session = session;
session.setState(new JSONState(session.getUserProperties()));
}
use of org.commonjava.maven.ext.core.state.JSONState in project pom-manipulation-ext by release-engineering.
the class JSONManipulatorTest method testStateConstructionNoEscape.
@Test(expected = ManipulationException.class)
public void testStateConstructionNoEscape() throws ManipulationException {
Properties p = new Properties();
p.put("jsonUpdate", "amg-plugin-registry.json:$..plugins[0].description:CORS,and:controlling");
new JSONState(p);
}
use of org.commonjava.maven.ext.core.state.JSONState in project pom-manipulation-ext by release-engineering.
the class JSONManipulatorTest method testStateConstructionEscaping.
@Test
public void testStateConstructionEscaping() throws ManipulationException {
Properties p = new Properties();
p.put("jsonUpdate", "amg-plugin-registry.json:$xpath-with\\:and\\,:replace with space and \\,\\:controlling\\:access_to_resources_outside_of_an_originating_domain\\,and_to_this_domain.");
JSONState js = new JSONState(p);
}
Aggregations