-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[MNG-8232] Introduce ModelTransformer
# Conflicts: # api/maven-api-spi/src/main/resources/META-INF/maven/org.apache.maven.api.di.Inject
- Loading branch information
Showing
8 changed files
with
150 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
78 changes: 78 additions & 0 deletions
78
api/maven-api-spi/src/main/java/org/apache/maven/api/spi/ModelTransformer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
package org.apache.maven.api.spi; | ||
|
||
import org.apache.maven.api.annotations.Experimental; | ||
import org.apache.maven.api.annotations.Nonnull; | ||
import org.apache.maven.api.model.Model; | ||
import org.apache.maven.api.services.ModelTransformerException; | ||
|
||
/** | ||
* Marker interface for model transformers. | ||
* | ||
* @since 4.0.0 | ||
*/ | ||
@Experimental | ||
public interface ModelTransformer extends SpiService { | ||
|
||
/** | ||
* Apply a transformation on the file model. | ||
* | ||
* This method will be called on each file model being loaded, | ||
* just before validation. | ||
* | ||
* @param model the input model | ||
* @return the transformed model, or the input model if no transformation is needed | ||
* @throws ModelTransformerException | ||
*/ | ||
@Nonnull | ||
default Model transformFileModel(@Nonnull Model model) throws ModelTransformerException { | ||
return model; | ||
} | ||
|
||
/** | ||
* Apply a transformation on the raw models. | ||
* | ||
* This method will be called on each raw model being loaded, | ||
* just before validation. | ||
* | ||
* @param model the input model | ||
* @return the transformed model, or the input model if no transformation is needed | ||
* @throws ModelTransformerException | ||
*/ | ||
@Nonnull | ||
default Model transformRawModel(@Nonnull Model model) throws ModelTransformerException { | ||
return model; | ||
} | ||
|
||
/** | ||
* Apply a transformation on the effective models. | ||
* | ||
* This method will be called on each effective model being loaded, | ||
* just before validation. | ||
* | ||
* @param model the input model | ||
* @return the transformed model, or the input model if no transformation is needed | ||
* @throws ModelTransformerException | ||
*/ | ||
@Nonnull | ||
default Model transformEffectiveModel(@Nonnull Model model) throws ModelTransformerException { | ||
return model; | ||
} | ||
} |
42 changes: 42 additions & 0 deletions
42
api/maven-api-spi/src/main/java/org/apache/maven/api/spi/ModelTransformerException.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
package org.apache.maven.api.spi; | ||
|
||
import org.apache.maven.api.annotations.Experimental; | ||
import org.apache.maven.api.services.MavenException; | ||
|
||
@Experimental | ||
public class ModelTransformerException extends MavenException { | ||
|
||
public ModelTransformerException() { | ||
this(null, null); | ||
} | ||
|
||
public ModelTransformerException(String message) { | ||
this(message, null); | ||
} | ||
|
||
public ModelTransformerException(Throwable cause) { | ||
this(null, cause); | ||
} | ||
|
||
public ModelTransformerException(String message, Throwable cause) { | ||
super(message, cause); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters