Skip to content

Commit 9bad973

Browse files
authored
Rework POM transformation (#169)
Reused existing good codebase to implement existing transformations.
1 parent 918fa36 commit 9bad973

File tree

22 files changed

+1852
-347
lines changed

22 files changed

+1852
-347
lines changed

it/toolbox-plugin-its/src/it/plugin-versions/expected-pom.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
<artifactId>versions</artifactId>
1515
<version>1.0.0</version>
1616
<properties>
17+
<data><![CDATA[some data]]></data>
1718
<first.version>1.1</first.version>
1819
<third.version>1.1</third.version>
1920
</properties>

it/toolbox-plugin-its/src/it/plugin-versions/pom.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
<artifactId>versions</artifactId>
1515
<version>1.0.0</version>
1616
<properties>
17+
<data><![CDATA[some data]]></data>
1718
<first.version>1.0</first.version>
1819
<third.version>1.0</third.version>
1920
</properties>

it/toolbox-plugin-its/src/it/versions/expected-pom.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
<artifactId>versions</artifactId>
1515
<version>1.0.0</version>
1616
<properties>
17+
<data><![CDATA[some data]]></data>
1718
<first.version>1.1</first.version>
1819
<third.version>1.1</third.version>
1920
</properties>

it/toolbox-plugin-its/src/it/versions/pom.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
<artifactId>versions</artifactId>
1515
<version>1.0.0</version>
1616
<properties>
17+
<data><![CDATA[some data]]></data>
1718
<first.version>1.0</first.version>
1819
<third.version>1.0</third.version>
1920
</properties>

pom.xml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -272,11 +272,11 @@
272272
<version>${version.jline}</version>
273273
</dependency>
274274

275-
<!-- POM tuner -->
275+
<!-- POM editing -->
276276
<dependency>
277-
<groupId>org.l2x6.pom-tuner</groupId>
278-
<artifactId>pom-tuner</artifactId>
279-
<version>4.4.0</version>
277+
<groupId>org.jdom</groupId>
278+
<artifactId>jdom2</artifactId>
279+
<version>2.0.6.1</version>
280280
</dependency>
281281

282282
<dependency>

shared/pom.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -108,10 +108,10 @@
108108
<artifactId>search-backend-smo</artifactId>
109109
</dependency>
110110

111-
<!-- POM tuner -->
111+
<!-- POM editing -->
112112
<dependency>
113-
<groupId>org.l2x6.pom-tuner</groupId>
114-
<artifactId>pom-tuner</artifactId>
113+
<groupId>org.jdom</groupId>
114+
<artifactId>jdom2</artifactId>
115115
</dependency>
116116

117117
<!-- Commons Compress (unpack) -->

shared/src/main/java/eu/maveniverse/maven/toolbox/shared/FileUtils.java

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,9 @@
11
/*
2-
* Licensed to the Apache Software Foundation (ASF) under one
3-
* or more contributor license agreements. See the NOTICE file
4-
* distributed with this work for additional information
5-
* regarding copyright ownership. The ASF licenses this file
6-
* to you under the Apache License, Version 2.0 (the
7-
* "License"); you may not use this file except in compliance
8-
* with the License. You may obtain a copy of the License at
9-
*
10-
* http://www.apache.org/licenses/LICENSE-2.0
11-
*
12-
* Unless required by applicable law or agreed to in writing,
13-
* software distributed under the License is distributed on an
14-
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15-
* KIND, either express or implied. See the License for the
16-
* specific language governing permissions and limitations
17-
* under the License.
2+
* Copyright (c) 2023-2024 Maveniverse Org.
3+
* All rights reserved. This program and the accompanying materials
4+
* are made available under the terms of the Eclipse Public License v2.0
5+
* which accompanies this distribution, and is available at
6+
* https://www.eclipse.org/legal/epl-v20.html
187
*/
198
package eu.maveniverse.maven.toolbox.shared;
209

shared/src/main/java/eu/maveniverse/maven/toolbox/shared/ToolboxCommando.java

Lines changed: 28 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -405,24 +405,6 @@ Result<Map<Artifact, List<Version>>> versions(
405405

406406
// POM editing
407407

408-
/**
409-
* The version operation mode to apply.
410-
*/
411-
enum Op {
412-
/**
413-
* Always add: if exists "update" version, if not exist, create new entry with it.
414-
*/
415-
UPSERT,
416-
/**
417-
* Add only if it exists: "update" version, otherwise no-op.
418-
*/
419-
UPDATE,
420-
/**
421-
* Remove if exists.
422-
*/
423-
DELETE
424-
}
425-
426408
interface EditSession extends Closeable {
427409
Path editedPom();
428410
}
@@ -462,12 +444,34 @@ default List<Artifact> calculateLatest(
462444
: versionSelector.apply(e.getKey(), e.getValue())))
463445
.collect(Collectors.toList());
464446
}
447+
/**
448+
* The operation subject to apply to.
449+
*/
450+
enum OpSubject {
451+
MANAGED_PLUGINS,
452+
PLUGINS,
453+
MANAGED_DEPENDENCIES,
454+
DEPENDENCIES
455+
}
465456

466-
Result<List<Artifact>> doManagedPlugins(EditSession es, Op op, Source<Artifact> artifacts) throws Exception;
467-
468-
Result<List<Artifact>> doPlugins(EditSession es, Op op, Source<Artifact> artifacts) throws Exception;
469-
470-
Result<List<Artifact>> doManagedDependencies(EditSession es, Op op, Source<Artifact> artifacts) throws Exception;
457+
/**
458+
* The operation mode to apply.
459+
*/
460+
enum Op {
461+
/**
462+
* Always alter: like if exists "update" version, if does not exist, create new entry with provided one.
463+
*/
464+
UPSERT,
465+
/**
466+
* Alter it only if it exists: like "update" version, otherwise no-op.
467+
*/
468+
UPDATE,
469+
/**
470+
* Remove, if exists.
471+
*/
472+
DELETE
473+
}
471474

472-
Result<List<Artifact>> doDependencies(EditSession es, Op op, Source<Artifact> artifacts) throws Exception;
475+
Result<List<Artifact>> doEdit(EditSession es, OpSubject subject, Op op, Source<Artifact> artifacts)
476+
throws Exception;
473477
}

0 commit comments

Comments
 (0)