首页 \ 问答 \ 构建多个Maven项目(Build multiple Maven projects)

构建多个Maven项目(Build multiple Maven projects)

我是Maven的新手,对于构建多个Maven项目有疑问。

我们有两个Maven项目,项目A和项目B.

项目A取决于项目B生成的人工制品。

当对项目A或B的更改检入SVN时,我们的本地Hudson服务器构建修改后的项目(以及任何相关项目)并将人工制品上传到我们的本地Nexus存储库。

现在,考虑两个开发人员。

开发人员1只攻击项目A,当开发人员1在本地构建项目A时,Maven从我们的Nexus服务器获取最新的项目B快照假象。

开发人员2同时攻击项目A和项目B. 当Developer 2在本地构建项目A时,我们希望maven使用任何本地更改构建项目B并使用生成的artefact来构建项目A.我们如何使用项目B的本地版本来设置Maven而不是从中获取artefact关系? 这是Maven的标准使用模式吗?


I'm very new to Maven, and have a question about building multiple Maven projects.

We have two Maven projects, Project A and Project B.

Project A depends on an artefact generated by Project B.

When changes to project A or B are checked into SVN, our local Hudson server builds the modified project (and any dependent projects) and uploads the artefacts into our local Nexus repository.

Now, consider two developers.

Developer 1 hacks away at project A only, and when Developer 1 builds project A locally, Maven goes and gets the latest project B snapshot artefact from our Nexus server.

Developer 2 hacks on both project A and project B simultaneously. When Developer 2 builds project A locally, we want maven to build project B with any local changes and use the resulting artefact to build project A. How do we set up Maven to build using the local version of project B instead of getting the artefact from Nexus? Is this a standard usage pattern for Maven?


原文:https://stackoverflow.com/questions/3377173
更新时间:2021-12-18 08:12

最满意答案

这只是一个Numpy解决方案,希望它足够了。 我假设你的函数是由对矩阵元素和平均值的操作组成的,即一个缩放的和。 因此,将Y看作是足够的

Y = np.power(X-X0, 2)

所以我们只需要处理确定窗口均值。 注意,对于1D情况,可以确定具有合适的1的矢量的矩阵乘积用于计算平均值,例如

h = np.array([0, 1, 1, 0])  # same dimension as y
m1 = np.dot(h, y) / 2 
m2 = (y[1] + y[2]) / 2
print(m1 == m2)  # True

2D情况类似,但有两个矩阵乘法,一个用于行,一个用于列。 例如

m_2 = np.dot(np.dot(h, Y), h) / 2**2

要构建一个滑动窗口,我们需要构建一个移动窗口矩阵,例如

H = [[1, 1, 1, 0, 0, ..., 0],
     [0, 1, 1, 1, 0, ..., 0],
            .
            .
            .
     [0, ..., 0, 0, 1, 1, 1]] 

计算所有的总和

S = np.dot(np.dot(H, Y), H.T)

具有(m, m)窗口的(n, n)矩阵的完整示例将是

import numpy as np

n, m = 500, 10
X0 = np.ones((n, n))
X = np.random.rand(n, n)
Y = np.power(X-X0, 2)

h = np.concatenate((np.ones(m), np.zeros(n-m)))  # window at position 0
H = np.vstack((np.roll(h, k) for k in range(n+1-m)))  # slide the window 
M = np.dot(np.dot(H,Y), H.T) / m**2  # calculate the mean
print(M.shape)  # (491, 491)

构建H的另一种但可能稍微有效的方法是

H = np.sum(np.diag(np.ones(n-k), k)[:-m+1, :] for k in range(m))

更新

使用该方法也可以计算均方偏差。 为此,我们推广了向量恒等|x-x0|^2 = (x-x0).T (x-x0) = xT x - 2 x0.T x + x0.T x0 (空格表示标量或矩阵)乘法和.T转置向量)到矩阵的情况:

我们假设W是包含块(mm)单位矩阵的(m,n)矩阵,它能够通过Y = WZ WT提取(k0,k1) th (m,m)子矩阵,其中Z是包含数据的(n,n)矩阵。 计算差异

 D = Y - X0 = Y = W Z W.T - X0 

很简单,其中X0D(m,m)矩阵。 元素平方和的平方根称为Frobenius范数 。 基于这些身份 ,我们可以将平方和写为

s = sum_{i,j} D_{i,j}^2 = trace(D.T D) = trace((W Z W.T - X0).T (H Z H.T - X0))
  = trace(W Z.T W.T W Z W.T) - 2 trace(X0.T W Z W.T) + trace(X0.T X0)
  =: Y0 + Y1 + Y2

术语Y0可以从上面的方法解释为HZ HT 。术语Y1可以被解释为Z上的加权平均值, Y2是常数,其仅需要确定一次。 因此,可能的实现方式是:

import numpy as np

n, m = 500, 10
x0 = np.ones(m)
Z = np.random.rand(n, n)

Y0 = Z**2
h0 = np.concatenate((np.ones(m), np.zeros(n-m)))
H0 = np.vstack((np.roll(h0, k) for k in range(n+1-m)))
M0 = np.dot(np.dot(H0, Y0), H0.T)

h1 = np.concatenate((-2*x0, np.zeros(n-m)))
H1 = np.vstack((np.roll(h1, k) for k in range(n+1-m)))
M1 = np.dot(np.dot(H1, Z), H0.T)

Y2 = np.dot(x0, x0)
M = (M0 + M1) / m**2 + Y2

This is only a Numpy solution, hope it suffices. I assume that your function is made up of an operation on the matrix elements and of a mean, i.e. a scaled sum. Hence, it is sufficient to look at Y as in

Y = np.power(X-X0, 2)

So we only need to deal with determining a windowed mean. Note that for the 1D case the matrix product with an appropriate vector of ones can be determined for calculating the mean, e.g.

h = np.array([0, 1, 1, 0])  # same dimension as y
m1 = np.dot(h, y) / 2 
m2 = (y[1] + y[2]) / 2
print(m1 == m2)  # True

The 2D case is analogous, but with two matrix multiplications, one for the rows and one for the columns. E.g.

m_2 = np.dot(np.dot(h, Y), h) / 2**2

To construct a sliding window, we need to build a matrix of shifted windows, e.g.

H = [[1, 1, 1, 0, 0, ..., 0],
     [0, 1, 1, 1, 0, ..., 0],
            .
            .
            .
     [0, ..., 0, 0, 1, 1, 1]] 

to calculate all the sums

S = np.dot(np.dot(H, Y), H.T)

A full example for a (n, n) matrix with a (m, m) window would be

import numpy as np

n, m = 500, 10
X0 = np.ones((n, n))
X = np.random.rand(n, n)
Y = np.power(X-X0, 2)

h = np.concatenate((np.ones(m), np.zeros(n-m)))  # window at position 0
H = np.vstack((np.roll(h, k) for k in range(n+1-m)))  # slide the window 
M = np.dot(np.dot(H,Y), H.T) / m**2  # calculate the mean
print(M.shape)  # (491, 491)

An alternative but probably slightly less efficient way for building H is

H = np.sum(np.diag(np.ones(n-k), k)[:-m+1, :] for k in range(m))

Update

Calculating the mean squared deviation is also possible with that approach. For that, we generalize the vector identity |x-x0|^2 = (x-x0).T (x-x0) = x.T x - 2 x0.T x + x0.T x0 (a space denotes a scalar or matrix multiplication and .T a transposed vector) to the matrix case:

We assume W is a (m,n) matrix containing a block (m.m) identity matrix, which is able to extract the (k0,k1)-th (m,m) sub-matrix by Y = W Z W.T, where Z is the (n,n) matrix containing the data. Calculating the difference

 D = Y - X0 = Y = W Z W.T - X0 

is straightforward, where X0 and D is a (m,m) matrix. The square-root of the squared sum of the elements is called Frobenius norm. Based on those identities, we can write the squared sum as

s = sum_{i,j} D_{i,j}^2 = trace(D.T D) = trace((W Z W.T - X0).T (H Z H.T - X0))
  = trace(W Z.T W.T W Z W.T) - 2 trace(X0.T W Z W.T) + trace(X0.T X0)
  =: Y0 + Y1 + Y2

The term Y0 can be interpreted as H Z H.T from the method from above.The term Y1 can be interpreted as a weighted mean on Z and Y2 is a constant, which only needs to be determined once. Thus, a possible implementation would be:

import numpy as np

n, m = 500, 10
x0 = np.ones(m)
Z = np.random.rand(n, n)

Y0 = Z**2
h0 = np.concatenate((np.ones(m), np.zeros(n-m)))
H0 = np.vstack((np.roll(h0, k) for k in range(n+1-m)))
M0 = np.dot(np.dot(H0, Y0), H0.T)

h1 = np.concatenate((-2*x0, np.zeros(n-m)))
H1 = np.vstack((np.roll(h1, k) for k in range(n+1-m)))
M1 = np.dot(np.dot(H1, Z), H0.T)

Y2 = np.dot(x0, x0)
M = (M0 + M1) / m**2 + Y2

相关问答

更多
  • 它主要被称为窗口的“自动隐藏”功能。 CodeProject上有一个很好的例子: WPF Docking Library 还可以看看AvalonDock 。 It is mostly called 'Auto Hide' feature for the window. There is a very good example on CodeProject: WPF Docking Library Also have a look on AvalonDock.
  • 您可以在numpy中执行以下操作: import numpy as np A = np.arange(4 * 2 * 5).reshape(4, 2, 5) B = np.arange(4 * 2).reshape(4, 2) % 5 C = A[np.arange(A.shape[0])[:, np.newaxis], np.arange(A.shape[1]), B] 所以你可以在theano做同样的事情: import theano import theano.tensor as T AA = ...
  • def recurrence(x_t, h_tm1): h_t = T.nnet.sigmoid(T.dot(x_t, self.wx) + T.dot(h_tm1, self.wh) + self.bh) s_t = T.nnet.softmax(T.dot(h_t, self.w) + self.b) return [h_t, s_t] 所以,首先你问我们为什么不在递归函数中使用h0。 让我们分解 ...
  • 使用theano.tensor.TensorType(dtype, broadcastable) dtype是一个numpy dtype字符串,broadcastable是一个布尔列表,指定维度是否可播放。 你的功能的一个例子是: def arbitrary_tensor(dtype, shape, name=None): # create the type. var_type = theano.tensor.TensorType( dtype=dtype, ...
  • for(int w = 1; w <= a.length; w++){ System.out.println("Window size : " + w); for(int i = 0; i < a.length - w + 1; i++){ for(int j = i; j < i + w; j++){ System.out.print(a[j]); } System.out.println(); } ...
  • 在Android中,颜色可以具有透明度级别,因此您只需使用所需的透明度来构建颜色,并将其作为布局的背景。 所以你把它放在你的color.xml中 #AARRGGBB 只是替换: AA =>你想要多少透明度(称为Alpha) RR =>多少红色 GG =>多少绿色 BB =>蓝多少钱 请记住,这些是十六进制值,从00到FF不等 In Android colours can have a transparency level, so you ...
  • 虽然Theano未能指出这一点,但提供的代码中存在错误。 代替 f = theano.function([X_resh], Y) 你应该真的用 f = theano.function([X], Y) 使用原始代码,您实际上在重塑后提供张量,因此重塑命令永远不会被执行。 这可以通过添加来看出 theano.printing.debugprint(f) 打印 Elemwise{sqr,no_inplace} [id A] '' 0 | [id ...
  • 这只是一个Numpy解决方案,希望它足够了。 我假设你的函数是由对矩阵元素和平均值的操作组成的,即一个缩放的和。 因此,将Y看作是足够的 Y = np.power(X-X0, 2) 所以我们只需要处理确定窗口均值。 注意,对于1D情况,可以确定具有合适的1的矢量的矩阵乘积用于计算平均值,例如 h = np.array([0, 1, 1, 0]) # same dimension as y m1 = np.dot(h, y) / 2 m2 = (y[1] + y[2]) / 2 print(m1 == ...
  • 在theano中,您必须使用T.sum(), T.neq(), T.argmax(),T.grad()进行符号计算,使用像T.matrix这样的变量。 例如,您不能使用内置的sum() 。 如果你使用theano你必须遵循theano自己的方法,因为theano使用不同形式的计算来利用gpu的架构。 但是,如果你想使用sum()你可以用它来计算,然后创建一个可以存储结果的theano.shared变量,这样你就可以在运行时将它存储在gpu的内存中。 关于T.grad(),也许你应该问theano开发者。 : ...
  • 使用有点广播魔术的tile : import theano as th import theano.tensor as T def general_outer(elem_op, a, b): a_shape = T.shape(a) b_shape = T.shape(b) return elem_op(T.tile(a, T.join(0,T.ones_like(a_shape),b_shape), b)) #note the broadcast use tile with a ...

相关文章

更多

最新问答

更多
  • 获取MVC 4使用的DisplayMode后缀(Get the DisplayMode Suffix being used by MVC 4)
  • 如何通过引用返回对象?(How is returning an object by reference possible?)
  • 矩阵如何存储在内存中?(How are matrices stored in memory?)
  • 每个请求的Java新会话?(Java New Session For Each Request?)
  • css:浮动div中重叠的标题h1(css: overlapping headlines h1 in floated divs)
  • 无论图像如何,Caffe预测同一类(Caffe predicts same class regardless of image)
  • xcode语法颜色编码解释?(xcode syntax color coding explained?)
  • 在Access 2010 Runtime中使用Office 2000校对工具(Use Office 2000 proofing tools in Access 2010 Runtime)
  • 从单独的Web主机将图像传输到服务器上(Getting images onto server from separate web host)
  • 从旧版本复制文件并保留它们(旧/新版本)(Copy a file from old revision and keep both of them (old / new revision))
  • 西安哪有PLC可控制编程的培训
  • 在Entity Framework中选择基类(Select base class in Entity Framework)
  • 在Android中出现错误“数据集和渲染器应该不为null,并且应该具有相同数量的系列”(Error “Dataset and renderer should be not null and should have the same number of series” in Android)
  • 电脑二级VF有什么用
  • Datamapper Ruby如何添加Hook方法(Datamapper Ruby How to add Hook Method)
  • 金华英语角.
  • 手机软件如何制作
  • 用于Android webview中图像保存的上下文菜单(Context Menu for Image Saving in an Android webview)
  • 注意:未定义的偏移量:PHP(Notice: Undefined offset: PHP)
  • 如何读R中的大数据集[复制](How to read large dataset in R [duplicate])
  • Unity 5 Heighmap与地形宽度/地形长度的分辨率关系?(Unity 5 Heighmap Resolution relationship to terrain width / terrain length?)
  • 如何通知PipedOutputStream线程写入最后一个字节的PipedInputStream线程?(How to notify PipedInputStream thread that PipedOutputStream thread has written last byte?)
  • python的访问器方法有哪些
  • DeviceNetworkInformation:哪个是哪个?(DeviceNetworkInformation: Which is which?)
  • 在Ruby中对组合进行排序(Sorting a combination in Ruby)
  • 网站开发的流程?
  • 使用Zend Framework 2中的JOIN sql检索数据(Retrieve data using JOIN sql in Zend Framework 2)
  • 条带格式类型格式模式编号无法正常工作(Stripes format type format pattern number not working properly)
  • 透明度错误IE11(Transparency bug IE11)
  • linux的基本操作命令。。。