ppkarwasz commented on code in PR #279:
URL: 
https://github.com/apache/logging-log4j-samples/pull/279#discussion_r2035076308


##########
settings.gradle:
##########
@@ -0,0 +1,19 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to you under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+

Review Comment:
   It would be nice to configure all the repositories in one place. The 
`settings.gradle` file seems the most appropriate.
   
   Since too many `404` requests to `repository.apache.org` ends up in a ban 
for the IP of the GitHub runner, it is important to limit those requests to the 
minimum:
   
   - If `LOG4J_REPOSITORY_URL` is absent or empty, then 
`https://repository.apache.org/snapshots` should be used (only for snapshots).
   - Otherwise the repository should be used only for release versions.
   
   The best I could come up with is:
   
   ```gradle
   dependencyResolutionManagement {
       repositories {
           google()
           mavenCentral()
           // Points to the correct Apache staging repository
           var apacheSnapshots = 'https://repository.apache.org/snapshots'
           var repositoryUrl = 
providers.environmentVariable("LOG4J_REPOSITORY_URL")
                   .filter { !it.isEmpty() }
                   .orElseGet(apacheSnapshots)
           maven {
               name = 'Log4j Repository'
               url = repositoryUrl
               mavenContent {
                   // Only use this repository for Apache Logging Services 
artifacts
                   includeGroupAndSubgroups('org.apache.logging')
                   // Only use this repository for either snapshots or releases
                   repositoryUrl == apacheSnapshots ? snapshotsOnly() : 
releasesOnly()
               }
           }
       }
   }
   ```



##########
log4j-samples-gradle-metadata/build.gradle.kts:
##########
@@ -0,0 +1,80 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to you under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+plugins {
+    id("application")
+}
+
+val log4jVersion = 
providers.environmentVariable("LOG4J_VERSION").getOrElse("2.+")
+
+repositories {
+    
maven(providers.environmentVariable("LOG4J_REPOSITORY_URL").getOrElse("https://repo.maven.apache.org/maven2";))
+}

Review Comment:
   I would prefer to keep this in `settings.gradle` if possible.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscr...@logging.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to