Skip to content

Commit a37b800

Browse files
author
Myron Scott
authored
Merge pull request #1134 from myronkscott/adopt_new_api
Adopt new api
2 parents 0db9694 + fefa4b6 commit a37b800

File tree

140 files changed

+1381
-675
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

140 files changed

+1381
-675
lines changed
Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
/*
2+
* Copyright 2007-present the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
import java.net.*;
17+
import java.io.*;
18+
import java.nio.channels.*;
19+
import java.util.Properties;
20+
21+
public class MavenWrapperDownloader {
22+
23+
private static final String WRAPPER_VERSION = "0.5.6";
24+
/**
25+
* Default URL to download the maven-wrapper.jar from, if no 'downloadUrl' is provided.
26+
*/
27+
private static final String DEFAULT_DOWNLOAD_URL = "https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/"
28+
+ WRAPPER_VERSION + "/maven-wrapper-" + WRAPPER_VERSION + ".jar";
29+
30+
/**
31+
* Path to the maven-wrapper.properties file, which might contain a downloadUrl property to
32+
* use instead of the default one.
33+
*/
34+
private static final String MAVEN_WRAPPER_PROPERTIES_PATH =
35+
".mvn/wrapper/maven-wrapper.properties";
36+
37+
/**
38+
* Path where the maven-wrapper.jar will be saved to.
39+
*/
40+
private static final String MAVEN_WRAPPER_JAR_PATH =
41+
".mvn/wrapper/maven-wrapper.jar";
42+
43+
/**
44+
* Name of the property which should be used to override the default download url for the wrapper.
45+
*/
46+
private static final String PROPERTY_NAME_WRAPPER_URL = "wrapperUrl";
47+
48+
public static void main(String args[]) {
49+
System.out.println("- Downloader started");
50+
File baseDirectory = new File(args[0]);
51+
System.out.println("- Using base directory: " + baseDirectory.getAbsolutePath());
52+
53+
// If the maven-wrapper.properties exists, read it and check if it contains a custom
54+
// wrapperUrl parameter.
55+
File mavenWrapperPropertyFile = new File(baseDirectory, MAVEN_WRAPPER_PROPERTIES_PATH);
56+
String url = DEFAULT_DOWNLOAD_URL;
57+
if(mavenWrapperPropertyFile.exists()) {
58+
FileInputStream mavenWrapperPropertyFileInputStream = null;
59+
try {
60+
mavenWrapperPropertyFileInputStream = new FileInputStream(mavenWrapperPropertyFile);
61+
Properties mavenWrapperProperties = new Properties();
62+
mavenWrapperProperties.load(mavenWrapperPropertyFileInputStream);
63+
url = mavenWrapperProperties.getProperty(PROPERTY_NAME_WRAPPER_URL, url);
64+
} catch (IOException e) {
65+
System.out.println("- ERROR loading '" + MAVEN_WRAPPER_PROPERTIES_PATH + "'");
66+
} finally {
67+
try {
68+
if(mavenWrapperPropertyFileInputStream != null) {
69+
mavenWrapperPropertyFileInputStream.close();
70+
}
71+
} catch (IOException e) {
72+
// Ignore ...
73+
}
74+
}
75+
}
76+
System.out.println("- Downloading from: " + url);
77+
78+
File outputFile = new File(baseDirectory.getAbsolutePath(), MAVEN_WRAPPER_JAR_PATH);
79+
if(!outputFile.getParentFile().exists()) {
80+
if(!outputFile.getParentFile().mkdirs()) {
81+
System.out.println(
82+
"- ERROR creating output directory '" + outputFile.getParentFile().getAbsolutePath() + "'");
83+
}
84+
}
85+
System.out.println("- Downloading to: " + outputFile.getAbsolutePath());
86+
try {
87+
downloadFileFromURL(url, outputFile);
88+
System.out.println("Done");
89+
System.exit(0);
90+
} catch (Throwable e) {
91+
System.out.println("- Error downloading");
92+
e.printStackTrace();
93+
System.exit(1);
94+
}
95+
}
96+
97+
private static void downloadFileFromURL(String urlString, File destination) throws Exception {
98+
if (System.getenv("MVNW_USERNAME") != null && System.getenv("MVNW_PASSWORD") != null) {
99+
String username = System.getenv("MVNW_USERNAME");
100+
char[] password = System.getenv("MVNW_PASSWORD").toCharArray();
101+
Authenticator.setDefault(new Authenticator() {
102+
@Override
103+
protected PasswordAuthentication getPasswordAuthentication() {
104+
return new PasswordAuthentication(username, password);
105+
}
106+
});
107+
}
108+
URL website = new URL(urlString);
109+
ReadableByteChannel rbc;
110+
rbc = Channels.newChannel(website.openStream());
111+
FileOutputStream fos = new FileOutputStream(destination);
112+
fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE);
113+
fos.close();
114+
rbc.close();
115+
}
116+
117+
}

.mvn/wrapper/maven-wrapper.jar

49.5 KB
Binary file not shown.

.mvn/wrapper/maven-wrapper.properties

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
distributionUrl=https://repo1.maven.org/maven2/org/apache/maven/apache-maven/3.6.3/apache-maven-3.6.3-bin.zip
2+
wrapperUrl=https://repo1.maven.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar

common-spi/pom.xml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
~
4+
~ The contents of this file are subject to the Terracotta Public License Version
5+
~ 2.0 (the "License"); You may not use this file except in compliance with the
6+
~ License. You may obtain a copy of the License at
7+
~
8+
~ http://terracotta.org/legal/terracotta-public-license.
9+
~
10+
~ Software distributed under the License is distributed on an "AS IS" basis,
11+
~ WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
12+
~ the specific language governing rights and limitations under the License.
13+
~
14+
~ The Covered Software is Terracotta Core.
15+
~
16+
~ The Initial Developer of the Covered Software is
17+
~ Terracotta, Inc., a Software AG company
18+
~
19+
-->
20+
21+
<project xmlns="http://maven.apache.org/POM/4.0.0"
22+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
23+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
24+
<parent>
25+
<groupId>org.terracotta.internal</groupId>
26+
<artifactId>build-parent</artifactId>
27+
<version>5.7-SNAPSHOT</version>
28+
<relativePath>../build-parent</relativePath>
29+
</parent>
30+
<modelVersion>4.0.0</modelVersion>
31+
32+
<groupId>org.terracotta.internal</groupId>
33+
<artifactId>common-spi</artifactId>
34+
<properties>
35+
<java.build.version>1.8</java.build.version>
36+
</properties>
37+
38+
<dependencies>
39+
</dependencies>
40+
</project>

common/src/main/java/com/tc/net/core/AbstractBufferManager.java renamed to common-spi/src/main/java/com/tc/net/core/AbstractBufferManager.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
1111
* the specific language governing rights and limitations under the License.
1212
*
13-
* The Covered Software is Terracotta Core.
13+
* The Covered Software is common SPI.
1414
*
1515
* The Initial Developer of the Covered Software is
1616
* Terracotta, Inc., a Software AG company

common/src/main/java/com/tc/net/core/BufferManager.java renamed to common-spi/src/main/java/com/tc/net/core/BufferManager.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
1111
* the specific language governing rights and limitations under the License.
1212
*
13-
* The Covered Software is Terracotta Core.
13+
* The Covered Software is common SPI.
1414
*
1515
* The Initial Developer of the Covered Software is
1616
* Terracotta, Inc., a Software AG company

common/src/main/java/com/tc/net/core/BufferManagerFactory.java renamed to common-spi/src/main/java/com/tc/net/core/BufferManagerFactory.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
1111
* the specific language governing rights and limitations under the License.
1212
*
13-
* The Covered Software is Terracotta Core.
13+
* The Covered Software is common SPI.
1414
*
1515
* The Initial Developer of the Covered Software is
1616
* Terracotta, Inc., a Software AG company

tc-messaging/src/main/java/com/tc/util/ProductCapabilities.java renamed to common-spi/src/main/java/com/tc/net/core/BufferManagerFactorySupplier.java

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,19 +10,20 @@
1010
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
1111
* the specific language governing rights and limitations under the License.
1212
*
13-
* The Covered Software is Terracotta Core.
13+
* The Covered Software is common SPI.
1414
*
1515
* The Initial Developer of the Covered Software is
1616
* Terracotta, Inc., a Software AG company
1717
*
1818
*/
19-
package com.tc.util;
19+
package com.tc.net.core;
2020

21-
import java.util.Set;
21+
import java.util.Properties;
2222

2323
/**
24-
*
2524
*/
26-
public interface ProductCapabilities {
27-
Set<ProductID> supportedClients();
25+
public interface BufferManagerFactorySupplier {
26+
27+
BufferManagerFactory createBufferManagerFactory(Properties properties);
28+
2829
}

tc-messaging/src/main/java/com/tc/util/ProductID.java renamed to common-spi/src/main/java/com/tc/net/core/ProductID.java

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,15 @@
1717
*
1818
*/
1919

20-
package com.tc.util;
20+
package com.tc.net.core;
2121

2222
/**
23-
* @author tim
2423
*/
2524
public enum ProductID {
26-
DIAGNOSTIC(true, false, false, false),
27-
INFORMATIONAL(true, true, true, false),
28-
STRIPE(false, true, true, false),
29-
SERVER(false, false, true, false),
25+
DIAGNOSTIC(true, false, false, false),
26+
INFORMATIONAL(true, true, true, false),
27+
STRIPE(false, true, true, false),
28+
SERVER(false, false, true, false),
3029
PERMANENT(false, true, true, true);
3130

3231
private final boolean internal;
@@ -44,19 +43,19 @@ public enum ProductID {
4443
public boolean isInternal() {
4544
return internal;
4645
}
47-
46+
4847
public boolean isReconnectEnabled() {
4948
return reconnect;
5049
}
5150

5251
public boolean isRedirectEnabled() {
5352
return redirect;
5453
}
55-
54+
5655
public boolean isPermanent() {
5756
return permanent;
5857
}
59-
58+
6059
@Override
6160
public String toString() {
6261
return name().charAt(0) + name().substring(1).toLowerCase();

tc-messaging/src/main/java/com/tc/text/PrettyPrintable.java renamed to common-spi/src/main/java/com/tc/text/PrettyPrintable.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
1111
* the specific language governing rights and limitations under the License.
1212
*
13-
* The Covered Software is Terracotta Core.
13+
* The Covered Software is common SPI.
1414
*
1515
* The Initial Developer of the Covered Software is
1616
* Terracotta, Inc., a Software AG company
@@ -25,6 +25,6 @@ public interface PrettyPrintable {
2525
default PrettyPrinter prettyPrint(PrettyPrinter out) {
2626
return out.println(getStateMap());
2727
}
28-
28+
2929
public Map<String, ?> getStateMap();
3030
}

0 commit comments

Comments
 (0)