Skip to content

Commit

Permalink
IGNITE-15872 Add Maven Wrapper to facilitate and standardize the buil…
Browse files Browse the repository at this point in the history
…d process (apache#9554)
  • Loading branch information
rpuch authored Mar 11, 2022
1 parent f686e28 commit 2ea4de6
Show file tree
Hide file tree
Showing 20 changed files with 674 additions and 37 deletions.
3 changes: 0 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,6 @@ git-patch-prop-local.sh
**/dotnet/libs/
*.classname*
*.exe
.mvn/
mvnw
mvnw.cmd

#Ignore all Intellij IDEA files (except default inspections config)
.idea/
Expand Down
117 changes: 117 additions & 0 deletions .mvn/wrapper/MavenWrapperDownloader.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
/*
* Copyright 2007-present the original author or authors.
*
* Licensed 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.
*/
import java.net.*;
import java.io.*;
import java.nio.channels.*;
import java.util.Properties;

public class MavenWrapperDownloader {

private static final String WRAPPER_VERSION = "0.5.6";
/**
* Default URL to download the maven-wrapper.jar from, if no 'downloadUrl' is provided.
*/
private static final String DEFAULT_DOWNLOAD_URL = "https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/"
+ WRAPPER_VERSION + "/maven-wrapper-" + WRAPPER_VERSION + ".jar";

/**
* Path to the maven-wrapper.properties file, which might contain a downloadUrl property to
* use instead of the default one.
*/
private static final String MAVEN_WRAPPER_PROPERTIES_PATH =
".mvn/wrapper/maven-wrapper.properties";

/**
* Path where the maven-wrapper.jar will be saved to.
*/
private static final String MAVEN_WRAPPER_JAR_PATH =
".mvn/wrapper/maven-wrapper.jar";

/**
* Name of the property which should be used to override the default download url for the wrapper.
*/
private static final String PROPERTY_NAME_WRAPPER_URL = "wrapperUrl";

public static void main(String args[]) {
System.out.println("- Downloader started");
File baseDirectory = new File(args[0]);
System.out.println("- Using base directory: " + baseDirectory.getAbsolutePath());

// If the maven-wrapper.properties exists, read it and check if it contains a custom
// wrapperUrl parameter.
File mavenWrapperPropertyFile = new File(baseDirectory, MAVEN_WRAPPER_PROPERTIES_PATH);
String url = DEFAULT_DOWNLOAD_URL;
if(mavenWrapperPropertyFile.exists()) {
FileInputStream mavenWrapperPropertyFileInputStream = null;
try {
mavenWrapperPropertyFileInputStream = new FileInputStream(mavenWrapperPropertyFile);
Properties mavenWrapperProperties = new Properties();
mavenWrapperProperties.load(mavenWrapperPropertyFileInputStream);
url = mavenWrapperProperties.getProperty(PROPERTY_NAME_WRAPPER_URL, url);
} catch (IOException e) {
System.out.println("- ERROR loading '" + MAVEN_WRAPPER_PROPERTIES_PATH + "'");
} finally {
try {
if(mavenWrapperPropertyFileInputStream != null) {
mavenWrapperPropertyFileInputStream.close();
}
} catch (IOException e) {
// Ignore ...
}
}
}
System.out.println("- Downloading from: " + url);

File outputFile = new File(baseDirectory.getAbsolutePath(), MAVEN_WRAPPER_JAR_PATH);
if(!outputFile.getParentFile().exists()) {
if(!outputFile.getParentFile().mkdirs()) {
System.out.println(
"- ERROR creating output directory '" + outputFile.getParentFile().getAbsolutePath() + "'");
}
}
System.out.println("- Downloading to: " + outputFile.getAbsolutePath());
try {
downloadFileFromURL(url, outputFile);
System.out.println("Done");
System.exit(0);
} catch (Throwable e) {
System.out.println("- Error downloading");
e.printStackTrace();
System.exit(1);
}
}

private static void downloadFileFromURL(String urlString, File destination) throws Exception {
if (System.getenv("MVNW_USERNAME") != null && System.getenv("MVNW_PASSWORD") != null) {
String username = System.getenv("MVNW_USERNAME");
char[] password = System.getenv("MVNW_PASSWORD").toCharArray();
Authenticator.setDefault(new Authenticator() {
@Override
protected PasswordAuthentication getPasswordAuthentication() {
return new PasswordAuthentication(username, password);
}
});
}
URL website = new URL(urlString);
ReadableByteChannel rbc;
rbc = Channels.newChannel(website.openStream());
FileOutputStream fos = new FileOutputStream(destination);
fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE);
fos.close();
rbc.close();
}

}
Binary file added .mvn/wrapper/maven-wrapper.jar
Binary file not shown.
19 changes: 19 additions & 0 deletions .mvn/wrapper/maven-wrapper.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#
# 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.
#

distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.8.3/apache-maven-3.8.3-bin.zip
wrapperUrl=https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,6 @@ Inspection profile is placed to IDEA [Project_Default](.idea/inspectionProfiles/
### Building project
Usually all Maven builds are to be run with skipped tests:
```
mvn -DskipTests
./mvnw -DskipTests
```
See also [DEVNOTES.txt](DEVNOTES.txt)
50 changes: 31 additions & 19 deletions DEVNOTES.txt
Original file line number Diff line number Diff line change
@@ -1,29 +1,41 @@
A Note about Invoking Maven
===========================

Apache Ignite build system uses Maven Wrapper to simplify and standardize build process. On different operating
systems, it should be run slightly differently:

* On Unix-like systems (including Cygwin, WSL, git-bash), it's `./mvnw <arguments>`
* On Windows (in PowerShell), it's `./mvnw <arguments>` as well
* On Windows (in cmd shell), it's `.\mvnw <arguments>` or `mvnw <arguments>` (in older versions)

Further in our documentation, we always use the ./mvnw form. Please adapt it to your system if needed.

Apache Ignite Maven Build Instructions
======================================
1) Optional: build Apache Ignite.NET as described at modules/platforms/dotnet/DEVNOTES.txt.

2) Compile and install:

mvn clean install -Pall-java,all-scala,licenses -DskipTests
./mvnw clean install -Pall-java,all-scala,licenses -DskipTests

or if you have built Apache Ignite.NET on the first step use following command:
(Note that 'doxygen' should be installed before running this command.)

mvn clean install -Pall-java,all-scala,licenses -DskipTests -DclientDocs
./mvnw clean install -Pall-java,all-scala,licenses -DskipTests -DclientDocs

3) Javadoc generation (optional):

mvn initialize -Pjavadoc
./mvnw initialize -Pjavadoc

4) Build Apache Ignite assembly:

mvn initialize -Prelease
./mvnw initialize -Prelease

Look for apache-ignite-<version>-bin.zip in ./target/bin directory.

5) Build Apache Ignite slim edition assembly:

mvn initialize -Prelease -Dignite.edition=apache-ignite-slim
./mvnw initialize -Prelease -Dignite.edition=apache-ignite-slim

Look for apache-ignite-slim-<version>-bin.zip in ./target/bin directory.

Expand All @@ -34,20 +46,20 @@ Apache Ignite with LGPL Maven Build Instructions

2) Compile and install:

mvn clean install -Pall-java,all-scala,licenses -DskipTests
./mvnw clean install -Pall-java,all-scala,licenses -DskipTests

or if you have built Apache Ignite.NET on the first step use following command:
(Note that 'doxygen' should be installed before running this command.)

mvn clean install -Pall-java,all-scala,licenses -DskipTests -DclientDocs
./mvnw clean install -Pall-java,all-scala,licenses -DskipTests -DclientDocs

3) Javadoc generation with LGPL (optional):

mvn initialize -Pjavadoc,lgpl
./mvnw initialize -Pjavadoc,lgpl

4) Build Apache Ignite assembly with LGPL dependencies:

mvn initialize -Prelease,lgpl -Dignite.edition=apache-ignite-lgpl
./mvnw initialize -Prelease,lgpl -Dignite.edition=apache-ignite-lgpl

Look for apache-ignite-lgpl-<version>-bin.zip in ./target/bin directory.

Expand Down Expand Up @@ -133,18 +145,18 @@ Ignite Release Instructions

3.1) Deploy Ignite to maven repository, prepares sources and binaries.

mvn deploy -Papache-release,gpg,all-java,all-scala,licenses,deploy-ignite-site -Dignite.edition=apache-ignite -DskipTests
./mvnw deploy -Papache-release,gpg,all-java,all-scala,licenses,deploy-ignite-site -Dignite.edition=apache-ignite -DskipTests

3.2) Javadoc generation:

mvn initialize -Pjavadoc
./mvnw initialize -Pjavadoc

3.3) Assembly Apache Ignite:

mvn initialize -Prelease
./mvnw initialize -Prelease

NOTE: Nexus staging (repository.apache.org) should be closed with appropriate comment contains release version and
release candidate number, for example "Apache Ignite 1.0.0-rc7", when mvn deploy finished.
release candidate number, for example "Apache Ignite 1.0.0-rc7", when `./mvnw deploy` finished.

3.5) Checkout https://dist.apache.org/repos/dist/dev/ignite svn. Create release candidate folder with name
equals to release version with "-rc*" ending, for example "1.0.0-rc7", at svn root.
Expand All @@ -167,7 +179,7 @@ JCache TCK compliance
======================
To test compliance with JCache TCK use:

mvn test -P-release,jcache-tck -pl :ignite-core -am
./mvnw test -P-release,jcache-tck -pl :ignite-core -am


Ignite Mesos Maven Build Instructions
Expand All @@ -192,33 +204,33 @@ Run tests
=========
To run tests locally use:

mvn clean test -U -Plgpl,examples,-clean-libs,-release -Dmaven.test.failure.ignore=true -DfailIfNoTests=false -Dtest=%TEST_PATTERN%
./mvnw clean test -U -Plgpl,examples,-clean-libs,-release -Dmaven.test.failure.ignore=true -DfailIfNoTests=false -Dtest=%TEST_PATTERN%

For example, %TEST_PATTERN% can be 'org.apache.ignite.testsuites.IgniteBasicTestSuite' or 'GridCacheLocalAtomicFullApiSelfTest#testGet'

Test suites
=========
All unit tests must be included in any test suite. Travis runs a check for that. To check it locally run for the root project:

mvn test -Pcheck-test-suites
./mvnw test -Pcheck-test-suites

If you want to check a single module only:

1) Add ignite-tools dependency to the test scope of the module.

2) Install ignite-tools with command:

mvn install -Pcheck-test-suites
./mvnw install -Pcheck-test-suites

3) Run tests in the module:

mvn test
./mvnw test

Apache RAT Instructions
=======================
To check license headers use:

mvn clean validate -Pcheck-licenses
./mvnw clean validate -Pcheck-licenses

For more information (e.g. exclude list) see "check-licenses" profile in "parent/pom.xml".

Expand Down
2 changes: 1 addition & 1 deletion docs/_docs/machine-learning/machine-learning.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ The latest Apache Ignite Machine Learning jar is always uploaded to the Maven re
+
[source, shell]
----
mvn clean install -DskipTests -Dmaven.javadoc.skip=true
./mvnw clean install -DskipTests -Dmaven.javadoc.skip=true
----

4. Locate the Machine Learning jar in your local Maven repository under the path `{user_dir}/.m2/repository/org/apache/ignite/ignite-ml/{ignite-version}/ignite-ml-{ignite-version}.jar`.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ CONFIGS="-b 1 -sm PRIMARY_SYNC -dn PutBenchmark`IgniteNode"

== Building From Sources

Run `mvn clean package -Pyardstick -pl modules/yardstick -am -DskipTests` in the Apache Ignite root directory.
Run `./mvnw clean package -Pyardstick -pl modules/yardstick -am -DskipTests` in the Apache Ignite root directory.

This command will compile the project and also unpack the scripts from `yardstick-resources.zip` file to `modules/yardstick/target/assembly/bin` directory.

Expand Down
2 changes: 1 addition & 1 deletion docs/_docs/setup.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ For example, to install `ignite-hibernate` into your local repository, run this

[source, shell]
----
mvn clean install -DskipTests -Plgpl -pl modules/hibernate -am
./mvnw clean install -DskipTests -Plgpl -pl modules/hibernate -am
----


Expand Down
2 changes: 1 addition & 1 deletion examples/DEVNOTES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Ignite Examples Build Instructions
==================================
1) Compile and install Ignite from project root folder:

mvn clean install -Pall-java,all-scala,licenses -DskipTests
./mvnw clean install -Pall-java,all-scala,licenses -DskipTests

(If needed, refer DEVNOTES.txt in project root folder for most up-to-date build instructions.)

Expand Down
4 changes: 2 additions & 2 deletions examples/README.txt
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ at https://ignite.apache.org/download.cgi#sources.

There are some ways to gain required libs from sources:

1) Run "mvn clean install -DskipTests -P lgpl" at Apache Ignite sources.
1) Run "./mvnw clean install -DskipTests -P lgpl" at Apache Ignite sources.
This case will install lgpl-based libs to local maven repository.

2) Run "mvn clean package -DskipTests -Prelease,lgpl -Dignite.edition=apache-ignite-lgpl" at Apache Ignite sources.
2) Run "./mvnw clean package -DskipTests -Prelease,lgpl -Dignite.edition=apache-ignite-lgpl" at Apache Ignite sources.
Required libs will appear at /target/release-package/libs/optional subfolders.
Found libs should be copied to global or project's classpath.
2 changes: 1 addition & 1 deletion modules/geospatial/README.txt
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,4 @@ Apache binary releases cannot include LGPL dependencies. If you would like inclu
optional LGPL dependencies into your release, you should download the source release
from Ignite website and do the build with the following maven command:

mvn clean package -DskipTests -Prelease,lgpl
./mvnw clean package -DskipTests -Prelease,lgpl
2 changes: 1 addition & 1 deletion modules/hibernate-4.2/README.txt
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,4 @@ Apache binary releases cannot include LGPL dependencies. If you would like inclu
optional LGPL dependencies into your release, you should download the source release
from Ignite website and do the build with the following maven command:

mvn clean package -DskipTests -Prelease,lgpl
./mvnw clean package -DskipTests -Prelease,lgpl
2 changes: 1 addition & 1 deletion modules/hibernate-5.1/README.txt
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,4 @@ Apache binary releases cannot include LGPL dependencies. If you would like inclu
optional LGPL dependencies into your release, you should download the source release
from Ignite website and do the build with the following maven command:

mvn clean package -DskipTests -Prelease,lgpl
./mvnw clean package -DskipTests -Prelease,lgpl
4 changes: 2 additions & 2 deletions modules/ml/README.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ Apache Ignite ML Grid module provides machine learning features, along with invo
# Local build with javadoc

Run from project root:
mvn clean package -DskipTests -pl modules/ml -am
./mvnw clean package -DskipTests -pl modules/ml -am

Apache binary releases cannot include LGPL dependencies. If you would like to activate native BLAS optimizations
into your build, you should download the source release
from Ignite website and do the build with the following maven command:

mvn clean package -Plgpl -DskipTests -pl modules/ml -am
./mvnw clean package -Plgpl -DskipTests -pl modules/ml -am

Find generated jars in target folder.
2 changes: 1 addition & 1 deletion modules/platforms/cpp/examples/README.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Common requirements
* Java Development Kit (JDK) must be installed: https://java.com/en/download/index.jsp
* JAVA_HOME environment variable must be set pointing to Java installation directory.
* IGNITE_HOME environment variable must be set to Ignite installation directory.
* Ignite must be built and packaged using Maven. You can use the following Maven command: mvn clean package -DskipTests
* Ignite must be built and packaged using Maven. You can use the following Maven command: ./mvnw clean package -DskipTests
* Apache Ignite C++ must be built according to instructions for your platform. Refer to
$IGNITE_HOME/platforms/cpp/DEVNOTES.txt for instructions.
* For odbc-example additionally ODBC Driver Manager must be present and installed on your platform and
Expand Down
2 changes: 1 addition & 1 deletion modules/schedule/README.txt
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,4 @@ Apache binary releases cannot include LGPL dependencies. If you would like inclu
optional LGPL dependencies into your release, you should download the source release
from Ignite website and do the build with the following maven command:

mvn clean package -DskipTests -Prelease,lgpl
./mvnw clean package -DskipTests -Prelease,lgpl
Loading

0 comments on commit 2ea4de6

Please sign in to comment.