Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(build): move depdendencies enforcer script to build/scripts #215

Merged
merged 1 commit into from
Sep 30, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
34 changes: 34 additions & 0 deletions build/scripts/validate-dependencies.groovy
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/*
* 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.
*/
final List<String> badDeps = []
final File pomXml = new File(project.basedir, "pom.xml")

if (pomXml.exists()) {
def pomXmlProject = new XmlParser().parseText(pomXml.getText('UTF-8'))
pomXmlProject.dependencies.dependency
.findAll {
!it.version.text().isEmpty()
}
.each {
badDeps << "in ${project.basedir}/pom.xml : ${it.groupId.text()}:${it.artifactId.text()}"
}
}

if (!badDeps.isEmpty()) {
throw new RuntimeException("\nRemove explicit version from the following dependencies and rather manage them in one of the BOMs:\n\n "
+ badDeps.join("\n "))
}
37 changes: 19 additions & 18 deletions poms/build-parent/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
<jandex-maven-plugin.version>1.0.6</jandex-maven-plugin.version>
<maven-resources-plugin.version>3.1.0</maven-resources-plugin.version>
<docker-maven-plugin.version>0.3.0</docker-maven-plugin.version>
<directory-maven-plugin.version>0.3.1</directory-maven-plugin.version>
</properties>

<dependencyManagement>
Expand Down Expand Up @@ -108,6 +109,23 @@
</pluginManagement>

<plugins>
<plugin>
<groupId>org.commonjava.maven.plugins</groupId>
<artifactId>directory-maven-plugin</artifactId>
<version>${directory-maven-plugin.version}</version>
<executions>
<execution>
<id>directories</id>
<goals>
<goal>highest-basedir</goal>
</goals>
<phase>validate</phase>
<configuration>
<property>camel.quarkus.project.root</property>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.gmaven</groupId>
<artifactId>groovy-maven-plugin</artifactId>
Expand All @@ -119,24 +137,7 @@
</goals>
<phase>validate</phase>
<configuration>
<useSharedClassLoader>false</useSharedClassLoader>
<source><![CDATA[
final List<String> badDeps = []
final File pomXml = new File(project.basedir, "pom.xml")
if (pomXml.exists()) {
def pomXmlProject = new XmlParser().parseText(pomXml.getText('UTF-8'))
pomXmlProject.dependencies.dependency
.findAll { dep ->
!dep.version.text().isEmpty()
}.stream()
.map { dep -> "in "+ project.basedir +"/pom.xml : "+ dep.groupId.text() +":"+ dep.artifactId.text() }
.each { key -> badDeps.add(key) }
}
if (!badDeps.isEmpty()) {
throw new RuntimeException("\nRemove explicit version from the following dependencies and rather manage them in one of the BOMs:\n\n "
+ badDeps.join("\n "))
}
]]></source>
<source>file://${camel.quarkus.project.root}/build/scripts/validate-dependencies.groovy</source>
</configuration>
</execution>
</executions>
Expand Down