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
IGNITE-11133: Refactoring of compatibility framework #5974
Open
avplatonov
wants to merge
1
commit into
apache:master
Choose a base branch
from
gridgain:ignite-gg-12486
base: master
Could not load branches
Branch not found: {{ refName }}
Could not load tags
Nothing to show
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
:: | ||
:: 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. | ||
:: | ||
|
||
@echo off | ||
|
||
set SCRIPT_DIR=%~dp0 | ||
set SCRIPT_DIR=%SCRIPT_DIR:~0,-1% | ||
|
||
if defined M2_HOME ( | ||
set MVN_CMD=%M2_HOME%\bin\mvn.bat | ||
) else ( | ||
set MVN_CMD=mvn | ||
) | ||
|
||
for /D %%F in ("%SCRIPT_DIR%"\..\ignite-versions\*) do ( | ||
IF EXIST "%%F\pom.xml" ( | ||
call "%MVN_CMD%" -s "%SCRIPT_DIR%\settings.xml" -f "%%F\pom.xml" clean package | ||
|
||
if ERRORLEVEL 1 exit \b | ||
) | ||
) |
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,60 @@ | ||
#!/bin/bash | ||
|
||
# | ||
# 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. | ||
# | ||
|
||
SCRIPT_DIR=$(cd $(dirname "$0"); pwd) | ||
|
||
if [ "${M2_HOME}" = "" ]; then | ||
MVN_CMD=mvn | ||
else | ||
MVN_CMD=${M2_HOME}/bin/mvn | ||
fi | ||
|
||
#Install custom source Maven plugin | ||
COMPATIBILITY_MODULE_DIR="$(dirname ${SCRIPT_DIR})" | ||
|
||
PLUGIN_DIR=$COMPATIBILITY_MODULE_DIR/ignite-filter-source-plugin | ||
|
||
CMD="${MVN_CMD} -f $PLUGIN_DIR/pom.xml clean install" | ||
|
||
echo "Executing: "${CMD} | ||
|
||
${CMD} | ||
|
||
ERROR=$? | ||
|
||
if [ ${ERROR} -ne 0 ]; then | ||
exit 1 | ||
fi | ||
|
||
for file in $SCRIPT_DIR/../ignite-versions/* | ||
do | ||
if [ -d ${file} ] && [ "$(basename ${file})" != "base" ]; then | ||
CMD="${MVN_CMD} -s $SCRIPT_DIR/settings.xml -f ${file}/pom.xml clean install" | ||
|
||
echo "Executing: "${CMD} | ||
|
||
${CMD} | ||
|
||
ERROR=$? | ||
|
||
if [ ${ERROR} -ne 0 ]; then | ||
exit 1 | ||
fi | ||
fi | ||
done |
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,5 @@ | ||
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 | ||
http://maven.apache.org/xsd/settings-1.0.0.xsd"> | ||
</settings> |
105 changes: 105 additions & 0 deletions
105
modules/compatibility/ignite-filter-source-plugin/pom.xml
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,105 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
|
||
<!-- | ||
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. | ||
--> | ||
|
||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
<groupId>org.apache.ignite</groupId> | ||
<artifactId>ignite-filter-source-plugin</artifactId> | ||
<packaging>maven-plugin</packaging> | ||
<version>1.0</version> | ||
|
||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-compiler-plugin</artifactId> | ||
<version>3.1</version> | ||
<configuration> | ||
<source>1.8</source> | ||
<target>1.8</target> | ||
</configuration> | ||
</plugin> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-plugin-plugin</artifactId> | ||
<version>3.6.0</version> | ||
<configuration> | ||
<!-- see https://issues.apache.org/jira/browse/MNG-5346 --> | ||
<skipErrorNoDescriptorsFound>true</skipErrorNoDescriptorsFound> | ||
</configuration> | ||
<executions> | ||
<execution> | ||
<id>mojo-descriptor</id> | ||
<goals> | ||
<goal>descriptor</goal> | ||
</goals> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
<plugin> | ||
<groupId>org.codehaus.mojo</groupId> | ||
<artifactId>build-helper-maven-plugin</artifactId> | ||
<executions> | ||
<execution> | ||
<phase>generate-sources</phase> | ||
<goals> | ||
<goal>add-source</goal> | ||
</goals> | ||
<configuration> | ||
<sources> | ||
<source>src/main/java</source> | ||
</sources> | ||
</configuration> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
|
||
<name>Ignite filter source maven plugin</name> | ||
<url>http://maven.apache.org</url> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>org.apache.maven</groupId> | ||
<artifactId>maven-core</artifactId> | ||
<version>3.0</version> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.apache.maven</groupId> | ||
<artifactId>maven-plugin-api</artifactId> | ||
<version>3.0</version> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.apache.maven.plugin-tools</groupId> | ||
<artifactId>maven-plugin-annotations</artifactId> | ||
<version>3.4</version> | ||
</dependency> | ||
|
||
<!-- https://mvnrepository.com/artifact/commons-io/commons-io --> | ||
<dependency> | ||
<groupId>commons-io</groupId> | ||
<artifactId>commons-io</artifactId> | ||
<version>2.6</version> | ||
</dependency> | ||
</dependencies> | ||
</project> |
127 changes: 127 additions & 0 deletions
127
...er-source-plugin/src/main/java/org/apache/ignite/maven/plugin/AddAndFilterSourceMojo.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,127 @@ | ||
/* | ||
* 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.ignite.maven.plugin; | ||
|
||
import java.io.File; | ||
import java.io.IOException; | ||
import java.nio.file.FileVisitResult; | ||
import java.nio.file.Files; | ||
import java.nio.file.Path; | ||
import java.nio.file.SimpleFileVisitor; | ||
import java.nio.file.attribute.BasicFileAttributes; | ||
import java.util.ArrayList; | ||
import java.util.List; | ||
import javax.inject.Inject; | ||
import org.apache.commons.io.FileUtils; | ||
import org.apache.maven.plugin.AbstractMojo; | ||
import org.apache.maven.plugin.MojoExecutionException; | ||
import org.apache.maven.plugins.annotations.LifecyclePhase; | ||
import org.apache.maven.plugins.annotations.Mojo; | ||
import org.apache.maven.plugins.annotations.Parameter; | ||
import org.apache.maven.project.MavenProject; | ||
|
||
@Mojo(name = "add-and-filter-source", defaultPhase = LifecyclePhase.GENERATE_SOURCES, threadSafe = true) | ||
public class AddAndFilterSourceMojo extends AbstractMojo { | ||
@Parameter(required = true) | ||
private String version; | ||
|
||
@Parameter(required = true) | ||
private File[] sources; | ||
|
||
@Parameter( readonly = true, defaultValue = "${project}") | ||
private MavenProject project; | ||
|
||
@Inject | ||
private FileVersionChecker fileVersionChecker; | ||
|
||
/** | ||
* Executes mojo. | ||
* | ||
* TODO: Introduce new mojo that will clean-up shared source folder after compilation. | ||
* | ||
* @throws MojoExecutionException If failed. | ||
*/ | ||
public void execute() throws MojoExecutionException { | ||
try { | ||
File sharedSourcesDir = prepareSharedSourcesDirectory(); | ||
|
||
for (int i = 0; i < sources.length; i++) { | ||
File sourceDir = sources[i]; | ||
File targetDir = new File(sharedSourcesDir, "source-" + i); | ||
|
||
// Deep-copy all sources to separate directory. | ||
FileUtils.copyDirectory(sourceDir, targetDir); | ||
|
||
List<File> notSatisfied = findFilesNotSatisfiedVersion(targetDir, version); | ||
|
||
// Delete such files. | ||
for (File file : notSatisfied) | ||
Files.delete(file.toPath()); | ||
|
||
project.addCompileSourceRoot(targetDir.getAbsolutePath()); | ||
} | ||
} | ||
catch (IOException e) { | ||
throw new MojoExecutionException("Failed to copy and filter sources", e); | ||
} | ||
} | ||
|
||
/** | ||
* | ||
*/ | ||
private File prepareSharedSourcesDirectory() throws IOException { | ||
File projectRoot = project.getFile().getParentFile(); | ||
|
||
File sharedSourcesDir = new File(projectRoot, "shared-sources"); | ||
|
||
if (Files.exists(sharedSourcesDir.toPath())) | ||
FileUtils.deleteDirectory(sharedSourcesDir); | ||
|
||
Files.createDirectory(sharedSourcesDir.toPath()); | ||
|
||
return sharedSourcesDir; | ||
} | ||
|
||
/** | ||
* @param rootDir Root directory. | ||
* @param version Version. | ||
*/ | ||
private List<File> findFilesNotSatisfiedVersion(File rootDir, String version) throws IOException { | ||
List<File> filtered = new ArrayList<>(); | ||
|
||
Files.walkFileTree( | ||
rootDir.toPath(), | ||
new SimpleFileVisitor<Path>() { | ||
@Override public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException { | ||
if (file.toFile().getAbsolutePath().endsWith(".java")) { | ||
getLog().info("Processing: " + file.toFile().getAbsolutePath()); | ||
|
||
if (!fileVersionChecker.satisfiesVersion(file.toFile(), version)) { | ||
filtered.add(file.toFile()); | ||
|
||
getLog().info("Excluded: " + file.toFile().getAbsolutePath()); | ||
} | ||
} | ||
|
||
return FileVisitResult.CONTINUE; | ||
} | ||
}); | ||
|
||
return filtered; | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please, remove or create new ticket for it.