Merge branch 'start-init-improvements'
This commit is contained in:
commit
994f00102d
|
@ -2,7 +2,7 @@
|
|||
protonego-boot
|
||||
|
||||
[files]
|
||||
http://central.maven.org/maven2/org/mortbay/jetty/alpn/alpn-boot/7.1.0.v20141016/alpn-boot-7.1.0.v20141016.jar|lib/alpn/alpn-boot-7.1.0.v20141016.jar
|
||||
maven://org.mortbay.jetty.alpn/alpn-boot/7.1.0.v20141016|lib/alpn/alpn-boot-7.1.0.v20141016.jar
|
||||
|
||||
[exec]
|
||||
-Xbootclasspath/p:lib/alpn/alpn-boot-7.1.0.v20141016.jar
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
protonego-boot
|
||||
|
||||
[files]
|
||||
http://central.maven.org/maven2/org/mortbay/jetty/alpn/alpn-boot/7.1.0.v20141016/alpn-boot-7.1.0.v20141016.jar|lib/alpn/alpn-boot-7.1.0.v20141016.jar
|
||||
maven://org.mortbay.jetty.alpn/alpn-boot/7.1.0.v20141016|lib/alpn/alpn-boot-7.1.0.v20141016.jar
|
||||
|
||||
[exec]
|
||||
-Xbootclasspath/p:lib/alpn/alpn-boot-7.1.0.v20141016.jar
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
protonego-boot
|
||||
|
||||
[files]
|
||||
http://central.maven.org/maven2/org/mortbay/jetty/alpn/alpn-boot/7.1.0.v20141016/alpn-boot-7.1.0.v20141016.jar|lib/alpn/alpn-boot-7.1.0.v20141016.jar
|
||||
maven://org.mortbay.jetty.alpn/alpn-boot/7.1.0.v20141016|lib/alpn/alpn-boot-7.1.0.v20141016.jar
|
||||
|
||||
[exec]
|
||||
-Xbootclasspath/p:lib/alpn/alpn-boot-7.1.0.v20141016.jar
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
protonego-boot
|
||||
|
||||
[files]
|
||||
http://central.maven.org/maven2/org/mortbay/jetty/alpn/alpn-boot/7.1.0.v20141016/alpn-boot-7.1.0.v20141016.jar|lib/alpn/alpn-boot-7.1.0.v20141016.jar
|
||||
maven://org.mortbay.jetty.alpn/alpn-boot/7.1.0.v20141016|lib/alpn/alpn-boot-7.1.0.v20141016.jar
|
||||
|
||||
[exec]
|
||||
-Xbootclasspath/p:lib/alpn/alpn-boot-7.1.0.v20141016.jar
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
protonego-boot
|
||||
|
||||
[files]
|
||||
http://central.maven.org/maven2/org/mortbay/jetty/alpn/alpn-boot/7.1.0.v20141016/alpn-boot-7.1.0.v20141016.jar|lib/alpn/alpn-boot-7.1.0.v20141016.jar
|
||||
maven://org.mortbay.jetty.alpn/alpn-boot/7.1.0.v20141016|lib/alpn/alpn-boot-7.1.0.v20141016.jar
|
||||
|
||||
[exec]
|
||||
-Xbootclasspath/p:lib/alpn/alpn-boot-7.1.0.v20141016.jar
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
protonego-boot
|
||||
|
||||
[files]
|
||||
http://central.maven.org/maven2/org/mortbay/jetty/alpn/alpn-boot/7.1.0.v20141016/alpn-boot-7.1.0.v20141016.jar|lib/alpn/alpn-boot-7.1.0.v20141016.jar
|
||||
maven://org.mortbay.jetty.alpn/alpn-boot/7.1.0.v20141016|lib/alpn/alpn-boot-7.1.0.v20141016.jar
|
||||
|
||||
[exec]
|
||||
-Xbootclasspath/p:lib/alpn/alpn-boot-7.1.0.v20141016.jar
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
protonego-boot
|
||||
|
||||
[files]
|
||||
http://central.maven.org/maven2/org/mortbay/jetty/alpn/alpn-boot/7.1.0.v20141016/alpn-boot-7.1.0.v20141016.jar|lib/alpn/alpn-boot-7.1.0.v20141016.jar
|
||||
maven://org.mortbay.jetty.alpn/alpn-boot/7.1.0.v20141016|lib/alpn/alpn-boot-7.1.0.v20141016.jar
|
||||
|
||||
[exec]
|
||||
-Xbootclasspath/p:lib/alpn/alpn-boot-7.1.0.v20141016.jar
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
protonego-boot
|
||||
|
||||
[files]
|
||||
http://central.maven.org/maven2/org/mortbay/jetty/alpn/alpn-boot/7.1.1.v20141016/alpn-boot-7.1.1.v20141016.jar|lib/alpn/alpn-boot-7.1.1.v20141016.jar
|
||||
maven://org.mortbay.jetty.alpn/alpn-boot/7.1.1.v20141016|lib/alpn/alpn-boot-7.1.1.v20141016.jar
|
||||
|
||||
[exec]
|
||||
-Xbootclasspath/p:lib/alpn/alpn-boot-7.1.1.v20141016.jar
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
protonego-boot
|
||||
|
||||
[files]
|
||||
http://central.maven.org/maven2/org/mortbay/jetty/alpn/alpn-boot/7.1.1.v20141016/alpn-boot-7.1.1.v20141016.jar|lib/alpn/alpn-boot-7.1.1.v20141016.jar
|
||||
maven://org.mortbay.jetty.alpn/alpn-boot/7.1.1.v20141016|lib/alpn/alpn-boot-7.1.1.v20141016.jar
|
||||
|
||||
[exec]
|
||||
-Xbootclasspath/p:lib/alpn/alpn-boot-7.1.1.v20141016.jar
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
protonego-boot
|
||||
|
||||
[files]
|
||||
http://central.maven.org/maven2/org/mortbay/jetty/alpn/alpn-boot/8.1.0.v20141016/alpn-boot-8.1.0.v20141016.jar|lib/alpn/alpn-boot-8.1.0.v20141016.jar
|
||||
maven://org.mortbay.jetty.alpn/alpn-boot/8.1.0.v20141016|lib/alpn/alpn-boot-8.1.0.v20141016.jar
|
||||
|
||||
[exec]
|
||||
-Xbootclasspath/p:lib/alpn/alpn-boot-8.1.0.v20141016.jar
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
protonego-boot
|
||||
|
||||
[files]
|
||||
http://central.maven.org/maven2/org/mortbay/jetty/alpn/alpn-boot/8.1.0.v20141016/alpn-boot-8.1.0.v20141016.jar|lib/alpn/alpn-boot-8.1.0.v20141016.jar
|
||||
maven://org.mortbay.jetty.alpn/alpn-boot/8.1.0.v20141016|lib/alpn/alpn-boot-8.1.0.v20141016.jar
|
||||
|
||||
[exec]
|
||||
-Xbootclasspath/p:lib/alpn/alpn-boot-8.1.0.v20141016.jar
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
protonego-boot
|
||||
|
||||
[files]
|
||||
http://central.maven.org/maven2/org/mortbay/jetty/alpn/alpn-boot/8.1.0.v20141016/alpn-boot-8.1.0.v20141016.jar|lib/alpn/alpn-boot-8.1.0.v20141016.jar
|
||||
maven://org.mortbay.jetty.alpn/alpn-boot/8.1.0.v20141016|lib/alpn/alpn-boot-8.1.0.v20141016.jar
|
||||
|
||||
[exec]
|
||||
-Xbootclasspath/p:lib/alpn/alpn-boot-8.1.0.v20141016.jar
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
protonego-boot
|
||||
|
||||
[files]
|
||||
http://central.maven.org/maven2/org/mortbay/jetty/alpn/alpn-boot/8.1.0.v20141016/alpn-boot-8.1.0.v20141016.jar|lib/alpn/alpn-boot-8.1.0.v20141016.jar
|
||||
maven://org.mortbay.jetty.alpn/alpn-boot/8.1.0.v20141016|lib/alpn/alpn-boot-8.1.0.v20141016.jar
|
||||
|
||||
[exec]
|
||||
-Xbootclasspath/p:lib/alpn/alpn-boot-8.1.0.v20141016.jar
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
protonego-boot
|
||||
|
||||
[files]
|
||||
http://central.maven.org/maven2/org/mortbay/jetty/alpn/alpn-boot/8.1.1.v20141016/alpn-boot-8.1.1.v20141016.jar|lib/alpn/alpn-boot-8.1.1.v20141016.jar
|
||||
maven://org.mortbay.jetty.alpn/alpn-boot/8.1.1.v20141016|lib/alpn/alpn-boot-8.1.1.v20141016.jar
|
||||
|
||||
[exec]
|
||||
-Xbootclasspath/p:lib/alpn/alpn-boot-8.1.1.v20141016.jar
|
||||
|
|
|
@ -11,7 +11,7 @@ jsp
|
|||
|
||||
[files]
|
||||
lib/weld/
|
||||
http://central.maven.org/maven2/org/jboss/weld/servlet/weld-servlet/2.2.5.Final/weld-servlet-2.2.5.Final.jar|lib/weld/weld-servlet-2.2.5.Final.jar
|
||||
maven://org.jboss.weld.servlet/weld-servlet/2.2.5.Final|lib/weld/weld-servlet-2.2.5.Final.jar
|
||||
|
||||
[lib]
|
||||
lib/weld/weld-servlet-2.2.5.Final.jar
|
||||
|
|
|
@ -13,8 +13,8 @@ etc/jamon.xml
|
|||
|
||||
[files]
|
||||
lib/jamon/
|
||||
http://central.maven.org/maven2/com/jamonapi/jamon/2.79/jamon-2.79.jar|lib/jamon/jamon-2.79.jar
|
||||
http://central.maven.org/maven2/com/jamonapi/jamon_war/2.79/jamon_war-2.79.war|lib/jamon/jamon.war
|
||||
maven://com.jamonapi/jamon/2.79|lib/jamon/jamon-2.79.jar
|
||||
maven://com.jamonapi/jamon_war/2.79/war|lib/jamon/jamon.war
|
||||
|
||||
[lib]
|
||||
lib/jamon/**.jar
|
||||
|
|
|
@ -11,21 +11,21 @@ etc/jminix.xml
|
|||
|
||||
[files]
|
||||
lib/jminix/
|
||||
http://central.maven.org/maven2/org/jminix/jminix/1.1.0/jminix-1.1.0.jar|lib/jminix/jminix-1.1.0.jar
|
||||
maven://org.jminix/jminix/1.1.0|lib/jminix/jminix-1.1.0.jar
|
||||
http://maven.restlet.com/org/restlet/org.restlet/1.1.5/org.restlet-1.1.5.jar|lib/jminix/org.restlet-1.1.5.jar
|
||||
http://maven.restlet.com/org/restlet/org.restlet.ext.velocity/1.1.5/org.restlet.ext.velocity-1.1.5.jar|lib/jminix/org.restlet.ext.velocity-1.1.5.jar
|
||||
http://central.maven.org/maven2/org/apache/velocity/velocity/1.5/velocity-1.5.jar|lib/jminix/velocity-1.5.jar
|
||||
http://central.maven.org/maven2/oro/oro/2.0.8/oro-2.0.8.jar|lib/jminix/oro-2.0.8.jar
|
||||
maven://org.apache.velocity/velocity/1.5|lib/jminix/velocity-1.5.jar
|
||||
maven://oro/oro/2.0.8|lib/jminix/oro-2.0.8.jar
|
||||
http://maven.restlet.com/com/noelios/restlet/com.noelios.restlet/1.1.5/com.noelios.restlet-1.1.5.jar|lib/jminix/com.noelios.restlet-1.1.5.jar
|
||||
http://maven.restlet.com/com/noelios/restlet/com.noelios.restlet.ext.servlet/1.1.5/com.noelios.restlet.ext.servlet-1.1.5.jar|lib/jminix/com.noelios.restlet.ext.servlet-1.1.5.jar
|
||||
http://central.maven.org/maven2/commons-logging/commons-logging/1.1.1/commons-logging-1.1.1.jar|lib/jminix/commons-logging-1.1.1.jar
|
||||
http://repo2.maven.org/maven2/net/sf/json-lib/json-lib/2.2.3/json-lib-2.2.3-jdk15.jar|lib/jminix/json-lib-2.2.3-jdk15.jar
|
||||
http://central.maven.org/maven2/commons-lang/commons-lang/2.4/commons-lang-2.4.jar|lib/jminix/commons-lang-2.4.jar
|
||||
http://central.maven.org/maven2/commons-beanutils/commons-beanutils/1.7.0/commons-beanutils-1.7.0.jar|lib/jminix/commons-beanutils-1.7.0.jar
|
||||
http://central.maven.org/maven2/commons-collections/commons-collections/3.2/commons-collections-3.2.jar|lib/jminix/commons-collections-3.2.jar
|
||||
http://central.maven.org/maven2/net/sf/ezmorph/ezmorph/1.0.6/ezmorph-1.0.6.jar|lib/jminix/ezmorph-1.0.6.jar
|
||||
http://central.maven.org/maven2/org/jgroups/jgroups/2.12.1.3.Final/jgroups-2.12.1.3.Final.jar|lib/jminix/jgroups-2.12.1.3.Final.jar
|
||||
http://central.maven.org/maven2/org/jasypt/jasypt/1.8/jasypt-1.8.jar|lib/jminix/jasypt-1.8.jar
|
||||
maven://commons-logging/commons-logging/1.1.1|lib/jminix/commons-logging-1.1.1.jar
|
||||
maven://net.sf.json-lib/json-lib/2.2.3/jar/jdk15|lib/jminix/json-lib-2.2.3-jdk15.jar
|
||||
maven://commons-lang/commons-lang/2.4|lib/jminix/commons-lang-2.4.jar
|
||||
maven://commons-beanutils/commons-beanutils/1.7.0|lib/jminix/commons-beanutils-1.7.0.jar
|
||||
maven://commons-collections/commons-collections/3.2|lib/jminix/commons-collections-3.2.jar
|
||||
maven://net.sf.ezmorph/ezmorph/1.0.6|lib/jminix/ezmorph-1.0.6.jar
|
||||
maven://org.jgroups/jgroups/2.12.1.3.Final|lib/jminix/jgroups-2.12.1.3.Final.jar
|
||||
maven://org.jasypt/jasypt/1.8|lib/jminix/jasypt-1.8.jar
|
||||
|
||||
[lib]
|
||||
lib/jminix/**.jar
|
||||
|
|
|
@ -11,7 +11,7 @@ jmx
|
|||
etc/jolokia.xml
|
||||
|
||||
[files]
|
||||
http://repo1.maven.org/maven2/org/jolokia/jolokia-war/1.2.2/jolokia-war-1.2.2.war|lib/jolokia/jolokia.war
|
||||
maven://org.jolokia/jolokia-war/1.2.2/war|lib/jolokia/jolokia.war
|
||||
|
||||
[license]
|
||||
Jolokia is released under the Apache License 2.0
|
||||
|
|
|
@ -1,23 +0,0 @@
|
|||
#
|
||||
# Weld Jetty module
|
||||
#
|
||||
|
||||
[depend]
|
||||
annotations
|
||||
|
||||
#[xml]
|
||||
|
||||
[files]
|
||||
lib/weld/
|
||||
http://central.maven.org/maven2/org/jboss/weld/servlet/weld-servlet/2.2.4.Final/weld-servlet-2.2.4.Final.jar|lib/weld/weld-servlet-2.2.4.Final.jar
|
||||
|
||||
|
||||
[lib]
|
||||
lib/weld/**.jar
|
||||
|
||||
[license]
|
||||
Weld is an open source project hosted on Github and released under the Apache 2.0 license.
|
||||
http://weld.cdi-spec.org/
|
||||
http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
|
||||
|
|
@ -2,7 +2,7 @@
|
|||
protonego-boot
|
||||
|
||||
[files]
|
||||
http://central.maven.org/maven2/org/mortbay/jetty/npn/npn-boot/1.1.0.v20120525/npn-boot-1.1.0.v20120525.jar|lib/npn/npn-boot-1.1.0.v20120525.jar
|
||||
maven://org.mortbay.jetty.npn/npn-boot/1.1.0.v20120525|lib/npn/npn-boot-1.1.0.v20120525.jar
|
||||
|
||||
[exec]
|
||||
-Xbootclasspath/p:lib/npn/npn-boot-1.1.0.v20120525.jar
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
protonego-boot
|
||||
|
||||
[files]
|
||||
http://central.maven.org/maven2/org/mortbay/jetty/npn/npn-boot/1.1.0.v20120525/npn-boot-1.1.0.v20120525.jar|lib/npn/npn-boot-1.1.0.v20120525.jar
|
||||
maven://org.mortbay.jetty.npn/npn-boot/1.1.0.v20120525|lib/npn/npn-boot-1.1.0.v20120525.jar
|
||||
|
||||
[exec]
|
||||
-Xbootclasspath/p:lib/npn/npn-boot-1.1.0.v20120525.jar
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
protonego-boot
|
||||
|
||||
[files]
|
||||
http://central.maven.org/maven2/org/mortbay/jetty/npn/npn-boot/1.1.1.v20121030/npn-boot-1.1.1.v20121030.jar|lib/npn/npn-boot-1.1.1.v20121030.jar
|
||||
maven://org.mortbay.jetty.npn/npn-boot/1.1.1.v20121030|lib/npn/npn-boot-1.1.1.v20121030.jar
|
||||
|
||||
[exec]
|
||||
-Xbootclasspath/p:lib/npn/npn-boot-1.1.1.v20121030.jar
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
protonego-boot
|
||||
|
||||
[files]
|
||||
http://central.maven.org/maven2/org/mortbay/jetty/npn/npn-boot/1.1.1.v20121030/npn-boot-1.1.1.v20121030.jar|lib/npn/npn-boot-1.1.1.v20121030.jar
|
||||
maven://org.mortbay.jetty.npn/npn-boot/1.1.1.v20121030|lib/npn/npn-boot-1.1.1.v20121030.jar
|
||||
|
||||
[exec]
|
||||
-Xbootclasspath/p:lib/npn/npn-boot-1.1.1.v20121030.jar
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
protonego-boot
|
||||
|
||||
[files]
|
||||
http://central.maven.org/maven2/org/mortbay/jetty/npn/npn-boot/1.1.3.v20130313/npn-boot-1.1.3.v20130313.jar|lib/npn/npn-boot-1.1.3.v20130313.jar
|
||||
maven://org.mortbay.jetty.npn/npn-boot/1.1.3.v20130313|lib/npn/npn-boot-1.1.3.v20130313.jar
|
||||
|
||||
[exec]
|
||||
-Xbootclasspath/p:lib/npn/npn-boot-1.1.3.v20130313.jar
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
protonego-boot
|
||||
|
||||
[files]
|
||||
http://central.maven.org/maven2/org/mortbay/jetty/npn/npn-boot/1.1.3.v20130313/npn-boot-1.1.3.v20130313.jar|lib/npn/npn-boot-1.1.3.v20130313.jar
|
||||
maven://org.mortbay.jetty.npn/npn-boot/1.1.3.v20130313|lib/npn/npn-boot-1.1.3.v20130313.jar
|
||||
|
||||
[exec]
|
||||
-Xbootclasspath/p:lib/npn/npn-boot-1.1.3.v20130313.jar
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
protonego-boot
|
||||
|
||||
[files]
|
||||
http://central.maven.org/maven2/org/mortbay/jetty/npn/npn-boot/1.1.3.v20130313/npn-boot-1.1.3.v20130313.jar|lib/npn/npn-boot-1.1.3.v20130313.jar
|
||||
maven://org.mortbay.jetty.npn/npn-boot/1.1.3.v20130313|lib/npn/npn-boot-1.1.3.v20130313.jar
|
||||
|
||||
[exec]
|
||||
-Xbootclasspath/p:lib/npn/npn-boot-1.1.3.v20130313.jar
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
protonego-boot
|
||||
|
||||
[files]
|
||||
http://central.maven.org/maven2/org/mortbay/jetty/npn/npn-boot/1.1.4.v20130313/npn-boot-1.1.4.v20130313.jar|lib/npn/npn-boot-1.1.4.v20130313.jar
|
||||
maven://org.mortbay.jetty.npn/npn-boot/1.1.4.v20130313|lib/npn/npn-boot-1.1.4.v20130313.jar
|
||||
|
||||
[exec]
|
||||
-Xbootclasspath/p:lib/npn/npn-boot-1.1.4.v20130313.jar
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
protonego-boot
|
||||
|
||||
[files]
|
||||
http://central.maven.org/maven2/org/mortbay/jetty/npn/npn-boot/1.1.5.v20130313/npn-boot-1.1.5.v20130313.jar|lib/npn/npn-boot-1.1.5.v20130313.jar
|
||||
maven://org.mortbay.jetty.npn/npn-boot/1.1.5.v20130313|lib/npn/npn-boot-1.1.5.v20130313.jar
|
||||
|
||||
[exec]
|
||||
-Xbootclasspath/p:lib/npn/npn-boot-1.1.5.v20130313.jar
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
protonego-boot
|
||||
|
||||
[files]
|
||||
http://central.maven.org/maven2/org/mortbay/jetty/npn/npn-boot/1.1.5.v20130313/npn-boot-1.1.5.v20130313.jar|lib/npn/npn-boot-1.1.5.v20130313.jar
|
||||
maven://org.mortbay.jetty.npn/npn-boot/1.1.5.v20130313|lib/npn/npn-boot-1.1.5.v20130313.jar
|
||||
|
||||
[exec]
|
||||
-Xbootclasspath/p:lib/npn/npn-boot-1.1.5.v20130313.jar
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
protonego-boot
|
||||
|
||||
[files]
|
||||
http://central.maven.org/maven2/org/mortbay/jetty/npn/npn-boot/1.1.5.v20130313/npn-boot-1.1.5.v20130313.jar|lib/npn/npn-boot-1.1.5.v20130313.jar
|
||||
maven://org.mortbay.jetty.npn/npn-boot/1.1.5.v20130313|lib/npn/npn-boot-1.1.5.v20130313.jar
|
||||
|
||||
[exec]
|
||||
-Xbootclasspath/p:lib/npn/npn-boot-1.1.5.v20130313.jar
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
protonego-boot
|
||||
|
||||
[files]
|
||||
http://central.maven.org/maven2/org/mortbay/jetty/npn/npn-boot/1.1.5.v20130313/npn-boot-1.1.5.v20130313.jar|lib/npn/npn-boot-1.1.5.v20130313.jar
|
||||
maven://org.mortbay.jetty.npn/npn-boot/1.1.5.v20130313|lib/npn/npn-boot-1.1.5.v20130313.jar
|
||||
|
||||
[exec]
|
||||
-Xbootclasspath/p:lib/npn/npn-boot-1.1.5.v20130313.jar
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
protonego-boot
|
||||
|
||||
[files]
|
||||
http://central.maven.org/maven2/org/mortbay/jetty/npn/npn-boot/1.1.6.v20130911/npn-boot-1.1.6.v20130911.jar|lib/npn/npn-boot-1.1.6.v20130911.jar
|
||||
maven://org.mortbay.jetty.npn/npn-boot/1.1.6.v20130911|lib/npn/npn-boot-1.1.6.v20130911.jar
|
||||
|
||||
[exec]
|
||||
-Xbootclasspath/p:lib/npn/npn-boot-1.1.6.v20130911.jar
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
protonego-boot
|
||||
|
||||
[files]
|
||||
http://central.maven.org/maven2/org/mortbay/jetty/npn/npn-boot/1.1.6.v20130911/npn-boot-1.1.6.v20130911.jar|lib/npn/npn-boot-1.1.6.v20130911.jar
|
||||
maven://org.mortbay.jetty.npn/npn-boot/1.1.6.v20130911|lib/npn/npn-boot-1.1.6.v20130911.jar
|
||||
|
||||
[exec]
|
||||
-Xbootclasspath/p:lib/npn/npn-boot-1.1.6.v20130911.jar
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
protonego-boot
|
||||
|
||||
[files]
|
||||
http://central.maven.org/maven2/org/mortbay/jetty/npn/npn-boot/1.1.6.v20130911/npn-boot-1.1.6.v20130911.jar|lib/npn/npn-boot-1.1.6.v20130911.jar
|
||||
maven://org.mortbay.jetty.npn/npn-boot/1.1.6.v20130911|lib/npn/npn-boot-1.1.6.v20130911.jar
|
||||
|
||||
[exec]
|
||||
-Xbootclasspath/p:lib/npn/npn-boot-1.1.6.v20130911.jar
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
protonego-boot
|
||||
|
||||
[files]
|
||||
http://central.maven.org/maven2/org/mortbay/jetty/npn/npn-boot/1.1.8.v20141013/npn-boot-1.1.8.v20141013.jar|lib/npn/npn-boot-1.1.8.v20141013.jar
|
||||
maven://org.mortbay.jetty.npn/npn-boot/1.1.8.v20141013|lib/npn/npn-boot-1.1.8.v20141013.jar
|
||||
|
||||
[exec]
|
||||
-Xbootclasspath/p:lib/npn/npn-boot-1.1.8.v20141013.jar
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
protonego-boot
|
||||
|
||||
[files]
|
||||
http://central.maven.org/maven2/org/mortbay/jetty/npn/npn-boot/1.1.8.v20141013/npn-boot-1.1.8.v20141013.jar|lib/npn/npn-boot-1.1.8.v20141013.jar
|
||||
maven://org.mortbay.jetty.npn/npn-boot/1.1.8.v20141013|lib/npn/npn-boot-1.1.8.v20141013.jar
|
||||
|
||||
[exec]
|
||||
-Xbootclasspath/p:lib/npn/npn-boot-1.1.8.v20141013.jar
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
protonego-boot
|
||||
|
||||
[files]
|
||||
http://central.maven.org/maven2/org/mortbay/jetty/npn/npn-boot/1.1.8.v20141013/npn-boot-1.1.8.v20141013.jar|lib/npn/npn-boot-1.1.8.v20141013.jar
|
||||
maven://org.mortbay.jetty.npn/npn-boot/1.1.8.v20141013|lib/npn/npn-boot-1.1.8.v20141013.jar
|
||||
|
||||
[exec]
|
||||
-Xbootclasspath/p:lib/npn/npn-boot-1.1.8.v20141013.jar
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
protonego-boot
|
||||
|
||||
[files]
|
||||
http://central.maven.org/maven2/org/mortbay/jetty/npn/npn-boot/1.1.8.v20141013/npn-boot-1.1.8.v20141013.jar|lib/npn/npn-boot-1.1.8.v20141013.jar
|
||||
maven://org.mortbay.jetty.npn/npn-boot/1.1.8.v20141013|lib/npn/npn-boot-1.1.8.v20141013.jar
|
||||
|
||||
[exec]
|
||||
-Xbootclasspath/p:lib/npn/npn-boot-1.1.8.v20141013.jar
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
protonego-boot
|
||||
|
||||
[files]
|
||||
http://central.maven.org/maven2/org/mortbay/jetty/npn/npn-boot/1.1.9.v20141016/npn-boot-1.1.9.v20141016.jar|lib/npn/npn-boot-1.1.9.v20141016.jar
|
||||
maven://org.mortbay.jetty.npn/npn-boot/1.1.9.v20141016|lib/npn/npn-boot-1.1.9.v20141016.jar
|
||||
|
||||
[exec]
|
||||
-Xbootclasspath/p:lib/npn/npn-boot-1.1.9.v20141016.jar
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
protonego-boot
|
||||
|
||||
[files]
|
||||
http://central.maven.org/maven2/org/mortbay/jetty/npn/npn-boot/1.1.9.v20141016/npn-boot-1.1.9.v20141016.jar|lib/npn/npn-boot-1.1.9.v20141016.jar
|
||||
maven://org.mortbay.jetty.npn/npn-boot/1.1.9.v20141016|lib/npn/npn-boot-1.1.9.v20141016.jar
|
||||
|
||||
[exec]
|
||||
-Xbootclasspath/p:lib/npn/npn-boot-1.1.9.v20141016.jar
|
||||
|
|
|
@ -18,14 +18,11 @@
|
|||
|
||||
package org.eclipse.jetty.npn.server;
|
||||
|
||||
import static org.hamcrest.Matchers.*;
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URISyntaxException;
|
||||
import java.net.URL;
|
||||
import java.nio.file.Path;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
@ -36,7 +33,6 @@ import org.eclipse.jetty.start.FileArg;
|
|||
import org.eclipse.jetty.start.Module;
|
||||
import org.eclipse.jetty.toolchain.test.FS;
|
||||
import org.eclipse.jetty.toolchain.test.MavenTestingUtils;
|
||||
import org.eclipse.jetty.util.IO;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
@ -44,32 +40,9 @@ import org.junit.runners.Parameterized;
|
|||
import org.junit.runners.Parameterized.Parameter;
|
||||
import org.junit.runners.Parameterized.Parameters;
|
||||
|
||||
import static org.hamcrest.Matchers.is;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertThat;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assert.fail;
|
||||
|
||||
@RunWith(Parameterized.class)
|
||||
public class NPNModuleTest
|
||||
{
|
||||
/** This is here to prevent pointless download attempts */
|
||||
private static final List<String> KNOWN_GOOD_NPN_URLS = new ArrayList<>();
|
||||
|
||||
static
|
||||
{
|
||||
/** The main() method in this test case can be run to validate this list independently */
|
||||
KNOWN_GOOD_NPN_URLS.add("http://central.maven.org/maven2/org/mortbay/jetty/npn/npn-boot/1.1.9.v20141016/npn-boot-1.1.9.v20141016.jar");
|
||||
KNOWN_GOOD_NPN_URLS.add("http://central.maven.org/maven2/org/mortbay/jetty/npn/npn-boot/1.1.8.v20141013/npn-boot-1.1.8.v20141013.jar");
|
||||
KNOWN_GOOD_NPN_URLS.add("http://central.maven.org/maven2/org/mortbay/jetty/npn/npn-boot/1.1.6.v20130911/npn-boot-1.1.6.v20130911.jar");
|
||||
KNOWN_GOOD_NPN_URLS.add("http://central.maven.org/maven2/org/mortbay/jetty/npn/npn-boot/1.1.5.v20130313/npn-boot-1.1.5.v20130313.jar");
|
||||
KNOWN_GOOD_NPN_URLS.add("http://central.maven.org/maven2/org/mortbay/jetty/npn/npn-boot/1.1.4.v20130313/npn-boot-1.1.4.v20130313.jar");
|
||||
KNOWN_GOOD_NPN_URLS.add("http://central.maven.org/maven2/org/mortbay/jetty/npn/npn-boot/1.1.3.v20130313/npn-boot-1.1.3.v20130313.jar");
|
||||
KNOWN_GOOD_NPN_URLS.add("http://central.maven.org/maven2/org/mortbay/jetty/npn/npn-boot/1.1.2.v20130305/npn-boot-1.1.2.v20130305.jar");
|
||||
KNOWN_GOOD_NPN_URLS.add("http://central.maven.org/maven2/org/mortbay/jetty/npn/npn-boot/1.1.1.v20121030/npn-boot-1.1.1.v20121030.jar");
|
||||
KNOWN_GOOD_NPN_URLS.add("http://central.maven.org/maven2/org/mortbay/jetty/npn/npn-boot/1.1.0.v20120525/npn-boot-1.1.0.v20120525.jar");
|
||||
}
|
||||
|
||||
@Parameters(name = "{index}: mod:{0}")
|
||||
public static List<Object[]> data()
|
||||
{
|
||||
|
@ -121,7 +94,7 @@ public class NPNModuleTest
|
|||
FileArg farg = new FileArg(line);
|
||||
if (farg.uri != null)
|
||||
{
|
||||
assertTrue("Not a known good NPN URL: " + farg.uri,KNOWN_GOOD_NPN_URLS.contains(farg.uri));
|
||||
assertThat("NPN URL", farg.uri, startsWith("maven://org.mortbay.jetty.npn/npn-boot/"));
|
||||
expectedBootClasspath.add("-Xbootclasspath/p:" + farg.location);
|
||||
}
|
||||
}
|
||||
|
@ -145,47 +118,4 @@ public class NPNModuleTest
|
|||
fail(err.toString());
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String[] args)
|
||||
{
|
||||
File outputDir = MavenTestingUtils.getTargetTestingDir(NPNModuleTest.class.getSimpleName() + "-main");
|
||||
FS.ensureEmpty(outputDir);
|
||||
for (String ref : KNOWN_GOOD_NPN_URLS)
|
||||
{
|
||||
try
|
||||
{
|
||||
URL url = new URL(ref);
|
||||
System.err.printf("Attempting: %s%n",ref);
|
||||
HttpURLConnection connection = (HttpURLConnection)url.openConnection();
|
||||
String refname = url.toURI().getPath();
|
||||
int idx = refname.lastIndexOf('/');
|
||||
File outputFile = new File(outputDir,refname.substring(idx));
|
||||
try (InputStream stream = connection.getInputStream(); FileOutputStream out = new FileOutputStream(outputFile))
|
||||
{
|
||||
assertThat("Response Status Code",connection.getResponseCode(),is(200));
|
||||
IO.copy(stream,out);
|
||||
System.err.printf("Downloaded %,d bytes%n",outputFile.length());
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
e.printStackTrace(System.err);
|
||||
}
|
||||
}
|
||||
catch (MalformedURLException e)
|
||||
{
|
||||
System.err.printf("Bad Ref: %s%n",ref);
|
||||
e.printStackTrace(System.err);
|
||||
}
|
||||
catch (URISyntaxException e)
|
||||
{
|
||||
System.err.printf("Bad Ref Syntax: %s%n",ref);
|
||||
e.printStackTrace(System.err);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
System.err.printf("Bad Connection: %s%n",ref);
|
||||
e.printStackTrace(System.err);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,365 @@
|
|||
//
|
||||
// ========================================================================
|
||||
// Copyright (c) 1995-2014 Mort Bay Consulting Pty. Ltd.
|
||||
// ------------------------------------------------------------------------
|
||||
// All rights reserved. This program and the accompanying materials
|
||||
// are made available under the terms of the Eclipse Public License v1.0
|
||||
// and Apache License v2.0 which accompanies this distribution.
|
||||
//
|
||||
// The Eclipse Public License is available at
|
||||
// http://www.eclipse.org/legal/epl-v10.html
|
||||
//
|
||||
// The Apache License v2.0 is available at
|
||||
// http://www.opensource.org/licenses/apache2.0.php
|
||||
//
|
||||
// You may elect to redistribute this code under either of these licenses.
|
||||
// ========================================================================
|
||||
//
|
||||
|
||||
package org.eclipse.jetty.start;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URI;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.jetty.start.Modules.AndMatcher;
|
||||
import org.eclipse.jetty.start.Modules.EnabledMatcher;
|
||||
import org.eclipse.jetty.start.Modules.Matcher;
|
||||
import org.eclipse.jetty.start.Modules.SourceSetMatcher;
|
||||
import org.eclipse.jetty.start.Modules.UniqueSourceMatcher;
|
||||
import org.eclipse.jetty.start.builders.StartDirBuilder;
|
||||
import org.eclipse.jetty.start.builders.StartIniBuilder;
|
||||
import org.eclipse.jetty.start.fileinits.MavenLocalRepoFileInitializer;
|
||||
import org.eclipse.jetty.start.fileinits.TestFileInitializer;
|
||||
import org.eclipse.jetty.start.fileinits.UriFileInitializer;
|
||||
|
||||
/**
|
||||
* Build a start configuration in <code>${jetty.base}</code>, including
|
||||
* ini files, directories, and libs. Also handles License management.
|
||||
*/
|
||||
public class BaseBuilder
|
||||
{
|
||||
public static interface Config
|
||||
{
|
||||
/**
|
||||
* Add a module to the start environment in <code>${jetty.base}</code>
|
||||
*
|
||||
* @param module
|
||||
* the module to add
|
||||
* @return true if module was added, false if module was not added
|
||||
* (because that module already exists)
|
||||
* @throws IOException
|
||||
*/
|
||||
public boolean addModule(Module module) throws IOException;
|
||||
}
|
||||
|
||||
private static final String EXITING_LICENSE_NOT_ACKNOWLEDGED = "Exiting: license not acknowledged!";
|
||||
|
||||
private final BaseHome baseHome;
|
||||
private final List<FileInitializer> fileInitializers;
|
||||
private final StartArgs startArgs;
|
||||
|
||||
public BaseBuilder(BaseHome baseHome, StartArgs args)
|
||||
{
|
||||
this.baseHome = baseHome;
|
||||
this.startArgs = args;
|
||||
this.fileInitializers = new ArrayList<>();
|
||||
|
||||
// Establish FileInitializers
|
||||
if (args.isTestingModeEnabled())
|
||||
{
|
||||
// No downloads performed
|
||||
fileInitializers.add(new TestFileInitializer());
|
||||
}
|
||||
else if (args.isDownload())
|
||||
{
|
||||
// Downloads are allowed to be performed
|
||||
// Setup Maven Local Repo
|
||||
Path localRepoDir = args.getMavenLocalRepoDir();
|
||||
if (localRepoDir != null)
|
||||
{
|
||||
// Use provided local repo directory
|
||||
fileInitializers.add(new MavenLocalRepoFileInitializer(baseHome,localRepoDir));
|
||||
}
|
||||
else
|
||||
{
|
||||
// No no local repo directory (direct downloads)
|
||||
fileInitializers.add(new MavenLocalRepoFileInitializer(baseHome));
|
||||
}
|
||||
|
||||
// Normal URL downloads
|
||||
fileInitializers.add(new UriFileInitializer(baseHome));
|
||||
}
|
||||
}
|
||||
|
||||
private void ackLicenses() throws IOException
|
||||
{
|
||||
if (startArgs.isLicenseCheckRequired())
|
||||
{
|
||||
if (startArgs.isApproveAllLicenses())
|
||||
{
|
||||
StartLog.info("All Licenses Approved via Command Line Option");
|
||||
}
|
||||
else
|
||||
{
|
||||
Licensing licensing = new Licensing();
|
||||
for (Module module : startArgs.getAllModules().getEnabled())
|
||||
{
|
||||
licensing.addModule(module);
|
||||
}
|
||||
|
||||
if (licensing.hasLicenses())
|
||||
{
|
||||
StartLog.debug("Requesting License Acknowledgement");
|
||||
if (!licensing.acknowledgeLicenses())
|
||||
{
|
||||
StartLog.warn(EXITING_LICENSE_NOT_ACKNOWLEDGED);
|
||||
System.exit(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Build out the Base directory (if needed)
|
||||
*
|
||||
* @return true if base directory was changed, false if left unchanged.
|
||||
* @throws IOException
|
||||
*/
|
||||
public boolean build() throws IOException
|
||||
{
|
||||
Modules modules = startArgs.getAllModules();
|
||||
boolean dirty = false;
|
||||
|
||||
String dirSource = "<add-to-startd>";
|
||||
String iniSource = "<add-to-start-ini>";
|
||||
|
||||
int count = 0;
|
||||
count += modules.enableAll(startArgs.getAddToStartdIni(),dirSource);
|
||||
count += modules.enableAll(startArgs.getAddToStartIni(),iniSource);
|
||||
|
||||
Matcher startDMatcher = new AndMatcher(new EnabledMatcher(),new UniqueSourceMatcher(dirSource));
|
||||
Matcher startIniMatcher = new AndMatcher(new EnabledMatcher(),new UniqueSourceMatcher(iniSource));
|
||||
|
||||
// look for ambiguous declaration in 2 places
|
||||
Matcher ambiguousMatcher = new AndMatcher(new EnabledMatcher(),new SourceSetMatcher(dirSource,iniSource));
|
||||
List<Module> ambiguous = modules.getMatching(ambiguousMatcher);
|
||||
|
||||
if (ambiguous.size() > 0)
|
||||
{
|
||||
StringBuilder err = new StringBuilder();
|
||||
err.append("Unable to add ");
|
||||
err.append(ambiguous.size());
|
||||
err.append(" module");
|
||||
if (ambiguous.size() > 1)
|
||||
{
|
||||
err.append('s');
|
||||
}
|
||||
err.append(" (found declared via both --add-to-start and --add-to-startd): [");
|
||||
for (int i = 0; i < ambiguous.size(); i++)
|
||||
{
|
||||
if (i > 0)
|
||||
{
|
||||
err.append(", ");
|
||||
}
|
||||
err.append(ambiguous.get(i).getName());
|
||||
}
|
||||
err.append(']');
|
||||
throw new RuntimeException(err.toString());
|
||||
}
|
||||
|
||||
StartLog.debug("Adding %s new module(s)",count);
|
||||
|
||||
// Acknowledge Licenses
|
||||
ackLicenses();
|
||||
|
||||
// Collect specific modules to enable
|
||||
List<Module> startDModules = modules.getMatching(startDMatcher);
|
||||
List<Module> startIniModules = modules.getMatching(startIniMatcher);
|
||||
|
||||
List<FileArg> files = new ArrayList<FileArg>();
|
||||
|
||||
if (!startDModules.isEmpty())
|
||||
{
|
||||
StartDirBuilder builder = new StartDirBuilder(this);
|
||||
for (Module mod : startDModules)
|
||||
{
|
||||
dirty |= builder.addModule(mod);
|
||||
for (String file : mod.getFiles())
|
||||
{
|
||||
files.add(new FileArg(mod,file));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!startIniModules.isEmpty())
|
||||
{
|
||||
StartIniBuilder builder = new StartIniBuilder(this);
|
||||
for (Module mod : startIniModules)
|
||||
{
|
||||
dirty |= builder.addModule(mod);
|
||||
for (String file : mod.getFiles())
|
||||
{
|
||||
files.add(new FileArg(mod,file));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Process files
|
||||
files.addAll(startArgs.getFiles());
|
||||
dirty |= processFileResources(files);
|
||||
|
||||
return dirty;
|
||||
}
|
||||
|
||||
public BaseHome getBaseHome()
|
||||
{
|
||||
return baseHome;
|
||||
}
|
||||
|
||||
public StartArgs getStartArgs()
|
||||
{
|
||||
return startArgs;
|
||||
}
|
||||
|
||||
/**
|
||||
* Process a specific file resource
|
||||
*
|
||||
* @param arg
|
||||
* the fileArg to work with
|
||||
* @param file
|
||||
* the resolved file reference to work with
|
||||
* @return true if change was made as a result of the file, false if no change made.
|
||||
* @throws IOException
|
||||
* if there was an issue in processing this file
|
||||
*/
|
||||
private boolean processFileResource(FileArg arg, Path file) throws IOException
|
||||
{
|
||||
if (startArgs.isDownload() && (arg.uri != null))
|
||||
{
|
||||
URI uri = URI.create(arg.uri);
|
||||
|
||||
// Process via initializers
|
||||
for (FileInitializer finit : fileInitializers)
|
||||
{
|
||||
if (finit.init(uri,file))
|
||||
{
|
||||
// Completed successfully
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Process directly
|
||||
boolean isDir = arg.location.endsWith("/");
|
||||
|
||||
if (FS.exists(file))
|
||||
{
|
||||
// Validate existence
|
||||
if (isDir)
|
||||
{
|
||||
if (!Files.isDirectory(file))
|
||||
{
|
||||
throw new IOException("Invalid: path should be a directory (but isn't): " + file);
|
||||
}
|
||||
if (!FS.canReadDirectory(file))
|
||||
{
|
||||
throw new IOException("Unable to read directory: " + file);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!FS.canReadFile(file))
|
||||
{
|
||||
throw new IOException("Unable to read file: " + file);
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
if (isDir)
|
||||
{
|
||||
// Create directory
|
||||
StartLog.log("MKDIR",baseHome.toShortForm(file));
|
||||
return FS.ensureDirectoryExists(file);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Warn on missing file (this has to be resolved manually by user)
|
||||
String shortRef = baseHome.toShortForm(file);
|
||||
if (startArgs.isTestingModeEnabled())
|
||||
{
|
||||
StartLog.log("TESTING MODE","Skipping required file check on: %s",shortRef);
|
||||
return true;
|
||||
}
|
||||
|
||||
StartLog.warn("Missing Required File: %s",baseHome.toShortForm(file));
|
||||
startArgs.setRun(false);
|
||||
if (arg.uri != null)
|
||||
{
|
||||
StartLog.warn(" Can be downloaded From: %s",arg.uri);
|
||||
StartLog.warn(" Run start.jar --create-files to download");
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Process the {@link FileArg} for startup, assume that all licenses have
|
||||
* been acknowledged at this stage.
|
||||
*
|
||||
* @param files
|
||||
* the list of {@link FileArg}s to process
|
||||
* @return true if base directory modified, false if left untouched
|
||||
*/
|
||||
private boolean processFileResources(List<FileArg> files) throws IOException
|
||||
{
|
||||
if ((files == null) || (files.isEmpty()))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
boolean dirty = false;
|
||||
|
||||
List<String> failures = new ArrayList<String>();
|
||||
|
||||
for (FileArg arg : files)
|
||||
{
|
||||
Path file = baseHome.getBasePath(arg.location);
|
||||
try
|
||||
{
|
||||
dirty |= processFileResource(arg,file);
|
||||
}
|
||||
catch (Throwable t)
|
||||
{
|
||||
StartLog.warn(t);
|
||||
failures.add(String.format("[%s] %s - %s",t.getClass().getSimpleName(),t.getMessage(),file.toAbsolutePath().toString()));
|
||||
}
|
||||
}
|
||||
|
||||
if (!failures.isEmpty())
|
||||
{
|
||||
StringBuilder err = new StringBuilder();
|
||||
err.append("Failed to process all file resources.");
|
||||
for (String failure : failures)
|
||||
{
|
||||
err.append(System.lineSeparator()).append(" - ").append(failure);
|
||||
}
|
||||
StartLog.warn(err.toString());
|
||||
|
||||
throw new RuntimeException(err.toString());
|
||||
}
|
||||
|
||||
return dirty;
|
||||
}
|
||||
}
|
|
@ -67,14 +67,15 @@ public class FS
|
|||
return Files.exists(ret);
|
||||
}
|
||||
|
||||
public static void ensureDirectoryExists(Path dir) throws IOException
|
||||
public static boolean ensureDirectoryExists(Path dir) throws IOException
|
||||
{
|
||||
if (exists(dir))
|
||||
{
|
||||
// exists already, nothing to do
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
Files.createDirectories(dir);
|
||||
return true;
|
||||
}
|
||||
|
||||
public static void ensureDirectoryWritable(Path dir) throws IOException
|
||||
|
|
|
@ -0,0 +1,43 @@
|
|||
//
|
||||
// ========================================================================
|
||||
// Copyright (c) 1995-2014 Mort Bay Consulting Pty. Ltd.
|
||||
// ------------------------------------------------------------------------
|
||||
// All rights reserved. This program and the accompanying materials
|
||||
// are made available under the terms of the Eclipse Public License v1.0
|
||||
// and Apache License v2.0 which accompanies this distribution.
|
||||
//
|
||||
// The Eclipse Public License is available at
|
||||
// http://www.eclipse.org/legal/epl-v10.html
|
||||
//
|
||||
// The Apache License v2.0 is available at
|
||||
// http://www.opensource.org/licenses/apache2.0.php
|
||||
//
|
||||
// You may elect to redistribute this code under either of these licenses.
|
||||
// ========================================================================
|
||||
//
|
||||
|
||||
package org.eclipse.jetty.start;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URI;
|
||||
import java.nio.file.Path;
|
||||
|
||||
/**
|
||||
* Interface for initializing a file resource.
|
||||
*/
|
||||
public interface FileInitializer
|
||||
{
|
||||
/**
|
||||
* Initialize a file resource
|
||||
*
|
||||
* @param uri
|
||||
* the remote URI of the resource acting as its source
|
||||
* @param file
|
||||
* the local file resource to initialize
|
||||
* @return true if local file is initialized (resulted in a change on disk), false if this
|
||||
* {@link FileInitializer} did nothing.
|
||||
* @throws IOException
|
||||
* if there was an attempt to initialize, but an error occurred.
|
||||
*/
|
||||
public boolean init(URI uri, Path file) throws IOException;
|
||||
}
|
|
@ -0,0 +1,104 @@
|
|||
//
|
||||
// ========================================================================
|
||||
// Copyright (c) 1995-2014 Mort Bay Consulting Pty. Ltd.
|
||||
// ------------------------------------------------------------------------
|
||||
// All rights reserved. This program and the accompanying materials
|
||||
// are made available under the terms of the Eclipse Public License v1.0
|
||||
// and Apache License v2.0 which accompanies this distribution.
|
||||
//
|
||||
// The Eclipse Public License is available at
|
||||
// http://www.eclipse.org/legal/epl-v10.html
|
||||
//
|
||||
// The Apache License v2.0 is available at
|
||||
// http://www.opensource.org/licenses/apache2.0.php
|
||||
//
|
||||
// You may elect to redistribute this code under either of these licenses.
|
||||
// ========================================================================
|
||||
//
|
||||
|
||||
package org.eclipse.jetty.start;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.TreeMap;
|
||||
|
||||
/**
|
||||
* Handles basic license presentation and acknowledgement.
|
||||
*/
|
||||
public class Licensing
|
||||
{
|
||||
private static final String PROP_ACK_LICENSES = "org.eclipse.jetty.start.ack.licenses";
|
||||
public Map<String, List<String>> licenseMap = new TreeMap<>(new NaturalSort.Strings());
|
||||
|
||||
public void addModule(Module module)
|
||||
{
|
||||
if (!module.hasLicense())
|
||||
{
|
||||
// skip, no license
|
||||
return;
|
||||
}
|
||||
|
||||
if (licenseMap.containsKey(module.getName()))
|
||||
{
|
||||
// skip, already being tracked
|
||||
return;
|
||||
}
|
||||
|
||||
licenseMap.put(module.getName(),module.getLicense());
|
||||
}
|
||||
|
||||
public boolean hasLicenses()
|
||||
{
|
||||
return !licenseMap.isEmpty();
|
||||
}
|
||||
|
||||
public boolean acknowledgeLicenses() throws IOException
|
||||
{
|
||||
if (!hasLicenses())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
System.err.printf("%nALERT: There are enabled module(s) with licenses.%n");
|
||||
System.err.printf("The following %d module(s):%n", licenseMap.size());
|
||||
System.err.printf(" + contains software not provided by the Eclipse Foundation!%n");
|
||||
System.err.printf(" + contains software not covered by the Eclipse Public License!%n");
|
||||
System.err.printf(" + has not been audited for compliance with its license%n");
|
||||
|
||||
for (String key : licenseMap.keySet())
|
||||
{
|
||||
System.err.printf("%n Module: %s%n",key);
|
||||
for (String line : licenseMap.get(key))
|
||||
{
|
||||
System.err.printf(" + %s%n",line);
|
||||
}
|
||||
}
|
||||
|
||||
boolean licenseAck = false;
|
||||
|
||||
String propBasedAckValue = System.getProperty(PROP_ACK_LICENSES);
|
||||
if (propBasedAckValue != null)
|
||||
{
|
||||
StartLog.log("TESTING MODE","Programmatic ACK - %s=%s",PROP_ACK_LICENSES,propBasedAckValue);
|
||||
licenseAck = Boolean.parseBoolean(propBasedAckValue);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (Boolean.getBoolean("org.eclipse.jetty.start.testing"))
|
||||
{
|
||||
throw new RuntimeException("Test Configuration Missing - Pre-specify answer to (" + PROP_ACK_LICENSES + ") in test case");
|
||||
}
|
||||
|
||||
BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
|
||||
System.err.printf("%nProceed (y/N)? ");
|
||||
String response = input.readLine();
|
||||
|
||||
licenseAck = (Utils.isNotBlank(response) && response.toLowerCase().startsWith("y"));
|
||||
}
|
||||
|
||||
return licenseAck;
|
||||
}
|
||||
}
|
|
@ -21,33 +21,21 @@ package org.eclipse.jetty.start;
|
|||
import static org.eclipse.jetty.start.UsageException.*;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.BufferedWriter;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.LineNumberReader;
|
||||
import java.io.OutputStream;
|
||||
import java.io.PrintWriter;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.net.ConnectException;
|
||||
import java.net.InetAddress;
|
||||
import java.net.Socket;
|
||||
import java.net.SocketTimeoutException;
|
||||
import java.net.URL;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.StandardOpenOption;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Set;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import org.eclipse.jetty.start.config.CommandLineConfigSource;
|
||||
|
||||
|
@ -80,29 +68,8 @@ import org.eclipse.jetty.start.config.CommandLineConfigSource;
|
|||
*/
|
||||
public class Main
|
||||
{
|
||||
private static final String EXITING_LICENSE_NOT_ACKNOWLEDGED = "Exiting: license not acknowledged!";
|
||||
private static final int EXIT_USAGE = 1;
|
||||
|
||||
public static String join(Collection<?> objs, String delim)
|
||||
{
|
||||
if (objs==null)
|
||||
{
|
||||
return "";
|
||||
}
|
||||
StringBuilder str = new StringBuilder();
|
||||
boolean needDelim = false;
|
||||
for (Object obj : objs)
|
||||
{
|
||||
if (needDelim)
|
||||
{
|
||||
str.append(delim);
|
||||
}
|
||||
str.append(obj);
|
||||
needDelim = true;
|
||||
}
|
||||
return str.toString();
|
||||
}
|
||||
|
||||
public static void main(String[] args)
|
||||
{
|
||||
try
|
||||
|
@ -172,76 +139,6 @@ public class Main
|
|||
}).start();
|
||||
}
|
||||
|
||||
private void initFile(StartArgs args, FileArg farg)
|
||||
{
|
||||
try
|
||||
{
|
||||
Path file = baseHome.getBasePath(farg.location);
|
||||
|
||||
StartLog.debug("[init-file] %s module specified file %s",file.toAbsolutePath(),(FS.exists(file)?"[Exists!]":""));
|
||||
if (FS.exists(file))
|
||||
{
|
||||
// file already initialized / downloaded, skip it
|
||||
return;
|
||||
}
|
||||
|
||||
if (farg.uri!=null)
|
||||
{
|
||||
URL url = new URL(farg.uri);
|
||||
|
||||
StartLog.log("DOWNLOAD", "%s to %s", url, farg.location);
|
||||
|
||||
FS.ensureDirectoryExists(file.getParent());
|
||||
|
||||
if (args.isTestingModeEnabled())
|
||||
{
|
||||
StartLog.log("TESTING MODE", "Skipping download of " + url);
|
||||
return;
|
||||
}
|
||||
|
||||
byte[] buf = new byte[8192];
|
||||
try (InputStream in = url.openStream();
|
||||
OutputStream out = Files.newOutputStream(file,StandardOpenOption.CREATE_NEW,StandardOpenOption.WRITE))
|
||||
{
|
||||
while (true)
|
||||
{
|
||||
int len = in.read(buf);
|
||||
|
||||
if (len > 0)
|
||||
{
|
||||
out.write(buf,0,len);
|
||||
}
|
||||
if (len < 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (farg.location.endsWith("/"))
|
||||
{
|
||||
StartLog.log("MKDIR",baseHome.toShortForm(file));
|
||||
FS.ensureDirectoryExists(file);
|
||||
}
|
||||
else
|
||||
{
|
||||
String shortRef = baseHome.toShortForm(file);
|
||||
if (args.isTestingModeEnabled())
|
||||
{
|
||||
StartLog.log("TESTING MODE","Skipping required file check on: %s",shortRef);
|
||||
return;
|
||||
}
|
||||
StartLog.warn("MISSING: Required file %s",shortRef);
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
StartLog.warn("ERROR: processing %s%n%s",farg,e);
|
||||
StartLog.warn(e);
|
||||
usageExit(EXIT_USAGE);
|
||||
}
|
||||
}
|
||||
|
||||
private void dumpClasspathWithVersions(Classpath classpath)
|
||||
{
|
||||
StartLog.endStartLog();
|
||||
|
@ -360,219 +257,6 @@ public class Main
|
|||
modules.dumpEnabledTree();
|
||||
}
|
||||
|
||||
/**
|
||||
* Build out INI file.
|
||||
* <p>
|
||||
* This applies equally for either <code>${jetty.base}/start.ini</code> or
|
||||
* <code>${jetty.base}/start.d/${name}.ini</code>
|
||||
*
|
||||
* @param args the arguments of what modules are enabled
|
||||
* @param name the name of the module to based the build of the ini
|
||||
* @param topLevel
|
||||
* @param appendStartIni true to append to <code>${jetty.base}/start.ini</code>,
|
||||
* false to create a <code>${jetty.base}/start.d/${name}.ini</code> entry instead.
|
||||
* @throws IOException
|
||||
*/
|
||||
private void buildIni(StartArgs args, String name, boolean topLevel, boolean appendStartIni) throws IOException
|
||||
{
|
||||
// Find the start.d relative to the base directory only.
|
||||
Path start_d = baseHome.getBasePath("start.d");
|
||||
|
||||
// Is this a module?
|
||||
Modules modules = args.getAllModules();
|
||||
Module module = modules.get(name);
|
||||
if (module == null)
|
||||
{
|
||||
StartLog.warn("ERROR: No known module for %s",name);
|
||||
return;
|
||||
}
|
||||
|
||||
boolean transitive = module.isEnabled() && (module.getSources().size() == 0);
|
||||
|
||||
// Find any named ini file and check it follows the convention
|
||||
Path start_ini = baseHome.getBasePath("start.ini");
|
||||
String short_start_ini = baseHome.toShortForm(start_ini);
|
||||
Path startd_ini = start_d.resolve(name + ".ini");
|
||||
String short_startd_ini = baseHome.toShortForm(startd_ini);
|
||||
StartIni module_ini = null;
|
||||
if (FS.exists(startd_ini))
|
||||
{
|
||||
module_ini = new StartIni(startd_ini);
|
||||
if (module_ini.getLineMatches(Pattern.compile("--module=(.*, *)*" + name)).size() == 0)
|
||||
{
|
||||
StartLog.warn("ERROR: %s is not enabled in %s!",name,short_startd_ini);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (!args.isApproveAllLicenses())
|
||||
{
|
||||
if (!module.acknowledgeLicense())
|
||||
{
|
||||
StartLog.warn(EXITING_LICENSE_NOT_ACKNOWLEDGED);
|
||||
System.exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
boolean buildIni=false;
|
||||
if (module.isEnabled())
|
||||
{
|
||||
// is it an explicit request to create an ini file?
|
||||
if (topLevel && !FS.exists(startd_ini) && !appendStartIni)
|
||||
{
|
||||
buildIni=true;
|
||||
}
|
||||
// else is it transitive
|
||||
else if (transitive)
|
||||
{
|
||||
if (module.hasDefaultConfig())
|
||||
{
|
||||
buildIni = true;
|
||||
StartLog.info("%-15s initialised transitively",name);
|
||||
}
|
||||
}
|
||||
// else must be initialized explicitly
|
||||
else
|
||||
{
|
||||
for (String source : module.getSources())
|
||||
{
|
||||
StartLog.info("%-15s initialised in %s",name,baseHome.toShortForm(source));
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
buildIni=true;
|
||||
}
|
||||
|
||||
String source = "<transitive>";
|
||||
|
||||
// If we need an ini
|
||||
if (buildIni)
|
||||
{
|
||||
// File BufferedWriter
|
||||
BufferedWriter writer = null;
|
||||
PrintWriter out = null;
|
||||
try
|
||||
{
|
||||
if (appendStartIni)
|
||||
{
|
||||
source = short_start_ini;
|
||||
StartLog.info("%-15s initialised in %s (appended)",name,source);
|
||||
writer = Files.newBufferedWriter(start_ini,StandardCharsets.UTF_8,StandardOpenOption.CREATE,StandardOpenOption.APPEND);
|
||||
out = new PrintWriter(writer);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Create the directory if needed
|
||||
FS.ensureDirectoryExists(start_d);
|
||||
FS.ensureDirectoryWritable(start_d);
|
||||
source = short_startd_ini;
|
||||
StartLog.info("%-15s initialised in %s (created)",name,source);
|
||||
writer = Files.newBufferedWriter(startd_ini,StandardCharsets.UTF_8,StandardOpenOption.CREATE_NEW,StandardOpenOption.WRITE);
|
||||
out = new PrintWriter(writer);
|
||||
}
|
||||
|
||||
if (appendStartIni)
|
||||
{
|
||||
out.println();
|
||||
}
|
||||
out.println("# --------------------------------------- ");
|
||||
out.println("# Module: " + name);
|
||||
|
||||
out.println("--module=" + name);
|
||||
|
||||
args.parse("--module=" + name,source);
|
||||
args.parseModule(module);
|
||||
|
||||
for (String line : module.getDefaultConfig())
|
||||
{
|
||||
out.println(line);
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (out != null)
|
||||
{
|
||||
out.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
modules.enable(name,Collections.singletonList(source));
|
||||
|
||||
// Also list other places this module is enabled
|
||||
for (String src : module.getSources())
|
||||
{
|
||||
StartLog.debug("also enabled in: %s",src);
|
||||
if (!short_start_ini.equals(src))
|
||||
{
|
||||
StartLog.info("%-15s enabled in %s",name,baseHome.toShortForm(src));
|
||||
}
|
||||
}
|
||||
|
||||
// Do downloads now
|
||||
for (String file : module.getFiles())
|
||||
{
|
||||
initFile(args, new FileArg(module,file));
|
||||
}
|
||||
|
||||
// Process dependencies
|
||||
module.expandProperties(args.getProperties());
|
||||
modules.registerParentsIfMissing(module);
|
||||
modules.buildGraph();
|
||||
|
||||
// process new ini modules
|
||||
if (topLevel)
|
||||
{
|
||||
List<Module> depends = new ArrayList<>();
|
||||
for (String depend : modules.resolveParentModulesOf(name))
|
||||
{
|
||||
if (!name.equals(depend))
|
||||
{
|
||||
Module m = modules.get(depend);
|
||||
m.setEnabled(true);
|
||||
depends.add(m);
|
||||
}
|
||||
}
|
||||
Collections.sort(depends,Collections.reverseOrder(new Module.DepthComparator()));
|
||||
|
||||
Set<String> done = new HashSet<>(0);
|
||||
while (true)
|
||||
{
|
||||
// initialize known dependencies
|
||||
boolean complete=true;
|
||||
for (Module m : depends)
|
||||
{
|
||||
if (!done.contains(m.getName()))
|
||||
{
|
||||
complete=false;
|
||||
buildIni(args,m.getName(),false,appendStartIni);
|
||||
done.add(m.getName());
|
||||
}
|
||||
}
|
||||
|
||||
if (complete)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
// look for any new ones resolved via expansion
|
||||
depends.clear();
|
||||
for (String depend : modules.resolveParentModulesOf(name))
|
||||
{
|
||||
if (!name.equals(depend))
|
||||
{
|
||||
Module m = modules.get(depend);
|
||||
m.setEnabled(true);
|
||||
depends.add(m);
|
||||
}
|
||||
}
|
||||
Collections.sort(depends,Collections.reverseOrder(new Module.DepthComparator()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Convenience for <code>processCommandLine(cmdLine.toArray(new String[cmdLine.size()]))</code>
|
||||
*/
|
||||
|
@ -619,7 +303,8 @@ public class Main
|
|||
modules.buildGraph();
|
||||
|
||||
args.setAllModules(modules);
|
||||
List<Module> activeModules = modules.resolveEnabled();
|
||||
List<Module> activeModules = modules.getEnabled();
|
||||
modules.assertModulesValid(activeModules);
|
||||
|
||||
// ------------------------------------------------------------
|
||||
// 5) Lib & XML Expansion / Resolution
|
||||
|
@ -636,7 +321,7 @@ public class Main
|
|||
|
||||
return args;
|
||||
}
|
||||
|
||||
|
||||
public void start(StartArgs args) throws IOException, InterruptedException
|
||||
{
|
||||
StartLog.debug("StartArgs: %s",args);
|
||||
|
@ -692,83 +377,12 @@ public class Main
|
|||
doStop(args);
|
||||
}
|
||||
|
||||
boolean rebuildGraph = false;
|
||||
|
||||
// Initialize start.ini
|
||||
for (String module : args.getAddToStartIni())
|
||||
BaseBuilder baseBuilder = new BaseBuilder(baseHome,args);
|
||||
if(baseBuilder.build())
|
||||
{
|
||||
buildIni(args,module,true,true);
|
||||
rebuildGraph = true;
|
||||
}
|
||||
|
||||
// Initialize start.d
|
||||
for (String module : args.getAddToStartdIni())
|
||||
{
|
||||
buildIni(args,module,true,false);
|
||||
rebuildGraph = true;
|
||||
}
|
||||
|
||||
if (rebuildGraph)
|
||||
{
|
||||
args.getAllModules().clearMissing();
|
||||
args.getAllModules().buildGraph();
|
||||
}
|
||||
|
||||
// If in --create-files, check licenses
|
||||
if(args.isDownload())
|
||||
{
|
||||
if (!args.isApproveAllLicenses())
|
||||
{
|
||||
for (Module module : args.getAllModules().resolveEnabled())
|
||||
{
|
||||
if (!module.acknowledgeLicense())
|
||||
{
|
||||
StartLog.warn(EXITING_LICENSE_NOT_ACKNOWLEDGED);
|
||||
System.exit(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Check ini files for download possibilities
|
||||
for (FileArg arg : args.getFiles())
|
||||
{
|
||||
Path file = baseHome.getBasePath(arg.location);
|
||||
if (!FS.exists(file) && args.isDownload())
|
||||
{
|
||||
initFile(args, arg);
|
||||
}
|
||||
|
||||
if (!FS.exists(file))
|
||||
{
|
||||
boolean isDir = arg.location.endsWith("/");
|
||||
if (isDir)
|
||||
{
|
||||
StartLog.log("MKDIR", baseHome.toShortForm(file));
|
||||
FS.ensureDirectoryExists(file);
|
||||
/* Startup should not fail to run on missing directories.
|
||||
* See Bug #427204
|
||||
*/
|
||||
// args.setRun(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
String shortRef = baseHome.toShortForm(file);
|
||||
if (args.isTestingModeEnabled())
|
||||
{
|
||||
StartLog.log("TESTING MODE","Skipping required file check on: %s",shortRef);
|
||||
return;
|
||||
}
|
||||
|
||||
StartLog.warn("Missing Required File: %s",baseHome.toShortForm(file));
|
||||
args.setRun(false);
|
||||
if (arg.uri != null)
|
||||
{
|
||||
StartLog.warn(" Can be downloaded From: %s",arg.uri);
|
||||
StartLog.warn(" Run start.jar --create-files to download");
|
||||
}
|
||||
}
|
||||
}
|
||||
// base directory changed.
|
||||
StartLog.info("Base directory was modified");
|
||||
return;
|
||||
}
|
||||
|
||||
// Informational command line, don't run jetty
|
||||
|
|
|
@ -108,7 +108,7 @@ public class Module
|
|||
/** License lines */
|
||||
private List<String> license;
|
||||
|
||||
/** Is this Module enabled via start.jar command line, start.ini, or start.d/*.ini ? */
|
||||
/** Is this Module enabled via start.jar command line, start.ini, or start.d/*.ini */
|
||||
private boolean enabled = false;
|
||||
/** List of sources that enabled this module */
|
||||
private final Set<String> sources = new HashSet<>();
|
||||
|
@ -272,6 +272,29 @@ public class Module
|
|||
{
|
||||
return license != null && license.size() > 0;
|
||||
}
|
||||
|
||||
|
||||
public boolean hasSource(String regex)
|
||||
{
|
||||
for (String source : sources)
|
||||
{
|
||||
if (source.matches(regex))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean hasUniqueSource(String regex)
|
||||
{
|
||||
if (sources.size() != 1)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return sources.iterator().next().matches(regex);
|
||||
}
|
||||
|
||||
public boolean acknowledgeLicense() throws IOException
|
||||
{
|
||||
|
@ -361,6 +384,11 @@ public class Module
|
|||
return enabled;
|
||||
}
|
||||
|
||||
public boolean isVirtual()
|
||||
{
|
||||
return !logicalName.equals(fileRef);
|
||||
}
|
||||
|
||||
public void process(BaseHome basehome) throws FileNotFoundException, IOException
|
||||
{
|
||||
Pattern section = Pattern.compile("\\s*\\[([^]]*)\\]\\s*");
|
||||
|
@ -477,5 +505,4 @@ public class Module
|
|||
str.append(']');
|
||||
return str.toString();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -23,6 +23,7 @@ import java.io.IOException;
|
|||
import java.nio.file.Path;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
|
@ -38,6 +39,134 @@ import java.util.regex.Pattern;
|
|||
*/
|
||||
public class Modules implements Iterable<Module>
|
||||
{
|
||||
public static interface Matcher
|
||||
{
|
||||
public boolean match(Module module);
|
||||
}
|
||||
|
||||
public static class AllMatcher implements Matcher
|
||||
{
|
||||
@Override
|
||||
public boolean match(Module module)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public static class AndMatcher implements Matcher
|
||||
{
|
||||
private final Matcher matchers[];
|
||||
|
||||
public AndMatcher(Matcher ... matchers)
|
||||
{
|
||||
this.matchers = matchers;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean match(Module module)
|
||||
{
|
||||
for (Matcher matcher : this.matchers)
|
||||
{
|
||||
if (!matcher.match(module))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public static class EnabledMatcher implements Matcher
|
||||
{
|
||||
@Override
|
||||
public boolean match(Module module)
|
||||
{
|
||||
return module.isEnabled();
|
||||
}
|
||||
}
|
||||
|
||||
public static class RegexNameMatcher implements Matcher
|
||||
{
|
||||
private final Pattern pat;
|
||||
|
||||
public RegexNameMatcher(String regex)
|
||||
{
|
||||
this.pat = Pattern.compile(regex);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean match(Module module)
|
||||
{
|
||||
return pat.matcher(module.getName()).matches();
|
||||
}
|
||||
}
|
||||
|
||||
public static class UniqueSourceMatcher implements Matcher
|
||||
{
|
||||
private final Pattern pat;
|
||||
|
||||
public UniqueSourceMatcher(String sourceRegex)
|
||||
{
|
||||
this.pat = Pattern.compile(sourceRegex);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean match(Module module)
|
||||
{
|
||||
if (module.getSources().size() != 1)
|
||||
{
|
||||
// Not unique
|
||||
return false;
|
||||
}
|
||||
|
||||
String sourceId = module.getSources().iterator().next();
|
||||
return pat.matcher(sourceId).matches();
|
||||
}
|
||||
}
|
||||
|
||||
public static class SourceSetMatcher implements Matcher
|
||||
{
|
||||
private final Set<String> nameSet;
|
||||
|
||||
public SourceSetMatcher(String... names)
|
||||
{
|
||||
this.nameSet = new HashSet<>();
|
||||
|
||||
for (String name : names)
|
||||
{
|
||||
this.nameSet.add(name);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean match(Module module)
|
||||
{
|
||||
Set<String> sources = module.getSources();
|
||||
if (sources == null)
|
||||
{
|
||||
// empty sources list
|
||||
return false;
|
||||
}
|
||||
|
||||
if (sources.size() != nameSet.size())
|
||||
{
|
||||
// non-equal sized set
|
||||
return false;
|
||||
}
|
||||
|
||||
for (String source : module.getSources())
|
||||
{
|
||||
if (!this.nameSet.contains(source))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private final BaseHome baseHome;
|
||||
private final StartArgs args;
|
||||
|
||||
|
@ -194,7 +323,7 @@ public class Modules implements Iterable<Module>
|
|||
ordered.addAll(modules.values());
|
||||
Collections.sort(ordered,new Module.NameComparator());
|
||||
|
||||
List<Module> active = resolveEnabled();
|
||||
List<Module> active = getEnabled();
|
||||
|
||||
for (Module module : ordered)
|
||||
{
|
||||
|
@ -275,37 +404,40 @@ public class Modules implements Iterable<Module>
|
|||
List<String> empty = Collections.emptyList();
|
||||
enable(name,empty);
|
||||
}
|
||||
|
||||
|
||||
public void enable(String name, List<String> sources) throws IOException
|
||||
public int enableAll(List<String> names, String source) throws IOException
|
||||
{
|
||||
if ((names == null) || (names.isEmpty()))
|
||||
{
|
||||
// nothing to do
|
||||
return 0;
|
||||
}
|
||||
|
||||
List<String> sources = Collections.singletonList(source);
|
||||
|
||||
int count = 0;
|
||||
for (String name : names)
|
||||
{
|
||||
count += enable(name,sources);
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
public int enable(String name, List<String> sources) throws IOException
|
||||
{
|
||||
int count = 0;
|
||||
|
||||
if (name.contains("*"))
|
||||
{
|
||||
// A regex!
|
||||
Pattern pat = Pattern.compile(name);
|
||||
List<Module> matching = new ArrayList<>();
|
||||
do
|
||||
List<Module> matching = getMatching(new RegexNameMatcher(name));
|
||||
|
||||
// enable them
|
||||
for (Module module : matching)
|
||||
{
|
||||
matching.clear();
|
||||
|
||||
// find matching entries that are not enabled
|
||||
for (Map.Entry<String, Module> entry : modules.entrySet())
|
||||
{
|
||||
if (pat.matcher(entry.getKey()).matches())
|
||||
{
|
||||
if (!entry.getValue().isEnabled())
|
||||
{
|
||||
matching.add(entry.getValue());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// enable them
|
||||
for (Module module : matching)
|
||||
{
|
||||
enableModule(module,sources);
|
||||
}
|
||||
count += enableModule(module,sources);
|
||||
}
|
||||
while (!matching.isEmpty());
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -313,32 +445,36 @@ public class Modules implements Iterable<Module>
|
|||
if (module == null)
|
||||
{
|
||||
System.err.printf("WARNING: Cannot enable requested module [%s]: not a valid module name.%n",name);
|
||||
return;
|
||||
return count;
|
||||
}
|
||||
enableModule(module,sources);
|
||||
count += enableModule(module,sources);
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
private void enableModule(Module module, List<String> sources) throws IOException
|
||||
private int enableModule(Module module, List<String> sources) throws IOException
|
||||
{
|
||||
String via = "<transitive>";
|
||||
|
||||
// Always add the sources
|
||||
if (sources != null)
|
||||
int count = 0;
|
||||
if(sources == null)
|
||||
{
|
||||
module.addSources(sources);
|
||||
via = Main.join(sources, ", ");
|
||||
// We use source for tagging how a node was selected, it should
|
||||
// always be required
|
||||
throw new RuntimeException("sources should never be empty");
|
||||
}
|
||||
|
||||
module.addSources(sources);
|
||||
String via = Utils.join(sources, ", ");
|
||||
|
||||
// If already enabled, nothing else to do
|
||||
if (module.isEnabled())
|
||||
{
|
||||
StartLog.debug("Enabled module: %s (via %s)",module.getName(),via);
|
||||
return;
|
||||
return count;
|
||||
}
|
||||
|
||||
StartLog.debug("Enabling module: %s (via %s)",module.getName(),via);
|
||||
module.setEnabled(true);
|
||||
count++;
|
||||
args.parseModule(module);
|
||||
module.expandProperties(args.getProperties());
|
||||
|
||||
|
@ -370,9 +506,10 @@ public class Modules implements Iterable<Module>
|
|||
}
|
||||
if (parent != null)
|
||||
{
|
||||
enableModule(parent,null);
|
||||
count += enableModule(parent,sources);
|
||||
}
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
private void findChildren(Module module, Set<Module> ret)
|
||||
|
@ -560,12 +697,40 @@ public class Modules implements Iterable<Module>
|
|||
findChildren(module,ret);
|
||||
return asNameSet(ret);
|
||||
}
|
||||
|
||||
public List<Module> getEnabled()
|
||||
{
|
||||
return getMatching(new EnabledMatcher());
|
||||
}
|
||||
|
||||
/**
|
||||
* Resolve the execution order of the enabled modules, and all dependant modules, based on depth first transitive reduction.
|
||||
* Get the modules from the tree that match the provided matcher.
|
||||
*
|
||||
* @return the list of active modules (plus dependant modules), in execution order.
|
||||
* @param matcher the matcher to use for matches
|
||||
* @return the list of matching modules in execution order.
|
||||
*/
|
||||
public List<Module> getMatching(Matcher matcher)
|
||||
{
|
||||
List<Module> selected = new ArrayList<Module>();
|
||||
|
||||
for (Module module : modules.values())
|
||||
{
|
||||
if (matcher.match(module))
|
||||
{
|
||||
selected.add(module);
|
||||
}
|
||||
}
|
||||
|
||||
Collections.sort(selected,new Module.DepthComparator());
|
||||
return selected;
|
||||
}
|
||||
|
||||
/**
|
||||
* Resolve the execution order of the enabled modules, and all dependent modules, based on depth first transitive reduction.
|
||||
*
|
||||
* @return the list of active modules (plus dependent modules), in execution order.
|
||||
*/
|
||||
@Deprecated
|
||||
public List<Module> resolveEnabled()
|
||||
{
|
||||
Map<String, Module> active = new HashMap<String, Module>();
|
||||
|
@ -578,6 +743,16 @@ public class Modules implements Iterable<Module>
|
|||
}
|
||||
}
|
||||
|
||||
assertModulesValid(active.values());
|
||||
|
||||
List<Module> ordered = new ArrayList<>();
|
||||
ordered.addAll(active.values());
|
||||
Collections.sort(ordered,new Module.DepthComparator());
|
||||
return ordered;
|
||||
}
|
||||
|
||||
public void assertModulesValid(Collection<Module> active)
|
||||
{
|
||||
/*
|
||||
* check against the missing modules
|
||||
*
|
||||
|
@ -585,9 +760,9 @@ public class Modules implements Iterable<Module>
|
|||
*/
|
||||
for (String missing : missingModules)
|
||||
{
|
||||
for (String activeModule : active.keySet())
|
||||
for (Module module : active)
|
||||
{
|
||||
if (missing.startsWith(activeModule))
|
||||
if (missing.startsWith(module.getName()))
|
||||
{
|
||||
StartLog.warn("** Unable to continue, required dependency missing. [%s]",missing);
|
||||
StartLog.warn("** As configured, Jetty is unable to start due to a missing enabled module dependency.");
|
||||
|
@ -596,11 +771,6 @@ public class Modules implements Iterable<Module>
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
List<Module> ordered = new ArrayList<>();
|
||||
ordered.addAll(active.values());
|
||||
Collections.sort(ordered,new Module.DepthComparator());
|
||||
return ordered;
|
||||
}
|
||||
|
||||
public Set<String> resolveParentModulesOf(String moduleName)
|
||||
|
|
|
@ -1,48 +0,0 @@
|
|||
Jetty start
|
||||
-----------
|
||||
|
||||
The run directory is either the top-level of a distribution
|
||||
or jetty-distribution/target/distribution directory when built from
|
||||
source.
|
||||
|
||||
Jetty start.jar provides a cross platform replacement for startup scripts.
|
||||
It makes use of executable JAR that builds the classpath and then executes
|
||||
jetty.
|
||||
|
||||
To run with the demo:
|
||||
|
||||
java -jar start.jar --enable=demo
|
||||
java -jar start.jar
|
||||
|
||||
To run with the default modules:
|
||||
|
||||
java -jar start.jar
|
||||
|
||||
The default options may be specified in the start.ini file, or if
|
||||
that is not present, they are defined in the start.config file that
|
||||
is within the start.jar.
|
||||
|
||||
To run with specific configuration file(s)
|
||||
|
||||
java -jar start.jar etc/jetty.xml
|
||||
|
||||
To see the available options
|
||||
|
||||
java -jar start.jar --help
|
||||
|
||||
To run with JSP support (if available)
|
||||
|
||||
java -jar start.jar --module=jsp
|
||||
|
||||
To run with JMX support
|
||||
|
||||
java -jar start.jar --module=jmx
|
||||
|
||||
To run with JSP & JMX support
|
||||
|
||||
java -jar start.jar --module=jsp,jmx
|
||||
|
||||
Note that JSP requires the jasper jars to be within $JETTY/lib/jsp These
|
||||
are currently not distributed with the eclipse release and must be
|
||||
obtained from a jetty-hightide release from codehaus.
|
||||
|
|
@ -23,6 +23,7 @@ import static org.eclipse.jetty.start.UsageException.*;
|
|||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
|
@ -112,7 +113,12 @@ public class StartArgs
|
|||
private Modules allModules;
|
||||
/** Should the server be run? */
|
||||
private boolean run = true;
|
||||
|
||||
/** Download related args */
|
||||
private boolean download = false;
|
||||
private boolean licenseCheckRequired = false;
|
||||
private boolean testingMode = false;
|
||||
|
||||
private boolean help = false;
|
||||
private boolean stopCommand = false;
|
||||
private boolean listModules = false;
|
||||
|
@ -123,7 +129,6 @@ public class StartArgs
|
|||
|
||||
private boolean exec = false;
|
||||
private boolean approveAllLicenses = false;
|
||||
private boolean testingMode = false;
|
||||
|
||||
public StartArgs()
|
||||
{
|
||||
|
@ -548,6 +553,46 @@ public class StartArgs
|
|||
return System.getProperty("main.class",mainclass);
|
||||
}
|
||||
|
||||
public Path getMavenLocalRepoDir()
|
||||
{
|
||||
// Try property first
|
||||
String localRepo = getProperties().getString("maven.local.repo");
|
||||
|
||||
if (Utils.isBlank(localRepo))
|
||||
{
|
||||
// Try jetty specific env variable
|
||||
localRepo = System.getenv("JETTY_MAVEN_LOCAL_REPO");
|
||||
}
|
||||
|
||||
if (Utils.isBlank(localRepo))
|
||||
{
|
||||
// Try generic env variable
|
||||
localRepo = System.getenv("MAVEN_LOCAL_REPO");
|
||||
}
|
||||
|
||||
// TODO: load & use $HOME/.m2/settings.xml ?
|
||||
// TODO: possibly use Eclipse Aether to manage it ?
|
||||
// TODO: see https://bugs.eclipse.org/bugs/show_bug.cgi?id=449511
|
||||
|
||||
// Still blank? then its not specified
|
||||
if (Utils.isBlank(localRepo))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
Path localRepoDir = new File(localRepo).toPath();
|
||||
localRepoDir = localRepoDir.normalize().toAbsolutePath();
|
||||
if (Files.exists(localRepoDir) && Files.isDirectory(localRepoDir))
|
||||
{
|
||||
return localRepoDir;
|
||||
}
|
||||
|
||||
StartLog.warn("Not a valid maven local repository directory: %s",localRepoDir);
|
||||
|
||||
// Not a valid repository directory, skip it
|
||||
return null;
|
||||
}
|
||||
|
||||
public String getModuleGraphFilename()
|
||||
{
|
||||
return moduleGraphFilename;
|
||||
|
@ -608,6 +653,11 @@ public class StartArgs
|
|||
return exec;
|
||||
}
|
||||
|
||||
public boolean isLicenseCheckRequired()
|
||||
{
|
||||
return licenseCheckRequired;
|
||||
}
|
||||
|
||||
public boolean isNormalMainClass()
|
||||
{
|
||||
return SERVER_MAIN.equals(getMainClassname());
|
||||
|
@ -744,6 +794,7 @@ public class StartArgs
|
|||
{
|
||||
run = false;
|
||||
download = true;
|
||||
licenseCheckRequired = true;
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -813,6 +864,7 @@ public class StartArgs
|
|||
addToStartdIni.addAll(moduleNames);
|
||||
run = false;
|
||||
download = true;
|
||||
licenseCheckRequired = true;
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -823,6 +875,7 @@ public class StartArgs
|
|||
addToStartIni.addAll(moduleNames);
|
||||
run = false;
|
||||
download = true;
|
||||
licenseCheckRequired = true;
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1043,5 +1096,4 @@ public class StartArgs
|
|||
builder.append("]");
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,122 @@
|
|||
//
|
||||
// ========================================================================
|
||||
// Copyright (c) 1995-2014 Mort Bay Consulting Pty. Ltd.
|
||||
// ------------------------------------------------------------------------
|
||||
// All rights reserved. This program and the accompanying materials
|
||||
// are made available under the terms of the Eclipse Public License v1.0
|
||||
// and Apache License v2.0 which accompanies this distribution.
|
||||
//
|
||||
// The Eclipse Public License is available at
|
||||
// http://www.eclipse.org/legal/epl-v10.html
|
||||
//
|
||||
// The Apache License v2.0 is available at
|
||||
// http://www.opensource.org/licenses/apache2.0.php
|
||||
//
|
||||
// You may elect to redistribute this code under either of these licenses.
|
||||
// ========================================================================
|
||||
//
|
||||
|
||||
package org.eclipse.jetty.start;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
public final class Utils
|
||||
{
|
||||
public static String join(Object[] arr, String delim)
|
||||
{
|
||||
if (arr == null)
|
||||
{
|
||||
return "";
|
||||
}
|
||||
|
||||
return join(arr,0,arr.length,delim);
|
||||
}
|
||||
|
||||
public static String join(Object[] arr, int start, int end, String delim)
|
||||
{
|
||||
if (arr == null)
|
||||
{
|
||||
return "";
|
||||
}
|
||||
StringBuilder str = new StringBuilder();
|
||||
for (int i = start; i < end; i++)
|
||||
{
|
||||
if (i > start)
|
||||
{
|
||||
str.append(delim);
|
||||
}
|
||||
str.append(arr[i]);
|
||||
}
|
||||
return str.toString();
|
||||
}
|
||||
|
||||
public static String join(Collection<?> objs, String delim)
|
||||
{
|
||||
if (objs == null)
|
||||
{
|
||||
return "";
|
||||
}
|
||||
StringBuilder str = new StringBuilder();
|
||||
boolean needDelim = false;
|
||||
for (Object obj : objs)
|
||||
{
|
||||
if (needDelim)
|
||||
{
|
||||
str.append(delim);
|
||||
}
|
||||
str.append(obj);
|
||||
needDelim = true;
|
||||
}
|
||||
return str.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Is String null, empty, or consisting of only whitespace.
|
||||
*
|
||||
* @param value
|
||||
* the value to test
|
||||
* @return true if null, empty, or consisting of only whitespace
|
||||
*/
|
||||
public static boolean isBlank(String value)
|
||||
{
|
||||
if (value == null)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
int len = value.length();
|
||||
for (int i = 0; i < len; i++)
|
||||
{
|
||||
int c = value.codePointAt(i);
|
||||
if (!Character.isWhitespace(c))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Is String valid and has something other than whitespace
|
||||
*
|
||||
* @param value
|
||||
* the value to test
|
||||
* @return true if String has something other than whitespace
|
||||
*/
|
||||
public static boolean isNotBlank(String value)
|
||||
{
|
||||
if (value == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
int len = value.length();
|
||||
for (int i = 0; i < len; i++)
|
||||
{
|
||||
int c = value.codePointAt(i);
|
||||
if (!Character.isWhitespace(c))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,86 @@
|
|||
//
|
||||
// ========================================================================
|
||||
// Copyright (c) 1995-2014 Mort Bay Consulting Pty. Ltd.
|
||||
// ------------------------------------------------------------------------
|
||||
// All rights reserved. This program and the accompanying materials
|
||||
// are made available under the terms of the Eclipse Public License v1.0
|
||||
// and Apache License v2.0 which accompanies this distribution.
|
||||
//
|
||||
// The Eclipse Public License is available at
|
||||
// http://www.eclipse.org/legal/epl-v10.html
|
||||
//
|
||||
// The Apache License v2.0 is available at
|
||||
// http://www.opensource.org/licenses/apache2.0.php
|
||||
//
|
||||
// You may elect to redistribute this code under either of these licenses.
|
||||
// ========================================================================
|
||||
//
|
||||
|
||||
package org.eclipse.jetty.start.builders;
|
||||
|
||||
import java.io.BufferedWriter;
|
||||
import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.StandardOpenOption;
|
||||
|
||||
import org.eclipse.jetty.start.BaseBuilder;
|
||||
import org.eclipse.jetty.start.FS;
|
||||
import org.eclipse.jetty.start.Module;
|
||||
|
||||
/**
|
||||
* Management of the <code>${jetty.base}/start.d/</code> based configuration.
|
||||
* <p>
|
||||
* Implementation of the <code>--add-to-startd=[name]</code> command line behavior
|
||||
*/
|
||||
public class StartDirBuilder implements BaseBuilder.Config
|
||||
{
|
||||
private final Path startDir;
|
||||
|
||||
public StartDirBuilder(BaseBuilder baseBuilder) throws IOException
|
||||
{
|
||||
this.startDir = baseBuilder.getBaseHome().getBasePath("start.d");
|
||||
FS.ensureDirectoryExists(startDir);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean addModule(Module module) throws IOException
|
||||
{
|
||||
if (module.isVirtual())
|
||||
{
|
||||
// skip, no need to reference
|
||||
return false;
|
||||
}
|
||||
|
||||
// Create start.d/{name}.ini
|
||||
|
||||
Path ini = startDir.resolve(module.getName() + ".ini");
|
||||
|
||||
try (BufferedWriter writer = Files.newBufferedWriter(ini,StandardCharsets.UTF_8,StandardOpenOption.CREATE,StandardOpenOption.TRUNCATE_EXISTING))
|
||||
{
|
||||
writeModuleSection(writer,module);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
protected void writeModuleSection(BufferedWriter writer, Module module)
|
||||
{
|
||||
PrintWriter out = new PrintWriter(writer);
|
||||
|
||||
out.println("# --------------------------------------- ");
|
||||
out.println("# Module: " + module.getName());
|
||||
|
||||
out.println("--module=" + module.getName());
|
||||
|
||||
for (String line : module.getDefaultConfig())
|
||||
{
|
||||
out.println(line);
|
||||
}
|
||||
|
||||
out.println();
|
||||
out.flush();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,127 @@
|
|||
//
|
||||
// ========================================================================
|
||||
// Copyright (c) 1995-2014 Mort Bay Consulting Pty. Ltd.
|
||||
// ------------------------------------------------------------------------
|
||||
// All rights reserved. This program and the accompanying materials
|
||||
// are made available under the terms of the Eclipse Public License v1.0
|
||||
// and Apache License v2.0 which accompanies this distribution.
|
||||
//
|
||||
// The Eclipse Public License is available at
|
||||
// http://www.eclipse.org/legal/epl-v10.html
|
||||
//
|
||||
// The Apache License v2.0 is available at
|
||||
// http://www.opensource.org/licenses/apache2.0.php
|
||||
//
|
||||
// You may elect to redistribute this code under either of these licenses.
|
||||
// ========================================================================
|
||||
//
|
||||
|
||||
package org.eclipse.jetty.start.builders;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.BufferedWriter;
|
||||
import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.StandardOpenOption;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import org.eclipse.jetty.start.BaseBuilder;
|
||||
import org.eclipse.jetty.start.Module;
|
||||
import org.eclipse.jetty.start.Props;
|
||||
|
||||
/**
|
||||
* Management of the <code>${jetty.base}/start.ini</code> based configuration.
|
||||
* <p>
|
||||
* Implementation of the <code>--add-to-start=[name]</code> command line
|
||||
* behavior
|
||||
*/
|
||||
public class StartIniBuilder implements BaseBuilder.Config
|
||||
{
|
||||
private final Path startIni;
|
||||
|
||||
/* List of modules already present in start.ini */
|
||||
private Set<String> modulesPresent = new HashSet<>();
|
||||
|
||||
/* List of properties (keys only) already present in start.ini */
|
||||
private Set<String> propsPresent = new HashSet<>();
|
||||
|
||||
public StartIniBuilder(BaseBuilder baseBuilder) throws IOException
|
||||
{
|
||||
this.startIni = baseBuilder.getBaseHome().getBasePath("start.ini");
|
||||
|
||||
if (Files.exists(startIni))
|
||||
{
|
||||
parseIni();
|
||||
}
|
||||
}
|
||||
|
||||
private void parseIni() throws IOException
|
||||
{
|
||||
try (BufferedReader reader = Files.newBufferedReader(startIni,StandardCharsets.UTF_8))
|
||||
{
|
||||
String line;
|
||||
while ((line = reader.readLine()) != null)
|
||||
{
|
||||
line = line.trim();
|
||||
if (line.startsWith("--module="))
|
||||
{
|
||||
List<String> moduleNames = Props.getValues(line);
|
||||
this.modulesPresent.addAll(moduleNames);
|
||||
}
|
||||
else if (!line.startsWith("-") && line.contains("-"))
|
||||
{
|
||||
String key = line.substring(0,line.indexOf('='));
|
||||
this.propsPresent.add(key);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean addModule(Module module) throws IOException
|
||||
{
|
||||
if (modulesPresent.contains(module.getName()))
|
||||
{
|
||||
// skip, already present
|
||||
return false;
|
||||
}
|
||||
|
||||
if (module.isVirtual())
|
||||
{
|
||||
// skip, no need to reference
|
||||
return false;
|
||||
}
|
||||
|
||||
// Append to start.ini
|
||||
try (BufferedWriter writer = Files.newBufferedWriter(startIni,StandardCharsets.UTF_8,StandardOpenOption.APPEND,StandardOpenOption.CREATE))
|
||||
{
|
||||
writeModuleSection(writer,module);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
protected void writeModuleSection(BufferedWriter writer, Module module)
|
||||
{
|
||||
PrintWriter out = new PrintWriter(writer);
|
||||
|
||||
out.println("# --------------------------------------- ");
|
||||
out.println("# Module: " + module.getName());
|
||||
|
||||
out.println("--module=" + module.getName());
|
||||
|
||||
for (String line : module.getDefaultConfig())
|
||||
{
|
||||
// TODO: validate property keys
|
||||
out.println(line);
|
||||
}
|
||||
|
||||
out.println();
|
||||
out.flush();
|
||||
}
|
||||
}
|
|
@ -32,6 +32,7 @@ import org.eclipse.jetty.start.Props;
|
|||
import org.eclipse.jetty.start.Props.Prop;
|
||||
import org.eclipse.jetty.start.RawArgs;
|
||||
import org.eclipse.jetty.start.UsageException;
|
||||
import org.eclipse.jetty.start.Utils;
|
||||
|
||||
/**
|
||||
* Configuration Source representing the Command Line arguments.
|
||||
|
@ -69,14 +70,14 @@ public class CommandLineConfigSource implements ConfigSource
|
|||
{
|
||||
// If a jetty property is defined, use it
|
||||
Prop prop = this.props.getProp(BaseHome.JETTY_BASE,false);
|
||||
if (prop != null && !isEmpty(prop.value))
|
||||
if (prop != null && !Utils.isBlank(prop.value))
|
||||
{
|
||||
return FS.toPath(prop.value);
|
||||
}
|
||||
|
||||
// If a system property is defined, use it
|
||||
String val = System.getProperty(BaseHome.JETTY_BASE);
|
||||
if (!isEmpty(val))
|
||||
if (!Utils.isBlank(val))
|
||||
{
|
||||
return FS.toPath(val);
|
||||
}
|
||||
|
@ -91,14 +92,14 @@ public class CommandLineConfigSource implements ConfigSource
|
|||
{
|
||||
// If a jetty property is defined, use it
|
||||
Prop prop = this.props.getProp(BaseHome.JETTY_HOME,false);
|
||||
if (prop != null && !isEmpty(prop.value))
|
||||
if (prop != null && !Utils.isBlank(prop.value))
|
||||
{
|
||||
return FS.toPath(prop.value);
|
||||
}
|
||||
|
||||
// If a system property is defined, use it
|
||||
String val = System.getProperty(BaseHome.JETTY_HOME);
|
||||
if (!isEmpty(val))
|
||||
if (!Utils.isBlank(val))
|
||||
{
|
||||
return FS.toPath(val);
|
||||
}
|
||||
|
@ -130,24 +131,6 @@ public class CommandLineConfigSource implements ConfigSource
|
|||
return home;
|
||||
}
|
||||
|
||||
private boolean isEmpty(String value)
|
||||
{
|
||||
if (value == null)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
int len = value.length();
|
||||
for (int i = 0; i < len; i++)
|
||||
{
|
||||
int c = value.codePointAt(i);
|
||||
if (!Character.isWhitespace(c))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj)
|
||||
{
|
||||
|
|
|
@ -0,0 +1,194 @@
|
|||
//
|
||||
// ========================================================================
|
||||
// Copyright (c) 1995-2014 Mort Bay Consulting Pty. Ltd.
|
||||
// ------------------------------------------------------------------------
|
||||
// All rights reserved. This program and the accompanying materials
|
||||
// are made available under the terms of the Eclipse Public License v1.0
|
||||
// and Apache License v2.0 which accompanies this distribution.
|
||||
//
|
||||
// The Eclipse Public License is available at
|
||||
// http://www.eclipse.org/legal/epl-v10.html
|
||||
//
|
||||
// The Apache License v2.0 is available at
|
||||
// http://www.opensource.org/licenses/apache2.0.php
|
||||
//
|
||||
// You may elect to redistribute this code under either of these licenses.
|
||||
// ========================================================================
|
||||
//
|
||||
|
||||
package org.eclipse.jetty.start.fileinits;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URI;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
|
||||
import org.eclipse.jetty.start.BaseHome;
|
||||
import org.eclipse.jetty.start.FS;
|
||||
import org.eclipse.jetty.start.FileInitializer;
|
||||
import org.eclipse.jetty.start.StartLog;
|
||||
import org.eclipse.jetty.start.Utils;
|
||||
|
||||
/**
|
||||
* Attempt to download a <code>maven://</code> URI, by first attempting to find
|
||||
* the resource in the maven repository system (starting with local, then
|
||||
* central)
|
||||
* <p>
|
||||
* Valid URI Formats:
|
||||
* <dl>
|
||||
* <dt><code>maven://<groupId>/<artifactId>/<version></code></dt>
|
||||
* <dd>minimum requirement (type defaults to <code>jar</code>, with no
|
||||
* classifier)</dd>
|
||||
* <dt><code>maven://<groupId>/<artifactId>/<version>/<type></code></dt>
|
||||
* <dd>optional type requirement</dd>
|
||||
* <dt>
|
||||
* <code>maven://<groupId>/<artifactId>/<version>/<type>/<classifier></code>
|
||||
* </dt>
|
||||
* <dd>optional type and classifier requirement</dd>
|
||||
* </dl>
|
||||
*/
|
||||
public class MavenLocalRepoFileInitializer extends UriFileInitializer implements FileInitializer
|
||||
{
|
||||
public static class Coordinates
|
||||
{
|
||||
public String groupId;
|
||||
public String artifactId;
|
||||
public String version;
|
||||
public String type;
|
||||
public String classifier;
|
||||
|
||||
public String toPath()
|
||||
{
|
||||
StringBuilder pathlike = new StringBuilder();
|
||||
pathlike.append(groupId.replace('.','/'));
|
||||
pathlike.append('/').append(artifactId);
|
||||
pathlike.append('/').append(version);
|
||||
pathlike.append('/').append(artifactId);
|
||||
pathlike.append('-').append(version);
|
||||
if (classifier != null)
|
||||
{
|
||||
pathlike.append('-').append(classifier);
|
||||
}
|
||||
pathlike.append('.').append(type);
|
||||
return pathlike.toString();
|
||||
}
|
||||
|
||||
public URI toCentralURI()
|
||||
{
|
||||
return URI.create("http://central.maven.org/maven2/" + toPath());
|
||||
}
|
||||
}
|
||||
|
||||
private Path localRepositoryDir;
|
||||
|
||||
public MavenLocalRepoFileInitializer(BaseHome baseHome)
|
||||
{
|
||||
this(baseHome,null);
|
||||
}
|
||||
|
||||
public MavenLocalRepoFileInitializer(BaseHome baseHome, Path localRepoDir)
|
||||
{
|
||||
super(baseHome);
|
||||
this.localRepositoryDir = localRepoDir;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean init(URI uri, Path file) throws IOException
|
||||
{
|
||||
Coordinates coords = getCoordinates(uri);
|
||||
if (coords == null)
|
||||
{
|
||||
// Skip, not a maven:// URI
|
||||
return false;
|
||||
}
|
||||
|
||||
if (isFilePresent(file))
|
||||
{
|
||||
// All done
|
||||
return true;
|
||||
}
|
||||
|
||||
// If using local repository
|
||||
if (this.localRepositoryDir != null)
|
||||
{
|
||||
// Grab copy from local repository (download if needed to local
|
||||
// repository)
|
||||
Path localRepoFile = getLocalRepoFile(coords);
|
||||
StartLog.log("COPY","%s to %s",localRepoFile,file);
|
||||
Files.copy(localRepoFile,file);
|
||||
}
|
||||
else
|
||||
{
|
||||
// normal non-local repo version
|
||||
download(coords.toCentralURI(),file);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private Path getLocalRepoFile(Coordinates coords) throws IOException
|
||||
{
|
||||
Path localFile = localRepositoryDir.resolve(coords.toPath());
|
||||
if (FS.canReadFile(localFile))
|
||||
{
|
||||
return localFile;
|
||||
}
|
||||
|
||||
// Download, if needed
|
||||
download(coords.toCentralURI(),localFile);
|
||||
return localFile;
|
||||
}
|
||||
|
||||
public Coordinates getCoordinates(URI uri)
|
||||
{
|
||||
if (!"maven".equalsIgnoreCase(uri.getScheme()))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
String ssp = uri.getSchemeSpecificPart();
|
||||
|
||||
if (ssp.startsWith("//"))
|
||||
{
|
||||
ssp = ssp.substring(2);
|
||||
}
|
||||
|
||||
String parts[] = ssp.split("/");
|
||||
|
||||
if (StartLog.isDebugEnabled())
|
||||
{
|
||||
StartLog.debug("ssp = %s",ssp);
|
||||
StartLog.debug("parts = %d",parts.length);
|
||||
for (int i = 0; i < parts.length; i++)
|
||||
{
|
||||
StartLog.debug(" part[%2d]: [%s]",i,parts[i]);
|
||||
}
|
||||
}
|
||||
|
||||
if (parts.length < 3)
|
||||
{
|
||||
throw new RuntimeException("Not a valid maven:// uri - " + uri);
|
||||
}
|
||||
|
||||
Coordinates coords = new Coordinates();
|
||||
coords.groupId = parts[0];
|
||||
coords.artifactId = parts[1];
|
||||
coords.version = parts[2];
|
||||
coords.type = "jar";
|
||||
coords.classifier = null;
|
||||
|
||||
if (parts.length >= 4)
|
||||
{
|
||||
if (Utils.isNotBlank(parts[3]))
|
||||
{
|
||||
coords.type = parts[3];
|
||||
}
|
||||
|
||||
if ((parts.length == 5) && (Utils.isNotBlank(parts[4])))
|
||||
{
|
||||
coords.classifier = parts[4];
|
||||
}
|
||||
}
|
||||
|
||||
return coords;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,44 @@
|
|||
//
|
||||
// ========================================================================
|
||||
// Copyright (c) 1995-2014 Mort Bay Consulting Pty. Ltd.
|
||||
// ------------------------------------------------------------------------
|
||||
// All rights reserved. This program and the accompanying materials
|
||||
// are made available under the terms of the Eclipse Public License v1.0
|
||||
// and Apache License v2.0 which accompanies this distribution.
|
||||
//
|
||||
// The Eclipse Public License is available at
|
||||
// http://www.eclipse.org/legal/epl-v10.html
|
||||
//
|
||||
// The Apache License v2.0 is available at
|
||||
// http://www.opensource.org/licenses/apache2.0.php
|
||||
//
|
||||
// You may elect to redistribute this code under either of these licenses.
|
||||
// ========================================================================
|
||||
//
|
||||
|
||||
package org.eclipse.jetty.start.fileinits;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URI;
|
||||
import java.nio.file.Path;
|
||||
|
||||
import org.eclipse.jetty.start.FS;
|
||||
import org.eclipse.jetty.start.FileInitializer;
|
||||
import org.eclipse.jetty.start.StartLog;
|
||||
|
||||
/**
|
||||
* In a start testing scenario, it is often not important to actually download
|
||||
* or initialize a file, this implementation is merely a no-op for the
|
||||
* {@link FileInitializer}
|
||||
*/
|
||||
public class TestFileInitializer implements FileInitializer
|
||||
{
|
||||
@Override
|
||||
public boolean init(URI uri, Path file) throws IOException
|
||||
{
|
||||
FS.ensureDirectoryExists(file.getParent());
|
||||
|
||||
StartLog.log("TESTING MODE","Skipping download of " + uri);
|
||||
return true;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,137 @@
|
|||
//
|
||||
// ========================================================================
|
||||
// Copyright (c) 1995-2014 Mort Bay Consulting Pty. Ltd.
|
||||
// ------------------------------------------------------------------------
|
||||
// All rights reserved. This program and the accompanying materials
|
||||
// are made available under the terms of the Eclipse Public License v1.0
|
||||
// and Apache License v2.0 which accompanies this distribution.
|
||||
//
|
||||
// The Eclipse Public License is available at
|
||||
// http://www.eclipse.org/legal/epl-v10.html
|
||||
//
|
||||
// The Apache License v2.0 is available at
|
||||
// http://www.opensource.org/licenses/apache2.0.php
|
||||
//
|
||||
// You may elect to redistribute this code under either of these licenses.
|
||||
// ========================================================================
|
||||
//
|
||||
|
||||
package org.eclipse.jetty.start.fileinits;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URI;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.StandardOpenOption;
|
||||
|
||||
import org.eclipse.jetty.start.BaseHome;
|
||||
import org.eclipse.jetty.start.FS;
|
||||
import org.eclipse.jetty.start.FileInitializer;
|
||||
import org.eclipse.jetty.start.StartLog;
|
||||
|
||||
public class UriFileInitializer implements FileInitializer
|
||||
{
|
||||
private final static String[] SUPPORTED_SCHEMES = { "http", "https" };
|
||||
private final BaseHome baseHome;
|
||||
|
||||
public UriFileInitializer(BaseHome baseHome)
|
||||
{
|
||||
this.baseHome = baseHome;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean init(URI uri, Path file) throws IOException
|
||||
{
|
||||
if (!isSupportedScheme(uri))
|
||||
{
|
||||
// Not a supported scheme.
|
||||
return false;
|
||||
}
|
||||
|
||||
if(isFilePresent(file))
|
||||
{
|
||||
// All done
|
||||
return true;
|
||||
}
|
||||
|
||||
download(uri,file);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
protected void download(URI uri, Path file) throws IOException
|
||||
{
|
||||
StartLog.log("DOWNLOAD","%s to %s",uri,baseHome.toShortForm(file));
|
||||
|
||||
FS.ensureDirectoryExists(file.getParent());
|
||||
|
||||
HttpURLConnection http = (HttpURLConnection)uri.toURL().openConnection();
|
||||
http.setInstanceFollowRedirects(true);
|
||||
http.setAllowUserInteraction(false);
|
||||
|
||||
int status = http.getResponseCode();
|
||||
|
||||
if(status != HttpURLConnection.HTTP_OK)
|
||||
{
|
||||
throw new IOException("URL GET Failure [" + status + "/" + http.getResponseMessage() + "] on " + uri);
|
||||
}
|
||||
|
||||
byte[] buf = new byte[8192];
|
||||
try (InputStream in = http.getInputStream(); OutputStream out = Files.newOutputStream(file,StandardOpenOption.CREATE_NEW,StandardOpenOption.WRITE))
|
||||
{
|
||||
while (true)
|
||||
{
|
||||
int len = in.read(buf);
|
||||
|
||||
if (len > 0)
|
||||
{
|
||||
out.write(buf,0,len);
|
||||
}
|
||||
if (len < 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected boolean isFilePresent(Path file) throws IOException
|
||||
{
|
||||
if (Files.exists(file))
|
||||
{
|
||||
if (Files.isDirectory(file))
|
||||
{
|
||||
throw new IOException("Directory in the way: " + file.toAbsolutePath());
|
||||
}
|
||||
|
||||
if (Files.isReadable(file))
|
||||
{
|
||||
throw new IOException("File not readable: " + file.toAbsolutePath());
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean isSupportedScheme(URI uri)
|
||||
{
|
||||
String scheme = uri.getScheme();
|
||||
if (scheme == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
for (String supported : SUPPORTED_SCHEMES)
|
||||
{
|
||||
if (supported.equalsIgnoreCase(scheme))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
|
@ -57,7 +57,7 @@ public class BaseHomeTest
|
|||
System.out.printf(" %s%n",path);
|
||||
}
|
||||
}
|
||||
Assert.assertThat(message + ": " + Main.join(actual,", "),actual,containsInAnyOrder(expected.toArray()));
|
||||
Assert.assertThat(message + ": " + Utils.join(actual,", "),actual,containsInAnyOrder(expected.toArray()));
|
||||
}
|
||||
|
||||
public static void assertPathList(BaseHome hb, String message, List<String> expected, List<Path> paths)
|
||||
|
@ -81,7 +81,7 @@ public class BaseHomeTest
|
|||
System.out.printf(" %s%n",path);
|
||||
}
|
||||
}
|
||||
Assert.assertThat(message + ": " + Main.join(actual,", "),actual,containsInAnyOrder(expected.toArray()));
|
||||
Assert.assertThat(message + ": " + Utils.join(actual,", "),actual,containsInAnyOrder(expected.toArray()));
|
||||
}
|
||||
|
||||
public static void assertFileList(BaseHome hb, String message, List<String> expected, List<File> files)
|
||||
|
@ -91,7 +91,7 @@ public class BaseHomeTest
|
|||
{
|
||||
actual.add(hb.toShortForm(file));
|
||||
}
|
||||
Assert.assertThat(message + ": " + Main.join(actual,", "),actual,containsInAnyOrder(expected.toArray()));
|
||||
Assert.assertThat(message + ": " + Utils.join(actual,", "),actual,containsInAnyOrder(expected.toArray()));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -38,7 +38,7 @@ import org.junit.Test;
|
|||
/**
|
||||
* Test various license handling.
|
||||
*/
|
||||
public class LicenseTest
|
||||
public class LicensingTest
|
||||
{
|
||||
@Rule
|
||||
public TestingDir testdir = new TestingDir();
|
||||
|
@ -93,7 +93,7 @@ public class LicenseTest
|
|||
|
||||
List<String> cmds = getBaseCommandLine(basePath);
|
||||
|
||||
cmds.add("-Dorg.eclipse.jetty.start.ack.license.cdi=true");
|
||||
cmds.add("-Dorg.eclipse.jetty.start.ack.licenses=true");
|
||||
cmds.add("--add-to-start=cdi");
|
||||
|
||||
execMain(cmds);
|
||||
|
@ -106,7 +106,7 @@ public class LicenseTest
|
|||
|
||||
List<String> cmds = getBaseCommandLine(basePath);
|
||||
|
||||
cmds.add("-Dorg.eclipse.jetty.start.ack.license.protonego-impl=true");
|
||||
cmds.add("-Dorg.eclipse.jetty.start.ack.licenses=true");
|
||||
cmds.add("--add-to-start=spdy");
|
||||
|
||||
execMain(cmds);
|
||||
|
@ -122,7 +122,8 @@ public class LicenseTest
|
|||
|
||||
List<String> cmds = getBaseCommandLine(basePath);
|
||||
|
||||
cmds.add("-Dorg.eclipse.jetty.start.ack.license.protonego-impl=true");
|
||||
cmds.add("-Dorg.eclipse.jetty.start.ack.licenses=true");
|
||||
cmds.add("--dry-run");
|
||||
|
||||
StringReader startIni = new StringReader("--module=spdy\n");
|
||||
try (FileWriter writer = new FileWriter(new File(basePath,"start.ini")))
|
||||
|
@ -140,7 +141,7 @@ public class LicenseTest
|
|||
|
||||
List<String> cmds = getBaseCommandLine(basePath);
|
||||
|
||||
cmds.add("-Dorg.eclipse.jetty.start.ack.license.cdi=true");
|
||||
cmds.add("-Dorg.eclipse.jetty.start.ack.licenses=true");
|
||||
cmds.add("--create-files");
|
||||
|
||||
StringReader startIni = new StringReader("--module=cdi\n");
|
|
@ -18,21 +18,25 @@
|
|||
|
||||
package org.eclipse.jetty.start;
|
||||
|
||||
import static org.hamcrest.Matchers.contains;
|
||||
import static org.hamcrest.Matchers.*;
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import org.eclipse.jetty.start.Modules.AndMatcher;
|
||||
import org.eclipse.jetty.start.Modules.EnabledMatcher;
|
||||
import org.eclipse.jetty.start.Modules.UniqueSourceMatcher;
|
||||
import org.eclipse.jetty.start.config.CommandLineConfigSource;
|
||||
import org.eclipse.jetty.start.config.ConfigSources;
|
||||
import org.eclipse.jetty.start.config.JettyBaseConfigSource;
|
||||
import org.eclipse.jetty.start.config.JettyHomeConfigSource;
|
||||
import org.eclipse.jetty.toolchain.test.MavenTestingUtils;
|
||||
import org.eclipse.jetty.toolchain.test.TestingDir;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
|
||||
|
@ -49,18 +53,18 @@ public class ModulesTest
|
|||
// Test Env
|
||||
File homeDir = MavenTestingUtils.getTestResourceDir("usecases/home");
|
||||
File baseDir = testdir.getEmptyDir();
|
||||
String cmdLine[] = new String[] {"jetty.version=TEST"};
|
||||
|
||||
String cmdLine[] = new String[] { "jetty.version=TEST" };
|
||||
|
||||
// Configuration
|
||||
CommandLineConfigSource cmdLineSource = new CommandLineConfigSource(cmdLine);
|
||||
ConfigSources config = new ConfigSources();
|
||||
config.add(cmdLineSource);
|
||||
config.add(new JettyHomeConfigSource(homeDir.toPath()));
|
||||
config.add(new JettyBaseConfigSource(baseDir.toPath()));
|
||||
|
||||
|
||||
// Initialize
|
||||
BaseHome basehome = new BaseHome(config);
|
||||
|
||||
|
||||
StartArgs args = new StartArgs();
|
||||
args.parse(config);
|
||||
|
||||
|
@ -112,14 +116,14 @@ public class ModulesTest
|
|||
expected.add("server");
|
||||
expected.add("annotations");
|
||||
expected.add("resources");
|
||||
expected.add("logging");
|
||||
|
||||
expected.add("logging");
|
||||
|
||||
ConfigurationAssert.assertContainsUnordered("All Modules",expected,moduleNames);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Test loading of only shallow modules, not deep references.
|
||||
* In other words. ${search-dir}/modules/*.mod should be the only
|
||||
* In other words. ${search-dir}/modules/*.mod should be the only
|
||||
* valid references, but ${search-dir}/alt/foo/modules/*.mod should
|
||||
* not be considered valid.
|
||||
*/
|
||||
|
@ -128,20 +132,21 @@ public class ModulesTest
|
|||
{
|
||||
// Test Env
|
||||
File homeDir = MavenTestingUtils.getTestResourceDir("jetty home with spaces");
|
||||
// intentionally setup top level resources dir (as this would have many deep references)
|
||||
// intentionally setup top level resources dir (as this would have many
|
||||
// deep references)
|
||||
File baseDir = MavenTestingUtils.getTestResourcesDir();
|
||||
String cmdLine[] = new String[] {"jetty.version=TEST"};
|
||||
|
||||
String cmdLine[] = new String[] { "jetty.version=TEST" };
|
||||
|
||||
// Configuration
|
||||
CommandLineConfigSource cmdLineSource = new CommandLineConfigSource(cmdLine);
|
||||
ConfigSources config = new ConfigSources();
|
||||
config.add(cmdLineSource);
|
||||
config.add(new JettyHomeConfigSource(homeDir.toPath()));
|
||||
config.add(new JettyBaseConfigSource(baseDir.toPath()));
|
||||
|
||||
|
||||
// Initialize
|
||||
BaseHome basehome = new BaseHome(config);
|
||||
|
||||
|
||||
StartArgs args = new StartArgs();
|
||||
args.parse(config);
|
||||
|
||||
|
@ -154,10 +159,10 @@ public class ModulesTest
|
|||
{
|
||||
moduleNames.add(mod.getName());
|
||||
}
|
||||
|
||||
|
||||
List<String> expected = new ArrayList<>();
|
||||
expected.add("base");
|
||||
|
||||
|
||||
ConfigurationAssert.assertContainsUnordered("All Modules",expected,moduleNames);
|
||||
}
|
||||
|
||||
|
@ -167,18 +172,18 @@ public class ModulesTest
|
|||
// Test Env
|
||||
File homeDir = MavenTestingUtils.getTestResourceDir("usecases/home");
|
||||
File baseDir = testdir.getEmptyDir();
|
||||
String cmdLine[] = new String[] {"jetty.version=TEST", "java.version=1.7.0_60"};
|
||||
|
||||
String cmdLine[] = new String[] { "jetty.version=TEST", "java.version=1.7.0_60" };
|
||||
|
||||
// Configuration
|
||||
CommandLineConfigSource cmdLineSource = new CommandLineConfigSource(cmdLine);
|
||||
ConfigSources config = new ConfigSources();
|
||||
config.add(cmdLineSource);
|
||||
config.add(new JettyHomeConfigSource(homeDir.toPath()));
|
||||
config.add(new JettyBaseConfigSource(baseDir.toPath()));
|
||||
|
||||
|
||||
// Initialize
|
||||
BaseHome basehome = new BaseHome(config);
|
||||
|
||||
|
||||
StartArgs args = new StartArgs();
|
||||
args.parse(config);
|
||||
|
||||
|
@ -206,9 +211,9 @@ public class ModulesTest
|
|||
expected.add("protonego-impl");
|
||||
expected.add("xml");
|
||||
expected.add("jsp-impl");
|
||||
|
||||
|
||||
List<String> resolved = new ArrayList<>();
|
||||
for (Module module : modules.resolveEnabled())
|
||||
for (Module module : modules.getEnabled())
|
||||
{
|
||||
resolved.add(module.getName());
|
||||
}
|
||||
|
@ -222,23 +227,23 @@ public class ModulesTest
|
|||
// Test Env
|
||||
File homeDir = MavenTestingUtils.getTestResourceDir("usecases/home");
|
||||
File baseDir = testdir.getEmptyDir();
|
||||
String cmdLine[] = new String[] {"jetty.version=TEST"};
|
||||
|
||||
String cmdLine[] = new String[] { "jetty.version=TEST" };
|
||||
|
||||
// Configuration
|
||||
CommandLineConfigSource cmdLineSource = new CommandLineConfigSource(cmdLine);
|
||||
ConfigSources config = new ConfigSources();
|
||||
config.add(cmdLineSource);
|
||||
config.add(new JettyHomeConfigSource(homeDir.toPath()));
|
||||
config.add(new JettyBaseConfigSource(baseDir.toPath()));
|
||||
|
||||
|
||||
// Initialize
|
||||
BaseHome basehome = new BaseHome(config);
|
||||
|
||||
|
||||
StartArgs args = new StartArgs();
|
||||
args.parse(config);
|
||||
|
||||
// Test Modules
|
||||
Modules modules = new Modules(basehome, args);
|
||||
Modules modules = new Modules(basehome,args);
|
||||
modules.registerAll();
|
||||
|
||||
// Enable 2 modules
|
||||
|
@ -248,7 +253,7 @@ public class ModulesTest
|
|||
modules.buildGraph();
|
||||
|
||||
// Collect active module list
|
||||
List<Module> active = modules.resolveEnabled();
|
||||
List<Module> active = modules.getEnabled();
|
||||
|
||||
// Assert names are correct, and in the right order
|
||||
List<String> expectedNames = new ArrayList<>();
|
||||
|
@ -263,7 +268,7 @@ public class ModulesTest
|
|||
actualNames.add(actual.getName());
|
||||
}
|
||||
|
||||
Assert.assertThat("Resolved Names: " + actualNames,actualNames,contains(expectedNames.toArray()));
|
||||
assertThat("Resolved Names: " + actualNames,actualNames,contains(expectedNames.toArray()));
|
||||
|
||||
// Assert Library List
|
||||
List<String> expectedLibs = new ArrayList<>();
|
||||
|
@ -277,7 +282,7 @@ public class ModulesTest
|
|||
expectedLibs.add("lib/jetty-server-${jetty.version}.jar");
|
||||
|
||||
List<String> actualLibs = modules.normalizeLibs(active);
|
||||
Assert.assertThat("Resolved Libs: " + actualLibs,actualLibs,contains(expectedLibs.toArray()));
|
||||
assertThat("Resolved Libs: " + actualLibs,actualLibs,contains(expectedLibs.toArray()));
|
||||
|
||||
// Assert XML List
|
||||
List<String> expectedXmls = new ArrayList<>();
|
||||
|
@ -285,7 +290,7 @@ public class ModulesTest
|
|||
expectedXmls.add("etc/jetty-http.xml");
|
||||
|
||||
List<String> actualXmls = modules.normalizeXmls(active);
|
||||
Assert.assertThat("Resolved XMLs: " + actualXmls,actualXmls,contains(expectedXmls.toArray()));
|
||||
assertThat("Resolved XMLs: " + actualXmls,actualXmls,contains(expectedXmls.toArray()));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -294,18 +299,18 @@ public class ModulesTest
|
|||
// Test Env
|
||||
File homeDir = MavenTestingUtils.getTestResourceDir("usecases/home");
|
||||
File baseDir = testdir.getEmptyDir();
|
||||
String cmdLine[] = new String[] {"jetty.version=TEST"};
|
||||
|
||||
String cmdLine[] = new String[] { "jetty.version=TEST" };
|
||||
|
||||
// Configuration
|
||||
CommandLineConfigSource cmdLineSource = new CommandLineConfigSource(cmdLine);
|
||||
ConfigSources config = new ConfigSources();
|
||||
config.add(cmdLineSource);
|
||||
config.add(new JettyHomeConfigSource(homeDir.toPath()));
|
||||
config.add(new JettyBaseConfigSource(baseDir.toPath()));
|
||||
|
||||
|
||||
// Initialize
|
||||
BaseHome basehome = new BaseHome(config);
|
||||
|
||||
|
||||
StartArgs args = new StartArgs();
|
||||
args.parse(config);
|
||||
|
||||
|
@ -321,7 +326,7 @@ public class ModulesTest
|
|||
// modules.dump();
|
||||
|
||||
// Collect active module list
|
||||
List<Module> active = modules.resolveEnabled();
|
||||
List<Module> active = modules.getEnabled();
|
||||
|
||||
// Assert names are correct, and in the right order
|
||||
List<String> expectedNames = new ArrayList<>();
|
||||
|
@ -341,7 +346,7 @@ public class ModulesTest
|
|||
actualNames.add(actual.getName());
|
||||
}
|
||||
|
||||
Assert.assertThat("Resolved Names: " + actualNames,actualNames,contains(expectedNames.toArray()));
|
||||
assertThat("Resolved Names: " + actualNames,actualNames,contains(expectedNames.toArray()));
|
||||
|
||||
// Assert Library List
|
||||
List<String> expectedLibs = new ArrayList<>();
|
||||
|
@ -362,7 +367,7 @@ public class ModulesTest
|
|||
expectedLibs.add("lib/websocket/*.jar");
|
||||
|
||||
List<String> actualLibs = modules.normalizeLibs(active);
|
||||
Assert.assertThat("Resolved Libs: " + actualLibs,actualLibs,contains(expectedLibs.toArray()));
|
||||
assertThat("Resolved Libs: " + actualLibs,actualLibs,contains(expectedLibs.toArray()));
|
||||
|
||||
// Assert XML List
|
||||
List<String> expectedXmls = new ArrayList<>();
|
||||
|
@ -373,6 +378,98 @@ public class ModulesTest
|
|||
expectedXmls.add("etc/jetty-websockets.xml");
|
||||
|
||||
List<String> actualXmls = modules.normalizeXmls(active);
|
||||
Assert.assertThat("Resolved XMLs: " + actualXmls,actualXmls,contains(expectedXmls.toArray()));
|
||||
assertThat("Resolved XMLs: " + actualXmls,actualXmls,contains(expectedXmls.toArray()));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testResolve_Alt() throws IOException
|
||||
{
|
||||
// Test Env
|
||||
File homeDir = MavenTestingUtils.getTestResourceDir("usecases/home");
|
||||
File baseDir = testdir.getEmptyDir();
|
||||
String cmdLine[] = new String[] { "jetty.version=TEST" };
|
||||
|
||||
// Configuration
|
||||
CommandLineConfigSource cmdLineSource = new CommandLineConfigSource(cmdLine);
|
||||
ConfigSources config = new ConfigSources();
|
||||
config.add(cmdLineSource);
|
||||
config.add(new JettyHomeConfigSource(homeDir.toPath()));
|
||||
config.add(new JettyBaseConfigSource(baseDir.toPath()));
|
||||
|
||||
// Initialize
|
||||
BaseHome basehome = new BaseHome(config);
|
||||
|
||||
StartArgs args = new StartArgs();
|
||||
args.parse(config);
|
||||
|
||||
// Test Modules
|
||||
Modules modules = new Modules(basehome,args);
|
||||
modules.registerAll();
|
||||
|
||||
// Enable test modules
|
||||
modules.enable("http",TEST_SOURCE);
|
||||
modules.enable("annotations",TEST_SOURCE);
|
||||
modules.enable("deploy",TEST_SOURCE);
|
||||
// Enable alternate modules
|
||||
String alt = "<alt>";
|
||||
modules.enable("websocket",Collections.singletonList(alt));
|
||||
modules.enable("jsp",Collections.singletonList(alt));
|
||||
|
||||
modules.buildGraph();
|
||||
// modules.dump();
|
||||
|
||||
// Collect active module list
|
||||
List<Module> active = modules.getEnabled();
|
||||
|
||||
// Assert names are correct, and in the right order
|
||||
List<String> expectedNames = new ArrayList<>();
|
||||
expectedNames.add("base");
|
||||
expectedNames.add("jsp-impl");
|
||||
expectedNames.add("xml");
|
||||
expectedNames.add("server");
|
||||
expectedNames.add("http");
|
||||
expectedNames.add("jndi");
|
||||
expectedNames.add("security");
|
||||
expectedNames.add("servlet");
|
||||
expectedNames.add("jsp");
|
||||
expectedNames.add("plus");
|
||||
expectedNames.add("webapp");
|
||||
expectedNames.add("annotations");
|
||||
expectedNames.add("deploy");
|
||||
expectedNames.add("websocket");
|
||||
|
||||
List<String> actualNames = new ArrayList<>();
|
||||
for (Module actual : active)
|
||||
{
|
||||
actualNames.add(actual.getName());
|
||||
}
|
||||
|
||||
assertThat("Resolved Names: " + actualNames,actualNames,contains(expectedNames.toArray()));
|
||||
|
||||
// Now work with the 'alt' selected
|
||||
List<String> expectedAlts = new ArrayList<>();
|
||||
expectedAlts.add("jsp-impl");
|
||||
expectedAlts.add("jsp");
|
||||
expectedAlts.add("websocket");
|
||||
|
||||
for (String expectedAlt : expectedAlts)
|
||||
{
|
||||
Module altMod = modules.get(expectedAlt);
|
||||
assertThat("Alt.mod[" + expectedAlt + "].enabled",altMod.isEnabled(),is(true));
|
||||
Set<String> sources = altMod.getSources();
|
||||
assertThat("Alt.mod[" + expectedAlt + "].sources: [" + Utils.join(sources,", ") + "]",sources,contains(alt));
|
||||
}
|
||||
|
||||
// Now collect the unique source list
|
||||
List<Module> alts = modules.getMatching(new AndMatcher(new EnabledMatcher(),new UniqueSourceMatcher(alt)));
|
||||
|
||||
// Assert names are correct, and in the right order
|
||||
actualNames = new ArrayList<>();
|
||||
for (Module actual : alts)
|
||||
{
|
||||
actualNames.add(actual.getName());
|
||||
}
|
||||
|
||||
assertThat("Resolved Alt (Sources) Names: " + actualNames,actualNames,contains(expectedAlts.toArray()));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,151 @@
|
|||
//
|
||||
// ========================================================================
|
||||
// Copyright (c) 1995-2014 Mort Bay Consulting Pty. Ltd.
|
||||
// ------------------------------------------------------------------------
|
||||
// All rights reserved. This program and the accompanying materials
|
||||
// are made available under the terms of the Eclipse Public License v1.0
|
||||
// and Apache License v2.0 which accompanies this distribution.
|
||||
//
|
||||
// The Eclipse Public License is available at
|
||||
// http://www.eclipse.org/legal/epl-v10.html
|
||||
//
|
||||
// The Apache License v2.0 is available at
|
||||
// http://www.opensource.org/licenses/apache2.0.php
|
||||
//
|
||||
// You may elect to redistribute this code under either of these licenses.
|
||||
// ========================================================================
|
||||
//
|
||||
|
||||
package org.eclipse.jetty.start.fileinits;
|
||||
|
||||
import static org.hamcrest.Matchers.*;
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.net.URI;
|
||||
|
||||
import org.eclipse.jetty.start.BaseHome;
|
||||
import org.eclipse.jetty.start.config.ConfigSources;
|
||||
import org.eclipse.jetty.start.config.JettyBaseConfigSource;
|
||||
import org.eclipse.jetty.start.config.JettyHomeConfigSource;
|
||||
import org.eclipse.jetty.start.fileinits.MavenLocalRepoFileInitializer.Coordinates;
|
||||
import org.eclipse.jetty.toolchain.test.TestingDir;
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.rules.ExpectedException;
|
||||
|
||||
public class MavenLocalRepoFileInitializerTest
|
||||
{
|
||||
@Rule
|
||||
public ExpectedException expectedException = ExpectedException.none();
|
||||
|
||||
@Rule
|
||||
public TestingDir testdir = new TestingDir();
|
||||
|
||||
private BaseHome baseHome;
|
||||
|
||||
@Before
|
||||
public void setupBaseHome() throws IOException
|
||||
{
|
||||
File homeDir = testdir.getEmptyDir();
|
||||
|
||||
ConfigSources config = new ConfigSources();
|
||||
config.add(new JettyHomeConfigSource(homeDir.toPath()));
|
||||
config.add(new JettyBaseConfigSource(homeDir.toPath()));
|
||||
|
||||
this.baseHome = new BaseHome(config);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetCoordinate_NotMaven()
|
||||
{
|
||||
MavenLocalRepoFileInitializer repo = new MavenLocalRepoFileInitializer(baseHome);
|
||||
String ref = "http://www.eclipse.org/jetty";
|
||||
Coordinates coords = repo.getCoordinates(URI.create(ref));
|
||||
assertThat("Coords",coords,nullValue());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetCoordinate_InvalidMaven()
|
||||
{
|
||||
MavenLocalRepoFileInitializer repo = new MavenLocalRepoFileInitializer(baseHome);
|
||||
String ref = "maven://www.eclipse.org/jetty";
|
||||
expectedException.expect(RuntimeException.class);
|
||||
expectedException.expectMessage(containsString("Not a valid maven:// uri"));
|
||||
repo.getCoordinates(URI.create(ref));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetCoordinate_Normal()
|
||||
{
|
||||
MavenLocalRepoFileInitializer repo = new MavenLocalRepoFileInitializer(baseHome);
|
||||
String ref = "maven://org.eclipse.jetty/jetty-start/9.3.x";
|
||||
Coordinates coords = repo.getCoordinates(URI.create(ref));
|
||||
assertThat("Coordinates",coords,notNullValue());
|
||||
|
||||
assertThat("coords.groupId",coords.groupId,is("org.eclipse.jetty"));
|
||||
assertThat("coords.artifactId",coords.artifactId,is("jetty-start"));
|
||||
assertThat("coords.version",coords.version,is("9.3.x"));
|
||||
assertThat("coords.type",coords.type,is("jar"));
|
||||
assertThat("coords.classifier",coords.classifier,nullValue());
|
||||
|
||||
assertThat("coords.toCentralURI", coords.toCentralURI().toASCIIString(),
|
||||
is("http://central.maven.org/maven2/org/eclipse/jetty/jetty-start/9.3.x/jetty-start-9.3.x.jar"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetCoordinate_Zip()
|
||||
{
|
||||
MavenLocalRepoFileInitializer repo = new MavenLocalRepoFileInitializer(baseHome);
|
||||
String ref = "maven://org.eclipse.jetty/jetty-distribution/9.3.x/zip";
|
||||
Coordinates coords = repo.getCoordinates(URI.create(ref));
|
||||
assertThat("Coordinates",coords,notNullValue());
|
||||
|
||||
assertThat("coords.groupId",coords.groupId,is("org.eclipse.jetty"));
|
||||
assertThat("coords.artifactId",coords.artifactId,is("jetty-distribution"));
|
||||
assertThat("coords.version",coords.version,is("9.3.x"));
|
||||
assertThat("coords.type",coords.type,is("zip"));
|
||||
assertThat("coords.classifier",coords.classifier,nullValue());
|
||||
|
||||
assertThat("coords.toCentralURI", coords.toCentralURI().toASCIIString(),
|
||||
is("http://central.maven.org/maven2/org/eclipse/jetty/jetty-distribution/9.3.x/jetty-distribution-9.3.x.zip"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetCoordinate_TestJar()
|
||||
{
|
||||
MavenLocalRepoFileInitializer repo = new MavenLocalRepoFileInitializer(baseHome);
|
||||
String ref = "maven://org.eclipse.jetty/jetty-http/9.3.x/jar/tests";
|
||||
Coordinates coords = repo.getCoordinates(URI.create(ref));
|
||||
assertThat("Coordinates",coords,notNullValue());
|
||||
|
||||
assertThat("coords.groupId",coords.groupId,is("org.eclipse.jetty"));
|
||||
assertThat("coords.artifactId",coords.artifactId,is("jetty-http"));
|
||||
assertThat("coords.version",coords.version,is("9.3.x"));
|
||||
assertThat("coords.type",coords.type,is("jar"));
|
||||
assertThat("coords.classifier",coords.classifier,is("tests"));
|
||||
|
||||
assertThat("coords.toCentralURI", coords.toCentralURI().toASCIIString(),
|
||||
is("http://central.maven.org/maven2/org/eclipse/jetty/jetty-http/9.3.x/jetty-http-9.3.x-tests.jar"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetCoordinate_Test_UnspecifiedType()
|
||||
{
|
||||
MavenLocalRepoFileInitializer repo = new MavenLocalRepoFileInitializer(baseHome);
|
||||
String ref = "maven://org.eclipse.jetty/jetty-http/9.3.x//tests";
|
||||
Coordinates coords = repo.getCoordinates(URI.create(ref));
|
||||
assertThat("Coordinates",coords,notNullValue());
|
||||
|
||||
assertThat("coords.groupId",coords.groupId,is("org.eclipse.jetty"));
|
||||
assertThat("coords.artifactId",coords.artifactId,is("jetty-http"));
|
||||
assertThat("coords.version",coords.version,is("9.3.x"));
|
||||
assertThat("coords.type",coords.type,is("jar"));
|
||||
assertThat("coords.classifier",coords.classifier,is("tests"));
|
||||
|
||||
assertThat("coords.toCentralURI", coords.toCentralURI().toASCIIString(),
|
||||
is("http://central.maven.org/maven2/org/eclipse/jetty/jetty-http/9.3.x/jetty-http-9.3.x-tests.jar"));
|
||||
}
|
||||
}
|
|
@ -0,0 +1,256 @@
|
|||
//
|
||||
// ========================================================================
|
||||
// Copyright (c) 1995-2014 Mort Bay Consulting Pty. Ltd.
|
||||
// ------------------------------------------------------------------------
|
||||
// All rights reserved. This program and the accompanying materials
|
||||
// are made available under the terms of the Eclipse Public License v1.0
|
||||
// and Apache License v2.0 which accompanies this distribution.
|
||||
//
|
||||
// The Eclipse Public License is available at
|
||||
// http://www.eclipse.org/legal/epl-v10.html
|
||||
//
|
||||
// The Apache License v2.0 is available at
|
||||
// http://www.opensource.org/licenses/apache2.0.php
|
||||
//
|
||||
// You may elect to redistribute this code under either of these licenses.
|
||||
// ========================================================================
|
||||
//
|
||||
|
||||
package org.eclipse.jetty.start.util;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.BufferedWriter;
|
||||
import java.io.IOException;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.nio.file.FileVisitOption;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.PathMatcher;
|
||||
import java.nio.file.StandardOpenOption;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Set;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import org.eclipse.jetty.start.PathFinder;
|
||||
import org.eclipse.jetty.start.PathMatchers;
|
||||
import org.eclipse.jetty.start.Utils;
|
||||
import org.eclipse.jetty.toolchain.test.MavenTestingUtils;
|
||||
|
||||
/**
|
||||
* Simple utility to scan all of the mod files and correct references
|
||||
* to maven central URL in [files] sections to the new maven:// syntax
|
||||
*/
|
||||
public class CorrectMavenCentralRefs
|
||||
{
|
||||
public static void main(String[] args)
|
||||
{
|
||||
Path buildRoot = MavenTestingUtils.getProjectDir("..").toPath();
|
||||
buildRoot = buildRoot.normalize().toAbsolutePath();
|
||||
|
||||
// Test to make sure we are in right directory
|
||||
Path rootPomXml = buildRoot.resolve("pom.xml");
|
||||
Path distPomXml = buildRoot.resolve("jetty-distribution/pom.xml");
|
||||
if (!Files.exists(rootPomXml) || !Files.exists(distPomXml))
|
||||
{
|
||||
System.err.println("Not build root directory: " + buildRoot);
|
||||
System.exit(-1);
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
new CorrectMavenCentralRefs().fix(buildRoot);
|
||||
}
|
||||
catch (Throwable t)
|
||||
{
|
||||
t.printStackTrace(System.err);
|
||||
}
|
||||
}
|
||||
|
||||
public void fix(Path buildRoot) throws IOException
|
||||
{
|
||||
// Find all of the *.mod files
|
||||
PathFinder finder = new PathFinder();
|
||||
finder.setFileMatcher("glob:**/*.mod");
|
||||
finder.setBase(buildRoot);
|
||||
|
||||
// Matcher for target directories
|
||||
PathMatcher targetMatcher = PathMatchers.getMatcher("glob:**/target/**");
|
||||
PathMatcher testMatcher = PathMatchers.getMatcher("glob:**/test/**");
|
||||
|
||||
System.out.printf("Walking path: %s%n",buildRoot);
|
||||
Set<FileVisitOption> options = Collections.emptySet();
|
||||
Files.walkFileTree(buildRoot,options,30,finder);
|
||||
|
||||
System.out.printf("Found: %d hits%n",finder.getHits().size());
|
||||
int count = 0;
|
||||
for (Path path : finder.getHits())
|
||||
{
|
||||
if (Files.isDirectory(path))
|
||||
{
|
||||
// skip
|
||||
continue;
|
||||
}
|
||||
|
||||
if (targetMatcher.matches(path))
|
||||
{
|
||||
// skip
|
||||
continue;
|
||||
}
|
||||
|
||||
if (testMatcher.matches(path))
|
||||
{
|
||||
// skip
|
||||
continue;
|
||||
}
|
||||
|
||||
if (processModFile(path))
|
||||
{
|
||||
count++;
|
||||
}
|
||||
}
|
||||
|
||||
System.out.printf("Processed %,d modules",count);
|
||||
}
|
||||
|
||||
private boolean processFileRefs(List<String> lines)
|
||||
{
|
||||
Pattern section = Pattern.compile("\\s*\\[([^]]*)\\]\\s*");
|
||||
int filesStart = -1;
|
||||
int filesEnd = -1;
|
||||
|
||||
// Find [files] section
|
||||
String sectionId = null;
|
||||
int lineCount = lines.size();
|
||||
for (int i = 0; i < lineCount; i++)
|
||||
{
|
||||
String line = lines.get(i).trim();
|
||||
|
||||
Matcher sectionMatcher = section.matcher(line);
|
||||
|
||||
if (sectionMatcher.matches())
|
||||
{
|
||||
sectionId = sectionMatcher.group(1).trim().toUpperCase(Locale.ENGLISH);
|
||||
}
|
||||
else
|
||||
{
|
||||
if ("FILES".equals(sectionId))
|
||||
{
|
||||
if (filesStart < 0)
|
||||
{
|
||||
filesStart = i;
|
||||
}
|
||||
filesEnd = i;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (filesStart == (-1))
|
||||
{
|
||||
// no [files] section
|
||||
return false;
|
||||
}
|
||||
|
||||
// process lines, only in files section
|
||||
int updated = 0;
|
||||
for (int i = filesStart; i <= filesEnd; i++)
|
||||
{
|
||||
String line = lines.get(i);
|
||||
String keyword = "maven.org/maven2/";
|
||||
int idx = line.indexOf(keyword);
|
||||
if (idx > 0)
|
||||
{
|
||||
int pipe = line.indexOf('|');
|
||||
String rawpath = line.substring(idx + keyword.length(),pipe);
|
||||
String destpath = line.substring(pipe + 1);
|
||||
|
||||
String parts[] = rawpath.split("/");
|
||||
int rev = parts.length;
|
||||
String filename = parts[--rev];
|
||||
|
||||
String type = "jar";
|
||||
int ext = filename.lastIndexOf('.');
|
||||
if (ext > 0)
|
||||
{
|
||||
type = filename.substring(ext + 1);
|
||||
}
|
||||
String version = parts[--rev];
|
||||
String artifactId = parts[--rev];
|
||||
String groupId = Utils.join(parts,0,rev,".");
|
||||
|
||||
String classifier = filename.replaceFirst(artifactId + '-' + version,"");
|
||||
classifier = classifier.replaceFirst('.' + type + '$',"");
|
||||
if (Utils.isNotBlank(classifier) && (classifier.charAt(0) == '-'))
|
||||
{
|
||||
classifier = classifier.substring(1);
|
||||
}
|
||||
|
||||
StringBuilder murl = new StringBuilder();
|
||||
murl.append("maven://");
|
||||
murl.append(groupId).append('/');
|
||||
murl.append(artifactId).append('/');
|
||||
murl.append(version);
|
||||
if (!"jar".equals(type) || Utils.isNotBlank(classifier))
|
||||
{
|
||||
murl.append('/').append(type);
|
||||
if (Utils.isNotBlank(classifier))
|
||||
{
|
||||
murl.append('/').append(classifier);
|
||||
}
|
||||
}
|
||||
|
||||
lines.set(i,murl.toString()+'|'+destpath);
|
||||
|
||||
updated++;
|
||||
}
|
||||
}
|
||||
|
||||
return (updated > 0);
|
||||
}
|
||||
|
||||
private boolean processModFile(Path path) throws IOException
|
||||
{
|
||||
List<String> lines = readLines(path);
|
||||
if (processFileRefs(lines))
|
||||
{
|
||||
// the lines are now dirty, save them.
|
||||
System.out.printf("Updating: %s%n",path);
|
||||
saveLines(path,lines);
|
||||
return true;
|
||||
}
|
||||
|
||||
// no update performed
|
||||
return false;
|
||||
}
|
||||
|
||||
private List<String> readLines(Path path) throws IOException
|
||||
{
|
||||
List<String> lines = new ArrayList<>();
|
||||
|
||||
try (BufferedReader reader = Files.newBufferedReader(path,StandardCharsets.UTF_8))
|
||||
{
|
||||
String line;
|
||||
while ((line = reader.readLine()) != null)
|
||||
{
|
||||
lines.add(line);
|
||||
}
|
||||
}
|
||||
|
||||
return lines;
|
||||
}
|
||||
|
||||
private void saveLines(Path path, List<String> lines) throws IOException
|
||||
{
|
||||
try (BufferedWriter writer = Files.newBufferedWriter(path,StandardCharsets.UTF_8,StandardOpenOption.TRUNCATE_EXISTING))
|
||||
{
|
||||
for (String line : lines)
|
||||
{
|
||||
writer.write(line);
|
||||
writer.write(System.lineSeparator());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -16,7 +16,7 @@
|
|||
// ========================================================================
|
||||
//
|
||||
|
||||
package org.eclipse.jetty.start;
|
||||
package org.eclipse.jetty.start.util;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
Loading…
Reference in New Issue