Skip to content
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

JAMES-3398 add Maven wrapper (with latest Maven version 3.6.3) #253

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ dockerfiles/run/**/keystore
dockerfiles/run/**/glowroot
.m2
test-run.log
build
build
/.mvn/wrapper/maven-wrapper.jar
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;

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I understand this code is copied but can we have a link to the place it was copied from as a comment?

This helps code patternity.

This helps checking divergences from the original version.

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();
}

}
2 changes: 2 additions & 0 deletions .mvn/wrapper/maven-wrapper.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.3/apache-maven-3.6.3-bin.zip
wrapperUrl=https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar
45 changes: 29 additions & 16 deletions README.adoc
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
Apache James Project
====================
= Apache James Project
:idprefix:
:idseparator: -

link:https://gitter.im/apache/james-project[image:https://badges.gitter.im/apache/james-project.svg[Join the chat at link:https://gitter.im/apache/james-project]]

Expand Down Expand Up @@ -37,28 +38,27 @@ https://issues.apache.org/jira/issues/?jql=project%20%3D%20JAMES%20AND%20resolut

There is many other ways one can help us: packaging, communication, etc ...

= How to...
== Table of contents

* link:#how-to-try-james[How to try James]
* link:#how-to-try-james[How to try James]
* link:#how-to-check-the-compilation[How to check the compilation]
* link:#how-to-run-james-in-docker[How to run James in Docker]
** link:#run-james-with-guice-%2Dcassandra-%2Drabbitmq-%2Ds3-%2Delasticsearch[Run James with Guice + Cassandra + RabbitMQ + S3 + ElasticSearch]
** link:#run-james-with-guice-%2Dcassandra-%2Delasticsearch[Run James with Guice + Cassandra + ElasticSearch]
** link:#run-james-with-guice-%2Djpa-%2Dlucene[Run James with Guice + JPA + Lucene]
** link:#run-james-with-spring-%2Djpa[Run James with Spring + JPA]
* link:#other-useful-commands[Other Useful commands]
** link:#how-to-add-a-domain-[How to add a domain?]
** link:#how-to-add-a-user-[How to add a user?]
** link:#how-to-manage-sieve-scripts-[How to manage SIEVE scripts?]
** link:#how-to-add-a-domain[How to add a domain?]
** link:#how-to-add-a-user[How to add a user?]
** link:#how-to-manage-sieve-scripts[How to manage SIEVE scripts?]
** link:#how-to-retrieve-users-and-password-from-my-previous-container[How to retrieve users and password from my previous container?]
* link:#develop-on-james[Develop on James]
** link:#how-to-build-james[How to build James]
** link:#how-to-run-deployment-tests[How to run deployment Tests]
** link:#how-to-check-the-merge-of-a-commit[How to check the merge of a commit]
* link:#generating-a-package-for-james[Generating a package for James]
* link:#know-more-about-james-design[Know more about James design]
* link:#articles-for-james-community[Articles for James community]
** link:#how-to-build-and-publish-the-website[How to build and publish the website]
** link:#how-to-release-via-maven-release-plugin[How to release via maven release plugin]

== How to try James

Expand Down Expand Up @@ -150,7 +150,7 @@ If you haven't already:
-t james/project -s HEAD


==== How to ?
==== How-to
You need a running *cassandra* in docker. To achieve this run:

$ docker run -d --name=cassandra cassandra:3.11.3
Expand Down Expand Up @@ -281,7 +281,7 @@ If you haven't already:
-t james/project -s HEAD


==== How to ?
==== How-to
We need to provide the key we will use for TLS. For obvious reasons, this is not provided in this git.

Copy your TLS keys to `run/guice/jpa/destination/conf/keystore` or generate it using the following command. The password must be `james72laBalle` to match default configuration.
Expand Down Expand Up @@ -318,7 +318,7 @@ If you haven't already:
-t james/project -s HEAD


==== Howto ?
==== How-to

We need to provide the key we will use for TLS. For obvious reasons, this is not provided in this git.

Expand Down Expand Up @@ -348,7 +348,7 @@ The base command is different whether you choose guice flavor or spring :
* guice use : `docker exec james_run java -jar /root/james-cli.jar`
* spring use : `docker exec james_run /root/james-server-app-3.0.0-beta6-SNAPSHOT/bin/james-cli.sh`

=== How to add a domain ?
=== How to add a domain?

# Add DOMAIN to 127.0.0.1 in your host /etc/hosts
$ <your-command-here> -h 127.0.0.1 -p 9999 adddomain DOMAIN
Expand All @@ -360,7 +360,7 @@ domain will be created upon James start:

$ --environment DOMAIN=domain.tld

=== How to add a user ?
=== How to add a user?

$ <your-command-here> -h 127.0.0.1 -p 9999 adduser USER_MAIL_ADDRESS PASSWORD

Expand All @@ -371,7 +371,7 @@ Where :

You can then just add DOMAIN to your /etc/hosts and you can connect to your james account with for instance Thunderbird.

=== How to manage SIEVE scripts ?
=== How to manage SIEVE scripts?

Each user can manage his SIEVE scripts through the manage SIEVE mailet.

Expand Down Expand Up @@ -401,7 +401,20 @@ Beware : you will have concurrency issues if multiple containers are running on

== Develop on James

James requires at least JDK 11 and Maven 3.6.0 to build.
=== How to build James

James requires JDK 11 (or newer).

The encouraged method for building and running tests is to use Maven wrapper from
root directory by running:

`./mvnw install` (when running from project root) or
`../mvnw install` (when running from a subdirectory)

mvnw (or mvnw.bat) is a small script that downloads the correct Maven distribution into .mvn/wrapper directory
on first run and uses that.
It is also possible to use locally installed Maven (3.6+) instead of Maven wrapper by running: `mvn install`

Some parts of James are written in Scala so one might need to enable Scala plugin in IDE.

=== How to run deployment Tests
Expand Down
Loading