@@ -21,7 +21,7 @@ abstract class BaseMavenVersionController(
2121
2222 abstract val mavenUrl: String
2323 abstract val stableMetaUrl: URL
24- abstract val snapshotMetaUrl : URL
24+ abstract val devMetaUrl : URL
2525 abstract val artifactPath: String
2626 abstract val artifactName: String
2727
@@ -39,12 +39,12 @@ abstract class BaseMavenVersionController(
3939 }
4040 }
4141
42- protected fun checkSnapshotVersion (): String? {
42+ protected fun checkDevVersion (): String? {
4343 return try {
44- val xml = snapshotMetaUrl .readText()
44+ val xml = devMetaUrl .readText()
4545 parseLatestVersionForMinecraft(xml)
4646 } catch (e: Exception ) {
47- e.printStackTrace()
47+ if ( ConfigManager .config.debug) e.printStackTrace()
4848 null
4949 }
5050 }
@@ -102,62 +102,19 @@ abstract class BaseMavenVersionController(
102102 }
103103 }
104104
105- data class SnapshotInfo (
106- val version : String ,
107- val timestamp : String ,
108- val buildNumber : String
109- )
110-
111- protected fun getLatestSnapshotInfo (): SnapshotInfo ? {
112- return try {
113- val version = checkSnapshotVersion() ? : return null
114- val snapshotMetaUrl = URI (" $mavenUrl /snapshots/$artifactPath /$version /maven-metadata.xml" ).toURL()
115- val xml = snapshotMetaUrl.readText()
116- parseSnapshotInfo(xml, version)
117- } catch (e: Exception ) {
118- e.printStackTrace()
119- null
120- }
121- }
122-
123- protected fun parseSnapshotInfo (xml : String , version : String ): SnapshotInfo ? {
124- return try {
125- val factory = DocumentBuilderFactory .newInstance()
126- val builder = factory.newDocumentBuilder()
127- val document = builder.parse(xml.byteInputStream())
128-
129- val timestampNodes = document.getElementsByTagName(" timestamp" )
130- val buildNumberNodes = document.getElementsByTagName(" buildNumber" )
131-
132- if (timestampNodes.length > 0 && buildNumberNodes.length > 0 ) {
133- val timestamp = timestampNodes.item(0 ).textContent
134- val buildNumber = buildNumberNodes.item(0 ).textContent
135- SnapshotInfo (version, timestamp, buildNumber)
136- } else {
137- null
138- }
139- } catch (e: Exception ) {
140- e.printStackTrace()
141- null
142- }
143- }
144-
145- protected fun getSnapshotJarUrl (): String? {
146- val snapshotInfo = getLatestSnapshotInfo() ? : return null
147- val baseVersion = snapshotInfo.version.replace(" -SNAPSHOT" , " " )
148- val timestamp = snapshotInfo.timestamp
149- val buildNumber = snapshotInfo.buildNumber
150- return " $mavenUrl /snapshots/$artifactPath /${snapshotInfo.version} /$artifactName -$baseVersion -$timestamp -$buildNumber .jar"
105+ protected fun getDevJarUrl (): String? {
106+ val version = checkDevVersion() ? : return null
107+ return " $mavenUrl /dev/$artifactPath /$version /$artifactName -$version .jar"
151108 }
152109
153- protected fun getSnapshotChecksumUrl (): String? {
154- val jarUrl = getSnapshotJarUrl () ? : return null
110+ protected fun getDevChecksumUrl (): String? {
111+ val jarUrl = getDevJarUrl () ? : return null
155112 return " $jarUrl .md5"
156113 }
157114
158115 protected fun getStableJarUrl (): String? {
159116 val version = checkStableVersion() ? : return null
160- return " $mavenUrl /releases /$artifactPath /$version /$artifactName -$version .jar"
117+ return " $mavenUrl /stable /$artifactPath /$version /$artifactName -$version .jar"
161118 }
162119
163120 protected fun getStableChecksumUrl (): String? {
@@ -168,50 +125,44 @@ abstract class BaseMavenVersionController(
168125 protected fun getJarUrl (): String? {
169126 return when (getReleaseMode()) {
170127 ReleaseMode .Stable -> {
171- val releaseUrl = getStableJarUrl()
172- if (releaseUrl == null ) {
128+ val stableUrl = getStableJarUrl()
129+ if (stableUrl == null ) {
173130 val versionMsg = getVersionToMatch()?.let { " for version $it " } ? : " "
174- logger.warning(" No stable version found $versionMsg , falling back to snapshot " )
175- getSnapshotJarUrl ()
176- } else releaseUrl
131+ logger.warning(" No stable version found $versionMsg , falling back to dev " )
132+ getDevJarUrl ()
133+ } else stableUrl
177134 }
178- ReleaseMode .Snapshot -> getSnapshotJarUrl ()
135+ ReleaseMode .Dev -> getDevJarUrl ()
179136 }
180137 }
181138
182139 protected fun getChecksumUrl (): String? {
183140 return when (getReleaseMode()) {
184141 ReleaseMode .Stable -> {
185- val releaseChecksumUrl = getStableChecksumUrl()
186- if (releaseChecksumUrl == null ) {
142+ val stableChecksumUrl = getStableChecksumUrl()
143+ if (stableChecksumUrl == null ) {
187144 val versionMsg = getVersionToMatch()?.let { " for version $it " } ? : " "
188- logger.warning(" No stable version checksum found $versionMsg , falling back to snapshot " )
189- getSnapshotChecksumUrl ()
190- } else releaseChecksumUrl
145+ logger.warning(" No stable version checksum found $versionMsg , falling back to dev " )
146+ getDevChecksumUrl ()
147+ } else stableChecksumUrl
191148 }
192- ReleaseMode .Snapshot -> getSnapshotChecksumUrl ()
149+ ReleaseMode .Dev -> getDevChecksumUrl ()
193150 }
194151 }
195152
196153 protected fun getCacheFileName (): String? {
197- return when (getReleaseMode()) {
154+ val version = when (getReleaseMode()) {
198155 ReleaseMode .Stable -> {
199- val version = checkStableVersion()
200- if (version == null ) {
156+ val stableVersion = checkStableVersion()
157+ if (stableVersion == null ) {
201158 val versionMsg = getVersionToMatch()?.let { " for version $it " } ? : " "
202- logger.warning(" No stable cache filename found $versionMsg , falling back to snapshot" )
203- val snapshotInfo = getLatestSnapshotInfo() ? : return null
204- val baseVersion = snapshotInfo.version.replace(" -SNAPSHOT" , " " )
205- " $artifactName -$baseVersion -${snapshotInfo.timestamp} -${snapshotInfo.buildNumber} .jar"
206- } else " $artifactName -$version .jar"
207- }
208-
209- ReleaseMode .Snapshot -> {
210- val snapshotInfo = getLatestSnapshotInfo() ? : return null
211- val baseVersion = snapshotInfo.version.replace(" -SNAPSHOT" , " " )
212- " $artifactName -$baseVersion -${snapshotInfo.timestamp} -${snapshotInfo.buildNumber} .jar"
159+ logger.warning(" No stable cache filename found $versionMsg , falling back to dev" )
160+ checkDevVersion() ? : return null
161+ } else stableVersion
213162 }
163+ ReleaseMode .Dev -> checkDevVersion() ? : return null
214164 }
165+ return " $artifactName -$version .jar"
215166 }
216167
217168 protected fun downloadChecksum (): String? {
@@ -296,16 +247,16 @@ abstract class BaseMavenVersionController(
296247 return try {
297248 if (! ensureLatestVersionCached()) {
298249 val stableVersion = checkStableVersion()
299- val snapshotVersion = checkSnapshotVersion ()
250+ val devVersion = checkDevVersion ()
300251
301- if (stableVersion == null && snapshotVersion == null ) {
252+ if (stableVersion == null && devVersion == null ) {
302253 val versionMsg = getVersionToMatch()?.let { " for version $it " } ? : " "
303254 logger.severe(" ============================================================" )
304255 logger.severe(" FATAL ERROR: No $artifactName version found!" )
305256 if (versionMsg.isNotEmpty()) {
306257 logger.severe(" Target version: $versionMsg " )
307258 }
308- logger.severe(" Neither STABLE nor SNAPSHOT versions are available." )
259+ logger.severe(" Neither stable nor dev versions are available." )
309260 logger.severe(" Please check:" )
310261 logger.severe(" 1. Your internet connection" )
311262 logger.severe(" 2. Maven repository availability at: $mavenUrl " )
0 commit comments