├── .gitignore
├── .mvn
└── wrapper
│ ├── maven-wrapper.jar
│ └── maven-wrapper.properties
├── .travis.yml
├── LICENSE.txt
├── README.adoc
├── appveyor.yml
├── checkstyle.xml
├── doc
├── images
│ ├── srcdeps-for-maven.svg
│ └── srcdeps-logo-with-text.svg
└── srcdeps-maven-configuration.adoc
├── mvnw
├── mvnw.cmd
├── pom.xml
├── srcdeps-maven-base
├── pom.xml
└── src
│ └── main
│ └── java
│ └── org
│ └── srcdeps
│ └── mvn
│ ├── Constants.java
│ └── config
│ └── ConfigurationProducer.java
├── srcdeps-maven-enforcer
├── pom.xml
└── src
│ ├── main
│ └── java
│ │ └── org
│ │ └── srcdeps
│ │ └── mvn
│ │ └── enforcer
│ │ └── SrcdepsEnforcer.java
│ └── test
│ └── java
│ └── org
│ └── srcdeps
│ └── mvn
│ └── enforcer
│ └── SrcdepsEnforcerTest.java
├── srcdeps-maven-local-repository
├── pom.xml
└── src
│ └── main
│ └── java
│ └── org
│ └── srcdeps
│ └── mvn
│ └── localrepo
│ ├── SrcdepsLocalRepositoryManager.java
│ └── SrcdepsRepositoryManagerFactory.java
├── srcdeps-maven-plugin
├── pom.xml
└── src
│ ├── main
│ └── java
│ │ └── org
│ │ └── srcdeps
│ │ └── mvn
│ │ └── plugin
│ │ ├── ExtensionsXmlUtils.java
│ │ ├── Ga.java
│ │ ├── SrcdepsInitMojo.java
│ │ └── SrcdepsUpgradeMojo.java
│ └── test
│ ├── java
│ └── org
│ │ └── srcdeps
│ │ └── mvn
│ │ └── plugin
│ │ ├── ExtensionsXmlUtilsTest.java
│ │ ├── ScmUrlChainTest.java
│ │ └── SrcdepsInitMojoTest.java
│ └── projects
│ └── parent-with-jar
│ ├── jar
│ ├── pom.xml
│ └── src
│ │ └── main
│ │ └── java
│ │ └── org
│ │ └── srcdeps
│ │ └── mvn
│ │ └── plugin
│ │ └── it
│ │ └── Main.java
│ └── pom.xml
└── srcdeps-maven-quickstarts
├── pom.xml
├── src
└── test
│ ├── java
│ └── org
│ │ └── srcdeps
│ │ └── mvn
│ │ └── itest
│ │ ├── AbstractMavenDepsIntegrationTest.java
│ │ ├── LocalMavenRepoVerifier.java
│ │ ├── MavenDepsGradleIntegrationTest.java
│ │ ├── MavenDepsMavenIntegrationTest.java
│ │ ├── MavenFailWithIntegrationTest.java
│ │ ├── MavenMasterConfigIntegrationTest.java
│ │ ├── SrcdepsTestResources.java
│ │ ├── TestUtils.java
│ │ └── WrappedMavenExecutionResult.java
│ └── resources
│ └── settings-mrm.xml
├── srcdeps-mvn-git-bom-quickstart
├── .mvn
│ └── extensions.xml
├── pom.xml
├── src
│ ├── main
│ │ └── java
│ │ │ └── org
│ │ │ └── srcdeps
│ │ │ └── mvn
│ │ │ └── quickstarts
│ │ │ └── git
│ │ │ └── parent
│ │ │ └── AppClient.java
│ └── test
│ │ └── java
│ │ └── org
│ │ └── srcdeps
│ │ └── mvn
│ │ └── quickstarts
│ │ └── git
│ │ └── parent
│ │ └── AppClientTest.java
└── srcdeps.yaml
├── srcdeps-mvn-git-branch-quickstart
├── .mvn
│ └── extensions.xml
├── api
│ ├── pom.xml
│ └── src
│ │ └── main
│ │ └── java
│ │ └── org
│ │ └── srcdeps
│ │ └── quickstarts
│ │ └── mvn
│ │ └── git
│ │ └── branch
│ │ └── AppClient.java
├── jar
│ ├── pom.xml
│ └── src
│ │ ├── main
│ │ └── java
│ │ │ └── org
│ │ │ └── srcdeps
│ │ │ └── quickstarts
│ │ │ └── mvn
│ │ │ └── git
│ │ │ └── branch
│ │ │ └── AppClientImpl.java
│ │ └── test
│ │ └── java
│ │ └── org
│ │ └── srcdeps
│ │ └── quickstarts
│ │ └── mvn
│ │ └── git
│ │ └── branch
│ │ └── AppClientTest.java
├── pom.xml
└── srcdeps.yaml
├── srcdeps-mvn-git-gradle-source-dependency-quickstart
├── .mvn
│ └── extensions.xml
├── README.adoc
├── jar
│ ├── pom.xml
│ └── src
│ │ ├── main
│ │ └── java
│ │ │ └── org
│ │ │ └── srcdeps
│ │ │ └── quickstarts
│ │ │ └── mvn
│ │ │ └── git
│ │ │ └── revision
│ │ │ └── gradle
│ │ │ └── GreetingApp.java
│ │ └── test
│ │ └── java
│ │ └── org
│ │ └── srcdeps
│ │ └── quickstarts
│ │ └── mvn
│ │ └── git
│ │ └── revision
│ │ └── gradle
│ │ └── GreetingAppTest.java
├── pom.xml
└── srcdeps.yaml
├── srcdeps-mvn-git-include-required-quickstart
├── .mvn
│ └── extensions.xml
├── jar
│ ├── pom.xml
│ └── src
│ │ ├── main
│ │ └── java
│ │ │ └── org
│ │ │ └── srcdeps
│ │ │ └── quickstarts
│ │ │ └── mvn
│ │ │ └── git
│ │ │ └── interdep
│ │ │ └── Interdep.java
│ │ └── test
│ │ └── java
│ │ └── org
│ │ └── srcdeps
│ │ └── quickstarts
│ │ └── mvn
│ │ └── git
│ │ └── interdep
│ │ └── InterdepTest.java
├── pom.xml
└── srcdeps.yaml
├── srcdeps-mvn-git-interdep-modules-quickstart
├── .mvn
│ └── extensions.xml
├── jar
│ ├── pom.xml
│ └── src
│ │ ├── main
│ │ └── java
│ │ │ └── org
│ │ │ └── srcdeps
│ │ │ └── quickstarts
│ │ │ └── mvn
│ │ │ └── git
│ │ │ └── interdep
│ │ │ └── Interdep.java
│ │ └── test
│ │ └── java
│ │ └── org
│ │ └── srcdeps
│ │ └── quickstarts
│ │ └── mvn
│ │ └── git
│ │ └── interdep
│ │ └── InterdepTest.java
├── pom.xml
└── srcdeps.yaml
├── srcdeps-mvn-git-master-config
├── .mvn
│ └── extensions.xml
├── pom.xml
├── src
│ └── test
│ │ ├── dependency-projects
│ │ ├── srcdeps-mvn-git-master-config-hello-decorator
│ │ │ ├── .gitignore
│ │ │ ├── pom.xml
│ │ │ └── src
│ │ │ │ └── main
│ │ │ │ └── java
│ │ │ │ └── org
│ │ │ │ └── srcdeps
│ │ │ │ └── mvn
│ │ │ │ └── quickstarts
│ │ │ │ └── master
│ │ │ │ └── config
│ │ │ │ └── hello
│ │ │ │ └── NameDecorator.java
│ │ └── srcdeps-mvn-git-master-config-hello
│ │ │ ├── .gitignore
│ │ │ ├── pom.xml
│ │ │ └── src
│ │ │ └── main
│ │ │ └── java
│ │ │ └── org
│ │ │ └── srcdeps
│ │ │ └── mvn
│ │ │ └── quickstarts
│ │ │ └── master
│ │ │ └── config
│ │ │ └── hello
│ │ │ └── decorator
│ │ │ ├── Greeter.java
│ │ │ └── Hello.java
│ │ └── java
│ │ └── org
│ │ └── srcdeps
│ │ └── mvn
│ │ └── quickstarts
│ │ └── master
│ │ └── config
│ │ └── HelloDecoratorTest.java
└── srcdeps.yaml
├── srcdeps-mvn-git-parent-quickstart
├── .mvn
│ └── extensions.xml
├── pom.xml
├── src
│ ├── main
│ │ └── java
│ │ │ └── org
│ │ │ └── srcdeps
│ │ │ └── mvn
│ │ │ └── quickstarts
│ │ │ └── git
│ │ │ └── parent
│ │ │ └── AppClient.java
│ └── test
│ │ └── java
│ │ └── org
│ │ └── srcdeps
│ │ └── mvn
│ │ └── quickstarts
│ │ └── git
│ │ └── parent
│ │ └── AppClientTest.java
└── srcdeps.yaml
├── srcdeps-mvn-git-profile-and-properties-quickstart
├── .mvn
│ └── extensions.xml
├── jar
│ ├── pom.xml
│ └── src
│ │ ├── main
│ │ └── java
│ │ │ └── org
│ │ │ └── srcdeps
│ │ │ └── quickstarts
│ │ │ └── mvn
│ │ │ └── git
│ │ │ └── prop
│ │ │ └── profile
│ │ │ └── GreetingConsumer.java
│ │ └── test
│ │ └── java
│ │ └── org
│ │ └── srcdeps
│ │ └── quickstarts
│ │ └── mvn
│ │ └── git
│ │ └── prop
│ │ └── profile
│ │ └── GreetingConsumerTest.java
├── pom.xml
└── srcdeps.yaml
├── srcdeps-mvn-git-profile-quickstart
├── .mvn
│ └── extensions.xml
├── pom.xml
├── src
│ ├── main
│ │ └── java
│ │ │ └── org
│ │ │ └── srcdeps
│ │ │ └── mvn
│ │ │ └── quickstarts
│ │ │ └── git
│ │ │ └── parent
│ │ │ └── AppClient.java
│ └── test
│ │ └── java
│ │ └── org
│ │ └── srcdeps
│ │ └── mvn
│ │ └── quickstarts
│ │ └── git
│ │ └── parent
│ │ └── AppClientTest.java
└── srcdeps.yaml
├── srcdeps-mvn-git-revision-non-master-quickstart
├── .mvn
│ └── extensions.xml
├── jar
│ └── pom.xml
├── pom.xml
└── srcdeps.yaml
├── srcdeps-mvn-git-revision-quickstart
├── .mvn
│ └── extensions.xml
├── README.adoc
├── jar
│ ├── pom.xml
│ └── src
│ │ ├── main
│ │ └── java
│ │ │ └── org
│ │ │ └── srcdeps
│ │ │ └── quickstarts
│ │ │ └── mvn
│ │ │ └── git
│ │ │ └── revision
│ │ │ └── AppClient.java
│ │ └── test
│ │ └── java
│ │ └── org
│ │ └── srcdeps
│ │ └── quickstarts
│ │ └── mvn
│ │ └── git
│ │ └── revision
│ │ └── AppClientTest.java
├── pom.xml
└── srcdeps.yaml
├── srcdeps-mvn-git-snapshot-quickstart
├── .mvn
│ └── extensions.xml
├── README.adoc
├── jar
│ ├── pom.xml
│ └── src
│ │ ├── main
│ │ └── java
│ │ │ └── org
│ │ │ └── srcdeps
│ │ │ └── quickstarts
│ │ │ └── mvn
│ │ │ └── git
│ │ │ └── revision
│ │ │ └── AppClient.java
│ │ └── test
│ │ └── java
│ │ └── org
│ │ └── srcdeps
│ │ └── quickstarts
│ │ └── mvn
│ │ └── git
│ │ └── revision
│ │ └── AppClientTest.java
├── pom.xml
└── srcdeps.yaml
├── srcdeps-mvn-git-tag-quickstart
├── .mvn
│ └── extensions.xml
├── jar
│ ├── pom.xml
│ └── src
│ │ ├── main
│ │ └── java
│ │ │ └── org
│ │ │ └── srcdeps
│ │ │ └── quickstarts
│ │ │ └── mvn
│ │ │ └── git
│ │ │ └── revision
│ │ │ └── AppClient.java
│ │ └── test
│ │ └── java
│ │ └── org
│ │ └── srcdeps
│ │ └── quickstarts
│ │ └── mvn
│ │ └── git
│ │ └── revision
│ │ └── AppClientTest.java
├── pom.xml
└── srcdeps.yaml
└── srcdeps-mvnw-git-quickstart
├── .mvn
└── extensions.xml
├── pom.xml
├── src
├── main
│ └── java
│ │ └── org
│ │ └── srcdeps
│ │ └── mvn
│ │ └── quickstarts
│ │ └── git
│ │ └── parent
│ │ └── AppClient.java
└── test
│ └── java
│ └── org
│ └── srcdeps
│ └── mvn
│ └── quickstarts
│ └── git
│ └── parent
│ └── AppClientTest.java
└── srcdeps.yaml
/.gitignore:
--------------------------------------------------------------------------------
1 | # Maven
2 | target/
3 | pom.xml.tag
4 | pom.xml.releaseBackup
5 | pom.xml.versionsBackup
6 | pom.xml.next
7 | release.properties
8 |
9 | # Eclipse
10 | .project
11 | .classpath
12 | .settings/
13 | bin/
14 |
15 | # IDEA
16 | .idea
17 | *.ipr
18 | *.iml
19 | *.iws
20 |
21 | # NetBeans
22 | nb-configuration.xml
23 |
24 | # KDE
25 | .directory
26 |
27 | # OSX
28 | .DS_Store
--------------------------------------------------------------------------------
/.mvn/wrapper/maven-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/srcdeps/srcdeps-maven/f41195d06147f32670059f5788b5677fc37161b8/.mvn/wrapper/maven-wrapper.jar
--------------------------------------------------------------------------------
/.mvn/wrapper/maven-wrapper.properties:
--------------------------------------------------------------------------------
1 | #
2 | # Copyright 2015-2018 Maven Source Dependencies
3 | # Plugin contributors as indicated by the @author tags.
4 | #
5 | # Licensed under the Apache License, Version 2.0 (the "License");
6 | # you may not use this file except in compliance with the License.
7 | # You may obtain a copy of the License at
8 | #
9 | # http://www.apache.org/licenses/LICENSE-2.0
10 | #
11 | # Unless required by applicable law or agreed to in writing, software
12 | # distributed under the License is distributed on an "AS IS" BASIS,
13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | # See the License for the specific language governing permissions and
15 | # limitations under the License.
16 | #
17 |
18 | distributionUrl=https://repo1.maven.org/maven2/org/apache/maven/apache-maven/3.5.3/apache-maven-3.5.3-bin.zip
--------------------------------------------------------------------------------
/.travis.yml:
--------------------------------------------------------------------------------
1 | language: java
2 | # Enable container-based infrastructure
3 | # see http://docs.travis-ci.com/user/workers/container-based-infrastructure/
4 | sudo: false
5 | jdk:
6 | - openjdk8
7 | cache:
8 | directories:
9 | - $HOME/.m2/repository
10 | - $HOME/.m2/wrapper
11 | install:
12 | - ./mvnw -version
13 | # license plugin requires full git history
14 | - git fetch --unshallow
15 | script:
16 | - ./mvnw -Prun-its clean install -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn
--------------------------------------------------------------------------------
/appveyor.yml:
--------------------------------------------------------------------------------
1 | #
2 | # Copyright 2015-2018 Maven Source Dependencies
3 | # Plugin contributors as indicated by the @author tags.
4 | #
5 | # Licensed under the Apache License, Version 2.0 (the "License");
6 | # you may not use this file except in compliance with the License.
7 | # You may obtain a copy of the License at
8 | #
9 | # http://www.apache.org/licenses/LICENSE-2.0
10 | #
11 | # Unless required by applicable law or agreed to in writing, software
12 | # distributed under the License is distributed on an "AS IS" BASIS,
13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | # See the License for the specific language governing permissions and
15 | # limitations under the License.
16 | #
17 |
18 | environment:
19 | JAVA_HOME: C:\Program Files\Java\jdk1.8.0
20 | install:
21 | - cmd: SET PATH=C:\Users\appveyor\.m2\wrapper\dists\apache-maven-3.5.3-bin\2c22a6s60afpuloj4v181qvild\apache-maven-3.5.3\bin;%JAVA_HOME%\bin;%PATH%
22 | build_script:
23 | - .\mvnw.cmd clean install -B -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn
24 | on_failure:
25 | - echo "failed"
26 | # - type C:\projects\srcdeps-maven\srcdeps-maven-quickstarts\target\test-projects\MavenDepsMavenIntegrationTest_mvnGitSnapshotRevision[3.5.3]_srcdeps-mvn-git-snapshot-quickstart\log.txt
27 | cache:
28 | - C:\Users\appveyor\.m2\wrapper
29 |
--------------------------------------------------------------------------------
/checkstyle.xml:
--------------------------------------------------------------------------------
1 |
2 |
20 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
--------------------------------------------------------------------------------
/doc/srcdeps-maven-configuration.adoc:
--------------------------------------------------------------------------------
1 | image::doc/images/srcdeps-for-maven.svg[ec4j,height=60,alt=srcdeps for Maven]
2 |
3 | = `srcdeps` for Maven Configuration Guide
4 |
5 | The behavior of `srcdeps` is controlled through two configuration files:
6 |
7 | <> - make Maven aware of `srcdeps` +
8 | <> - the main srcdeps configuration file
9 |
10 | Note that both files can be initialized by running our `srcdeps-maven-plugin`'s `init` mojo the in the root
11 | directory of your project tree:
12 |
13 | [source,shell]
14 | ----
15 | mvn org.srcdeps.mvn:srcdeps-maven-plugin:init
16 | ----
17 |
18 | [[extensions-xml]]
19 | == 1. `.mvn/extensions.xml`
20 |
21 | `srcdeps-maven-local-repository` needs to be declared as a Maven Core Extension in `.mvn/extensions.xml`
22 | of the maven project.
23 |
24 | [source,xml]
25 | ----
26 |
27 |
28 |
29 | org.l2x6.maven.srcdeps
30 | srcdeps-maven-local-repository
31 | 4.0.0
32 |
33 |
34 | org.srcdeps.mvn
35 | srcdeps-maven-enforcer
36 | 4.0.0
37 |
38 |
39 | ----
40 |
41 | [[srcdeps-yaml]]
42 | == 2. `srcdeps.yaml`
43 |
44 | A few settings have to be configured in `srcdeps.yaml` file. Especially, the mapping from groupId's of
45 | dependencies to SCM repositories where their sources reside. This is a minimal `srcdeps.yaml` file. Please
46 | refer to link:https://github.com/srcdeps/srcdeps-core/tree/master/doc/srcdeps.yaml[srcdeps.yaml reference] for more
47 | details.
48 |
49 | The `srcdeps.yaml` file has to be located in the root directory of a Maven source tree. Before version 3.1.0 of
50 | `srcdeps-maven` the location was `.mvn/srcdeps.yaml` and it is still supported as a fall back location in case
51 | there is no `srcdeps.yaml` in the root directory.
52 |
53 | [source,yaml]
54 | ----
55 | configModelVersion: 2.4
56 | repositories:
57 | org.my-group:
58 | includes:
59 | - org.my-group:*:* # if one of the includes matches the groupId of a -SRC- dependency,
60 | # then the following urls will be used to build that dependency
61 | urls:
62 | - https://github.com/my-org/my-project.git # If you list multiple SCM repos here then only
63 | # the first successful checkout will count
64 |
65 | ----
66 |
67 | == 3. Setting dependency versions
68 |
69 | There are two alternative ways how you can define which source repository reference should be used to build your
70 | dependency: in `pom.xml` or in `srcdeps.yaml`.
71 |
72 | [[srcdeps-in-pom-xml]]
73 | === 3.1 In `pom.xml`
74 |
75 | Defining source repository refs in `pom.xml` is older and perhaps more straightforward:
76 |
77 | [source,yaml]
78 | ----
79 |
80 | org.my-group
81 | my-artifact
82 | 0.0.1-SRC-revision-66ea95d890531f4eaaa5aa04a9b1c69b409dcd0b
83 |
84 | ----
85 |
86 | The `-SRC-` infix in the version makes `srcdeps-maven-local-repository` detect the dependency as source
87 | dependency. The part after the `-SRC-` infix is supposed to be a dash separated pair of `refType` and `refName`.
88 | `refType` is one of `revision`, `branch` or `tag` and the `refName` is the actual commitId, branch name or
89 | tag name.
90 |
91 | Examples:
92 |
93 | * `0.0.1-SRC-revision-66ea95d890531f4eaaa5aa04a9b1c69b409dcd0b`
94 | * `1.2.3-SRC-branch-1.2.x`
95 | * `2.0.1-SRC-tag-2.0.1`
96 |
97 | The part before `-SRC-` has no significance for `srcdeps`. It also has no significance for Maven. It may be
98 | important for Gradle when resolving version conflicts; Gradle prefers higher versions by default. A practical reason
99 | to keep it there is to have a mnemonic that helps a human reader to set her expectations about the compatibility of
100 | the dependency.
101 |
102 | [[srcdeps-in-srcdeps-yaml]]
103 | === 3.2 in `srcdeps.yaml` (since `srcdeps-maven` 3.3.0)
104 |
105 | If you do not want or cannot change the `pom.xml`, you can achieve a similar result by using
106 | `buildVersionPattern` and `buildRef` of `srcdeps.yaml`.
107 |
108 | [source,yaml]
109 | ----
110 | configModelVersion: 2.4
111 | repositories:
112 | org.my-group:
113 | includes:
114 | - org.my-group:*:* # if one of the includes matches the groupId of a -SRC- dependency,
115 | # then the following urls will be used to build that dependency
116 | urls:
117 | - https://github.com/my-org/my-project.git # If you list multiple SCM repos here then only
118 | # the first successful checkout will count
119 | buildVersionPattern: .*-SNAPSHOT # versions matching .*-SNAPSHOT pattern will be built
120 | buildRef: branch-1.2.x # using branch 1.2.x from https://github.com/my-org/my-project.git
121 | ----
122 |
123 | If you combine the above `srcdeps.yaml` with a `pom.xml` like the following
124 |
125 | ----
126 |
127 | org.my-group
128 | my-artifact
129 | 0.0.1-SNAPSHOT
130 |
131 | ----
132 |
133 | `srcdeps` will build the snapshot
134 | of `org.my-group:my-artifact` from the remote branch 1.2.x every time you build the dependent project.
--------------------------------------------------------------------------------
/mvnw.cmd:
--------------------------------------------------------------------------------
1 | @REM ----------------------------------------------------------------------------
2 | @REM Licensed to the Apache Software Foundation (ASF) under one
3 | @REM or more contributor license agreements. See the NOTICE file
4 | @REM distributed with this work for additional information
5 | @REM regarding copyright ownership. The ASF licenses this file
6 | @REM to you under the Apache License, Version 2.0 (the
7 | @REM "License"); you may not use this file except in compliance
8 | @REM with the License. You may obtain a copy of the License at
9 | @REM
10 | @REM http://www.apache.org/licenses/LICENSE-2.0
11 | @REM
12 | @REM Unless required by applicable law or agreed to in writing,
13 | @REM software distributed under the License is distributed on an
14 | @REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 | @REM KIND, either express or implied. See the License for the
16 | @REM specific language governing permissions and limitations
17 | @REM under the License.
18 | @REM ----------------------------------------------------------------------------
19 |
20 | @REM ----------------------------------------------------------------------------
21 | @REM Maven2 Start Up Batch script
22 | @REM
23 | @REM Required ENV vars:
24 | @REM JAVA_HOME - location of a JDK home dir
25 | @REM
26 | @REM Optional ENV vars
27 | @REM M2_HOME - location of maven2's installed home dir
28 | @REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands
29 | @REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a key stroke before ending
30 | @REM MAVEN_OPTS - parameters passed to the Java VM when running Maven
31 | @REM e.g. to debug Maven itself, use
32 | @REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000
33 | @REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files
34 | @REM ----------------------------------------------------------------------------
35 |
36 | @REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on'
37 | @echo off
38 | @REM enable echoing my setting MAVEN_BATCH_ECHO to 'on'
39 | @if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO%
40 |
41 | @REM set %HOME% to equivalent of $HOME
42 | if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%")
43 |
44 | @REM Execute a user defined script before this one
45 | if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre
46 | @REM check for pre script, once with legacy .bat ending and once with .cmd ending
47 | if exist "%HOME%\mavenrc_pre.bat" call "%HOME%\mavenrc_pre.bat"
48 | if exist "%HOME%\mavenrc_pre.cmd" call "%HOME%\mavenrc_pre.cmd"
49 | :skipRcPre
50 |
51 | @setlocal
52 |
53 | set ERROR_CODE=0
54 |
55 | @REM To isolate internal variables from possible post scripts, we use another setlocal
56 | @setlocal
57 |
58 | @REM ==== START VALIDATION ====
59 | if not "%JAVA_HOME%" == "" goto OkJHome
60 |
61 | echo.
62 | echo Error: JAVA_HOME not found in your environment. >&2
63 | echo Please set the JAVA_HOME variable in your environment to match the >&2
64 | echo location of your Java installation. >&2
65 | echo.
66 | goto error
67 |
68 | :OkJHome
69 | if exist "%JAVA_HOME%\bin\java.exe" goto init
70 |
71 | echo.
72 | echo Error: JAVA_HOME is set to an invalid directory. >&2
73 | echo JAVA_HOME = "%JAVA_HOME%" >&2
74 | echo Please set the JAVA_HOME variable in your environment to match the >&2
75 | echo location of your Java installation. >&2
76 | echo.
77 | goto error
78 |
79 | @REM ==== END VALIDATION ====
80 |
81 | :init
82 |
83 | set MAVEN_CMD_LINE_ARGS=%MAVEN_CONFIG% %*
84 |
85 | @REM Find the project base dir, i.e. the directory that contains the folder ".mvn".
86 | @REM Fallback to current working directory if not found.
87 |
88 | set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR%
89 | IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir
90 |
91 | set EXEC_DIR=%CD%
92 | set WDIR=%EXEC_DIR%
93 | :findBaseDir
94 | IF EXIST "%WDIR%"\.mvn goto baseDirFound
95 | cd ..
96 | IF "%WDIR%"=="%CD%" goto baseDirNotFound
97 | set WDIR=%CD%
98 | goto findBaseDir
99 |
100 | :baseDirFound
101 | set MAVEN_PROJECTBASEDIR=%WDIR%
102 | cd "%EXEC_DIR%"
103 | goto endDetectBaseDir
104 |
105 | :baseDirNotFound
106 | set MAVEN_PROJECTBASEDIR=%EXEC_DIR%
107 | cd "%EXEC_DIR%"
108 |
109 | :endDetectBaseDir
110 |
111 | IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig
112 |
113 | @setlocal EnableExtensions EnableDelayedExpansion
114 | for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a
115 | @endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS%
116 |
117 | :endReadAdditionalConfig
118 |
119 | SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe"
120 |
121 | set WRAPPER_JAR=""%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar""
122 | set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain
123 |
124 | %MAVEN_JAVA_EXE% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %WRAPPER_JAR% "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %WRAPPER_LAUNCHER% %MAVEN_CMD_LINE_ARGS%
125 | if ERRORLEVEL 1 goto error
126 | goto end
127 |
128 | :error
129 | set ERROR_CODE=1
130 |
131 | :end
132 | @endlocal & set ERROR_CODE=%ERROR_CODE%
133 |
134 | if not "%MAVEN_SKIP_RC%" == "" goto skipRcPost
135 | @REM check for post script, once with legacy .bat ending and once with .cmd ending
136 | if exist "%HOME%\mavenrc_post.bat" call "%HOME%\mavenrc_post.bat"
137 | if exist "%HOME%\mavenrc_post.cmd" call "%HOME%\mavenrc_post.cmd"
138 | :skipRcPost
139 |
140 | @REM pause the script if MAVEN_BATCH_PAUSE is set to 'on'
141 | if "%MAVEN_BATCH_PAUSE%" == "on" pause
142 |
143 | if "%MAVEN_TERMINATE_CMD%" == "on" exit %ERROR_CODE%
144 |
145 | exit /B %ERROR_CODE%
146 |
--------------------------------------------------------------------------------
/srcdeps-maven-base/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
20 |
21 | 4.0.0
22 |
23 |
24 | org.srcdeps.mvn
25 | srcdeps-maven-parent
26 | 4.0.1-SNAPSHOT
27 |
28 |
29 | srcdeps-maven-base
30 | takari-maven-component
31 |
32 | Srcdeps Maven Base
33 | Some base classes used by other srcdeps Maven components
34 |
35 |
36 |
37 |
38 | javax.inject
39 | javax.inject
40 | provided
41 |
42 |
43 |
44 |
45 | org.eclipse.sisu
46 | org.eclipse.sisu.inject
47 | provided
48 |
49 |
50 |
51 | org.srcdeps.core
52 | srcdeps-core
53 |
54 |
55 |
56 | org.srcdeps.core
57 | srcdeps-core-config-yaml
58 |
59 |
60 |
61 | org.slf4j
62 | slf4j-api
63 | provided
64 |
65 |
66 |
67 |
68 |
--------------------------------------------------------------------------------
/srcdeps-maven-base/src/main/java/org/srcdeps/mvn/Constants.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2015-2019 Maven Source Dependencies
3 | * Plugin contributors as indicated by the @author tags.
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 | package org.srcdeps.mvn;
18 |
19 | public interface Constants {
20 |
21 | /** See the bin/mvn or bin/mvn.cmd script of your maven distro, where maven.multiModuleProjectDirectory is set */
22 | String MAVEN_MULTI_MODULE_PROJECT_DIRECTORY_PROPERTY = "maven.multiModuleProjectDirectory";
23 |
24 | String SRCDEPS_MAVEN_VERSION = "4.0.1-SNAPSHOT"; // @srcdeps.version@
25 |
26 | }
27 |
--------------------------------------------------------------------------------
/srcdeps-maven-base/src/main/java/org/srcdeps/mvn/config/ConfigurationProducer.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2015-2018 Maven Source Dependencies
3 | * Plugin contributors as indicated by the @author tags.
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 | package org.srcdeps.mvn.config;
18 |
19 | import java.nio.file.Path;
20 | import java.nio.file.Paths;
21 |
22 | import javax.inject.Named;
23 |
24 | import org.srcdeps.config.yaml.YamlConfigurationReader;
25 | import org.srcdeps.core.config.Configuration;
26 | import org.srcdeps.core.config.ConfigurationException;
27 | import org.srcdeps.core.config.ConfigurationLocator;
28 | import org.srcdeps.core.config.Maven;
29 | import org.srcdeps.core.config.tree.walk.DefaultsAndInheritanceVisitor;
30 | import org.srcdeps.core.config.tree.walk.OverrideVisitor;
31 | import org.srcdeps.mvn.Constants;
32 |
33 | @Named
34 | public class ConfigurationProducer {
35 |
36 | private final Configuration configuration;
37 | private final Path multimoduleProjectRootDirectory;
38 |
39 | public ConfigurationProducer() throws ConfigurationException {
40 | super();
41 |
42 | String basePathString = System.getProperty(Constants.MAVEN_MULTI_MODULE_PROJECT_DIRECTORY_PROPERTY);
43 | if (basePathString == null || basePathString.isEmpty()) {
44 | throw new RuntimeException(String.format("The system property %s must not be null or empty",
45 | Constants.MAVEN_MULTI_MODULE_PROJECT_DIRECTORY_PROPERTY));
46 | }
47 | multimoduleProjectRootDirectory = Paths.get(basePathString).toAbsolutePath();
48 |
49 | this.configuration = new ConfigurationLocator(System.getProperties(), true) //
50 | .locate(multimoduleProjectRootDirectory, new YamlConfigurationReader()) //
51 | .accept(new OverrideVisitor(System.getProperties())) //
52 | .accept(new DefaultsAndInheritanceVisitor()) //
53 | .forwardPropertyValue(Maven.getSrcdepsMavenVersionProperty(), Constants.SRCDEPS_MAVEN_VERSION)
54 | .build();
55 |
56 | }
57 |
58 | public Configuration getConfiguration() {
59 | return configuration;
60 | }
61 |
62 | /**
63 | * @return the root directory of the Maven multimodule project.
64 | */
65 | public Path getMultimoduleProjectRootDirectory() {
66 | return multimoduleProjectRootDirectory;
67 | }
68 |
69 | }
70 |
--------------------------------------------------------------------------------
/srcdeps-maven-enforcer/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
20 |
21 | 4.0.0
22 |
23 |
24 | org.srcdeps.mvn
25 | srcdeps-maven-parent
26 | 4.0.1-SNAPSHOT
27 |
28 |
29 | srcdeps-maven-enforcer
30 | takari-maven-component
31 |
32 | Srcdeps Maven Enforcer
33 | A safeguard to prevent usage of srcdeps as defined in srcdeps.yaml
34 |
35 |
36 |
37 |
38 | javax.inject
39 | javax.inject
40 | provided
41 |
42 |
43 |
44 | junit
45 | junit
46 | test
47 |
48 |
49 |
50 | org.apache.maven
51 | maven-artifact
52 | provided
53 |
54 |
55 |
56 | org.apache.maven
57 | maven-core
58 | provided
59 |
60 |
61 |
62 | org.apache.maven
63 | maven-model
64 | provided
65 |
66 |
67 |
68 | org.apache.maven
69 | maven-plugin-api
70 | provided
71 |
72 |
73 |
74 | org.eclipse.aether
75 | aether-api
76 | provided
77 |
78 |
79 | org.eclipse.aether
80 | aether-spi
81 | provided
82 |
83 |
84 | org.eclipse.aether
85 | aether-impl
86 | provided
87 |
88 |
89 |
90 | org.eclipse.sisu
91 | org.eclipse.sisu.inject
92 | provided
93 |
94 |
95 |
96 | org.srcdeps.core
97 | srcdeps-core
98 |
99 |
100 |
101 | org.srcdeps.core
102 | srcdeps-core-config-yaml
103 |
104 |
105 |
106 | org.srcdeps.mvn
107 | srcdeps-maven-base
108 |
109 |
110 |
111 | org.slf4j
112 | slf4j-api
113 | provided
114 |
115 |
116 |
117 |
118 |
119 |
--------------------------------------------------------------------------------
/srcdeps-maven-local-repository/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
20 |
21 | 4.0.0
22 |
23 |
24 | org.srcdeps.mvn
25 | srcdeps-maven-parent
26 | 4.0.1-SNAPSHOT
27 |
28 |
29 | srcdeps-maven-local-repository
30 | takari-maven-component
31 |
32 | Srcdeps Maven Local Repository
33 | A srcdeps implementation of org.eclipse.aether.spi.localrepo.LocalRepositoryManagerFactory
34 |
35 |
36 |
37 |
38 | io.takari.aether
39 | takari-local-repository
40 |
41 |
42 |
43 | javax.inject
44 | javax.inject
45 | provided
46 |
47 |
48 |
49 | org.apache.maven
50 | maven-core
51 | provided
52 |
53 |
54 |
55 | org.eclipse.aether
56 | aether-api
57 | provided
58 |
59 |
60 | org.eclipse.aether
61 | aether-spi
62 | provided
63 |
64 |
65 | org.eclipse.aether
66 | aether-impl
67 | provided
68 |
69 |
70 |
71 | org.eclipse.sisu
72 | org.eclipse.sisu.inject
73 | provided
74 |
75 |
76 |
77 | org.srcdeps.core
78 | srcdeps-core
79 |
80 |
81 |
82 | org.srcdeps.core
83 | srcdeps-core-config-yaml
84 |
85 |
86 |
87 | org.srcdeps.mvn
88 | srcdeps-maven-base
89 |
90 |
91 |
92 | org.slf4j
93 | slf4j-api
94 | provided
95 |
96 |
97 |
98 |
99 |
100 |
--------------------------------------------------------------------------------
/srcdeps-maven-plugin/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
20 |
21 | 4.0.0
22 |
23 |
24 | org.srcdeps.mvn
25 | srcdeps-maven-parent
26 | 4.0.1-SNAPSHOT
27 |
28 |
29 | srcdeps-maven-plugin
30 | takari-maven-plugin
31 |
32 | Srcdeps Maven Plugin
33 |
34 |
35 |
36 |
37 | io.takari.maven.plugins
38 | takari-plugin-testing
39 | test
40 |
41 |
42 |
43 | io.takari.maven.plugins
44 | takari-plugin-integration-testing
45 | pom
46 | test
47 |
48 |
49 |
50 | javax.inject
51 | javax.inject
52 |
53 |
54 |
55 | org.apache.maven
56 | maven-artifact
57 | provided
58 |
59 |
60 |
61 | org.apache.maven
62 | maven-core
63 | provided
64 |
65 |
66 |
67 | org.apache.maven
68 | maven-model
69 | provided
70 |
71 |
72 |
73 | org.apache.maven
74 | maven-model-builder
75 | provided
76 |
77 |
78 |
79 | org.apache.maven
80 | maven-plugin-api
81 | provided
82 |
83 |
84 |
85 | org.apache.maven.plugin-tools
86 | maven-plugin-annotations
87 | provided
88 |
89 |
90 |
91 | org.eclipse.aether
92 | aether-api
93 | provided
94 |
95 |
96 |
97 | org.srcdeps.core
98 | srcdeps-core
99 |
100 |
101 |
102 | org.srcdeps.core
103 | srcdeps-core-config-yaml
104 |
105 |
106 |
107 | org.srcdeps.mvn
108 | srcdeps-maven-base
109 |
110 |
111 |
112 | org.slf4j
113 | slf4j-api
114 | provided
115 |
116 |
117 |
118 | junit
119 | junit
120 | test
121 |
122 |
123 |
124 | xerces
125 | xercesImpl
126 |
127 |
128 |
129 |
130 |
131 |
132 |
133 |
134 | org.apache.maven.plugins
135 | maven-surefire-plugin
136 |
137 |
138 | ${project.build.directory}
139 | ${project.version}
140 | ${project.build.sourceEncoding}
141 | ${project.build.directory}/settings-mrm.xml
142 |
143 |
144 |
145 |
146 |
147 |
148 |
149 |
150 |
--------------------------------------------------------------------------------
/srcdeps-maven-plugin/src/main/java/org/srcdeps/mvn/plugin/Ga.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2015-2017 Maven Source Dependencies
3 | * Plugin contributors as indicated by the @author tags.
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 | package org.srcdeps.mvn.plugin;
18 |
19 | /**
20 | * An immutable {@link #groupId}, {@link #artifactId} pair with a fast {@link #hashCode()} and {@link #equals(Object)}.
21 | *
22 | * @author Peter Palaga
23 | */
24 | public class Ga implements Comparable {
25 | private final String artifactId;
26 | private final String groupId;
27 | private final int hashCode;
28 |
29 | public Ga(String groupId, String artifactId) {
30 | super();
31 | this.groupId = groupId;
32 | this.artifactId = artifactId;
33 | this.hashCode = 31 * (31 + artifactId.hashCode()) + groupId.hashCode();
34 | }
35 |
36 | @Override
37 | public int compareTo(Ga other) {
38 | int g = this.groupId.compareTo(other.groupId);
39 | if (g != 0) {
40 | return g;
41 | } else {
42 | return this.artifactId.compareTo(other.artifactId);
43 | }
44 | }
45 |
46 | @Override
47 | public boolean equals(Object obj) {
48 | if (this == obj)
49 | return true;
50 | if (obj == null)
51 | return false;
52 | if (getClass() != obj.getClass())
53 | return false;
54 | Ga other = (Ga) obj;
55 | return this.artifactId.equals(other.artifactId) && this.groupId.equals(other.groupId);
56 | }
57 |
58 | public String getArtifactId() {
59 | return artifactId;
60 | }
61 |
62 | public String getGroupId() {
63 | return groupId;
64 | }
65 |
66 | @Override
67 | public int hashCode() {
68 | return hashCode;
69 | }
70 |
71 | @Override
72 | public String toString() {
73 | return groupId + ":" + artifactId;
74 | }
75 | }
76 |
--------------------------------------------------------------------------------
/srcdeps-maven-plugin/src/test/java/org/srcdeps/mvn/plugin/ScmUrlChainTest.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2015-2017 Maven Source Dependencies
3 | * Plugin contributors as indicated by the @author tags.
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 | package org.srcdeps.mvn.plugin;
18 |
19 | import org.junit.Assert;
20 | import org.junit.Test;
21 | import org.srcdeps.mvn.plugin.SrcdepsInitMojo.ScmRepositoryIndex.ScmUrlAncestry;
22 |
23 | public class ScmUrlChainTest {
24 |
25 | @Test
26 | public void chain() {
27 | ScmUrlAncestry chain = ScmUrlAncestry.builder() //
28 | .element(
29 | "scm:git:git://git@github.com:arquillian/arquillian-extension-rest.git/arquillian-rest-warp-parent/arquillian-rest-warp-api",
30 | new Ga("org.jboss.arquillian.extension", "arquillian-rest-warp-api"))
31 | .element(
32 | "scm:git:git://git@github.com:arquillian/arquillian-extension-rest.git/arquillian-rest-warp-parent",
33 | new Ga("org.jboss.arquillian.extension", "arquillian-rest-warp-parent"))
34 | .build();
35 |
36 | Assert.assertTrue(chain.hasUrl());
37 | Assert.assertEquals(2, chain.getLength());
38 | Assert.assertEquals("git:git://git@github.com:arquillian/arquillian-extension-rest.git", chain.getUrl());
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/srcdeps-maven-plugin/src/test/java/org/srcdeps/mvn/plugin/SrcdepsInitMojoTest.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2015-2019 Maven Source Dependencies
3 | * Plugin contributors as indicated by the @author tags.
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 | package org.srcdeps.mvn.plugin;
18 |
19 | import java.io.File;
20 | import java.io.IOException;
21 | import java.nio.file.Files;
22 | import java.nio.file.Path;
23 | import java.nio.file.Paths;
24 |
25 | import org.junit.Assert;
26 | import org.junit.BeforeClass;
27 | import org.junit.Rule;
28 | import org.junit.Test;
29 | import org.junit.runner.RunWith;
30 | import org.slf4j.Logger;
31 | import org.slf4j.LoggerFactory;
32 | import org.srcdeps.core.config.Maven;
33 | import org.srcdeps.core.util.SrcdepsCoreUtils;
34 | import org.srcdeps.mvn.Constants;
35 |
36 | import io.takari.maven.testing.TestResources;
37 | import io.takari.maven.testing.executor.MavenExecution;
38 | import io.takari.maven.testing.executor.MavenRuntime;
39 | import io.takari.maven.testing.executor.MavenRuntime.MavenRuntimeBuilder;
40 | import io.takari.maven.testing.executor.MavenVersions;
41 | import io.takari.maven.testing.executor.junit.MavenJUnitTestRunner;
42 |
43 | @RunWith(MavenJUnitTestRunner.class)
44 | @MavenVersions({ "3.3.1" })
45 | public class SrcdepsInitMojoTest {
46 | private static final Path basedir = Paths.get(System.getProperty("basedir", new File("").getAbsolutePath()));
47 |
48 | private static final String encoding = System.getProperty("project.build.sourceEncoding");
49 |
50 | private static final String EXTENSIONS_XML_TEMPLATE = "\n" + //
51 | "\n" + //
52 | " \n" + //
53 | " org.srcdeps.mvn\n" + //
54 | " srcdeps-maven-local-repository\n" + //
55 | " %s\n" + //
56 | " \n" + //
57 | " \n" + //
58 | " org.srcdeps.mvn\n" + //
59 | " srcdeps-maven-enforcer\n" + //
60 | " %s\n" + //
61 | " \n" + //
62 | "\n";
63 |
64 | private static final Logger log = LoggerFactory.getLogger(SrcdepsInitMojoTest.class);
65 |
66 | private static final String mrmSettingsXmlPath = System.getProperty("mrm.settings.xml");
67 |
68 | private static final Path mvnLocalRepo;
69 | private static final String projectVersion = System.getProperty("project.version");
70 | private static final String SRCDEPS_YAML_EXPECTED = "#\n" + //
71 | "# srcdeps.yaml - the srcdeps configuration file\n" + //
72 | "#\n" + //
73 | "# The full srcdeps.yaml reference can be found under https://github.com/srcdeps/srcdeps-core/tree/master/doc/srcdeps.yaml\n"
74 | + //
75 | "#\n" + //
76 | "# This file was generated by the following command:\n" + //
77 | "#\n" + //
78 | "# mvn org.srcdeps.mvn:srcdeps-maven-plugin:init\n" + //
79 | "#\n" + //
80 | "configModelVersion: 3.0\n" + //
81 | "repositories:\n" + //
82 | " org.srcdeps.core:\n" + //
83 | " includes:\n" + //
84 | " - org.srcdeps.core\n" + //
85 | " urls:\n" + //
86 | " - git:git@github.com:srcdeps/srcdeps-core.git\n";
87 | static {
88 | mvnLocalRepo = basedir.resolve("target/mvn-local-repo");
89 | }
90 |
91 | @BeforeClass
92 | public static void beforeClass() throws IOException {
93 |
94 | SrcdepsCoreUtils.ensureDirectoryExistsAndEmpty(mvnLocalRepo);
95 |
96 | System.setProperty(Maven.getSrcdepsMavenSettingsProperty(), mrmSettingsXmlPath);
97 |
98 | // Assert.assertTrue("[" + mrmSettingsXmlPath + "] should exist", Files.exists(Paths.get(mrmSettingsXmlPath)));
99 | Assert.assertNotNull("project.build.sourceEncoding property must be set", encoding);
100 | Assert.assertNotNull("project.version property must be set", projectVersion);
101 | }
102 |
103 | @Rule
104 | public final TestResources resources = new TestResources();
105 |
106 | public final MavenRuntime verifier;
107 |
108 | public SrcdepsInitMojoTest(MavenRuntimeBuilder runtimeBuilder) throws Exception {
109 | this.verifier = runtimeBuilder.withExtension(new File("target/classes").getCanonicalFile()).build();
110 | }
111 |
112 | @Test
113 | public void initNoArgs() throws Exception {
114 |
115 | File projDir = resources.getBasedir("parent-with-jar");
116 |
117 | MavenExecution mavenExec = verifier.forProject(projDir) //
118 | .withCliOption("-e");
119 |
120 | final String srcdepsVersion = Constants.SRCDEPS_MAVEN_VERSION;
121 |
122 | Assert.assertEquals(projectVersion, srcdepsVersion);
123 |
124 | final File srcdepsYamlPath = new File(projDir, "srcdeps.yaml");
125 | Assert.assertFalse(
126 | String.format("The file [%s] must not exist before the test", srcdepsYamlPath.getAbsolutePath()),
127 | srcdepsYamlPath.exists());
128 |
129 | final File extensionsXmlPath = new File(projDir, ".mvn/extensions.xml");
130 | Assert.assertFalse(
131 | String.format("The file [%s] must not exist before the test", extensionsXmlPath.getAbsolutePath()),
132 | extensionsXmlPath.exists());
133 |
134 | mavenExec //
135 | .execute("org.srcdeps.mvn:srcdeps-maven-plugin:" + projectVersion + ":init") //
136 | .assertErrorFreeLog();
137 |
138 | String srcdepsYamlContent = new String(Files.readAllBytes(srcdepsYamlPath.toPath()), "utf-8");
139 | Assert.assertEquals(SRCDEPS_YAML_EXPECTED, srcdepsYamlContent);
140 |
141 | String extensionsXmlContent = new String(Files.readAllBytes(extensionsXmlPath.toPath()), "utf-8");
142 | Assert.assertEquals(String.format(EXTENSIONS_XML_TEMPLATE, srcdepsVersion, srcdepsVersion),
143 | extensionsXmlContent);
144 | }
145 |
146 | }
147 |
--------------------------------------------------------------------------------
/srcdeps-maven-plugin/src/test/projects/parent-with-jar/jar/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
20 |
21 | 4.0.0
22 |
23 |
24 | org.srcdeps.mvn.plugin.it
25 | test-project-parent
26 | 0.0.1-SNAPSHOT
27 |
28 |
29 | test-project-jar
30 | jar
31 |
32 |
33 |
34 | org.srcdeps.core
35 | srcdeps-core
36 | 2.0.0
37 |
38 |
39 |
40 |
41 |
--------------------------------------------------------------------------------
/srcdeps-maven-plugin/src/test/projects/parent-with-jar/jar/src/main/java/org/srcdeps/mvn/plugin/it/Main.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2015-2017 Maven Source Dependencies
3 | * Plugin contributors as indicated by the @author tags.
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 | package org.srcdeps.mvn.plugin.it;
18 |
19 | public class Main {
20 |
21 | }
22 |
--------------------------------------------------------------------------------
/srcdeps-maven-plugin/src/test/projects/parent-with-jar/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
20 |
21 | 4.0.0
22 |
23 | org.srcdeps.mvn.plugin.it
24 | test-project-parent
25 | 0.0.1-SNAPSHOT
26 | pom
27 |
28 |
29 | jar
30 |
31 |
32 |
33 |
34 | scm:git:git@github.com:srcdeps/scm-in-parent-parent.git
35 | scm:git:git@github.com:srcdeps/scm-in-parent-parent.git
36 | https://github.com/srcdeps/scm-in-parent-parent
37 | head
38 |
39 |
40 |
41 |
--------------------------------------------------------------------------------
/srcdeps-maven-quickstarts/src/test/java/org/srcdeps/mvn/itest/LocalMavenRepoVerifier.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2015-2018 Maven Source Dependencies
3 | * Plugin contributors as indicated by the @author tags.
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 | package org.srcdeps.mvn.itest;
18 |
19 | import java.io.IOException;
20 | import java.util.ArrayList;
21 | import java.util.List;
22 |
23 | import org.srcdeps.core.Gavtc;
24 | import org.srcdeps.core.util.SrcdepsCoreUtils;
25 |
26 | public class LocalMavenRepoVerifier {
27 | private final List expectedNotToExist;
28 | private final List expectedToExist;
29 | private final String project;
30 |
31 | protected LocalMavenRepoVerifier(String project, String[] gavtcPatternsExpectedToExist) {
32 | this(project, gavtcPatternsExpectedToExist, new String[0]);
33 | }
34 | protected LocalMavenRepoVerifier(String project, String[] gavtcPatternsExpectedToExist,
35 | String[] gavtcPatternsExpectedNotToExist) {
36 | this.project = project;
37 | /* delete all expected and unexpected groups */
38 | this.expectedToExist = new ArrayList<>();
39 | for (String gavtcPattern : gavtcPatternsExpectedToExist) {
40 | for (Gavtc gavtc : Gavtc.ofPattern(gavtcPattern)) {
41 | expectedToExist.add(gavtc);
42 | }
43 | }
44 | this.expectedNotToExist = new ArrayList<>();
45 | for (String gavtcPattern : gavtcPatternsExpectedNotToExist) {
46 | for (Gavtc gavtc : Gavtc.ofPattern(gavtcPattern)) {
47 | expectedNotToExist.add(gavtc);
48 | }
49 | }
50 | }
51 | public void clean() throws IOException {
52 | for (Gavtc gavtc : expectedToExist) {
53 | SrcdepsCoreUtils.deleteDirectory(TestUtils.getMvnLocalRepo().resolveGroup(gavtc.getGroupId()));
54 | }
55 | for (Gavtc gavtc : expectedNotToExist) {
56 | SrcdepsCoreUtils.deleteDirectory(TestUtils.getMvnLocalRepo().resolveGroup(gavtc.getGroupId()));
57 | }
58 | }
59 |
60 | public void verify() {
61 | for (Gavtc gavtc : expectedToExist) {
62 | TestUtils.assertExists(TestUtils.getMvnLocalRepo().resolve(gavtc));
63 | }
64 | for (Gavtc gavtc : expectedNotToExist) {
65 | TestUtils.assertNotExists(TestUtils.getMvnLocalRepo().resolve(gavtc));
66 | }
67 | }
68 |
69 | }
--------------------------------------------------------------------------------
/srcdeps-maven-quickstarts/src/test/java/org/srcdeps/mvn/itest/MavenDepsGradleIntegrationTest.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2015-2017 Maven Source Dependencies
3 | * Plugin contributors as indicated by the @author tags.
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 | package org.srcdeps.mvn.itest;
18 |
19 | import java.io.IOException;
20 |
21 | import org.junit.Test;
22 | import org.junit.runner.RunWith;
23 |
24 | import io.takari.maven.testing.executor.MavenRuntime.MavenRuntimeBuilder;
25 | import io.takari.maven.testing.executor.MavenVersions;
26 | import io.takari.maven.testing.executor.junit.MavenJUnitTestRunner;
27 |
28 | @RunWith(MavenJUnitTestRunner.class)
29 | @MavenVersions({ "3.3.1" })
30 | public class MavenDepsGradleIntegrationTest extends AbstractMavenDepsIntegrationTest {
31 |
32 | private static final String ORG_SRCDEPS_ITEST_GRADLE_GROUPID = "org.srcdeps.test.gradle";
33 |
34 | public MavenDepsGradleIntegrationTest(MavenRuntimeBuilder runtimeBuilder) throws IOException, Exception {
35 | super(runtimeBuilder);
36 | }
37 |
38 | @Test
39 | public void mvnGitGradleSourceDependency() throws Exception {
40 | final String project = "srcdeps-mvn-git-gradle-source-dependency-quickstart";
41 | final String srcVersion = "1.0-SRC-revision-e63539236a94e8f6c2d720f8bda0323d1ce4db0f";
42 |
43 | String[] expectedGavtcs = new String[] { //
44 | pom(groupId(project), project, QUICKSTART_VERSION), //
45 | pomJar(groupId(project), project + "-jar", QUICKSTART_VERSION), //
46 | pomJar(ORG_SRCDEPS_ITEST_GRADLE_GROUPID, "srcdeps-test-artifact-gradle-api", srcVersion), //
47 | pomJar(ORG_SRCDEPS_ITEST_GRADLE_GROUPID, "srcdeps-test-artifact-gradle-impl", srcVersion) //
48 | };
49 | assertBuild(project, expectedGavtcs, new String[] {}, "clean", "install");
50 | }
51 |
52 | }
53 |
--------------------------------------------------------------------------------
/srcdeps-maven-quickstarts/src/test/java/org/srcdeps/mvn/itest/MavenMasterConfigIntegrationTest.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2015-2018 Maven Source Dependencies
3 | * Plugin contributors as indicated by the @author tags.
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 | package org.srcdeps.mvn.itest;
18 |
19 | import java.io.IOException;
20 | import java.nio.charset.StandardCharsets;
21 | import java.nio.file.Files;
22 | import java.nio.file.Path;
23 | import java.util.AbstractMap;
24 | import java.util.Map;
25 | import java.util.Map.Entry;
26 |
27 | import org.eclipse.jgit.api.Git;
28 | import org.eclipse.jgit.api.errors.GitAPIException;
29 | import org.eclipse.jgit.lib.Constants;
30 | import org.eclipse.jgit.lib.ObjectId;
31 | import org.eclipse.jgit.revwalk.RevCommit;
32 | import org.junit.Test;
33 | import org.junit.runner.RunWith;
34 | import org.slf4j.Logger;
35 | import org.slf4j.LoggerFactory;
36 | import org.srcdeps.core.util.SrcdepsCoreUtils;
37 |
38 | import io.takari.aether.localrepo.TakariLocalRepositoryManagerFactory;
39 | import io.takari.maven.testing.executor.MavenRuntime.MavenRuntimeBuilder;
40 | import io.takari.maven.testing.executor.MavenVersions;
41 | import io.takari.maven.testing.executor.junit.MavenJUnitTestRunner;
42 |
43 | /**
44 | * @author Peter Palaga
45 | */
46 | @RunWith(MavenJUnitTestRunner.class)
47 | @MavenVersions({ "3.3.1" })
48 | public class MavenMasterConfigIntegrationTest extends AbstractMavenDepsIntegrationTest {
49 | static final Logger log = LoggerFactory.getLogger(MavenDepsMavenIntegrationTest.class);
50 |
51 | public MavenMasterConfigIntegrationTest(MavenRuntimeBuilder runtimeBuilder) throws IOException, Exception {
52 | super(runtimeBuilder);
53 | }
54 |
55 | private static Map.Entry prepareGitRepo(String artifactId, Path masterProjectDir,
56 | Path dependencySourceTrees) throws IOException, IllegalStateException, GitAPIException {
57 | final Path path = dependencySourceTrees.resolve(artifactId);
58 | Files.move(masterProjectDir.resolve("src/test/dependency-projects/" + artifactId), path);
59 |
60 | Map.Entry result;
61 | try (Git git = Git.init().setDirectory(path.toFile()).call()) {
62 | git.add().addFilepattern(".").call();
63 | git.add().setUpdate(true).addFilepattern(".").call();
64 | final RevCommit commit = git.commit().setMessage("Test commit to " + artifactId + " repo").call();
65 | final String gitUri = path.resolve(".git").toUri().toString();
66 | result = new AbstractMap.SimpleImmutableEntry<>(gitUri, commit.getId().name());
67 | }
68 |
69 | try (Git git = Git.open(path.toFile())) {
70 | ObjectId id = git.getRepository().resolve(Constants.HEAD);
71 | }
72 |
73 | return result;
74 | }
75 |
76 | @Test
77 | public void masterConfig() throws Exception {
78 |
79 | SrcdepsCoreUtils.deleteDirectory(TestUtils.getMvnLocalRepo()
80 | .resolveGroup("org.srcdeps.mvn.quickstarts.srcdeps-mvn-git-master-config.hello"));
81 | SrcdepsCoreUtils.deleteDirectory(TestUtils.getMvnLocalRepo()
82 | .resolveGroup("org.srcdeps.mvn.quickstarts.srcdeps-mvn-git-master-config.hello-decorator"));
83 |
84 | final String project = "srcdeps-mvn-git-master-config";
85 | final Path masterProjectDir = resources.getBasedirPath(project);
86 |
87 | final Path dependencySourceTrees = TestUtils.createSourceTreesTestRunPath();
88 | final Entry helloSourceTree = prepareGitRepo("srcdeps-mvn-git-master-config-hello",
89 | masterProjectDir, dependencySourceTrees);
90 | final Entry helloDecoratorSourceTree = prepareGitRepo(
91 | "srcdeps-mvn-git-master-config-hello-decorator", masterProjectDir, dependencySourceTrees);
92 |
93 | final Path srcdepsYamlPath = masterProjectDir.resolve("srcdeps.yaml");
94 | String srcdepsYaml = new String(Files.readAllBytes(srcdepsYamlPath), StandardCharsets.UTF_8);
95 | srcdepsYaml = srcdepsYaml.replace("${hello.git.url}",
96 | "git:" + helloSourceTree.getKey());
97 | srcdepsYaml = srcdepsYaml.replace("${hello.git.revision}", helloSourceTree.getValue());
98 | srcdepsYaml = srcdepsYaml.replace("${hello-decorator.git.url}",
99 | "git:" + helloDecoratorSourceTree.getKey());
100 | srcdepsYaml = srcdepsYaml.replace("${hello-decorator.git.revision}", helloDecoratorSourceTree.getValue());
101 | Files.write(srcdepsYamlPath, srcdepsYaml.getBytes(StandardCharsets.UTF_8));
102 |
103 | WrappedMavenExecutionResult result = build(project, "clean", "test");
104 | result.assertLogText("SrcdepsLocalRepositoryManager will decorate ["
105 | + TakariLocalRepositoryManagerFactory.class.getName() + "]") //
106 | .assertLogText("BUILD SUCCESS");
107 | }
108 | }
109 |
--------------------------------------------------------------------------------
/srcdeps-maven-quickstarts/src/test/java/org/srcdeps/mvn/itest/SrcdepsTestResources.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2015-2018 Maven Source Dependencies
3 | * Plugin contributors as indicated by the @author tags.
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 | package org.srcdeps.mvn.itest;
18 |
19 | import java.io.File;
20 | import java.io.IOException;
21 | import java.nio.file.Files;
22 | import java.nio.file.Path;
23 | import java.util.regex.Pattern;
24 |
25 | import org.junit.Assert;
26 | import org.junit.runner.Description;
27 |
28 | import io.takari.maven.testing.TestResources;
29 |
30 | /**
31 | * @author Peter Palaga
32 | */
33 | public class SrcdepsTestResources extends TestResources {
34 | private static final Pattern replacementPattern = Pattern
35 | .compile(Pattern.quote("") + "[^<]+" + Pattern.quote(""));
36 |
37 | private Path basedir;
38 | private String project;
39 |
40 | public SrcdepsTestResources() throws IOException {
41 | super(TestUtils.getSrcdepsQuickstartsPath().toString(), "target/test-projects");
42 | }
43 |
44 | @Override
45 | public File getBasedir(String project) throws IOException {
46 | if (this.project != null && !this.project.equals(project)) {
47 | throw new IllegalStateException(
48 | "org.srcdeps.mvn.itest.SrcdepsTestResources.getBasedir(String) can be called once only");
49 | }
50 | this.project = project;
51 | final File result = super.getBasedir(project);
52 |
53 | final Path extensionsXmlPath = result.toPath().resolve(".mvn/extensions.xml");
54 |
55 | final String extensionsXmlContent = new String(Files.readAllBytes(extensionsXmlPath), TestUtils.getEncoding());
56 |
57 | final String newContent = replacementPattern.matcher(extensionsXmlContent)
58 | .replaceAll("" + TestUtils.getProjectversion() + "");
59 |
60 | Assert.assertNotEquals(newContent, extensionsXmlContent);
61 |
62 | Files.write(extensionsXmlPath, newContent.getBytes(TestUtils.getEncoding()));
63 |
64 | this.basedir = result.toPath();
65 | return result;
66 | }
67 |
68 | public Path getBasedirPath() {
69 | return basedir;
70 | }
71 |
72 | public Path getBasedirPath(String project) throws IOException {
73 | if (this.project == null) {
74 | return getBasedir(project).toPath();
75 | } else {
76 | return basedir;
77 | }
78 | }
79 |
80 | public void reset() {
81 | this.project = null;
82 | this.basedir = null;
83 | }
84 |
85 | @Override
86 | protected void starting(Description d) {
87 | super.starting(d);
88 | reset();
89 | }
90 | }
91 |
--------------------------------------------------------------------------------
/srcdeps-maven-quickstarts/src/test/java/org/srcdeps/mvn/itest/TestUtils.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2015-2019 Maven Source Dependencies
3 | * Plugin contributors as indicated by the @author tags.
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 | package org.srcdeps.mvn.itest;
18 |
19 | import java.io.File;
20 | import java.io.IOException;
21 | import java.nio.file.Files;
22 | import java.nio.file.Path;
23 | import java.nio.file.Paths;
24 | import java.time.LocalDateTime;
25 | import java.time.format.DateTimeFormatter;
26 | import java.util.jar.JarInputStream;
27 | import java.util.jar.Manifest;
28 | import java.util.regex.Matcher;
29 | import java.util.regex.Pattern;
30 |
31 | import org.junit.Assert;
32 | import org.srcdeps.core.Gavtc;
33 | import org.srcdeps.core.MavenLocalRepository;
34 | import org.srcdeps.core.fs.CannotAcquireLockException;
35 | import org.srcdeps.core.fs.PathLocker;
36 | import org.srcdeps.core.util.SrcdepsCoreUtils;
37 |
38 | /**
39 | * @author Peter Palaga
40 | */
41 | public class TestUtils {
42 | private static final Path basedir = Paths.get(System.getProperty("basedir", new File("").getAbsolutePath()));
43 | private static final Path dependencySourceTreesPath;
44 | private static final String encoding = System.getProperty("project.build.sourceEncoding");
45 | private static final boolean isWindows = System.getProperty("os.name").toLowerCase().contains("win");
46 | private static final MavenLocalRepository mvnLocalRepo;
47 | private static final Path mvnLocalRepoBasePath;
48 | private static final Path mvnLocalRepoPath;
49 | private static final String projectVersion = System.getProperty("project.version");
50 | private static final Path srcdepsBuildMetadataPath;
51 | private static final Path srcdepsQuickstartsPath;
52 | static {
53 | srcdepsQuickstartsPath = basedir.resolve("../srcdeps-maven-quickstarts").normalize();
54 | mvnLocalRepoBasePath = basedir.resolve("target/mvn-local-repo-base");
55 | mvnLocalRepoPath = basedir.resolve("target/mvn-local-repo");
56 | dependencySourceTreesPath = basedir.resolve("target/dependency-source-trees");
57 | srcdepsBuildMetadataPath = basedir.resolve("target/srcdeps/build-metadata");
58 | mvnLocalRepo = new MavenLocalRepository(mvnLocalRepoPath);
59 | }
60 |
61 | public static void assertExists(Path path) {
62 | Assert.assertTrue(String.format("File or directory does not exist [%s]", path.toString()), Files.exists(path));
63 | }
64 |
65 | public static void assertNotExists(Path path) {
66 | Assert.assertTrue(String.format("File or directory exists [%s], but should not", path.toString()),
67 | !Files.exists(path));
68 | }
69 |
70 | public static Path createSourceTreesTestRunPath() throws IOException {
71 | final String subdir = LocalDateTime.now().format(DateTimeFormatter.ISO_LOCAL_DATE_TIME).replace(':', '-') + "-"
72 | + ((int) (Math.random() * 1000));
73 | final Path result = dependencySourceTreesPath.resolve(subdir);
74 | Files.createDirectories(result);
75 | return result;
76 | }
77 |
78 | /**
79 | * Deletes {@code target/srcdeps}. This tends to fail in some cases on Windows for which we do a dirty workaround of
80 | * FS locking the git repo that cannot be deleted, so that it is not re-used by the subsequent test.
81 | *
82 | * @throws IOException
83 | * @throws CannotAcquireLockException
84 | */
85 | public static void deleteSrcdepsDirectory() throws IOException, CannotAcquireLockException {
86 | final Path srcdepsPath = basedir.resolve("target/srcdeps");
87 | MavenDepsMavenIntegrationTest.log.warn("Deleting [{}]", srcdepsPath);
88 | try {
89 | SrcdepsCoreUtils.deleteDirectory(srcdepsPath);
90 | } catch (IOException e) {
91 | if (isWindows()) {
92 | final String msg = e.getMessage();
93 | String slash = File.separator;
94 | if ("\\".equals(slash)) {
95 | slash = "\\\\";
96 | }
97 | final Matcher m = Pattern.compile("[^\\[]+\\[(.*" + slash + "\\d+)" + slash + "\\.git.*$").matcher(msg);
98 | if (m.matches()) {
99 | final String path = m.group(1);
100 | MavenDepsMavenIntegrationTest.log
101 | .warn("Locking [" + path + "] as a workaround of not being able to remove it", e);
102 | new PathLocker