├── .gitignore
├── LICENSE
├── build.sbt
├── project
├── build.properties
└── plugins.sbt
└── src
├── main
└── scala
│ └── com
│ └── updateimpact
│ ├── CreateModuleDependencies.scala
│ ├── FindModuleInfo.scala
│ ├── Plugin.scala
│ └── testing
│ └── ReportToString.scala
└── sbt-test
└── updateimpact
├── basic_13_8
├── build.sbt
├── expected.txt
├── project
│ ├── build.properties
│ └── plugins.sbt
└── test
├── basic_13_9
├── build.sbt
├── expected.txt
├── project
│ ├── build.properties
│ └── plugins.sbt
└── test
├── cached_13_8
├── build.sbt
├── expected.txt
├── project
│ ├── build.properties
│ └── plugins.sbt
└── test
├── cached_13_9
├── build.sbt
├── expected.txt
├── project
│ ├── build.properties
│ └── plugins.sbt
└── test
└── range_13_8
├── build.sbt
├── expected.txt
├── project
├── build.properties
└── plugins.sbt
└── test
/.gitignore:
--------------------------------------------------------------------------------
1 | *.class
2 | *.log
3 |
4 | # sbt specific
5 | .cache
6 | .history
7 | .lib/
8 | dist/*
9 | target/
10 | lib_managed/
11 | src_managed/
12 | project/boot/
13 | project/plugins/project/
14 |
15 | # Scala-IDE specific
16 | .scala_dependencies
17 | .worksheet
18 |
19 | .idea/*
20 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | Apache License
2 | Version 2.0, January 2004
3 | http://www.apache.org/licenses/
4 |
5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6 |
7 | 1. Definitions.
8 |
9 | "License" shall mean the terms and conditions for use, reproduction,
10 | and distribution as defined by Sections 1 through 9 of this document.
11 |
12 | "Licensor" shall mean the copyright owner or entity authorized by
13 | the copyright owner that is granting the License.
14 |
15 | "Legal Entity" shall mean the union of the acting entity and all
16 | other entities that control, are controlled by, or are under common
17 | control with that entity. For the purposes of this definition,
18 | "control" means (i) the power, direct or indirect, to cause the
19 | direction or management of such entity, whether by contract or
20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the
21 | outstanding shares, or (iii) beneficial ownership of such entity.
22 |
23 | "You" (or "Your") shall mean an individual or Legal Entity
24 | exercising permissions granted by this License.
25 |
26 | "Source" form shall mean the preferred form for making modifications,
27 | including but not limited to software source code, documentation
28 | source, and configuration files.
29 |
30 | "Object" form shall mean any form resulting from mechanical
31 | transformation or translation of a Source form, including but
32 | not limited to compiled object code, generated documentation,
33 | and conversions to other media types.
34 |
35 | "Work" shall mean the work of authorship, whether in Source or
36 | Object form, made available under the License, as indicated by a
37 | copyright notice that is included in or attached to the work
38 | (an example is provided in the Appendix below).
39 |
40 | "Derivative Works" shall mean any work, whether in Source or Object
41 | form, that is based on (or derived from) the Work and for which the
42 | editorial revisions, annotations, elaborations, or other modifications
43 | represent, as a whole, an original work of authorship. For the purposes
44 | of this License, Derivative Works shall not include works that remain
45 | separable from, or merely link (or bind by name) to the interfaces of,
46 | the Work and Derivative Works thereof.
47 |
48 | "Contribution" shall mean any work of authorship, including
49 | the original version of the Work and any modifications or additions
50 | to that Work or Derivative Works thereof, that is intentionally
51 | submitted to Licensor for inclusion in the Work by the copyright owner
52 | or by an individual or Legal Entity authorized to submit on behalf of
53 | the copyright owner. For the purposes of this definition, "submitted"
54 | means any form of electronic, verbal, or written communication sent
55 | to the Licensor or its representatives, including but not limited to
56 | communication on electronic mailing lists, source code control systems,
57 | and issue tracking systems that are managed by, or on behalf of, the
58 | Licensor for the purpose of discussing and improving the Work, but
59 | excluding communication that is conspicuously marked or otherwise
60 | designated in writing by the copyright owner as "Not a Contribution."
61 |
62 | "Contributor" shall mean Licensor and any individual or Legal Entity
63 | on behalf of whom a Contribution has been received by Licensor and
64 | subsequently incorporated within the Work.
65 |
66 | 2. Grant of Copyright License. Subject to the terms and conditions of
67 | this License, each Contributor hereby grants to You a perpetual,
68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69 | copyright license to reproduce, prepare Derivative Works of,
70 | publicly display, publicly perform, sublicense, and distribute the
71 | Work and such Derivative Works in Source or Object form.
72 |
73 | 3. Grant of Patent License. Subject to the terms and conditions of
74 | this License, each Contributor hereby grants to You a perpetual,
75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76 | (except as stated in this section) patent license to make, have made,
77 | use, offer to sell, sell, import, and otherwise transfer the Work,
78 | where such license applies only to those patent claims licensable
79 | by such Contributor that are necessarily infringed by their
80 | Contribution(s) alone or by combination of their Contribution(s)
81 | with the Work to which such Contribution(s) was submitted. If You
82 | institute patent litigation against any entity (including a
83 | cross-claim or counterclaim in a lawsuit) alleging that the Work
84 | or a Contribution incorporated within the Work constitutes direct
85 | or contributory patent infringement, then any patent licenses
86 | granted to You under this License for that Work shall terminate
87 | as of the date such litigation is filed.
88 |
89 | 4. Redistribution. You may reproduce and distribute copies of the
90 | Work or Derivative Works thereof in any medium, with or without
91 | modifications, and in Source or Object form, provided that You
92 | meet the following conditions:
93 |
94 | (a) You must give any other recipients of the Work or
95 | Derivative Works a copy of this License; and
96 |
97 | (b) You must cause any modified files to carry prominent notices
98 | stating that You changed the files; and
99 |
100 | (c) You must retain, in the Source form of any Derivative Works
101 | that You distribute, all copyright, patent, trademark, and
102 | attribution notices from the Source form of the Work,
103 | excluding those notices that do not pertain to any part of
104 | the Derivative Works; and
105 |
106 | (d) If the Work includes a "NOTICE" text file as part of its
107 | distribution, then any Derivative Works that You distribute must
108 | include a readable copy of the attribution notices contained
109 | within such NOTICE file, excluding those notices that do not
110 | pertain to any part of the Derivative Works, in at least one
111 | of the following places: within a NOTICE text file distributed
112 | as part of the Derivative Works; within the Source form or
113 | documentation, if provided along with the Derivative Works; or,
114 | within a display generated by the Derivative Works, if and
115 | wherever such third-party notices normally appear. The contents
116 | of the NOTICE file are for informational purposes only and
117 | do not modify the License. You may add Your own attribution
118 | notices within Derivative Works that You distribute, alongside
119 | or as an addendum to the NOTICE text from the Work, provided
120 | that such additional attribution notices cannot be construed
121 | as modifying the License.
122 |
123 | You may add Your own copyright statement to Your modifications and
124 | may provide additional or different license terms and conditions
125 | for use, reproduction, or distribution of Your modifications, or
126 | for any such Derivative Works as a whole, provided Your use,
127 | reproduction, and distribution of the Work otherwise complies with
128 | the conditions stated in this License.
129 |
130 | 5. Submission of Contributions. Unless You explicitly state otherwise,
131 | any Contribution intentionally submitted for inclusion in the Work
132 | by You to the Licensor shall be under the terms and conditions of
133 | this License, without any additional terms or conditions.
134 | Notwithstanding the above, nothing herein shall supersede or modify
135 | the terms of any separate license agreement you may have executed
136 | with Licensor regarding such Contributions.
137 |
138 | 6. Trademarks. This License does not grant permission to use the trade
139 | names, trademarks, service marks, or product names of the Licensor,
140 | except as required for reasonable and customary use in describing the
141 | origin of the Work and reproducing the content of the NOTICE file.
142 |
143 | 7. Disclaimer of Warranty. Unless required by applicable law or
144 | agreed to in writing, Licensor provides the Work (and each
145 | Contributor provides its Contributions) on an "AS IS" BASIS,
146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147 | implied, including, without limitation, any warranties or conditions
148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149 | PARTICULAR PURPOSE. You are solely responsible for determining the
150 | appropriateness of using or redistributing the Work and assume any
151 | risks associated with Your exercise of permissions under this License.
152 |
153 | 8. Limitation of Liability. In no event and under no legal theory,
154 | whether in tort (including negligence), contract, or otherwise,
155 | unless required by applicable law (such as deliberate and grossly
156 | negligent acts) or agreed to in writing, shall any Contributor be
157 | liable to You for damages, including any direct, indirect, special,
158 | incidental, or consequential damages of any character arising as a
159 | result of this License or out of the use or inability to use the
160 | Work (including but not limited to damages for loss of goodwill,
161 | work stoppage, computer failure or malfunction, or any and all
162 | other commercial damages or losses), even if such Contributor
163 | has been advised of the possibility of such damages.
164 |
165 | 9. Accepting Warranty or Additional Liability. While redistributing
166 | the Work or Derivative Works thereof, You may choose to offer,
167 | and charge a fee for, acceptance of support, warranty, indemnity,
168 | or other liability obligations and/or rights consistent with this
169 | License. However, in accepting such obligations, You may act only
170 | on Your own behalf and on Your sole responsibility, not on behalf
171 | of any other Contributor, and only if You agree to indemnify,
172 | defend, and hold each Contributor harmless for any liability
173 | incurred by, or claims asserted against, such Contributor by reason
174 | of your accepting any such warranty or additional liability.
175 |
176 | END OF TERMS AND CONDITIONS
177 |
178 | APPENDIX: How to apply the Apache License to your work.
179 |
180 | To apply the Apache License to your work, attach the following
181 | boilerplate notice, with the fields enclosed by brackets "{}"
182 | replaced with your own identifying information. (Don't include
183 | the brackets!) The text should be enclosed in the appropriate
184 | comment syntax for the file format. We also recommend that a
185 | file or class name and description of purpose be included on the
186 | same "printed page" as the copyright notice for easier
187 | identification within third-party archives.
188 |
189 | Copyright {yyyy} {name of copyright owner}
190 |
191 | Licensed under the Apache License, Version 2.0 (the "License");
192 | you may not use this file except in compliance with the License.
193 | You may obtain a copy of the License at
194 |
195 | http://www.apache.org/licenses/LICENSE-2.0
196 |
197 | Unless required by applicable law or agreed to in writing, software
198 | distributed under the License is distributed on an "AS IS" BASIS,
199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200 | See the License for the specific language governing permissions and
201 | limitations under the License.
202 |
203 |
--------------------------------------------------------------------------------
/build.sbt:
--------------------------------------------------------------------------------
1 | organization := "com.updateimpact"
2 |
3 | name := "updateimpact-sbt-plugin"
4 |
5 | version := "2.1.2"
6 |
7 | sbtPlugin := true
8 |
9 | crossSbtVersions := Vector("0.13.16", "1.0.0")
10 |
11 | libraryDependencies += "com.updateimpact" % "updateimpact-plugin-common" % "1.3.2"
12 |
13 | // Sonatype OSS deployment
14 | publishTo <<= version { (v: String) =>
15 | val nexus = "https://oss.sonatype.org/"
16 | if (v.trim.endsWith("SNAPSHOT"))
17 | Some("snapshots" at nexus + "content/repositories/snapshots")
18 | else
19 | Some("releases" at nexus + "service/local/staging/deploy/maven2")
20 | }
21 |
22 | credentials += Credentials(Path.userHome / ".ivy2" / ".credentials")
23 |
24 | publishMavenStyle := true
25 |
26 | pomIncludeRepository := { _ => false }
27 |
28 | pomExtra := (
29 |
30 | git@gihub.com/updateimpact/updateimpact-sbt-plugin.git
31 | scm:git:git@github.com/updateimpact/updateimpact-sbt-plugin.git
32 |
33 |
34 |
35 | adamw
36 | Adam Warski
37 | http://www.warski.org
38 |
39 |
40 | )
41 |
42 | licenses := ("Apache2", new java.net.URL("http://www.apache.org/licenses/LICENSE-2.0.txt")) :: Nil
43 |
44 | homepage := Some(new java.net.URL("http://updateimpact.com"))
45 |
46 | enablePlugins(BuildInfoPlugin)
47 |
48 | buildInfoPackage := "com.updateimpact"
49 |
50 | buildInfoObject := "UpdateimpactSbtBuildInfo"
51 |
52 | // Testing
53 |
54 | ScriptedPlugin.scriptedSettings
55 |
56 | scriptedLaunchOpts := { scriptedLaunchOpts.value ++
57 | Seq("-Xmx1024M", "-Dplugin.version=" + version.value)
58 | }
59 |
60 | scriptedBufferLog := false
61 |
62 | scriptedRun <<= scriptedRun dependsOn publishLocal
63 |
--------------------------------------------------------------------------------
/project/build.properties:
--------------------------------------------------------------------------------
1 | sbt.version=0.13.16
--------------------------------------------------------------------------------
/project/plugins.sbt:
--------------------------------------------------------------------------------
1 | addSbtPlugin("com.eed3si9n" % "sbt-buildinfo" % "0.4.0")
2 |
3 | libraryDependencies <+= (sbtVersion) { sv =>
4 | "org.scala-sbt" % "scripted-plugin" % sv
5 | }
6 |
--------------------------------------------------------------------------------
/src/main/scala/com/updateimpact/CreateModuleDependencies.scala:
--------------------------------------------------------------------------------
1 | package com.updateimpact
2 |
3 | import com.updateimpact.report.{Dependency, ModuleDependencies, DependencyId}
4 | import org.apache.ivy.Ivy
5 | import org.apache.ivy.core.module.descriptor.{Configuration => IvyCfg, DependencyDescriptor, ModuleDescriptor}
6 | import org.apache.ivy.core.module.id.ModuleRevisionId
7 | import sbt.Keys._
8 | import sbt._
9 | import scala.collection.JavaConversions._
10 |
11 | class CreateModuleDependencies(ivy: Ivy, log: Logger, rootMd: ModuleDescriptor,
12 | projectIdToIvyId: Map[ModuleID, ModuleRevisionId], updateReport: UpdateReport) {
13 |
14 | val LocalGroupId = "local"
15 |
16 | private val fmi = new FindModuleInfo(ivy)
17 | private val rootId = toDepId(rootMd.getModuleRevisionId)
18 |
19 | def forClasspath(cfg: Configuration, cpCfg: Configuration, cp: Classpath): ModuleDependencies = {
20 |
21 | val (depsWithModuleIds, depsWithoutModuleIDs) = depIdsFromClasspath(cfg, cp)
22 | val classpathDepIds = rootId :: depsWithModuleIds
23 |
24 | val classpathDepVersions = classpathDepIds.map { id => OrgAndName(id) -> id.getVersion }.toMap
25 |
26 | val classpathIdToDepIds = findClasspathIdToDepIds(classpathDepIds, cpCfg, classpathDepVersions)
27 |
28 | val idToDepsWithLocal = classpathIdToDepIds + (rootId -> (classpathIdToDepIds.getOrElse(rootId, Nil) ++ depsWithoutModuleIDs))
29 |
30 | // classpathIdToDepIds only contains entries for dependencies which are on the classpath. However, the dependencies
31 | // of each dependency may include items not included in the classpath (e.g. evicted version). We need to add empty
32 | // entries into the map for them too.
33 | val idToDepsWithMissing = addMissingEmptyDeps(idToDepsWithLocal)
34 |
35 | val deps = idToDepsWithMissing.map { case (id, idDeps) =>
36 | val evictedBy = classpathDepVersions.get(OrgAndName(id)) match {
37 | case None if id.getGroupId == LocalGroupId => null // local dependency
38 | case None => "exclude" // no other version present on the classpath, dep must have been excluded
39 | case Some(v) if v != id.getVersion => v
40 | case _ => null // not evicted, versions match
41 | }
42 |
43 | new Dependency(id, evictedBy, false, idDeps)
44 | }
45 |
46 | new ModuleDependencies(rootId, cfg.name, deps)
47 | }
48 |
49 | private def depIdsFromClasspath(cfg: Configuration, cp: Classpath) = {
50 | cp.foldLeft((List.empty[DependencyId], List.empty[DependencyId])) { case ((depIds, withoutModuleId), f) =>
51 | f.metadata.get(moduleID.key) match {
52 | case Some(mid) =>
53 | // If it's a project in this build, we need the special translation which adds the scala version suffix.
54 | val id = projectIdToIvyId.get(mid).map(toDepId).getOrElse(toDepId(mid))
55 | (id :: depIds, withoutModuleId)
56 | case None if f.data.exists() =>
57 | val depName = f.data.getName
58 | log.warn(s"Cannot find Ivy module ID for dependency $depName in configuration ${cfg.name}. " +
59 | s"Adding to the result as a top-level dependency of ${rootId.getArtifactId}")
60 | (depIds, new DependencyId(LocalGroupId, depName, "-", null, null) :: withoutModuleId)
61 | case None =>
62 | // local dependency which doesn't exist - not including
63 | (depIds, withoutModuleId)
64 | }
65 | }
66 | }
67 |
68 | private def findClasspathIdToDepIds(classpathDepIds: List[DependencyId], cpCfg: Configuration,
69 | classpathDepVersions: Map[OrgAndName, String]): Map[DependencyId, Seq[DependencyId]] = {
70 |
71 | val includedConfigs = getConfigsClosure(cpCfg.name, rootMd.getConfigurations)
72 | val includedConfigsWithoutOptional = includedConfigs - Configurations.Optional.name
73 |
74 | // If a dependency's version is specified using a range, we check if the chosen version is in that range and if
75 | // so, replace the version. Otherwise, it means that the dependency is evicted.
76 | def replaceVersionIfMatchesCp(id: DependencyId): DependencyId = {
77 | classpathDepVersions.get(OrgAndName(id)) match {
78 | case Some(v) if v != id.getVersion =>
79 | if (ivy.getSettings.getVersionMatcher.accept(
80 | ModuleRevisionId.newInstance("x", "x", id.getVersion),
81 | ModuleRevisionId.newInstance("x", "x", v)
82 | )) id.withVersion(v) else id
83 |
84 | case _ => id
85 | }
86 | }
87 |
88 | var moduleInfoCache = classpathDepIds.map { id =>
89 | id -> (fmi.forDependencyId(id) match {
90 | case None =>
91 | log.warn(s"Cannot get dependencies for module $id")
92 | None
93 | case s => s
94 | })
95 | }.toMap
96 | def getIvyModuleInfo(id: DependencyId): Option[(ModuleDescriptor, Seq[DependencyDescriptor])] =
97 | moduleInfoCache.get(id) match {
98 | case Some(r) => r
99 | case None =>
100 | val info = fmi.forDependencyId(id)
101 | moduleInfoCache += id -> info
102 | info
103 | }
104 |
105 | // Map from id of a dependency to the configurations in which it is included
106 | var depsToConfigsMap: Map[DependencyId, Set[String]] = Map(rootId -> includedConfigs.toSet)
107 |
108 | // Pattern for extracting Ivy configuration mappings with a fallback
109 | val FallbackConfig = """(.*)\((.*)\)""".r
110 |
111 | /**
112 | * For the given dependency and id, resolves the config specification to a list of valid configuration
113 | * names of the dependency. The specification can be a fallback, * or config name
114 | */
115 | def resolveConfig(dependency: DependencyId, configName: String): Set[String] = {
116 | val configs = getIvyModuleInfo(dependency).map(_._1.getConfigurations.toSet).getOrElse(Set())
117 | lazy val configNames = configs.map(_.getName)
118 |
119 | (configName match {
120 | case FallbackConfig(default, fallback) =>
121 | if (configNames.contains(default)) Set(default) else { if (configNames.contains(fallback)) Set(fallback) else Set() }
122 | case "*" => configNames - "optional"
123 | case _ => Set(configName)
124 | }).flatMap((cfg: String) => getConfigsClosure(cfg, configs))
125 | }
126 |
127 | def doPropagateCfgs(id: DependencyId): Unit = {
128 | val dependencyConfigs = depsToConfigsMap.getOrElse(id, Set()).toArray
129 |
130 | val subDependenciesIvyDescriptors = getIvyModuleInfo(id).map(_._2).getOrElse(Nil)
131 | var changed = Set.empty[DependencyId]
132 |
133 | subDependenciesIvyDescriptors.foreach { subDependencyDescriptor =>
134 | val subDependency = toDepId(subDependencyDescriptor.getDependencyRevisionId)
135 | val ivySubDependencyConfigs = subDependencyDescriptor.getDependencyConfigurations(dependencyConfigs).toSet.flatMap(resolveConfig(subDependency, _: String))
136 | val subDependencyConfigs = depsToConfigsMap.getOrElse(subDependency, Set())
137 | val mergedSubDependencyConfigs = subDependencyConfigs ++ ivySubDependencyConfigs
138 |
139 | if (mergedSubDependencyConfigs.size > subDependencyConfigs.size) {
140 | depsToConfigsMap += subDependency -> mergedSubDependencyConfigs
141 | changed += subDependency
142 | }
143 | }
144 |
145 | changed.foreach(doPropagateCfgs)
146 | }
147 |
148 | doPropagateCfgs(rootId)
149 |
150 | classpathDepIds.map { id =>
151 | id -> (fmi.forDependencyId(id) match {
152 | case None =>
153 | log.warn(s"Cannot get dependencies for module $id")
154 | Nil
155 | case Some((desc, ds)) =>
156 | val r = ds.filter { d =>
157 | depsToConfigsMap.get(toDepId(d.getDependencyRevisionId)).exists(_.nonEmpty)
158 | }.map(d => replaceVersionIfMatchesCp(toDepId(d.getDependencyRevisionId)))
159 | r
160 | })
161 | }.toMap
162 | }
163 |
164 |
165 | /**
166 | * Set of configurations closed under "extends" relation
167 | */
168 | private def getConfigsClosure(root: String, cfgs: Iterable[IvyCfg]): Set[String] = {
169 | cfgs.find(_.getName == root) match {
170 | case None => Set()
171 | case Some(cfg) =>
172 | cfg.getExtends.foldLeft(Set(root)) { (acc, cfg) => acc ++ getConfigsClosure(cfg, cfgs) }
173 | }
174 | }
175 |
176 | private def addMissingEmptyDeps(depsMap: Map[DependencyId, Seq[DependencyId]]): Map[DependencyId, Seq[DependencyId]] = {
177 | var result = depsMap
178 | depsMap.values.flatten.toSet.foreach { (id: DependencyId) =>
179 | if (!result.containsKey(id)) result += id -> Nil
180 | }
181 |
182 | result
183 | }
184 |
185 | private case class OrgAndName(org: String, name: String)
186 | private object OrgAndName {
187 | def apply(id: DependencyId): OrgAndName = OrgAndName(id.getGroupId, id.getArtifactId)
188 | }
189 |
190 | private def toDepId(mrid: ModuleRevisionId): DependencyId = new DependencyId(mrid.getOrganisation, mrid.getName,
191 | mrid.getRevision, null, null)
192 | private def toDepId(mid: ModuleID): DependencyId = new DependencyId(mid.organization, mid.name, mid.revision, null, null)
193 |
194 | private implicit class RichDependencyId(id: DependencyId) {
195 | def withVersion(v: String) = new DependencyId(id.getGroupId, id.getArtifactId, v, id.getType, id.getClassifier)
196 | }
197 | }
198 |
--------------------------------------------------------------------------------
/src/main/scala/com/updateimpact/FindModuleInfo.scala:
--------------------------------------------------------------------------------
1 | package com.updateimpact
2 |
3 | import java.io.FileInputStream
4 | import java.util.Properties
5 |
6 | import com.updateimpact.report.DependencyId
7 | import org.apache.ivy.Ivy
8 | import org.apache.ivy.core.LogOptions
9 | import org.apache.ivy.core.module.descriptor.{ModuleDescriptor, DependencyDescriptor}
10 | import org.apache.ivy.core.module.id.ModuleRevisionId
11 | import org.apache.ivy.core.resolve.ResolveOptions
12 | import org.apache.ivy.plugins.parser.xml.XmlModuleDescriptorParser
13 |
14 | class FindModuleInfo(ivy: Ivy) {
15 | /**
16 | * Looks for module info of the given dependency in:
17 | * - resolved ivy module file, in a local cache
18 | * - ivy cache
19 | */
20 | def forDependencyId(id: DependencyId): Option[(ModuleDescriptor, Seq[DependencyDescriptor])] = {
21 | val mrid = ModuleRevisionId.newInstance(id.getGroupId, id.getArtifactId, id.getVersion)
22 | findModuleFromCache(mrid)
23 | .orElse(findModuleUsingResolveEngine(mrid))
24 | }
25 |
26 | private def findModuleFromCache(mrid: ModuleRevisionId) = {
27 | val ivyFile = ivy.getResolutionCacheManager.getResolvedIvyFileInCache(mrid)
28 | if (!ivyFile.exists()) {
29 | None
30 | } else {
31 | // If a dependency's version is specified using a range, the cached descriptor will contain the range,
32 | // and the chosen specific version will be present in a separate .properties file. Hence replacing the versions
33 | // for all dependencies for which the properties file has an entry.
34 |
35 | // ResolutionCache:45
36 | val desc = XmlModuleDescriptorParser.getInstance().parseDescriptor(ivy.getSettings, ivyFile.toURI.toURL, false)
37 | val revReplacements = resolvedRevisionsFromCachedProperties(mrid)
38 |
39 | val deps = desc.getDependencies.map { d =>
40 | revReplacements.get(d.getDependencyRevisionId) match {
41 | case None => d
42 | case Some(rev) => d.clone(ModuleRevisionId.newInstance(d.getDependencyRevisionId, rev))
43 | }
44 | }
45 |
46 | Some((desc, deps.toSeq))
47 | }
48 | }
49 |
50 | // DeliverEngine:117
51 | private def resolvedRevisionsFromCachedProperties(mrid: ModuleRevisionId): Map[ModuleRevisionId, String] = {
52 | var resolvedRevisions = Map[ModuleRevisionId, String]() // Map (ModuleId -> String revision)
53 | val ivyProperties = ivy.getResolutionCacheManager.getResolvedIvyPropertiesInCache(mrid)
54 | if (!ivyProperties.exists()) {
55 | Map()
56 | } else {
57 | val props = new Properties()
58 | val in = new FileInputStream(ivyProperties)
59 | try props.load(in) finally in.close()
60 |
61 | val iter = props.keySet().iterator()
62 | while (iter.hasNext) {
63 | val depMridStr = iter.next().asInstanceOf[String]
64 | val parts = props.getProperty(depMridStr).split(" ")
65 | val decodedMrid = ModuleRevisionId.decode(depMridStr)
66 |
67 | if (parts.length >= 3) {
68 | resolvedRevisions += decodedMrid -> parts(2)
69 | } else {
70 | resolvedRevisions += decodedMrid -> parts(0)
71 | }
72 | }
73 |
74 | resolvedRevisions
75 | }
76 | }
77 |
78 | private def findModuleUsingResolveEngine(mrid: ModuleRevisionId) = {
79 | val resolveOptions = new ResolveOptions
80 | resolveOptions.setResolveId(ResolveOptions.getDefaultResolveId(mrid.getModuleId))
81 | resolveOptions.setLog(LogOptions.LOG_QUIET)
82 | resolveOptions.setDownload(false)
83 | resolveOptions.setRefresh(false)
84 | resolveOptions.setCheckIfChanged(false)
85 | resolveOptions.setOutputReport(false)
86 | resolveOptions.setUseCacheOnly(true)
87 | resolveOptions.setValidate(false)
88 |
89 | Option(ivy.getResolveEngine.findModule(mrid, resolveOptions))
90 | .map(fmr => (fmr.getDescriptor, fmr.getDescriptor.getDependencies.toSeq))
91 | }
92 | }
93 |
--------------------------------------------------------------------------------
/src/main/scala/com/updateimpact/Plugin.scala:
--------------------------------------------------------------------------------
1 | package com.updateimpact
2 |
3 | import java.awt.Desktop
4 | import java.net.URI
5 | import java.util.{Collections, UUID}
6 |
7 | import com.updateimpact.report._
8 | import org.apache.ivy.core.module.id.ModuleRevisionId
9 | import sbt._
10 | import sbt.Keys._
11 |
12 | import scala.collection.JavaConverters._
13 |
14 | object Plugin extends AutoPlugin {
15 | object autoImport {
16 | val updateImpactApiKey = settingKey[String]("The api key to access UpdateImpact")
17 |
18 | val updateImpactBaseUrl = settingKey[String]("The base UpdateImpact URL")
19 |
20 | val updateImpactOpenBrowser = settingKey[Boolean]("Should the default browser be " +
21 | "opened with the results after the build completes")
22 |
23 | val updateImpactBuildId = taskKey[() => String]("Create a unique id of a build")
24 |
25 | val updateImpactRootProjectId = taskKey[String]("The id of the root project, from which the name and apikeys are taken")
26 |
27 | val updateImpactDependencies = taskKey[ModuleDependencies]("Compute module dependencies for a single project in a given configuration")
28 |
29 | val updateImpactTree = taskKey[Unit]("Print the textual representation of the dependency tree to the console")
30 |
31 | val updateImpactDependencyReport = taskKey[DependencyReport]("Create the dependency report for all of the projects")
32 |
33 | val updateImpactSubmit = taskKey[Unit]("Submit the dependency report to UpdateImpact for all projects " +
34 | "and optionally open the browser with the results")
35 | }
36 |
37 | val apiKey = autoImport.updateImpactApiKey
38 | val baseUrl = autoImport.updateImpactBaseUrl
39 | val openBrowser = autoImport.updateImpactOpenBrowser
40 | val buildId = autoImport.updateImpactBuildId
41 | val rootProjectId = autoImport.updateImpactRootProjectId
42 |
43 | val dependencies = autoImport.updateImpactDependencies
44 | val tree = autoImport.updateImpactTree
45 |
46 | val dependencyReport = autoImport.updateImpactDependencyReport
47 | val submit = autoImport.updateImpactSubmit
48 |
49 | // We need a mapping from SBT's ModuleIDs, where for the projects in the build the artifact names do not contain
50 | // the _2.11 (scala version) suffix, to the artifact name that is used in Ivy (with the suffix)
51 | private val projectIdToIvyIdEntry = taskKey[(ModuleID, ModuleRevisionId)]("")
52 | private val projectIdToIvyIdEntryImpl = projectIdToIvyIdEntry := {
53 | projectID.value -> ivyModule.value.moduleDescriptor(streams.value.log).getModuleRevisionId
54 | }
55 |
56 | private val projectIdToIvyId = taskKey[Map[ModuleID, ModuleRevisionId]]("")
57 | private val projectIdToIvyIdImpl = projectIdToIvyId := {
58 | projectIdToIvyIdEntry.all(ScopeFilter(inAnyProject)).value.toMap
59 | }
60 |
61 | val configs = List(Compile, Test, Runtime)
62 |
63 | val dependenciesImpl = dependencies := {
64 | val log = streams.value.log
65 | val md = ivyModule.value.moduleDescriptor(log)
66 | val pitii = projectIdToIvyId.value
67 | val cfg = configuration.value
68 | val ur = update.value
69 | val cc = classpathConfiguration.value
70 | val dc = dependencyClasspath.value
71 |
72 | ivySbt.value.withIvy(log) { ivy =>
73 | val cmd = new CreateModuleDependencies(ivy, log, md, pitii, ur)
74 | cmd.forClasspath(cfg, cc, dc)
75 | }
76 | }
77 |
78 | val rootProjectIdImpl = rootProjectId := {
79 | // Trying to find the "root project" using a heuristic: from all the projects that aggregate other projects,
80 | // looking for the one with the shortest path (longer paths probably mean subprojects).
81 | val allProjects = buildStructure.value.allProjects
82 | val withAggregate = allProjects.filter(_.aggregate.nonEmpty)
83 | (if (withAggregate.nonEmpty) withAggregate else allProjects)
84 | .sortBy(_.base.getAbsolutePath.length)
85 | .head
86 | .id
87 | }
88 |
89 | val dependencyReportImpl = dependencyReport := {
90 | val Some((_, (rootProjectName, ak0))) = thisProject.zip(name.zip(apiKey))
91 | .all(ScopeFilter(inAnyProject)).value
92 | .find(_._1.id == rootProjectId.value)
93 |
94 | val ak = if (ak0 == "") {
95 | sys.env.getOrElse("UPDATEIMPACT_API_KEY",
96 | throw new IllegalStateException("Please define the api key. You can find it on UpdateImpact.com"))
97 | } else ak0
98 |
99 | val moduleDependencies = dependencies.all(ScopeFilter(inAnyProject, configurations = inConfigurations(configs: _*))).value
100 |
101 | new DependencyReport(
102 | rootProjectName,
103 | ak,
104 | buildId.value(),
105 | moduleDependencies.asJavaCollection,
106 | Collections.emptyList(),
107 | "1.0",
108 | s"sbt-plugin-${UpdateimpactSbtBuildInfo.version}")
109 | }
110 |
111 | override def projectSettings = Seq(
112 | projectIdToIvyIdEntryImpl,
113 | projectIdToIvyIdImpl
114 | ) ++ configs.flatMap(c => inConfig(c)(Seq(dependenciesImpl)))
115 |
116 | override def buildSettings = Seq(
117 | apiKey := "",
118 | baseUrl := "https://app.updateimpact.com",
119 | openBrowser := true,
120 | buildId := { () => UUID.randomUUID().toString },
121 | rootProjectIdImpl,
122 | dependencyReportImpl,
123 | submit := {
124 | val slog = streams.value.log
125 | val log = new SubmitLogger {
126 | override def error(message: String) = slog.error(message)
127 | override def info(message: String) = slog.info(message)
128 | }
129 | val dr = dependencyReport.value
130 | val ob = openBrowser.value
131 | Option(new ReportSubmitter(baseUrl.value, log).trySubmitReport(dr)).foreach { viewLink =>
132 | if (ob) {
133 | log.info("Trying to open the report in the default browser ... " +
134 | "(you can disable this by setting `updateImpactOpenBrowser in ThisBuild` to false)")
135 | openWebpage(viewLink)
136 | }
137 | }
138 | }
139 | )
140 |
141 | override def trigger = allRequirements
142 |
143 | // http://stackoverflow.com/questions/10967451/open-a-link-in-browser-with-java-button
144 | private def openWebpage(url: String) {
145 | val desktop = if (Desktop.isDesktopSupported) Desktop.getDesktop else null
146 | if (desktop != null && desktop.isSupported(Desktop.Action.BROWSE)) {
147 | desktop.browse(URI.create(url))
148 | }
149 | }
150 | }
151 |
--------------------------------------------------------------------------------
/src/main/scala/com/updateimpact/testing/ReportToString.scala:
--------------------------------------------------------------------------------
1 | package com.updateimpact.testing
2 |
3 | import com.updateimpact.report.DependencyReport
4 | import scala.collection.JavaConversions._
5 |
6 | object ReportToString {
7 | def toString(dr: DependencyReport): String = {
8 | dr.getModuleDependencies.groupBy(_.getConfig).toList.sortBy(_._1).map { case (config, modules) =>
9 | modules.toList.sortBy(_.getModuleId.toString).map { m =>
10 | val h1 = s"${m.getModuleId} in ${m.getConfig}\n"
11 |
12 | h1 + m.getDependencies.toList.sortBy(_.getId.toString).map { d =>
13 | val h2 = s" ${d.getId}${if (d.getEvictedByVersion != null) s" evicted by ${d.getEvictedByVersion}" else ""}"
14 |
15 | val chld = d.getChildren.toList.sortBy(_.toString).map { c =>
16 | " " + c.toString
17 | }
18 |
19 | if (chld.isEmpty) h2 else h2 + "\n" + chld.mkString("\n")
20 | }.mkString("\n")
21 | }.mkString("\n")
22 | }.mkString("\n")
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/src/sbt-test/updateimpact/basic_13_8/build.sbt:
--------------------------------------------------------------------------------
1 | val commonSettings = Seq(
2 | organization := "com.softwaremill.example",
3 | version := "0.1-SNAPSHOT",
4 | scalaVersion := "2.11.6"
5 | )
6 |
7 | lazy val rootProject = (project in file("."))
8 | .settings(commonSettings: _*)
9 | .settings(
10 | name := "sbt-example",
11 | libraryDependencies ++= Seq(
12 | "junit" % "junit" % "3.8.1" % "test"
13 | )).aggregate(module1, module2)
14 |
15 | lazy val module1: Project = (project in file("module1"))
16 | .settings(commonSettings: _*)
17 | .settings(
18 | libraryDependencies ++= Seq(
19 | "log4j" % "log4j" % "1.2.14",
20 | "dom4j" % "dom4j" % "1.6.1",
21 | "org.apache.httpcomponents" % "httpclient" % "4.0.1",
22 | // evicts a dep in httpclient
23 | "commons-logging" % "commons-logging" % "1.2"
24 | ))
25 |
26 | lazy val module2: Project = (project in file("module2"))
27 | .settings(commonSettings: _*)
28 | .settings(
29 | libraryDependencies ++= Seq(
30 | "javax.servlet" % "servlet-api" % "2.4" % "provided",
31 | "com.softwaremill.macwire" %% "runtime" % "1.0.5"
32 | )).dependsOn(module1)
33 |
34 | updateImpactApiKey in ThisBuild := "x"
35 |
36 | TaskKey[Unit]("check") := {
37 | val expected = scala.io.Source.fromFile("expected.txt").getLines().mkString("\n")
38 |
39 | val report = updateImpactDependencyReport.value
40 | val str = com.updateimpact.testing.ReportToString.toString(report)
41 |
42 | if (expected != str) {
43 | println("EXPECTED: ")
44 | println(expected)
45 |
46 | println("GOT: ")
47 | println(str)
48 |
49 | sys.error("Invalid report generated")
50 | }
51 | }
--------------------------------------------------------------------------------
/src/sbt-test/updateimpact/basic_13_8/expected.txt:
--------------------------------------------------------------------------------
1 | com.softwaremill.example:module1_2.11:0.1-SNAPSHOT in compile
2 | com.softwaremill.example:module1_2.11:0.1-SNAPSHOT
3 | commons-logging:commons-logging:1.2
4 | dom4j:dom4j:1.6.1
5 | log4j:log4j:1.2.14
6 | org.apache.httpcomponents:httpclient:4.0.1
7 | org.scala-lang:scala-library:2.11.6
8 | commons-codec:commons-codec:1.3
9 | commons-logging:commons-logging:1.1.1 evicted by 1.2
10 | commons-logging:commons-logging:1.2
11 | dom4j:dom4j:1.6.1
12 | xml-apis:xml-apis:1.0.b2
13 | log4j:log4j:1.2.14
14 | org.apache.httpcomponents:httpclient:4.0.1
15 | commons-codec:commons-codec:1.3
16 | commons-logging:commons-logging:1.1.1
17 | org.apache.httpcomponents:httpcore:4.0.1
18 | org.apache.httpcomponents:httpcore:4.0.1
19 | org.scala-lang:scala-library:2.11.6
20 | xml-apis:xml-apis:1.0.b2
21 | com.softwaremill.example:module2_2.11:0.1-SNAPSHOT in compile
22 | com.softwaremill.example:module1_2.11:0.1-SNAPSHOT
23 | commons-logging:commons-logging:1.2
24 | dom4j:dom4j:1.6.1
25 | log4j:log4j:1.2.14
26 | org.apache.httpcomponents:httpclient:4.0.1
27 | org.scala-lang:scala-library:2.11.6
28 | com.softwaremill.example:module2_2.11:0.1-SNAPSHOT
29 | com.softwaremill.example:module1_2.11:0.1-SNAPSHOT
30 | com.softwaremill.macwire:runtime_2.11:1.0.5
31 | javax.servlet:servlet-api:2.4
32 | org.scala-lang:scala-library:2.11.6
33 | com.softwaremill.macwire:runtime_2.11:1.0.5
34 | org.javassist:javassist:3.19.0-GA
35 | org.scala-lang:scala-library:2.11.6
36 | commons-codec:commons-codec:1.3
37 | commons-logging:commons-logging:1.1.1 evicted by 1.2
38 | commons-logging:commons-logging:1.2
39 | dom4j:dom4j:1.6.1
40 | xml-apis:xml-apis:1.0.b2
41 | javax.servlet:servlet-api:2.4
42 | log4j:log4j:1.2.14
43 | org.apache.httpcomponents:httpclient:4.0.1
44 | commons-codec:commons-codec:1.3
45 | commons-logging:commons-logging:1.1.1
46 | org.apache.httpcomponents:httpcore:4.0.1
47 | org.apache.httpcomponents:httpcore:4.0.1
48 | org.javassist:javassist:3.19.0-GA
49 | org.scala-lang:scala-library:2.11.6
50 | xml-apis:xml-apis:1.0.b2
51 | com.softwaremill.example:sbt-example_2.11:0.1-SNAPSHOT in compile
52 | com.softwaremill.example:sbt-example_2.11:0.1-SNAPSHOT
53 | org.scala-lang:scala-library:2.11.6
54 | org.scala-lang:scala-library:2.11.6
55 | com.softwaremill.example:module1_2.11:0.1-SNAPSHOT in runtime
56 | com.softwaremill.example:module1_2.11:0.1-SNAPSHOT
57 | commons-logging:commons-logging:1.2
58 | dom4j:dom4j:1.6.1
59 | log4j:log4j:1.2.14
60 | org.apache.httpcomponents:httpclient:4.0.1
61 | org.scala-lang:scala-library:2.11.6
62 | commons-codec:commons-codec:1.3
63 | commons-logging:commons-logging:1.1.1 evicted by 1.2
64 | commons-logging:commons-logging:1.2
65 | dom4j:dom4j:1.6.1
66 | xml-apis:xml-apis:1.0.b2
67 | log4j:log4j:1.2.14
68 | org.apache.httpcomponents:httpclient:4.0.1
69 | commons-codec:commons-codec:1.3
70 | commons-logging:commons-logging:1.1.1
71 | org.apache.httpcomponents:httpcore:4.0.1
72 | org.apache.httpcomponents:httpcore:4.0.1
73 | org.scala-lang:scala-library:2.11.6
74 | xml-apis:xml-apis:1.0.b2
75 | com.softwaremill.example:module2_2.11:0.1-SNAPSHOT in runtime
76 | com.softwaremill.example:module1_2.11:0.1-SNAPSHOT
77 | commons-logging:commons-logging:1.2
78 | dom4j:dom4j:1.6.1
79 | log4j:log4j:1.2.14
80 | org.apache.httpcomponents:httpclient:4.0.1
81 | org.scala-lang:scala-library:2.11.6
82 | com.softwaremill.example:module2_2.11:0.1-SNAPSHOT
83 | com.softwaremill.example:module1_2.11:0.1-SNAPSHOT
84 | com.softwaremill.macwire:runtime_2.11:1.0.5
85 | org.scala-lang:scala-library:2.11.6
86 | com.softwaremill.macwire:runtime_2.11:1.0.5
87 | org.javassist:javassist:3.19.0-GA
88 | org.scala-lang:scala-library:2.11.6
89 | commons-codec:commons-codec:1.3
90 | commons-logging:commons-logging:1.1.1 evicted by 1.2
91 | commons-logging:commons-logging:1.2
92 | dom4j:dom4j:1.6.1
93 | xml-apis:xml-apis:1.0.b2
94 | log4j:log4j:1.2.14
95 | org.apache.httpcomponents:httpclient:4.0.1
96 | commons-codec:commons-codec:1.3
97 | commons-logging:commons-logging:1.1.1
98 | org.apache.httpcomponents:httpcore:4.0.1
99 | org.apache.httpcomponents:httpcore:4.0.1
100 | org.javassist:javassist:3.19.0-GA
101 | org.scala-lang:scala-library:2.11.6
102 | xml-apis:xml-apis:1.0.b2
103 | com.softwaremill.example:sbt-example_2.11:0.1-SNAPSHOT in runtime
104 | com.softwaremill.example:sbt-example_2.11:0.1-SNAPSHOT
105 | org.scala-lang:scala-library:2.11.6
106 | org.scala-lang:scala-library:2.11.6
107 | com.softwaremill.example:module1_2.11:0.1-SNAPSHOT in test
108 | com.softwaremill.example:module1_2.11:0.1-SNAPSHOT
109 | commons-logging:commons-logging:1.2
110 | dom4j:dom4j:1.6.1
111 | log4j:log4j:1.2.14
112 | org.apache.httpcomponents:httpclient:4.0.1
113 | org.scala-lang:scala-library:2.11.6
114 | commons-codec:commons-codec:1.3
115 | commons-logging:commons-logging:1.1.1 evicted by 1.2
116 | commons-logging:commons-logging:1.2
117 | dom4j:dom4j:1.6.1
118 | xml-apis:xml-apis:1.0.b2
119 | log4j:log4j:1.2.14
120 | org.apache.httpcomponents:httpclient:4.0.1
121 | commons-codec:commons-codec:1.3
122 | commons-logging:commons-logging:1.1.1
123 | org.apache.httpcomponents:httpcore:4.0.1
124 | org.apache.httpcomponents:httpcore:4.0.1
125 | org.scala-lang:scala-library:2.11.6
126 | xml-apis:xml-apis:1.0.b2
127 | com.softwaremill.example:module2_2.11:0.1-SNAPSHOT in test
128 | com.softwaremill.example:module1_2.11:0.1-SNAPSHOT
129 | commons-logging:commons-logging:1.2
130 | dom4j:dom4j:1.6.1
131 | log4j:log4j:1.2.14
132 | org.apache.httpcomponents:httpclient:4.0.1
133 | org.scala-lang:scala-library:2.11.6
134 | com.softwaremill.example:module2_2.11:0.1-SNAPSHOT
135 | com.softwaremill.example:module1_2.11:0.1-SNAPSHOT
136 | com.softwaremill.macwire:runtime_2.11:1.0.5
137 | javax.servlet:servlet-api:2.4
138 | org.scala-lang:scala-library:2.11.6
139 | com.softwaremill.macwire:runtime_2.11:1.0.5
140 | org.javassist:javassist:3.19.0-GA
141 | org.scala-lang:scala-library:2.11.6
142 | commons-codec:commons-codec:1.3
143 | commons-logging:commons-logging:1.1.1 evicted by 1.2
144 | commons-logging:commons-logging:1.2
145 | dom4j:dom4j:1.6.1
146 | xml-apis:xml-apis:1.0.b2
147 | javax.servlet:servlet-api:2.4
148 | log4j:log4j:1.2.14
149 | org.apache.httpcomponents:httpclient:4.0.1
150 | commons-codec:commons-codec:1.3
151 | commons-logging:commons-logging:1.1.1
152 | org.apache.httpcomponents:httpcore:4.0.1
153 | org.apache.httpcomponents:httpcore:4.0.1
154 | org.javassist:javassist:3.19.0-GA
155 | org.scala-lang:scala-library:2.11.6
156 | xml-apis:xml-apis:1.0.b2
157 | com.softwaremill.example:sbt-example_2.11:0.1-SNAPSHOT in test
158 | com.softwaremill.example:sbt-example_2.11:0.1-SNAPSHOT
159 | junit:junit:3.8.1
160 | org.scala-lang:scala-library:2.11.6
161 | junit:junit:3.8.1
162 | org.scala-lang:scala-library:2.11.6
--------------------------------------------------------------------------------
/src/sbt-test/updateimpact/basic_13_8/project/build.properties:
--------------------------------------------------------------------------------
1 | sbt.version=0.13.8
--------------------------------------------------------------------------------
/src/sbt-test/updateimpact/basic_13_8/project/plugins.sbt:
--------------------------------------------------------------------------------
1 | {
2 | val pluginVersion = System.getProperty("plugin.version")
3 | if(pluginVersion == null)
4 | throw new RuntimeException("""|The system property 'plugin.version' is not defined.
5 | |Specify this property using the scriptedLaunchOpts -D.""".stripMargin)
6 | else addSbtPlugin("com.updateimpact" % "updateimpact-sbt-plugin" % pluginVersion)
7 | }
--------------------------------------------------------------------------------
/src/sbt-test/updateimpact/basic_13_8/test:
--------------------------------------------------------------------------------
1 | > check
--------------------------------------------------------------------------------
/src/sbt-test/updateimpact/basic_13_9/build.sbt:
--------------------------------------------------------------------------------
1 | val commonSettings = Seq(
2 | organization := "com.softwaremill.example",
3 | version := "0.1-SNAPSHOT",
4 | scalaVersion := "2.11.6"
5 | )
6 |
7 | lazy val rootProject = (project in file("."))
8 | .settings(commonSettings: _*)
9 | .settings(
10 | name := "sbt-example",
11 | libraryDependencies ++= Seq(
12 | "junit" % "junit" % "3.8.1" % "test"
13 | )).aggregate(module1, module2)
14 |
15 | lazy val module1: Project = (project in file("module1"))
16 | .settings(commonSettings: _*)
17 | .settings(
18 | libraryDependencies ++= Seq(
19 | "log4j" % "log4j" % "1.2.14",
20 | "dom4j" % "dom4j" % "1.6.1",
21 | "org.apache.httpcomponents" % "httpclient" % "4.0.1",
22 | // evicts a dep in httpclient
23 | "commons-logging" % "commons-logging" % "1.2"
24 | ))
25 |
26 | lazy val module2: Project = (project in file("module2"))
27 | .settings(commonSettings: _*)
28 | .settings(
29 | libraryDependencies ++= Seq(
30 | "javax.servlet" % "servlet-api" % "2.4" % "provided",
31 | "com.softwaremill.macwire" %% "runtime" % "1.0.5"
32 | )).dependsOn(module1)
33 |
34 | updateImpactApiKey in ThisBuild := "x"
35 |
36 | TaskKey[Unit]("check") := {
37 | val expected = scala.io.Source.fromFile("expected.txt").getLines().mkString("\n")
38 |
39 | val report = updateImpactDependencyReport.value
40 | val str = com.updateimpact.testing.ReportToString.toString(report)
41 |
42 | if (expected != str) {
43 | println("EXPECTED: ")
44 | println(expected)
45 |
46 | println("GOT: ")
47 | println(str)
48 |
49 | sys.error("Invalid report generated")
50 | }
51 | }
--------------------------------------------------------------------------------
/src/sbt-test/updateimpact/basic_13_9/expected.txt:
--------------------------------------------------------------------------------
1 | com.softwaremill.example:module1_2.11:0.1-SNAPSHOT in compile
2 | com.softwaremill.example:module1_2.11:0.1-SNAPSHOT
3 | commons-logging:commons-logging:1.2
4 | dom4j:dom4j:1.6.1
5 | log4j:log4j:1.2.14
6 | org.apache.httpcomponents:httpclient:4.0.1
7 | org.scala-lang:scala-library:2.11.6
8 | commons-codec:commons-codec:1.3
9 | commons-logging:commons-logging:1.1.1 evicted by 1.2
10 | commons-logging:commons-logging:1.2
11 | dom4j:dom4j:1.6.1
12 | xml-apis:xml-apis:1.0.b2
13 | log4j:log4j:1.2.14
14 | org.apache.httpcomponents:httpclient:4.0.1
15 | commons-codec:commons-codec:1.3
16 | commons-logging:commons-logging:1.1.1
17 | org.apache.httpcomponents:httpcore:4.0.1
18 | org.apache.httpcomponents:httpcore:4.0.1
19 | org.scala-lang:scala-library:2.11.6
20 | xml-apis:xml-apis:1.0.b2
21 | com.softwaremill.example:module2_2.11:0.1-SNAPSHOT in compile
22 | com.softwaremill.example:module1_2.11:0.1-SNAPSHOT
23 | commons-logging:commons-logging:1.2
24 | dom4j:dom4j:1.6.1
25 | log4j:log4j:1.2.14
26 | org.apache.httpcomponents:httpclient:4.0.1
27 | org.scala-lang:scala-library:2.11.6
28 | com.softwaremill.example:module2_2.11:0.1-SNAPSHOT
29 | com.softwaremill.example:module1_2.11:0.1-SNAPSHOT
30 | com.softwaremill.macwire:runtime_2.11:1.0.5
31 | javax.servlet:servlet-api:2.4
32 | org.scala-lang:scala-library:2.11.6
33 | com.softwaremill.macwire:runtime_2.11:1.0.5
34 | org.javassist:javassist:3.19.0-GA
35 | org.scala-lang:scala-library:2.11.6
36 | commons-codec:commons-codec:1.3
37 | commons-logging:commons-logging:1.1.1 evicted by 1.2
38 | commons-logging:commons-logging:1.2
39 | dom4j:dom4j:1.6.1
40 | xml-apis:xml-apis:1.0.b2
41 | javax.servlet:servlet-api:2.4
42 | log4j:log4j:1.2.14
43 | org.apache.httpcomponents:httpclient:4.0.1
44 | commons-codec:commons-codec:1.3
45 | commons-logging:commons-logging:1.1.1
46 | org.apache.httpcomponents:httpcore:4.0.1
47 | org.apache.httpcomponents:httpcore:4.0.1
48 | org.javassist:javassist:3.19.0-GA
49 | org.scala-lang:scala-library:2.11.6
50 | xml-apis:xml-apis:1.0.b2
51 | com.softwaremill.example:sbt-example_2.11:0.1-SNAPSHOT in compile
52 | com.softwaremill.example:sbt-example_2.11:0.1-SNAPSHOT
53 | org.scala-lang:scala-library:2.11.6
54 | org.scala-lang:scala-library:2.11.6
55 | com.softwaremill.example:module1_2.11:0.1-SNAPSHOT in runtime
56 | com.softwaremill.example:module1_2.11:0.1-SNAPSHOT
57 | commons-logging:commons-logging:1.2
58 | dom4j:dom4j:1.6.1
59 | log4j:log4j:1.2.14
60 | org.apache.httpcomponents:httpclient:4.0.1
61 | org.scala-lang:scala-library:2.11.6
62 | commons-codec:commons-codec:1.3
63 | commons-logging:commons-logging:1.1.1 evicted by 1.2
64 | commons-logging:commons-logging:1.2
65 | dom4j:dom4j:1.6.1
66 | xml-apis:xml-apis:1.0.b2
67 | log4j:log4j:1.2.14
68 | org.apache.httpcomponents:httpclient:4.0.1
69 | commons-codec:commons-codec:1.3
70 | commons-logging:commons-logging:1.1.1
71 | org.apache.httpcomponents:httpcore:4.0.1
72 | org.apache.httpcomponents:httpcore:4.0.1
73 | org.scala-lang:scala-library:2.11.6
74 | xml-apis:xml-apis:1.0.b2
75 | com.softwaremill.example:module2_2.11:0.1-SNAPSHOT in runtime
76 | com.softwaremill.example:module1_2.11:0.1-SNAPSHOT
77 | commons-logging:commons-logging:1.2
78 | dom4j:dom4j:1.6.1
79 | log4j:log4j:1.2.14
80 | org.apache.httpcomponents:httpclient:4.0.1
81 | org.scala-lang:scala-library:2.11.6
82 | com.softwaremill.example:module2_2.11:0.1-SNAPSHOT
83 | com.softwaremill.example:module1_2.11:0.1-SNAPSHOT
84 | com.softwaremill.macwire:runtime_2.11:1.0.5
85 | org.scala-lang:scala-library:2.11.6
86 | com.softwaremill.macwire:runtime_2.11:1.0.5
87 | org.javassist:javassist:3.19.0-GA
88 | org.scala-lang:scala-library:2.11.6
89 | commons-codec:commons-codec:1.3
90 | commons-logging:commons-logging:1.1.1 evicted by 1.2
91 | commons-logging:commons-logging:1.2
92 | dom4j:dom4j:1.6.1
93 | xml-apis:xml-apis:1.0.b2
94 | log4j:log4j:1.2.14
95 | org.apache.httpcomponents:httpclient:4.0.1
96 | commons-codec:commons-codec:1.3
97 | commons-logging:commons-logging:1.1.1
98 | org.apache.httpcomponents:httpcore:4.0.1
99 | org.apache.httpcomponents:httpcore:4.0.1
100 | org.javassist:javassist:3.19.0-GA
101 | org.scala-lang:scala-library:2.11.6
102 | xml-apis:xml-apis:1.0.b2
103 | com.softwaremill.example:sbt-example_2.11:0.1-SNAPSHOT in runtime
104 | com.softwaremill.example:sbt-example_2.11:0.1-SNAPSHOT
105 | org.scala-lang:scala-library:2.11.6
106 | org.scala-lang:scala-library:2.11.6
107 | com.softwaremill.example:module1_2.11:0.1-SNAPSHOT in test
108 | com.softwaremill.example:module1_2.11:0.1-SNAPSHOT
109 | commons-logging:commons-logging:1.2
110 | dom4j:dom4j:1.6.1
111 | log4j:log4j:1.2.14
112 | org.apache.httpcomponents:httpclient:4.0.1
113 | org.scala-lang:scala-library:2.11.6
114 | commons-codec:commons-codec:1.3
115 | commons-logging:commons-logging:1.1.1 evicted by 1.2
116 | commons-logging:commons-logging:1.2
117 | dom4j:dom4j:1.6.1
118 | xml-apis:xml-apis:1.0.b2
119 | log4j:log4j:1.2.14
120 | org.apache.httpcomponents:httpclient:4.0.1
121 | commons-codec:commons-codec:1.3
122 | commons-logging:commons-logging:1.1.1
123 | org.apache.httpcomponents:httpcore:4.0.1
124 | org.apache.httpcomponents:httpcore:4.0.1
125 | org.scala-lang:scala-library:2.11.6
126 | xml-apis:xml-apis:1.0.b2
127 | com.softwaremill.example:module2_2.11:0.1-SNAPSHOT in test
128 | com.softwaremill.example:module1_2.11:0.1-SNAPSHOT
129 | commons-logging:commons-logging:1.2
130 | dom4j:dom4j:1.6.1
131 | log4j:log4j:1.2.14
132 | org.apache.httpcomponents:httpclient:4.0.1
133 | org.scala-lang:scala-library:2.11.6
134 | com.softwaremill.example:module2_2.11:0.1-SNAPSHOT
135 | com.softwaremill.example:module1_2.11:0.1-SNAPSHOT
136 | com.softwaremill.macwire:runtime_2.11:1.0.5
137 | javax.servlet:servlet-api:2.4
138 | org.scala-lang:scala-library:2.11.6
139 | com.softwaremill.macwire:runtime_2.11:1.0.5
140 | org.javassist:javassist:3.19.0-GA
141 | org.scala-lang:scala-library:2.11.6
142 | commons-codec:commons-codec:1.3
143 | commons-logging:commons-logging:1.1.1 evicted by 1.2
144 | commons-logging:commons-logging:1.2
145 | dom4j:dom4j:1.6.1
146 | xml-apis:xml-apis:1.0.b2
147 | javax.servlet:servlet-api:2.4
148 | log4j:log4j:1.2.14
149 | org.apache.httpcomponents:httpclient:4.0.1
150 | commons-codec:commons-codec:1.3
151 | commons-logging:commons-logging:1.1.1
152 | org.apache.httpcomponents:httpcore:4.0.1
153 | org.apache.httpcomponents:httpcore:4.0.1
154 | org.javassist:javassist:3.19.0-GA
155 | org.scala-lang:scala-library:2.11.6
156 | xml-apis:xml-apis:1.0.b2
157 | com.softwaremill.example:sbt-example_2.11:0.1-SNAPSHOT in test
158 | com.softwaremill.example:sbt-example_2.11:0.1-SNAPSHOT
159 | junit:junit:3.8.1
160 | org.scala-lang:scala-library:2.11.6
161 | junit:junit:3.8.1
162 | org.scala-lang:scala-library:2.11.6
163 |
--------------------------------------------------------------------------------
/src/sbt-test/updateimpact/basic_13_9/project/build.properties:
--------------------------------------------------------------------------------
1 | sbt.version=0.13.9
--------------------------------------------------------------------------------
/src/sbt-test/updateimpact/basic_13_9/project/plugins.sbt:
--------------------------------------------------------------------------------
1 | {
2 | val pluginVersion = System.getProperty("plugin.version")
3 | if(pluginVersion == null)
4 | throw new RuntimeException("""|The system property 'plugin.version' is not defined.
5 | |Specify this property using the scriptedLaunchOpts -D.""".stripMargin)
6 | else addSbtPlugin("com.updateimpact" % "updateimpact-sbt-plugin" % pluginVersion)
7 | }
--------------------------------------------------------------------------------
/src/sbt-test/updateimpact/basic_13_9/test:
--------------------------------------------------------------------------------
1 | > check
--------------------------------------------------------------------------------
/src/sbt-test/updateimpact/cached_13_8/build.sbt:
--------------------------------------------------------------------------------
1 | val commonSettings = Seq(
2 | organization := "com.softwaremill.example",
3 | version := "0.1-SNAPSHOT",
4 | scalaVersion := "2.11.6",
5 | updateOptions := updateOptions.value.withCachedResolution(true)
6 | )
7 |
8 | lazy val rootProject = (project in file("."))
9 | .settings(commonSettings: _*)
10 | .settings(
11 | name := "sbt-example",
12 | libraryDependencies ++= Seq(
13 | "junit" % "junit" % "3.8.1" % "test"
14 | )).aggregate(module1, module2)
15 |
16 | lazy val module1: Project = (project in file("module1"))
17 | .settings(commonSettings: _*)
18 | .settings(
19 | libraryDependencies ++= Seq(
20 | "log4j" % "log4j" % "1.2.14",
21 | "dom4j" % "dom4j" % "1.6.1",
22 | "org.apache.httpcomponents" % "httpclient" % "4.0.1",
23 | // evicts a dep in httpclient
24 | "commons-logging" % "commons-logging" % "1.2"
25 | ))
26 |
27 | lazy val module2: Project = (project in file("module2"))
28 | .settings(commonSettings: _*)
29 | .settings(
30 | libraryDependencies ++= Seq(
31 | "javax.servlet" % "servlet-api" % "2.4" % "provided",
32 | "com.softwaremill.macwire" %% "runtime" % "1.0.5"
33 | )).dependsOn(module1)
34 |
35 | updateImpactApiKey in ThisBuild := "x"
36 |
37 | TaskKey[Unit]("check") := {
38 | val expected = scala.io.Source.fromFile("expected.txt").getLines().mkString("\n")
39 |
40 | val report = updateImpactDependencyReport.value
41 | val str = com.updateimpact.testing.ReportToString.toString(report)
42 |
43 | if (expected != str) {
44 | println("EXPECTED: ")
45 | println(expected)
46 |
47 | println("GOT: ")
48 | println(str)
49 |
50 | sys.error("Invalid report generated")
51 | }
52 | }
--------------------------------------------------------------------------------
/src/sbt-test/updateimpact/cached_13_8/expected.txt:
--------------------------------------------------------------------------------
1 | com.softwaremill.example:module1_2.11:0.1-SNAPSHOT in compile
2 | com.softwaremill.example:module1_2.11:0.1-SNAPSHOT
3 | commons-logging:commons-logging:1.2
4 | dom4j:dom4j:1.6.1
5 | log4j:log4j:1.2.14
6 | org.apache.httpcomponents:httpclient:4.0.1
7 | org.scala-lang:scala-library:2.11.6
8 | commons-codec:commons-codec:1.3
9 | commons-logging:commons-logging:1.1.1 evicted by 1.2
10 | commons-logging:commons-logging:1.2
11 | dom4j:dom4j:1.6.1
12 | xml-apis:xml-apis:1.0.b2
13 | log4j:log4j:1.2.14
14 | org.apache.httpcomponents:httpclient:4.0.1
15 | commons-codec:commons-codec:1.3
16 | commons-logging:commons-logging:1.1.1
17 | org.apache.httpcomponents:httpcore:4.0.1
18 | org.apache.httpcomponents:httpcore:4.0.1
19 | org.scala-lang:scala-library:2.11.6
20 | xml-apis:xml-apis:1.0.b2
21 | com.softwaremill.example:module2_2.11:0.1-SNAPSHOT in compile
22 | com.softwaremill.example:module1_2.11:0.1-SNAPSHOT
23 | commons-logging:commons-logging:1.2
24 | dom4j:dom4j:1.6.1
25 | log4j:log4j:1.2.14
26 | org.apache.httpcomponents:httpclient:4.0.1
27 | org.scala-lang:scala-library:2.11.6
28 | com.softwaremill.example:module2_2.11:0.1-SNAPSHOT
29 | com.softwaremill.example:module1_2.11:0.1-SNAPSHOT
30 | com.softwaremill.macwire:runtime_2.11:1.0.5
31 | javax.servlet:servlet-api:2.4
32 | org.scala-lang:scala-library:2.11.6
33 | com.softwaremill.macwire:runtime_2.11:1.0.5
34 | org.javassist:javassist:3.19.0-GA
35 | org.scala-lang:scala-library:2.11.6
36 | commons-codec:commons-codec:1.3
37 | commons-logging:commons-logging:1.1.1 evicted by 1.2
38 | commons-logging:commons-logging:1.2
39 | dom4j:dom4j:1.6.1
40 | xml-apis:xml-apis:1.0.b2
41 | javax.servlet:servlet-api:2.4
42 | log4j:log4j:1.2.14
43 | org.apache.httpcomponents:httpclient:4.0.1
44 | commons-codec:commons-codec:1.3
45 | commons-logging:commons-logging:1.1.1
46 | org.apache.httpcomponents:httpcore:4.0.1
47 | org.apache.httpcomponents:httpcore:4.0.1
48 | org.javassist:javassist:3.19.0-GA
49 | org.scala-lang:scala-library:2.11.6
50 | xml-apis:xml-apis:1.0.b2
51 | com.softwaremill.example:sbt-example_2.11:0.1-SNAPSHOT in compile
52 | com.softwaremill.example:sbt-example_2.11:0.1-SNAPSHOT
53 | org.scala-lang:scala-library:2.11.6
54 | org.scala-lang:scala-library:2.11.6
55 | com.softwaremill.example:module1_2.11:0.1-SNAPSHOT in runtime
56 | com.softwaremill.example:module1_2.11:0.1-SNAPSHOT
57 | commons-logging:commons-logging:1.2
58 | dom4j:dom4j:1.6.1
59 | log4j:log4j:1.2.14
60 | org.apache.httpcomponents:httpclient:4.0.1
61 | org.scala-lang:scala-library:2.11.6
62 | commons-codec:commons-codec:1.3
63 | commons-logging:commons-logging:1.1.1 evicted by 1.2
64 | commons-logging:commons-logging:1.2
65 | dom4j:dom4j:1.6.1
66 | xml-apis:xml-apis:1.0.b2
67 | log4j:log4j:1.2.14
68 | org.apache.httpcomponents:httpclient:4.0.1
69 | commons-codec:commons-codec:1.3
70 | commons-logging:commons-logging:1.1.1
71 | org.apache.httpcomponents:httpcore:4.0.1
72 | org.apache.httpcomponents:httpcore:4.0.1
73 | org.scala-lang:scala-library:2.11.6
74 | xml-apis:xml-apis:1.0.b2
75 | com.softwaremill.example:module2_2.11:0.1-SNAPSHOT in runtime
76 | com.softwaremill.example:module1_2.11:0.1-SNAPSHOT
77 | commons-logging:commons-logging:1.2
78 | dom4j:dom4j:1.6.1
79 | log4j:log4j:1.2.14
80 | org.apache.httpcomponents:httpclient:4.0.1
81 | org.scala-lang:scala-library:2.11.6
82 | com.softwaremill.example:module2_2.11:0.1-SNAPSHOT
83 | com.softwaremill.example:module1_2.11:0.1-SNAPSHOT
84 | com.softwaremill.macwire:runtime_2.11:1.0.5
85 | org.scala-lang:scala-library:2.11.6
86 | com.softwaremill.macwire:runtime_2.11:1.0.5
87 | org.javassist:javassist:3.19.0-GA
88 | org.scala-lang:scala-library:2.11.6
89 | commons-codec:commons-codec:1.3
90 | commons-logging:commons-logging:1.1.1 evicted by 1.2
91 | commons-logging:commons-logging:1.2
92 | dom4j:dom4j:1.6.1
93 | xml-apis:xml-apis:1.0.b2
94 | log4j:log4j:1.2.14
95 | org.apache.httpcomponents:httpclient:4.0.1
96 | commons-codec:commons-codec:1.3
97 | commons-logging:commons-logging:1.1.1
98 | org.apache.httpcomponents:httpcore:4.0.1
99 | org.apache.httpcomponents:httpcore:4.0.1
100 | org.javassist:javassist:3.19.0-GA
101 | org.scala-lang:scala-library:2.11.6
102 | xml-apis:xml-apis:1.0.b2
103 | com.softwaremill.example:sbt-example_2.11:0.1-SNAPSHOT in runtime
104 | com.softwaremill.example:sbt-example_2.11:0.1-SNAPSHOT
105 | org.scala-lang:scala-library:2.11.6
106 | org.scala-lang:scala-library:2.11.6
107 | com.softwaremill.example:module1_2.11:0.1-SNAPSHOT in test
108 | com.softwaremill.example:module1_2.11:0.1-SNAPSHOT
109 | commons-logging:commons-logging:1.2
110 | dom4j:dom4j:1.6.1
111 | log4j:log4j:1.2.14
112 | org.apache.httpcomponents:httpclient:4.0.1
113 | org.scala-lang:scala-library:2.11.6
114 | commons-codec:commons-codec:1.3
115 | commons-logging:commons-logging:1.1.1 evicted by 1.2
116 | commons-logging:commons-logging:1.2
117 | dom4j:dom4j:1.6.1
118 | xml-apis:xml-apis:1.0.b2
119 | log4j:log4j:1.2.14
120 | org.apache.httpcomponents:httpclient:4.0.1
121 | commons-codec:commons-codec:1.3
122 | commons-logging:commons-logging:1.1.1
123 | org.apache.httpcomponents:httpcore:4.0.1
124 | org.apache.httpcomponents:httpcore:4.0.1
125 | org.scala-lang:scala-library:2.11.6
126 | xml-apis:xml-apis:1.0.b2
127 | com.softwaremill.example:module2_2.11:0.1-SNAPSHOT in test
128 | com.softwaremill.example:module1_2.11:0.1-SNAPSHOT
129 | commons-logging:commons-logging:1.2
130 | dom4j:dom4j:1.6.1
131 | log4j:log4j:1.2.14
132 | org.apache.httpcomponents:httpclient:4.0.1
133 | org.scala-lang:scala-library:2.11.6
134 | com.softwaremill.example:module2_2.11:0.1-SNAPSHOT
135 | com.softwaremill.example:module1_2.11:0.1-SNAPSHOT
136 | com.softwaremill.macwire:runtime_2.11:1.0.5
137 | javax.servlet:servlet-api:2.4
138 | org.scala-lang:scala-library:2.11.6
139 | com.softwaremill.macwire:runtime_2.11:1.0.5
140 | org.javassist:javassist:3.19.0-GA
141 | org.scala-lang:scala-library:2.11.6
142 | commons-codec:commons-codec:1.3
143 | commons-logging:commons-logging:1.1.1 evicted by 1.2
144 | commons-logging:commons-logging:1.2
145 | dom4j:dom4j:1.6.1
146 | xml-apis:xml-apis:1.0.b2
147 | javax.servlet:servlet-api:2.4
148 | log4j:log4j:1.2.14
149 | org.apache.httpcomponents:httpclient:4.0.1
150 | commons-codec:commons-codec:1.3
151 | commons-logging:commons-logging:1.1.1
152 | org.apache.httpcomponents:httpcore:4.0.1
153 | org.apache.httpcomponents:httpcore:4.0.1
154 | org.javassist:javassist:3.19.0-GA
155 | org.scala-lang:scala-library:2.11.6
156 | xml-apis:xml-apis:1.0.b2
157 | com.softwaremill.example:sbt-example_2.11:0.1-SNAPSHOT in test
158 | com.softwaremill.example:sbt-example_2.11:0.1-SNAPSHOT
159 | junit:junit:3.8.1
160 | org.scala-lang:scala-library:2.11.6
161 | junit:junit:3.8.1
162 | org.scala-lang:scala-library:2.11.6
163 |
--------------------------------------------------------------------------------
/src/sbt-test/updateimpact/cached_13_8/project/build.properties:
--------------------------------------------------------------------------------
1 | sbt.version=0.13.8
--------------------------------------------------------------------------------
/src/sbt-test/updateimpact/cached_13_8/project/plugins.sbt:
--------------------------------------------------------------------------------
1 | {
2 | val pluginVersion = System.getProperty("plugin.version")
3 | if(pluginVersion == null)
4 | throw new RuntimeException("""|The system property 'plugin.version' is not defined.
5 | |Specify this property using the scriptedLaunchOpts -D.""".stripMargin)
6 | else addSbtPlugin("com.updateimpact" % "updateimpact-sbt-plugin" % pluginVersion)
7 | }
--------------------------------------------------------------------------------
/src/sbt-test/updateimpact/cached_13_8/test:
--------------------------------------------------------------------------------
1 | > check
--------------------------------------------------------------------------------
/src/sbt-test/updateimpact/cached_13_9/build.sbt:
--------------------------------------------------------------------------------
1 | val commonSettings = Seq(
2 | organization := "com.softwaremill.example",
3 | version := "0.1-SNAPSHOT",
4 | scalaVersion := "2.11.6",
5 | updateOptions := updateOptions.value.withCachedResolution(true)
6 | )
7 |
8 | lazy val rootProject = (project in file("."))
9 | .settings(commonSettings: _*)
10 | .settings(
11 | name := "sbt-example",
12 | libraryDependencies ++= Seq(
13 | "junit" % "junit" % "3.8.1" % "test"
14 | )).aggregate(module1, module2)
15 |
16 | lazy val module1: Project = (project in file("module1"))
17 | .settings(commonSettings: _*)
18 | .settings(
19 | libraryDependencies ++= Seq(
20 | "log4j" % "log4j" % "1.2.14",
21 | "dom4j" % "dom4j" % "1.6.1",
22 | "org.apache.httpcomponents" % "httpclient" % "4.0.1",
23 | // evicts a dep in httpclient
24 | "commons-logging" % "commons-logging" % "1.2"
25 | ))
26 |
27 | lazy val module2: Project = (project in file("module2"))
28 | .settings(commonSettings: _*)
29 | .settings(
30 | libraryDependencies ++= Seq(
31 | "javax.servlet" % "servlet-api" % "2.4" % "provided",
32 | "com.softwaremill.macwire" %% "runtime" % "1.0.5"
33 | )).dependsOn(module1)
34 |
35 | updateImpactApiKey in ThisBuild := "x"
36 |
37 | TaskKey[Unit]("check") := {
38 | val expected = scala.io.Source.fromFile("expected.txt").getLines().mkString("\n")
39 |
40 | val report = updateImpactDependencyReport.value
41 | val str = com.updateimpact.testing.ReportToString.toString(report)
42 |
43 | if (expected != str) {
44 | println("EXPECTED: ")
45 | println(expected)
46 |
47 | println("GOT: ")
48 | println(str)
49 |
50 | sys.error("Invalid report generated")
51 | }
52 | }
--------------------------------------------------------------------------------
/src/sbt-test/updateimpact/cached_13_9/expected.txt:
--------------------------------------------------------------------------------
1 | com.softwaremill.example:module1_2.11:0.1-SNAPSHOT in compile
2 | com.softwaremill.example:module1_2.11:0.1-SNAPSHOT
3 | commons-logging:commons-logging:1.2
4 | dom4j:dom4j:1.6.1
5 | log4j:log4j:1.2.14
6 | org.apache.httpcomponents:httpclient:4.0.1
7 | org.scala-lang:scala-library:2.11.6
8 | commons-codec:commons-codec:1.3
9 | commons-logging:commons-logging:1.1.1 evicted by 1.2
10 | commons-logging:commons-logging:1.2
11 | dom4j:dom4j:1.6.1
12 | xml-apis:xml-apis:1.0.b2
13 | log4j:log4j:1.2.14
14 | org.apache.httpcomponents:httpclient:4.0.1
15 | commons-codec:commons-codec:1.3
16 | commons-logging:commons-logging:1.1.1
17 | org.apache.httpcomponents:httpcore:4.0.1
18 | org.apache.httpcomponents:httpcore:4.0.1
19 | org.scala-lang:scala-library:2.11.6
20 | xml-apis:xml-apis:1.0.b2
21 | com.softwaremill.example:module2_2.11:0.1-SNAPSHOT in compile
22 | com.softwaremill.example:module1_2.11:0.1-SNAPSHOT
23 | commons-logging:commons-logging:1.2
24 | dom4j:dom4j:1.6.1
25 | log4j:log4j:1.2.14
26 | org.apache.httpcomponents:httpclient:4.0.1
27 | org.scala-lang:scala-library:2.11.6
28 | com.softwaremill.example:module2_2.11:0.1-SNAPSHOT
29 | com.softwaremill.example:module1_2.11:0.1-SNAPSHOT
30 | com.softwaremill.macwire:runtime_2.11:1.0.5
31 | javax.servlet:servlet-api:2.4
32 | org.scala-lang:scala-library:2.11.6
33 | com.softwaremill.macwire:runtime_2.11:1.0.5
34 | org.javassist:javassist:3.19.0-GA
35 | org.scala-lang:scala-library:2.11.6
36 | commons-codec:commons-codec:1.3
37 | commons-logging:commons-logging:1.1.1 evicted by 1.2
38 | commons-logging:commons-logging:1.2
39 | dom4j:dom4j:1.6.1
40 | xml-apis:xml-apis:1.0.b2
41 | javax.servlet:servlet-api:2.4
42 | log4j:log4j:1.2.14
43 | org.apache.httpcomponents:httpclient:4.0.1
44 | commons-codec:commons-codec:1.3
45 | commons-logging:commons-logging:1.1.1
46 | org.apache.httpcomponents:httpcore:4.0.1
47 | org.apache.httpcomponents:httpcore:4.0.1
48 | org.javassist:javassist:3.19.0-GA
49 | org.scala-lang:scala-library:2.11.6
50 | xml-apis:xml-apis:1.0.b2
51 | com.softwaremill.example:sbt-example_2.11:0.1-SNAPSHOT in compile
52 | com.softwaremill.example:sbt-example_2.11:0.1-SNAPSHOT
53 | org.scala-lang:scala-library:2.11.6
54 | org.scala-lang:scala-library:2.11.6
55 | com.softwaremill.example:module1_2.11:0.1-SNAPSHOT in runtime
56 | com.softwaremill.example:module1_2.11:0.1-SNAPSHOT
57 | commons-logging:commons-logging:1.2
58 | dom4j:dom4j:1.6.1
59 | log4j:log4j:1.2.14
60 | org.apache.httpcomponents:httpclient:4.0.1
61 | org.scala-lang:scala-library:2.11.6
62 | commons-codec:commons-codec:1.3
63 | commons-logging:commons-logging:1.1.1 evicted by 1.2
64 | commons-logging:commons-logging:1.2
65 | dom4j:dom4j:1.6.1
66 | xml-apis:xml-apis:1.0.b2
67 | log4j:log4j:1.2.14
68 | org.apache.httpcomponents:httpclient:4.0.1
69 | commons-codec:commons-codec:1.3
70 | commons-logging:commons-logging:1.1.1
71 | org.apache.httpcomponents:httpcore:4.0.1
72 | org.apache.httpcomponents:httpcore:4.0.1
73 | org.scala-lang:scala-library:2.11.6
74 | xml-apis:xml-apis:1.0.b2
75 | com.softwaremill.example:module2_2.11:0.1-SNAPSHOT in runtime
76 | com.softwaremill.example:module1_2.11:0.1-SNAPSHOT
77 | commons-logging:commons-logging:1.2
78 | dom4j:dom4j:1.6.1
79 | log4j:log4j:1.2.14
80 | org.apache.httpcomponents:httpclient:4.0.1
81 | org.scala-lang:scala-library:2.11.6
82 | com.softwaremill.example:module2_2.11:0.1-SNAPSHOT
83 | com.softwaremill.example:module1_2.11:0.1-SNAPSHOT
84 | com.softwaremill.macwire:runtime_2.11:1.0.5
85 | org.scala-lang:scala-library:2.11.6
86 | com.softwaremill.macwire:runtime_2.11:1.0.5
87 | org.javassist:javassist:3.19.0-GA
88 | org.scala-lang:scala-library:2.11.6
89 | commons-codec:commons-codec:1.3
90 | commons-logging:commons-logging:1.1.1 evicted by 1.2
91 | commons-logging:commons-logging:1.2
92 | dom4j:dom4j:1.6.1
93 | xml-apis:xml-apis:1.0.b2
94 | log4j:log4j:1.2.14
95 | org.apache.httpcomponents:httpclient:4.0.1
96 | commons-codec:commons-codec:1.3
97 | commons-logging:commons-logging:1.1.1
98 | org.apache.httpcomponents:httpcore:4.0.1
99 | org.apache.httpcomponents:httpcore:4.0.1
100 | org.javassist:javassist:3.19.0-GA
101 | org.scala-lang:scala-library:2.11.6
102 | xml-apis:xml-apis:1.0.b2
103 | com.softwaremill.example:sbt-example_2.11:0.1-SNAPSHOT in runtime
104 | com.softwaremill.example:sbt-example_2.11:0.1-SNAPSHOT
105 | org.scala-lang:scala-library:2.11.6
106 | org.scala-lang:scala-library:2.11.6
107 | com.softwaremill.example:module1_2.11:0.1-SNAPSHOT in test
108 | com.softwaremill.example:module1_2.11:0.1-SNAPSHOT
109 | commons-logging:commons-logging:1.2
110 | dom4j:dom4j:1.6.1
111 | log4j:log4j:1.2.14
112 | org.apache.httpcomponents:httpclient:4.0.1
113 | org.scala-lang:scala-library:2.11.6
114 | commons-codec:commons-codec:1.3
115 | commons-logging:commons-logging:1.1.1 evicted by 1.2
116 | commons-logging:commons-logging:1.2
117 | dom4j:dom4j:1.6.1
118 | xml-apis:xml-apis:1.0.b2
119 | log4j:log4j:1.2.14
120 | org.apache.httpcomponents:httpclient:4.0.1
121 | commons-codec:commons-codec:1.3
122 | commons-logging:commons-logging:1.1.1
123 | org.apache.httpcomponents:httpcore:4.0.1
124 | org.apache.httpcomponents:httpcore:4.0.1
125 | org.scala-lang:scala-library:2.11.6
126 | xml-apis:xml-apis:1.0.b2
127 | com.softwaremill.example:module2_2.11:0.1-SNAPSHOT in test
128 | com.softwaremill.example:module1_2.11:0.1-SNAPSHOT
129 | commons-logging:commons-logging:1.2
130 | dom4j:dom4j:1.6.1
131 | log4j:log4j:1.2.14
132 | org.apache.httpcomponents:httpclient:4.0.1
133 | org.scala-lang:scala-library:2.11.6
134 | com.softwaremill.example:module2_2.11:0.1-SNAPSHOT
135 | com.softwaremill.example:module1_2.11:0.1-SNAPSHOT
136 | com.softwaremill.macwire:runtime_2.11:1.0.5
137 | javax.servlet:servlet-api:2.4
138 | org.scala-lang:scala-library:2.11.6
139 | com.softwaremill.macwire:runtime_2.11:1.0.5
140 | org.javassist:javassist:3.19.0-GA
141 | org.scala-lang:scala-library:2.11.6
142 | commons-codec:commons-codec:1.3
143 | commons-logging:commons-logging:1.1.1 evicted by 1.2
144 | commons-logging:commons-logging:1.2
145 | dom4j:dom4j:1.6.1
146 | xml-apis:xml-apis:1.0.b2
147 | javax.servlet:servlet-api:2.4
148 | log4j:log4j:1.2.14
149 | org.apache.httpcomponents:httpclient:4.0.1
150 | commons-codec:commons-codec:1.3
151 | commons-logging:commons-logging:1.1.1
152 | org.apache.httpcomponents:httpcore:4.0.1
153 | org.apache.httpcomponents:httpcore:4.0.1
154 | org.javassist:javassist:3.19.0-GA
155 | org.scala-lang:scala-library:2.11.6
156 | xml-apis:xml-apis:1.0.b2
157 | com.softwaremill.example:sbt-example_2.11:0.1-SNAPSHOT in test
158 | com.softwaremill.example:sbt-example_2.11:0.1-SNAPSHOT
159 | junit:junit:3.8.1
160 | org.scala-lang:scala-library:2.11.6
161 | junit:junit:3.8.1
162 | org.scala-lang:scala-library:2.11.6
163 |
--------------------------------------------------------------------------------
/src/sbt-test/updateimpact/cached_13_9/project/build.properties:
--------------------------------------------------------------------------------
1 | sbt.version=0.13.9
--------------------------------------------------------------------------------
/src/sbt-test/updateimpact/cached_13_9/project/plugins.sbt:
--------------------------------------------------------------------------------
1 | {
2 | val pluginVersion = System.getProperty("plugin.version")
3 | if(pluginVersion == null)
4 | throw new RuntimeException("""|The system property 'plugin.version' is not defined.
5 | |Specify this property using the scriptedLaunchOpts -D.""".stripMargin)
6 | else addSbtPlugin("com.updateimpact" % "updateimpact-sbt-plugin" % pluginVersion)
7 | }
--------------------------------------------------------------------------------
/src/sbt-test/updateimpact/cached_13_9/test:
--------------------------------------------------------------------------------
1 | > check
--------------------------------------------------------------------------------
/src/sbt-test/updateimpact/range_13_8/build.sbt:
--------------------------------------------------------------------------------
1 | val commonSettings = Seq(
2 | organization := "com.softwaremill.example",
3 | version := "0.1-SNAPSHOT",
4 | scalaVersion := "2.11.6"
5 | )
6 |
7 | lazy val rootProject = (project in file("."))
8 | .settings(commonSettings: _*)
9 | .settings(name := "sbt-example")
10 | .aggregate(module1, module2)
11 |
12 | lazy val module1: Project = (project in file("module1"))
13 | .settings(commonSettings: _*)
14 | .settings(libraryDependencies ++= Seq(
15 | "log4j" % "log4j" % "[1.0, 1.2.12)"
16 | ))
17 |
18 | lazy val module2: Project = (project in file("module2"))
19 | .settings(commonSettings: _*)
20 | .dependsOn(module1)
21 |
22 |
23 | updateImpactApiKey in ThisBuild := "x"
24 |
25 | TaskKey[Unit]("check") := {
26 | val expected = scala.io.Source.fromFile("expected.txt").getLines().mkString("\n")
27 |
28 | val report = updateImpactDependencyReport.value
29 | val str = com.updateimpact.testing.ReportToString.toString(report)
30 |
31 | if (expected != str) {
32 | println("EXPECTED: ")
33 | println(expected)
34 |
35 | println("GOT: ")
36 | println(str)
37 |
38 | sys.error("Invalid report generated")
39 | }
40 | }
--------------------------------------------------------------------------------
/src/sbt-test/updateimpact/range_13_8/expected.txt:
--------------------------------------------------------------------------------
1 | com.softwaremill.example:module1_2.11:0.1-SNAPSHOT in compile
2 | com.softwaremill.example:module1_2.11:0.1-SNAPSHOT
3 | log4j:log4j:1.2.11
4 | org.scala-lang:scala-library:2.11.6
5 | log4j:log4j:1.2.11
6 | org.scala-lang:scala-library:2.11.6
7 | com.softwaremill.example:module2_2.11:0.1-SNAPSHOT in compile
8 | com.softwaremill.example:module1_2.11:0.1-SNAPSHOT
9 | log4j:log4j:1.2.11
10 | org.scala-lang:scala-library:2.11.6
11 | com.softwaremill.example:module2_2.11:0.1-SNAPSHOT
12 | com.softwaremill.example:module1_2.11:0.1-SNAPSHOT
13 | org.scala-lang:scala-library:2.11.6
14 | log4j:log4j:1.2.11
15 | org.scala-lang:scala-library:2.11.6
16 | com.softwaremill.example:sbt-example_2.11:0.1-SNAPSHOT in compile
17 | com.softwaremill.example:sbt-example_2.11:0.1-SNAPSHOT
18 | org.scala-lang:scala-library:2.11.6
19 | org.scala-lang:scala-library:2.11.6
20 | com.softwaremill.example:module1_2.11:0.1-SNAPSHOT in runtime
21 | com.softwaremill.example:module1_2.11:0.1-SNAPSHOT
22 | log4j:log4j:1.2.11
23 | org.scala-lang:scala-library:2.11.6
24 | log4j:log4j:1.2.11
25 | org.scala-lang:scala-library:2.11.6
26 | com.softwaremill.example:module2_2.11:0.1-SNAPSHOT in runtime
27 | com.softwaremill.example:module1_2.11:0.1-SNAPSHOT
28 | log4j:log4j:1.2.11
29 | org.scala-lang:scala-library:2.11.6
30 | com.softwaremill.example:module2_2.11:0.1-SNAPSHOT
31 | com.softwaremill.example:module1_2.11:0.1-SNAPSHOT
32 | org.scala-lang:scala-library:2.11.6
33 | log4j:log4j:1.2.11
34 | org.scala-lang:scala-library:2.11.6
35 | com.softwaremill.example:sbt-example_2.11:0.1-SNAPSHOT in runtime
36 | com.softwaremill.example:sbt-example_2.11:0.1-SNAPSHOT
37 | org.scala-lang:scala-library:2.11.6
38 | org.scala-lang:scala-library:2.11.6
39 | com.softwaremill.example:module1_2.11:0.1-SNAPSHOT in test
40 | com.softwaremill.example:module1_2.11:0.1-SNAPSHOT
41 | log4j:log4j:1.2.11
42 | org.scala-lang:scala-library:2.11.6
43 | log4j:log4j:1.2.11
44 | org.scala-lang:scala-library:2.11.6
45 | com.softwaremill.example:module2_2.11:0.1-SNAPSHOT in test
46 | com.softwaremill.example:module1_2.11:0.1-SNAPSHOT
47 | log4j:log4j:1.2.11
48 | org.scala-lang:scala-library:2.11.6
49 | com.softwaremill.example:module2_2.11:0.1-SNAPSHOT
50 | com.softwaremill.example:module1_2.11:0.1-SNAPSHOT
51 | org.scala-lang:scala-library:2.11.6
52 | log4j:log4j:1.2.11
53 | org.scala-lang:scala-library:2.11.6
54 | com.softwaremill.example:sbt-example_2.11:0.1-SNAPSHOT in test
55 | com.softwaremill.example:sbt-example_2.11:0.1-SNAPSHOT
56 | org.scala-lang:scala-library:2.11.6
57 | org.scala-lang:scala-library:2.11.6
58 |
--------------------------------------------------------------------------------
/src/sbt-test/updateimpact/range_13_8/project/build.properties:
--------------------------------------------------------------------------------
1 | sbt.version=0.13.8
--------------------------------------------------------------------------------
/src/sbt-test/updateimpact/range_13_8/project/plugins.sbt:
--------------------------------------------------------------------------------
1 | {
2 | val pluginVersion = System.getProperty("plugin.version")
3 | if(pluginVersion == null)
4 | throw new RuntimeException("""|The system property 'plugin.version' is not defined.
5 | |Specify this property using the scriptedLaunchOpts -D.""".stripMargin)
6 | else addSbtPlugin("com.updateimpact" % "updateimpact-sbt-plugin" % pluginVersion)
7 | }
--------------------------------------------------------------------------------
/src/sbt-test/updateimpact/range_13_8/test:
--------------------------------------------------------------------------------
1 | > check
--------------------------------------------------------------------------------